Language: C++

#include<cmath>
#include<iostream>
#include<complex>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef complex<double> P;
const double eps = 1e-9;
double pi= acos(-1);
double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}


int ccw(P a,P b){
  if ( cross(a,b)<0)return 1;
  else return -1;
}

namespace std{
  bool operator<(const P &a,const P &b){
    if ( a.real() != b.real())return a.real() < b.real();
    else return a.imag() < b.imag();
  }
}

void ConvexHull(int n,P *inp,P *out,int &p){
  sort(inp,inp+n);
  bool used[n];
  int num[n];
  fill(used,used+n,false);
  p=0;
  out[p++]=inp[0];out[p++]=inp[1];
  used[1]=true;
  num[0]=0;num[1]=1;
  REP(i,2,n){
    while(p>=2){
      if ( ccw(out[p-1]-out[p-2],inp[i]-out[p-2])==1)break;
      used[num[p-1]]=false;
      p--;
    }
    num[p]=i;
    used[i]=true;
    out[p++]=inp[i];
  }
  
  for(int i=n-2,t=p+1;i>=0;i--){
    if (used[i]==true)continue;
    while(p>=t){
      if ( ccw(out[p-1]-out[p-2],inp[i]-out[p-2])==1)break;
      else p--;
    }
    out[p++]=inp[i];
  }
  return;
}

bool check(int n,P *in,P*cmp,int base){
  rep(i,n){
    if ( abs(in[i]-cmp[(base+i)%n])>=1e-5)return false;
  }
  return true;
}

void rotate_all(int n,P *in,P * out,double angle){
  rep(i,n){
    out[i].real()=in[i].real()*cos(angle)-in[i].imag()*sin(angle);
    out[i].imag()=in[i].real()*sin(angle)+in[i].imag()*cos(angle);
  }
}

double solve(int n,P*in1,P*in2){
  static P in[1000],cmp[1000],tmp[1000],rot[1000];
  static int p1,p2,p;
  double ans = 10000000;

  ConvexHull(n,in1,in,p1);
  ConvexHull(n,in2,cmp,p2);

  p=p1-1;
  rep(i,p)in[i]-=in[0];
  
  
  rep(i,p){
    int base=i;
    rep(j,p)tmp[j]=cmp[j]-cmp[base];
    double a=abs(in[1]),b=abs(tmp[(base+1)%n]),c=abs(in[1]-tmp[(base+1)%n]);
    double angle = acos((a*a+b*b-c*c) /(2*a*b));
			
    if( angle < 0){
      angle = angle +2* pi;
    }
    //angle verification
    rotate_all(p,tmp,rot,angle);
    if ( check(p,in,rot,base))ans=min(angle,ans);
  }
  return ans;
}




main(){
  int n;
  P in1[1000],in2[1000];
  while(cin>>n && n){
    rep(i,n)cin>>in1[i].real()>>in1[i].imag();
    rep(i,n)cin>>in2[i].real()>>in2[i].imag();
    printf("%.7lf\n",solve(n,in1,in2));
  }
}

Compiler output:
a.cc: In function 'void ConvexHull(int, P*, P*, int&)':
a.cc:29:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   29 |   sort(inp,inp+n);
      |   ^~~~
      |   sqrt
a.cc: In function 'void rotate_all(int, P*, P*, double)':
a.cc:68:16: error: lvalue required as left operand of assignment
   68 |     out[i].real()=in[i].real()*cos(angle)-in[i].imag()*sin(angle);
      |     ~~~~~~~~~~~^~
a.cc:69:16: error: lvalue required as left operand of assignment
   69 |     out[i].imag()=in[i].real()*sin(angle)+in[i].imag()*cos(angle);
      |     ~~~~~~~~~~~^~
a.cc: At global scope:
a.cc:104:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  104 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:108:16: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double')
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |             ~~~^~~~~~~~~~~~~~~
      |             |               |
      |             |               double
      |             std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
                 from a.cc:2:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:181:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:184:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:188:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:192:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  199 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:199:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  203 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:203:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  219 |       operator>>(float& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:219:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  223 |       operator>>(double& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:223:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  227 |       operator>>(long double& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:227:7: note:   conversion of argument 1 would be ill-formed:
a.cc:108:29: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double'
  108 |     rep(i,n)cin>>in1[i].real()>>in1[i].imag();
      |                  ~~~~~~~~~~~^~
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
  328 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/14/istream:328:25: note:   no known conversion for argument 1 from 'double' to 'void*&'
  328 |       operator>>(void*& __p)
      |                  ~~~~~~~^~~
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
  122 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |       ^~~~~~~~
/usr/include/c++/14/istream:122:36: note:   no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
  122 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type