jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;

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

    int N = scanner.nextInt();
    Ball[] balls = new Ball[N];
    for (int i = 0; i < N; i++) balls[i] = new Ball(scanner.nextInt(), scanner.nextInt());
    Arrays.sort(balls, (b1, b2) -> {
      if (b1.x == b2.x) return b1.y - b2.y;
      return b1.x - b2.x;
    });

    Set<Pair> pqSet = new HashSet<>();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i == j) continue;
        pqSet.add(new Pair(balls[j].x - balls[i].x, balls[j].y - balls[i].y));
      }
    }
    int min = N;
    for (Pair pq : pqSet) {
      Set<Ball> set = new LinkedHashSet<>(Arrays.asList(balls));
      int cost = 0;
      Ball next = null;
      while (!set.isEmpty()) {
        if (next == null || !set.contains(next)) {
          cost++;
          Ball b = set.stream().findFirst().get();
          set.remove(b);
          next = new Ball(b.x + pq.p, b.y + pq.q);
        } else {
          set.remove(next);
          next = new Ball(next.x + pq.p, next.y + pq.q);
        }
      }
      min = Math.min(min, cost);
    }
    System.out.println(min);
  }

  private static class Pair {
    private final int p;
    private final int q;

    private Pair(int p, int q) {
      this.p = p;
      this.q = q;
    }

    @Override public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Pair pair = (Pair) o;
      return p == pair.p &&
          q == pair.q;
    }

    @Override public int hashCode() {
      return Objects.hash(p, q);
    }
  }

  private static class Ball {
    private final int x;
    private final int y;

    private Ball(int x, int y) {
      this.x = x;
      this.y = y;
    }

    @Override public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Ball ball = (Ball) o;
      return x == ball.x &&
          y == ball.y;
    }

    @Override public int hashCode() {
      return Objects.hash(x, y);
    }
  }
}
//  [java]
import java.awt.*;
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		ArrayList<Point> a=new ArrayList<>();
		ArrayList<Point> b=new ArrayList<>();
		for(int i=0;i<n;++i) {
			Point e=new Point(s.nextInt(),s.nextInt());
			a.add(e);
			b.add(e);
		}
		a.sort(Comparator.comparingInt(o->o.x));
		b.sort(Comparator.comparingInt(o->o.y));

		System.err.println(a);
		System.err.println(b);

		int r=n==1?1:Integer.MAX_VALUE;

		for(int i=0;i<n;++i){
			for(int j=i+1;j<n;++j){
				long dx=a.get(j).x-a.get(i).x;
				long dy=a.get(j).y-a.get(i).y;

				int t=Math.min(f(a,dx,dy),f(b,dx,dy));
				r=Math.min(r,t);
				//System.err.println(t+" "+dx+" "+dy);
			}
		}
		System.err.println();
		System.out.println(r);
	}

	private static int f(ArrayList<Point> a,long dx,long dy){
		ArrayList<Point> l=new ArrayList<>();
		int t=0;
		for(Point p:a){
			if(l.stream().noneMatch(q->(p.x==q.x+dx&&p.y==q.y+dy)||(p.x==q.x-dx&&p.y==q.y-dy)))
				++t;
			l.add(p);
		}
		return t;
	}
}
//  [cpp]
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;

template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) {
    if (x > y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) {
    if (x < y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);

template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
    while (begin != end) {
        out << (*begin) << " ";
        begin++;
    }
    out << endl;
}

template<class T> void output(const T &x, ostream &out = cerr) {
    output(x.begin(), x.end(), out);
}

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
}



int n;
int x[51], y[51];
map<pair<int, int>, bool> was;


int main() {
    fast_io();
   // read("input");
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    vector<int> vx, vy;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            vx.pb(x[i] - x[j]);
            vy.pb(y[i] - y[j]);
        }
        was[{x[i], y[i]}] = true;
    }
    sort(all(vx));
    vx.resize(distance(vx.begin(), unique(all(vx))));
    sort(all(vy));
    vy.resize(distance(vy.begin(), unique(all(vy))));
    int ans = n;
    for (auto xx: vx) {
        for (auto yy: vy) {
            if (xx == 0 && yy == 0) {
                continue;
            }
            if (xx < 0 || (xx == 0 && yy < 0)) {
                continue;
            }
            int cnt = n;
            for (int i = 0; i < n; i++) {
                if (was.find({x[i] - xx, y[i] - yy}) != was.end())  {
                    cnt--;
                }
            }
            chkmin(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e5 + 10 ;

int X[MAX] , Y[MAX] , X2[MAX] , Y2[MAX] ;

int n ;

bool cmp(int a , int b)
{
	return X[a] < X[b] ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	set< pair<int , int> >s ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>X[i]>>Y[i] ;
		X2[i] = X[i] , Y2[i] = Y[i] ;
		s.insert({X[i] , Y[i]}) ;
	}
	vector<int>idx ;
	for(int i = 0 ; i < n ; ++i)
		idx.push_back(i) ;
	sort(idx.begin() , idx.end() , cmp) ;
	for(int i = 0 ; i < n ; ++i)
		X[i] = X2[idx[i]] , Y[i] = Y2[idx[i]] ;
	vector<int>vx , vy ;
	for(int i = 0 ; i < n ; ++i)
	{
		for(int j = i-1 ; j >= 0 ; --j)
			vx.push_back(X[i] - X[j]) , vy.push_back(Y[i] - Y[j]) ;
	}
	int ans = n ;
	for(auto &p : vx)
	{
		for(auto &q : vy)
		{
			if(p == 0 && q == 0)
				continue ;
			int cnt = 0 ;
			for(int i = 0 ; i < n ; ++i)
			{
				int a = X[i] - p , b = Y[i] - q ;
				if(s.find({a , b}) == s.end())
					cnt++ ;
			}
			ans = min(ans , cnt) ;
		}
	}
	return cout<<ans<<"\n" , 0 ;
}
//  [cpp]
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans, x, y, ct, c, d, z;
	cin >> n;
	vector<pair<int, int>> a(n);
	set<pair<int, int>> s;
	for (i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
		s.insert(a[i]);
	}

	ans = n;
	sort(a.begin(), a.end());
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			x = a[i].first - a[j].first;
			for (c = 0; c < n; c++) {
				for (d = c + 1; d < n; d++) {
					y = a[c].second - a[d].second;
					if ((x == 0) && (y == 0)) continue;

					ct = 0;
					for (z = 0; z < n; z++) {
						if (s.find({ a[z].first - x, a[z].second - y }) != s.end()) ct++;
					}
					ans = min(ans, n - ct);
				}
			}
		}
	}
	cout << ans << "\n";




	return 0;
}
//  [c]
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  long long int a[n], b[n], aa, bb, min = 100, cnt;
  for(int i = 0;i < n;i++){
    scanf("%lld %lld",&a[i],&b[i]);
  }
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      if(i != j){
        aa = a[i] - a[j];
        bb = b[i] - b[j];
        cnt = 1;
        for(int s = 0;s < n;s++){
          for(int t = 0;t < n;t++){
            if((i != t || j != s) && (i != s || j != t) && s != t){
              if(aa == a[s] - a[t] && bb == b[s] - b[t])cnt++;
              //printf("%d : %d %d\n",s,t,cnt);
            }
          }
        }
        cnt = n - cnt;
        if(min > cnt)min = cnt;
        //printf("%d %d %d %lld %lld\n",i ,j ,cnt ,aa ,bb);
      }
    }
  }
  if(n == 1)min = 1;
  printf("%lld\n",min);
  return 0;
}
//  [c]
#include <stdio.h>
#include <inttypes.h>

#define KI_MAX 64

int ki[KI_MAX];

void ki_init(void) {
	int i;
	for (i = 0; i < KI_MAX; i++) {
		ki[i] = 1;
	}
}

int ki_root(int x) {
	if (ki[x] > 0) {
		return x;
	} else {
		int root = ki_root(-ki[x]);
		ki[x] = -root;
		return root;
	}
}

int ki_size(int x) {
	return ki[ki_root(x)];
}

void ki_merge(int a, int b) {
	int ar = ki_root(a);
	int br = ki_root(b);
	if (ar != br) {
		int as = ki_size(ar);
		int bs = ki_size(br);
		if (as >= bs) {
			ki[ar] += ki[br];
			ki[br] = -ar;
		} else {
			ki[br] += ki[ar];
			ki[ar] = -br;
		}
	}
}

int N;
int64_t x[64], y[64];

