Language: C++

#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FS first
#define SC second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for (auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for (auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&a){return accumulate(ALL(a),T());}
template<typename T>T max(vector<T>&a){return *max_element(ALL(a));}
template<typename T>T min(vector<T>&a){return *max_element(ALL(a));}
template<typename T>T max_index(vector<T>&a){return distance((a).begin(),max_element(ALL(a)));}
template<typename T>T min_index(vector<T>&a){return distance((a).begin(),min_element(ALL(a)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

signed main()
{
   int N, A, B; cin >> N >> A >> B;
   V<int> v(N);
   REP(i, N) {
      cin >> v[i];
   }

   map<int,int> cnt;
   REP(i, N) {
      cnt[v[i]]++;
   }

   int num = 0, sum = 0;
   REACH(i, cnt) {
      int n = i->SC, x = i->FS;
      if (num + n <= A) {
         num += n;
         sum += n * x;
      } else {
         sum += (A - num) * x;
         break;
      }
   }

   printf("%.9lf\n", (double)sum/A);
   cout << (cnt.size() == 1 ? (1LL<<50)-1 : 1) << endl;

   return 0;
}


Compiler output:
a.cc:30:41: error: 'pair' does not name a type
   30 | template<typename T,typename U> using P=pair<T,U>;
      |                                         ^~~~
a.cc:31:30: error: 'vector' does not name a type
   31 | template<typename T> using V=vector<T>;
      |                              ^~~~~~
a.cc:34:27: error: 'vector' was not declared in this scope
   34 | template<typename T>T sum(vector<T>&a){return accumulate(ALL(a),T());}
      |                           ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define int long long int
a.cc:34:35: error: expected primary-expression before '>' token
   34 | template<typename T>T sum(vector<T>&a){return accumulate(ALL(a),T());}
      |                                   ^
a.cc:34:37: error: 'a' was not declared in this scope
   34 | template<typename T>T sum(vector<T>&a){return accumulate(ALL(a),T());}
      |                                     ^
a.cc:34:39: error: expected ';' before '{' token
   34 | template<typename T>T sum(vector<T>&a){return accumulate(ALL(a),T());}
      |                                       ^
      |                                       ;
a.cc:35:27: error: 'vector' was not declared in this scope
   35 | template<typename T>T max(vector<T>&a){return *max_element(ALL(a));}
      |                           ^~~~~~
a.cc:35:27: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:35:35: error: expected primary-expression before '>' token
   35 | template<typename T>T max(vector<T>&a){return *max_element(ALL(a));}
      |                                   ^
a.cc:35:37: error: 'a' was not declared in this scope
   35 | template<typename T>T max(vector<T>&a){return *max_element(ALL(a));}
      |                                     ^
a.cc:35:39: error: expected ';' before '{' token
   35 | template<typename T>T max(vector<T>&a){return *max_element(ALL(a));}
      |                                       ^
      |                                       ;
a.cc:36:27: error: 'vector' was not declared in this scope
   36 | template<typename T>T min(vector<T>&a){return *max_element(ALL(a));}
      |                           ^~~~~~
a.cc:36:27: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:36:35: error: expected primary-expression before '>' token
   36 | template<typename T>T min(vector<T>&a){return *max_element(ALL(a));}
      |                                   ^
a.cc:36:37: error: 'a' was not declared in this scope
   36 | template<typename T>T min(vector<T>&a){return *max_element(ALL(a));}
      |                                     ^
a.cc:36:39: error: expected ';' before '{' token
   36 | template<typename T>T min(vector<T>&a){return *max_element(ALL(a));}
      |                                       ^
      |                                       ;
a.cc:37:33: error: 'vector' was not declared in this scope
   37 | template<typename T>T max_index(vector<T>&a){return distance((a).begin(),max_element(ALL(a)));}
      |                                 ^~~~~~
a.cc:37:33: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:37:41: error: expected primary-expression before '>' token
   37 | template<typename T>T max_index(vector<T>&a){return distance((a).begin(),max_element(ALL(a)));}
      |                                         ^
a.cc:37:43: error: 'a' was not declared in this scope
   37 | template<typename T>T max_index(vector<T>&a){return distance((a).begin(),max_element(ALL(a)));}
      |                                           ^
a.cc:37:45: error: expected ';' before '{' token
   37 | template<typename T>T max_index(vector<T>&a){return distance((a).begin(),max_element(ALL(a)));}
      |                                             ^
      |                                             ;
a.cc:38:33: error: 'vector' was not declared in this scope
   38 | template<typename T>T min_index(vector<T>&a){return distance((a).begin(),min_element(ALL(a)));}
      |                                 ^~~~~~
a.cc:38:33: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:38:41: error: expected primary-expression before '>' token
   38 | template<typename T>T min_index(vector<T>&a){return distance((a).begin(),min_element(ALL(a)));}
      |                                         ^
a.cc:38:43: error: 'a' was not declared in this scope
   38 | template<typename T>T min_index(vector<T>&a){return distance((a).begin(),min_element(ALL(a)));}
      |                                           ^
a.cc:38:45: error: expected ';' before '{' token
   38 | template<typename T>T min_index(vector<T>&a){return distance((a).begin(),min_element(ALL(a)));}
      |                                             ^
      |                                             ;
a.cc:42:26: error: declaration of 'operator<<' as non-function
   42 | template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
      |                          ^~~~~~~~
a.cc:42:37: error: 'ostream' was not declared in this scope
   42 | template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
      |                                     ^~~~~~~
a.cc:1:1: note: 'std::ostream' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define int long long int
a.cc:42:45: error: 's' was not declared in this scope
   42 | template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
      |                                             ^
a.cc:42:47: error: expected primary-expression before 'const'
   42 | template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
      |                                               ^~~~~
a.cc:43:37: error: declaration of 'operator<<' as non-function
   43 | template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
      |                                     ^~~~~~~~
a.cc:43:48: error: 'ostream' was not declared in this scope
   43 | template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
      |                                                ^~~~~~~
a.cc:43:48: note: 'std::ostream' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:43:56: error: 's' was not declared in this scope
   43 | template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
      |                                                        ^
a.cc:43:58: error: expected primary-expression before 'const'
   43 | template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
      |                                                          ^~~~~
a.cc:43:72: error: expected primary-expression before '>' token
   43 | template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
      |                                                                        ^
a.cc:43:74: error: 'p' was not declared in this scope
   43 | template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
      |                                                                          ^
a.cc:44:26: error: declaration of 'operator<<' as non-function
   44 | template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
      |                          ^~~~~~~~
a.cc:44:37: error: 'ostream' was not declared in this scope
   44 | template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
      |                                     ^~~~~~~
a.cc:44:37: note: 'std::ostream' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:44:45: error: 's' was not declared in this scope
   44 | template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
      |                                             ^
a.cc:44:47: error: expected primary-expression before 'const'
   44 | template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
      |                                               ^~~~~
a.cc:45:37: error: declaration of 'operator<<' as non-function
   45 | template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
      |                                     ^~~~~~~~
a.cc:45:48: error: 'ostream' was not declared in this scope
   45 | template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
      |                                                ^~~~~~~
a.cc:45:48: note: 'std::ostream' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:45:56: error: 's' was not declared in this scope
   45 | template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
      |                                                        ^
a.cc:45:58: error: expected primary-expression before 'const'
   45 | template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto