Problem:
Closest Pair

For given n points in metric space, find the distance of the closest points.

Input

n
x0 y0
x1 y1
:
xn-1 yn-1

The first integer n is the number of points.

In the following n lines, the coordinate of the i-th point is given by two real numbers xi and yi. Each value is a real number with at most 6 digits after the decimal point.

Output

Print the distance in a line. The output values should be in a decimal fraction with an error less than 0.000001.

Constraints

2 ≤ n ≤ 100,000

-100 ≤ x, y ≤ 100

Sample Input 1

2
0.0 0.0
1.0 0.0

Sample Output 1

1.000000

Sample Input 2

3
0.0 0.0
2.0 0.0
1.0 1.0

Sample Output 2

1.41421356237

Solution in C++11 (judge verdict: Time Limit Exceeded)

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<pair<double, double>>data;
	data.resize(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> data[i].first >> data[i].second;
	}
	sort(data.begin(), data.end(), [](const pair<double, double>a, const pair<double, double>b) {return a.first == b.first ? a.second < b.second : a.first < b.first; });
	double ans = 100000.0, memo;
	for (size_t i = 0; i < N - 1; i++)
	{
		memo = abs(data[i + 1].second - data[i].second);
		int j = 1;
		ans = min((data[i + j].first - data[i].first)*(data[i + j].first - data[i].first) + (data[i + j].second - data[i].second)*(data[i + j].second - data[i].second), ans);
		while (i+j<N&&memo >= abs(data[i + j].first - data[i].first))
		{
			ans = min((data[i + j].first - data[i].first)*(data[i + j].first - data[i].first) + (data[i + j].second - data[i].second)*(data[i + j].second - data[i].second), ans);
			j++;
		}
	}
	cout << fixed << setprecision(8)<<sqrt(ans) << endl;
	return 0;
}