int main(void) {
	int i, j;
	int ansaa;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64 "%" SCNd64, &x[i], &y[i]) != 2) return 1;
	}
	ansaa = N;
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			int64_t dx = x[i] - x[j], dy = y[i] - y[j];
			int k, l;
			int kaunto = 1, fr;
			ki_init();
			for (k = 0; k < N; k++) {
				for (l = k + 1; l < N; l++) {
					int64_t cx = x[k] - x[l], cy = y[k] - y[l];
					if ((cx == dx && cy == dy) || (cx == -dx && cy == -dy)) {
						ki_merge(k, l);
					}
				}
			}
			for (k = 1; k < N; k++) {
				if (ki_root(k) != ki_root(0)) {
					kaunto++;
					ki_merge(0, k);
				}
			}
			if (kaunto < ansaa) ansaa = kaunto;
		}
	}
	printf("%d\n", ansaa);
	return 0;
}
//  [javascript]
function Main(input) {
    input = input.trim().split("\n");
    var N = parseInt(input[0], 10);
    var x = [];
    var y = [];
    for (var i = 0; i < N; i++){
        var tmp = input[i+1].split(" ");
        x[i] = parseInt(tmp[0], 10);
        y[i] = parseInt(tmp[1], 10);
    }

    var a = [];
    var k = 0;
    for (var i = 0; i < N; i++){
        for (var j = 0; j < N; j++){
            if (i != j) {
                var p = x[j] - x[i];
                var q = y[j] - y[i];
                a[k] = p+","+q;
                    k++;
            }
        }
    }

    if (a.length == 0) {
        console.log(N);
    }
    else {
        var maxA = a[0];
        var maxCount = 0;
        for (var i = 0; i < a.length-1; i++) {
            var count = 0;
            for (var j = i+1; j < a.length; j++){
                if (a[i] == a[j]) {
                    count++;
                }
            }
            if (count > maxCount) {
                maxCount = count;
                maxA = a[i];
            }
        }
        var tmp = maxA.split(",");
        var p = parseInt(tmp[0], 10);
        var q = parseInt(tmp[1], 10);

        var cost = [];
        for (var i = 0; i < N; i++){
            cost[i] = 1;
        }
        for (var i = 0; i < N; i++){
            for (var j = 0; j < N; j++){
                if (i != j) {
                    if ((y[j] - y[i]) == q && (x[j] - x[i]) == p) {
                        cost[j] = 0;
                    }
                }
            }
        }

        var sumCost = 0;
        for (var i = 0; i < N; i++){
            sumCost += cost[i];
        }
        console.log(sumCost);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var x = o.m(n);
  x.sort((a,b)=>a[0]>b[0]?1:a[0]<b[0]?-1:a[1]-b[1]);
  var ans = n;
  for(var i = 0; i < n; i++){
    for(var j = i+1; j < n; j++){
      var a = xArray(0,n);
      var s = 0;
      var p = x[j][0]-x[i][0];
      var q = x[j][1]-x[i][1];
      for(var k = 0; k < n; k++){
        if(a[k])continue;
        s++;
        var tx = x[k][0];
        var ty = x[k][1];
        for(var l = k+1; l < n; l++){
          if(a[l])continue;
          if(x[l][0]-tx===p && x[l][1]-ty===q){
            a[l] = 1;
            tx = x[l][0], ty = x[l][1];
          }
        }
      }
      if(s < ans)ans = s;
    }
  }
  return ans;
}
//  [go]
package main

import (
	"fmt"
)

type xy struct {
	x int
	y int
}

type pq struct {
	p int
	q int
}

func main() {
	var N int
	fmt.Scan(&N)

	XY := make([]xy, 0, N)
	XYmapOrig := make(map[xy]int, N)

	for i := 0; i < N; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		x_y := xy{x, y}
		XY = append(XY, x_y)
		XYmapOrig[x_y] = 1
	}

	PQ := make([][]pq, N)
	PQmap := make(map[pq]int)

	for i := 0; i < N; i++ {
		PQ[i] = make([]pq, N)
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}
			p := XY[i].x - XY[j].x
			q := XY[i].y - XY[j].y
			p_q := pq{p, q}
			PQ[i][j] = p_q
			PQmap[p_q]++
		}
	}

	ans := N
	for target := range PQmap {
		XYmap := make(map[xy]int, N)
		for k, v := range XYmapOrig {
			XYmap[k] = v
		}
		cnt := 0
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if i == j {
					continue
				}
				xy1 := XY[i]
				xy2 := XY[j]
				if _, ok := XYmap[xy1]; !ok {
					continue
				}
				if _, ok := XYmap[xy2]; !ok {
					continue
				}
				p_q := PQ[i][j]
				if p_q.p == target.p && p_q.q == target.q {
					cnt++
					xy1 := XY[i]
					xy2 := XY[j]
					delete(XYmap, xy1)
					delete(XYmap, xy2)
					for {
						xy1 = xy{xy1.x + target.p, xy1.y + target.q}
						if _, ok := XYmap[xy1]; ok {
							delete(XYmap, xy1)
						} else {
							break
						}
					}
					for {
						xy2 = xy{xy2.x - target.p, xy2.y - target.q}
						if _, ok := XYmap[xy2]; ok {
							delete(XYmap, xy2)
						} else {
							break
						}
					}
					break
				}
			}
		}
		for range XYmap {
			cnt++
		}
		if ans > cnt {
			ans = cnt
		}
	}
	fmt.Println(ans)
}
//  [ruby]
n = gets.to_i
ball = Array.new(n).map{Array.new(2,0)}
n.times{|i| ball[i] = gets.split.map(&:to_i)}
ball.sort!
ans = 0
for i in 0..n-1
  for j in 0..n-1
    if i != j
      count = 0
      inst0 = ball[j][0]-ball[i][0]
      inst1 = ball[j][1]-ball[i][1]
      for k in 0..n-1
        for l in 0..n-1
          if k != l && ball[l][0]-ball[k][0]==inst0 && ball[l][1]-ball[k][1]==inst1
            count += 1
          end
        end
      end
      if ans < count
        ans = count
      end
    end
  end
