Загрузка данных


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Punkt
{
    long long iks,igrek;
};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int liczbaPunktow;
    if(!(cin>>liczbaPunktow)) return 0;
    
    vector<Punkt> punkty(liczbaPunktow);
    for(int i=0; i<liczbaPunktow; i++)
    {
        cin>>punkty[i].iks>>punkty[i].igrek;
    }
    
    sort(punkty.begin(),punkty.end(),[](const Punkt& a, const Punkt& b){
        if(a.iks!=b.iks) return a.iks<b.iks;
        return a.igrek<b.igrek;
    });
    
    long long maksymalnePole=-1;
    
    for(int i=0; i<liczbaPunktow; i++)
    {
        for(int j=i+1; j<liczbaPunktow; j++)
        {
            if(punkty[i].iks==punkty[j].iks && punkty[i].igrek<punkty[j].igrek)
            {
                long long x1=punkty[i].iks;
                long long y1=punkty[i].igrek;
                long long y2=punkty[j].igrek;
                
                long long szerokosc=y2-y1;
                if(szerokosc*szerokosc<=maksymalnePole) continue;
                
                for(int k=j+1; k<liczbaPunktow; k++)
                {
                    if(punkty[k].iks>x1)
                    {
                        long long x2=punkty[k].iks;
                        long long pole=(x2-x1)*szerokosc;
                        if(pole<=maksymalnePole) break;
                        
                        Punkt p3={x2,y1};
                        Punkt p4={x2,y2};
                        
                        auto it3=lower_bound(punkty.begin(),punkty.end(),p3,[](const Punkt& a, const Punkt& b){
                            if(a.iks!=b.iks) return a.iks<b.iks;
                            return a.igrek<b.igrek;
                        });
                        
                        auto it4=lower_bound(punkty.begin(),punkty.end(),p4,[](const Punkt& a, const Punkt& b){
                            if(a.iks!=b.iks) return a.iks<b.iks;
                            return a.igrek<b.igrek;
                        });
                        
                        bool jest3=(it3!=punkty.end() && it3->iks==p3.iks && it3->igrek==p3.igrek);
                        bool jest4=(it4!=punkty.end() && it4->iks==p4.iks && it4->igrek==p4.igrek);
                        
                        if(jest3 && jest4)
                        {
                            if(pole>maksymalnePole)
                            {
                                maksymalnePole=pole;
                            }
                        }
                    }
                }
            }
        }
    }
    
    cout<<maksymalnePole<<"\n";
    
    return 0;
}