end
puts n-ans
//  [ruby]
n = gets.chomp.to_i
s = []
h = {}
m = 0
x, y = [], []
n.times do |i|
  x[i], y[i] = gets.chomp.split.map(&:to_i)
end
n.times do |i|
  n.times do |j|
    l = [x[i] - x[j], y[i] - y[j]]
    next if l == [0, 0]
    if !s.include?(l)
      s << l
      h[l] = 1
      m = 1 if m == 0
    else
      h[l] += 1
      m = h[l] if m < h[l]
    end
  end
end
puts n - m
//  [ruby]
n = gets.chomp.to_i
s = []
h = {}
m = 0
x, y = [], []
n.times do |i|
  x[i], y[i] = gets.chomp.split.map(&:to_i)
end
n.times do |i|
  n.times do |j|
    l = [x[i] - x[j], y[i] - y[j]]
    next if l == [0, 0]
    next if s.include?([-l[0], -l[1]])
    if !s.include?(l)
      s << l
      h[l] = 1
      m = 1 if m == 0
    else
      h[l] += 1
      m = h[l] if m < h[l]
    end
  end
end
puts n - m
//  [rust]
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;

fn main() {
    input!{
        n:usize,
        xy: [[i64;2];n]
    }
    let mut h = HashSet::new();
    for i in 0..n {
        for j in 0..n {
            if i==j {
                continue;
            }
            let dx = xy[i][0] - xy[j][0];
            let dy = xy[i][1] - xy[j][1];
            h.insert((dx, dy));
        }
    }
    let mut ans = n;
    for &(dx, dy) in h.iter() {
        let mut cur = n;
        for i in 0..n {
            let nx = xy[i][0]+dx;
            let ny = xy[i][1]+dy;

            if xy.contains(&vec![nx, ny]) {
                cur -=1;
            }
        }
        ans = std::cmp::min(ans, cur);
    }
    println!("{}", ans);
}
//  [rust]
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let balls: Vec<(isize, isize)> = (0..n).map(|_| {
        let x: isize = iterator.next().unwrap().parse().unwrap();
        let y: isize = iterator.next().unwrap().parse().unwrap();
        (x, y)
    }).collect();

    if n == 1 {
        return "1".to_string();
    }

    let mut ans = 50;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            let p = balls[i].0 - balls[j].0;
            let q = balls[i].1 - balls[j].1;
            let mut count = 0;
            for k in 0..n {
                for l in 0..n {
                    if k == l {
                        continue;
                    }
                    if balls[l].0 - balls[k].0 == p && balls[l].1 - balls[k].1 == q {
                        count += 1;
                    }
                }
            }
            ans = min(ans, n - count);
        }
    }
    return ans.to_string();
}
//  [python]
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

a, b, c, d = getNM()
x = [a, b]
y = [c, d]

ans = []
for i in range(2):
    for j in range(2):
        ans.append(x[i] * y[j])

ans.sort()
print(ans[-1])
//  [python]
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
a,b,c,d = I()
mx = max(a*c,a*d,b*c,b*d)
print(mx)
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		solve(a, b, c, d);
	}

	private static void solve(long a, long b, long c, long d) {
		// TODO Auto-generated method stub
		long ans = Long.MIN_VALUE;
		ans = Math.max(ans, a * c);
		ans = Math.max(ans, b * d);
		for (long i = b; i >= a; i--) {
			for (long j = d; j >= c; j--) {
				long t = i * j;
				if (ans > t) break;
				else {
					ans = Math.max(ans, t);
				}
			}
		}
		System.out.println(ans);
	}

}
//  [java]
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    sc.close();
    long ans = Long.MIN_VALUE;
    ans = Math.max(ans, a * c);
    ans = Math.max(ans, a * d);
    ans = Math.max(ans, b * c);
    ans = Math.max(ans, b * d);
    System.out.println(ans);
  }
}
//  [java]
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    long c = scan.nextLong();
    long d = scan.nextLong();
    long max = 0;
    
    if(b<=0 && d<=0){
      System.out.println(a*c);
    }else if(a>=0 && c>=0){
      System.out.println(b*d);
    }else if(b<=0 && c>=0){
      System.out.println(b*c);
    }else if(a>=0 && d<=0){
      System.out.println(a*d);
    }else{
      long ac = a*c;
      long bd = b*d;
      if(ac >= bd){
        System.out.println(ac);
      }else{
        System.out.println(bd);
      }
    }
    
  }
}
//  [cpp]
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define F(i,n) for(long long int i=0;i<n;i++)
#define REF(i,a,b) for(int i=a;i<=b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ln "\n"
#define milli 1000000
#define M 1000000007
#define fastio ios::sync_with_stdio(0);cin.tie(0);

const ll N=1e7+1;
int p[N];

bool prime(ll n)
{
    if(n<2)return false;
    for(ll x=2;x*x<=n;x++)
    {
        if(n%x==0)
            return false;
    }
    return true;
}

ll largestDigit(ll n)
{
    ll largest=0;
    while(n)
    {
        ll r=n%10;
        largest=max(r,largest);
        n=n/10;
    }
    return largest;
}

ll smallestDigit(ll n)
{
    ll smallest=10;
    while(n)
    {
        ll r=n%10;
        smallest=min(r,smallest);
        n=n/10;
    }
    return smallest;
}

int numOfFactors(ll n)
{
    int ans=1;
    while(n > 1){
            int prime = p[n],cnt = 1;
            while(n % prime == 0)cnt++, n/=prime;
            ans*=cnt;
        }
    return ans;
}




int main()
{
   for(int i=2;i<N;i++)
    {
        if(p[i])
            continue;
        for(int j=i;j<N;j+=i)
            p[j]=i;
    }
    fast;
    fastio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll arr[4];
    arr[0]=a*c;
    arr[1]=a*d;
    arr[2]=b*c;
    arr[3]=b*d;
    cout<<*max_element(arr,arr+4)<<ln;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









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


//Answer


int main() {

long A,B,C,D;
cin>>A>>B>>C>>D;
if(C>=0){
    if(B>=0){
        cout<<B*D<<endl;;
    }else{
        cout<<B*C<<endl;
    }
}else if(D>=0){
    if(A*C>B*D){
        cout<<A*C<<endl;
    }else{
        cout<<B*D<<endl;
    }
}else{
    if(A>=0){
        cout<<A*D<<endl;
    }else{
        cout<<A*C<<endl;
    }
}

}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	long long int a, b, c, d;
	int i, fin;
	long long int p[4], temp;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a = atoi(ch);
	ch = strtok(NULL, " ");
	b = atoi(ch);
	ch = strtok(NULL, " ");
	c = atoi(ch);
	ch = strtok(NULL, " ");
	d = atoi(ch);

	p[0] = a * c;
	p[1] = a * d;
	p[2] = b * c;
	p[3] = b * d;

	fin = 0;
	while(fin < 3) {
		for(i = 0; i < 3; i += 1) {
			if(p[i] < p[i + 1]) {
				fin = 0;
				temp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = temp;
			} else {
				fin += 1;
			}
		}
	}

	printf("%lld\n", p[0]);

	return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
	long long x[4],a,b,c,d,mx;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	x[0]=a*c; x[1]=a*d; x[2]=b*c; x[3]=b*d;
	mx=x[0];
	for(int i=0;i<4;i++) if(mx<x[i]) mx=x[i];
	printf("%lld\n",mx);
	return 0;
}
//  [c]
long max(long a, long b){return a>b?a:b;}
long a, b, c, d;
main(){scanf("%ld%ld%ld%ld", &a, &b, &c, &d);printf("%ld\n", max(max(a*c, a*d), max(b*c, b*d)));}
//  [javascript]
'use strict';

const main = arg => {
  const [a, b, c, d] = arg.trim().split(' ').map(x => BigInt(x));
  var ans = a*c;
  if (ans < a*d) ans = a*d;
  if (ans < b*c) ans = b*c;
  if (ans < b*d) ans = b*d;
  console.log(ans.toString());
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
var Main  = function(input){
    const [a, b, c, d] = input.trim().split(' ').map(x => BigInt(x));
    var array=[];

    array.push(a*c,a*d,b*c,b*d);
    array.sort((a,b)=>(a>b)? -1: (a<b)? 1: 0);
    // Bigintのソート

    console.log(array[0].toString(10));
};


Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
const main = arg => {
  const [a,b,c,d] = arg.trim().split(' ').map(x => BigInt(x));
  let max = a * c
  if (a * d > max) max = a * d
  if (b * c > max) max = b * c
  if (b * d > max) max = b * d
  console.log(max.toString())
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"fmt"
	"math"
)

func Max(A ...int) int {
	res := A[0]
	for i := 1; i < len(A); i++ {
		if res < A[i] {
			res = A[i]
		}
	}
	return res
}

func main() {
	var a, b, c, d int

	ans := math.MinInt64

	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
	xlist := []int{a, b}
	ylist := []int{c, d}
	for _, x := range xlist {
		for _, y := range ylist {
			ans = Max(ans, x*y)
		}
	}
	fmt.Println(ans)
}
//  [go]
package main
 
import(
  "fmt"
  "sort"
)
 
func main(){
  var a,b,c,d int
  fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
  var ary []int
  
  ary = append(ary, a*c)
  ary = append(ary, a*d)
  ary = append(ary, b*c)
  ary = append(ary, b*d)
  
  sort.Ints(ary)
  
  fmt.Printf("%d",ary[3])
  
  
}
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
a,b,c,d = gets.chomp.split.map(&:to_i)
puts [a*c, a*d, b*c, b*d].max
//  [ruby]
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a,b,c,d = inp
p [b*d,a*c,a*d,b*c].max
//  [ruby]
eval'A,B,C,D='+`tr ' ' ,`
p [A*C,A*D,B*C,B*D].max
//  [swift]
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readString() -> String {
    return readLine()!
}

func readLines(times: Int) -> [String] {
    var array = [String]()
    for _ in 0..<times {
        array.append(readLine()!)
    }
    return array
}

func readSeparatedStrings() -> [String] {
    return readLine()!.split(separator: " ").map {String($0)}
}

func readStringToStrings() -> [String] {
    return readLine()!.map{String($0)}
}

func readSeparatedInts() -> [Int] {
    return readLine()!.split(separator: " ").map {Int($0)!}
}
func readSeparatedDouble() -> [Double] {
    return readLine()!.split(separator: " ").map {Double($0)!}
}

// 二進数に変換
func convertIntToRadix2(n: Int, radix: Int = 2) -> String {
    return String(n, radix: radix)
}

//配列を逆順にする reverced ソートする　sorted
//最初数文字取得 prefix

let abcd = readSeparatedInts()

var products = [Int]()
products.append(abcd[0] * abcd[2])
products.append(abcd[0] * abcd[3])
products.append(abcd[1] * abcd[2])
products.append(abcd[1] * abcd[3])
products.sort { a, b in a > b }
print(products.first!)
//  [typescript]
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let [a, b, c, d] = lines[0].split(' ').map( _ => parseInt(_))
    let ans = BigInt(a) * BigInt(c)
    
    if(BigInt(a) * BigInt(d) > ans) {
        ans = BigInt(a) * BigInt(d)
    }

    if(BigInt(b) * BigInt(c) > ans) {
        ans = BigInt(b) * BigInt(c)
    }

    if(BigInt(b) * BigInt(d) > ans) {
        ans = BigInt(b) * BigInt(d)
    }

    console.log(String(ans));

});
//  [typescript]
import * as fs from "fs";

const input = fs.readFileSync("/dev/stdin", "utf8");
const a = +input.split(" ")[0];
const b = +input.split(" ")[1];
const c = +input.split(" ")[2];
const d = +input.split(" ")[3];

const ac = BigInt(a) * BigInt(c);
const ad = BigInt(a) * BigInt(d);
const bc = BigInt(b) * BigInt(c);
const bd = BigInt(b) * BigInt(d);

let max: BigInt;

if (ac >= ad && ac >= bc && ac >= bd) {
  max = ac;
} else if (ad >= ac && ad >= bc && ad >= bd) {
  max = ad;
} else if (bc >= ac && bc >= ad && bc >= bd) {
  max = bc;
} else if (bd >= ac && bd >= ad && bd >= bc) {
  max = bd;
}

console.log(`${max}`);
//  [typescript]
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let a: bigint = 0n;
    let b: bigint = 0n;
    let c: bigint = 0n;
    let d: bigint = 0n;
    let ans: string = "";
    // init
    [a, b, c, d] = input.shift().split(" ").map(x => BigInt(x));
    // solve
    let val: bigint = a * c;
    if (val < a * d) val = a * d;
    if (val < b * c) val = b * c;
    if (val < b * d) val = b * d;
    ans = String(val).replace("n", "");
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();
//  [python]
import heapq

N = int(input())
tasks = []
for _ in range(N):
  a,b = map(int,input().split())
  if b-a < 0:
    print('No')
    exit()
  else:
    heapq.heappush(tasks,[b,-a])
    
day = 0
while len(tasks) != 0:
  b, neg_a = heapq.heappop(tasks)
  if day - neg_a > b:
    print('No')
    exit()
  else: day -= neg_a
print('Yes')
//  [python]
import numpy as np
import sys

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    A = np.empty((N, 2))
    for i in range(N):
        A[i,:] = InputToInt()
    A = A[np.argsort(A[:, 0])]
    A = A[np.argsort(A[:, 1])]
    T = 0
    for i in range(N):
        T+=A[i, 0]
        if T > A[i, 1]:
            print('No')
            sys.exit()
    print('Yes')
//  [python]
import math
from fractions import gcd


class Work():

    def __init__(self, a, b):
        self.a = a
        self.b = b

    def __lt__(self, other):
        return self.b < other.b

    def __eq__(self, other):
        return self.b == other.b

    def __repr__(self):
        return "Work(%d, %d)" % (self.a, self.b)


def read():
    N = int(input().strip())
    works = []
    for i in range(N):
        a, b = list(map(int, input().strip().split()))
        works.append(Work(a, b))
    return N, works


def solve(N, works):
    works = sorted(works)
    t = 0
    for work in works:
        t += work.a
        if t > work.b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] a = new String[n];
        for (int i = 0; i < n; i++) {
            int cost = Integer.parseInt(sc.next());
            int time = Integer.parseInt(sc.next());
            a[i] = String.format("%010d", time) + "/" + cost;
        }

        Arrays.sort(a);
        int task = 0;
        boolean result = true;
        for (String s : a) {
            String[] info = s.split("/");
            int time = Integer.parseInt(info[0]);
            task += Integer.parseInt(info[1]);
            if (time < task) {
                result = false;
                break;
            }
        }

        System.out.println(result ? "Yes" : "No");
    }
}
//  [java]
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            List<List<Integer>> numList = args.stream().skip(1)
                    .map(s -> Arrays.stream(s.split(" ")).map(Integer::valueOf).collect(Collectors.toList()))
                    .sorted(Comparator.comparingInt(o -> o.get(1)))
                    .collect(Collectors.toList());
            int curr = 0;
            boolean ans = true;
            for (List<Integer> intPair: numList) {
                int load = intPair.get(0);
                int deadline = intPair.get(1);
                if (curr + load <= deadline) {
                    curr += load;
                } else {
                    ans = false;
                    break;
                }
            }
            System.out.println(ans ? "Yes" : "No");
        };
    }

}
//  [java]
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] ab = new int[n][2];
        long sum=0;
        boolean isAble = true;

        for (int i = 0; i < n; i++) {
            ab[i][0] = scanner.nextInt();
            ab[i][1] = scanner.nextInt();
        }

        Arrays.sort(ab, Comparator.comparingInt(t -> t[0]));
        Arrays.sort(ab, Comparator.comparingInt(t -> t[1]));

        for (int i = 0; i < n; i++) {
            sum += ab[i][0];
            if(sum > ab[i][1]){
                isAble=false;
                break;
            }
        }

        if(isAble){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

template<typename T, typename Q>
istream &operator>>(istream &is, pair<T, Q> &p) {
	return is >> p.first >> p.second;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for (auto &x : v) is >> x;
	return is;
}

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

template<typename T>
ostream &operator<<(ostream &os, vector<T> v) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); it++)
		os << (it == v.begin() ? "" : ", ") << *it;
	return os << "]";
}

template<typename T, typename Q>
ostream &operator<<(ostream &os, map<T, Q> m) {
	os << "[";
	for (auto it = m.begin(); it != m.end(); it++) 
		os << (it == m.begin() ? "" : ", ") << *it;
	return os;
}
#define imie(...) " [" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
#define int long long

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].second >> a[i].first;
	}
	int sum = 0;
	sort(a.begin(), a.end());
	cerr << imie(a) << '\n';
	for (int i = 0; i < n; i++) {
		sum += a[i].second;
		if (sum > a[i].first) {
			cerr << imie(i) << '\n';
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

bool comp(l_l a,l_l b){
    return a.second<b.second;
}

int main(){fastio
    ll n;cin>>n;
    l_l a[n];rep(i,0,n-1)cin>>a[i].first>>a[i].second;
    sort(a,a+n,comp);
    
    rep(q,1,5000){
        ll time=0;
        rep(i,0,n-1){
            time+=a[i].first;
            if(time>a[i].second){
                cout<<"No"<<endl;return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}
//  [cpp]
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector< vector <long long int> > v(n);
  for (int i = 0; i < n; i++) {
    long long int tmp1;
    long long int tmp2;
    cin >> tmp1 >> tmp2;
    v[i].push_back(tmp1);
    v[i].push_back(tmp2);
  }

  sort(v.rbegin(), v.rend(), [](auto& x, auto& y) {return x[1] < y[1];});

  long long int tlimit = v[0][1];
  long long int count = 0;
  for (int i = 0; i < n; i++) {
    while (tlimit > 0) {
      if (v[i][1] >= tlimit) {
        tlimit -= v[i][0];
        count++;
        break;
      } else {
        tlimit--;
      }
    }
  }
  if (tlimit >= 0 && count == n) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
//  [c]
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

void merge_sort(int *t1, int *s1, int left, int right){//t1に基づいて。
    if(left==right){
        ;
    }
    else{
        int n2=(right-left+1)/2;
        int n3=right-left+1-n2;
        int i=0,j=0,k=0;

        // rep(p,n2+n3){
        //   printf("t1[%d] = %p, t1[%d][0] = %d, t1[%d][1] = %d\n", p, t1[p], p, t1[p][0], p, t1[p][1]);
        // }

        merge_sort(t1, s1, left, left+n2-1);
        merge_sort(t1, s1, left+n2, right);

        int *t2=(int *)malloc(sizeof(int)*n2);
        int *t3=(int *)malloc(sizeof(int)*n3);
        int *s2=(int *)malloc(sizeof(int)*n2);
        int *s3=(int *)malloc(sizeof(int)*n3);

        for(i=0;i<n2;i++){
          t2[i]=t1[left+i];
          s2[i]=s1[left+i];
        }
        for(i=0;i<n3;i++){
          t3[i]=t1[left+n2+i];
          s3[i]=s1[left+n2+i];
        }

        // printf("t2[0] = %d, t3[0] = %d\n", t2[0], t3[0]);
        // printf("s2[0] = %d, s3[0] = %d\n", s2[0], s3[0]);

        //ここの実装にn時間かかった。定義されていない領域にアクセスしないの重要。
        for(i=0;i<n2+n3;i++){
            if(k==n3 || (j<n2 && t2[j]<t3[k])){
                t1[left+i]=t2[j];
                s1[left+i]=s2[j];
                j++;
            }
            else{
                t1[left+i]=t3[k];
                s1[left+i]=s3[k];
                k++;
            }
        }
    }
}


int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  int *B=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%d %d", &A[i], &B[i]);
  }

  merge_sort(B, A, 0, N-1);

  long *sum=(long *)malloc(sizeof(long)*N);
  sum[0]=A[0];
  srep(i, 1, N){
    sum[i]=sum[i-1]+A[i];
  }

  int flag=0;
  rep(i,N){
    if(sum[i]>B[i]){
      flag=1;
      break;
    }
  }

  if(flag==1){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }

  return 0;


}
//  [c]
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


typedef unsigned long long int uint64;
typedef long long int          int64;

typedef struct _tmp_t {
  int64 a;
  int64 b;
} tmp_t;

void get_ab (int64 *a, int64 *b)
{
  int cnt;
  
  cnt = scanf("%lld %lld", a, b);

  return;
}

void get_n (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

int64 gcd(int64 a,int64 b){int64 c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int64 lcm(int64 a,int64 b){int64 c=gcd(a,b);a/=c;return a*b;};


#define SIZE (10*10*10*10*10*2)
tmp_t job[SIZE];


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N;
  int64 i;
  int64 t = 0;

  get_n(&N);

  for (i=0; i<N; i++) {
    get_ab(&job[i].a, &job[i].b);
  }

  qsort_a(job, N);
  qsort_b(job, N);

  for (i=0; i<N; i++) {
    t += job[i].a;
    if (t > job[i].b) {
      printf("No");
      return 0;
    }
  }
  
  printf("Yes");

  return 0;
}
//  [c]
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,a[200010],b,t=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a[R],&b);
    hin(b);
  }
  for(i=0;i<n;i++){
    b=hout();
    t+=a[b];
    if(t>N[b])break;
  }
  printf("%s\n",i-n?"No":"Yes");
  return 0;
}