Language: C++

#include <bits/stdc++.h>

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];
 ll C[101][101]; // C[n][k] -> nCk

 void comb_table(int N){
 for(int i=0;i<=N;++i){
 for(int j=0;j<=i;++j){
	if(j==0 or j==i){
	 C[i][j]=1;
 }else{
 C[i][j]=(C[i-1][j-1]+C[i-1][j]);
 }
 }
}
 }
int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
   	int n;
   	cin>>n;
   	comb_table(100);
   	int a,b;
   	cin>>a>>b;
   	vl vec;
   	mapii mps,mps2,mps3;
   	for(int i=0; i<n; ++i)
   	{
   		ll x;
   		cin>>x;
   		vec.pb(x);
   		++mps[x];
   	}
   	sort(all(vec));
   	double avg = 0.0;
   	reverse(all(vec));
   	//cout<<"\n"<<"\n";
   	//print(vec);
   	double sum = 0.0;
   	int idx = 0;
   	int x=vec[0];
   	int flag = 0;
   	for(int i=0; i<a; ++i)
   	{
   		sum+=(double)vec[i];
   		if(vec[i]==x)
   			++flag;
   	}
   	ll ans = 0;
   	avg = sum/a;
   	if(flag==a)
   	{
   		int y = mps[x];
   		for(int i=a; i<=b; ++i)
   		{
   			ans+=C[y][i];
   		}
   		cout<<fixed<<avg<<"\n";
   		cout<<ans<<"\n";
   		return 0;
   	}
   	ans = 1;
   	for(int i=0; i<a; ++i)
   	{
   		++mps2[vec[i]];
   	}
   	for(int i=0; i<a; ++i)
   	{
   		//cout<<vec[i]<<" "<<C[mps[vec[i]]][mps2[vec[i]]]<<"\n";
   		if(!mps3[vec[i]])
   		{
   			ans*=C[mps[vec[i]]][mps2[vec[i]]];
   			++mps3[vec[i]];
   		}
   		
   	}
   	cout<<fixed<<avg<<"\n";
   	cout<<ans<<"\n";
   	
 	   
}#include <bits/stdc++.h>

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];
 ll C[101][101]; // C[n][k] -> nCk

 void comb_table(int N){
 for(int i=0;i<=N;++i){
 for(int j=0;j<=i;++j){
	if(j==0 or j==i){
	 C[i][j]=1;
 }else{
 C[i][j]=(C[i-1][j-1]+C[i-1][j]);
 }
 }
}
 }
int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
   	int n;
   	cin>>n;
   	comb_table(100);
   	int a,b;
   	cin>>a>>b;
   	vl vec;
   	mapii mps,mps2,mps3;
   	for(int i=0; i<n; ++i)
   	{
   		ll x;
   		cin>>x;
   		vec.pb(x);
   		++mps[x];
   	}
   	sort(all(vec));
   	double avg = 0.0;
   	reverse(all(vec));
   	//cout<<"\n"<<"\n";
   	//print(vec);
   	double sum = 0.0;
   	int idx = 0;
   	int x=vec[0];
   	int flag = 0;
   	for(int i=0; i<a; ++i)
   	{
   		sum+=(double)vec[i];
   		if(vec[i]==x)
   			++flag;
   	}
   	ll ans = 0;
   	avg = sum/a;
   	if(flag==a)
   	{
   		int y = mps[x];
   		for(int i=a; i<=b; ++i)
   		{
   			ans+=C[y][i];
   		}
   		cout<<fixed<<avg<<"\n";
   		cout<<ans<<"\n";
   		return 0;
   	}
   	ans = 1;
   	for(int i=0; i<a; ++i)
   	{
   		++mps2[vec[i]];
   	}
   	for(int i=0; i<a; ++i)
   	{
   		//cout<<vec[i]<<" "<<C[mps[vec[i]]][mps2[vec[i]]]<<"\n";
   		if(!mps3[vec[i]])
   		{
   			ans*=C[mps[vec[i]]][mps2[vec[i]]];
   			++mps3[vec[i]];
   		}
   		
   	}
   	cout<<fixed<<avg<<"\n";
   	cout<<ans<<"\n";
   	
 	   
}

Compiler output:
a.cc:144:2: error: stray '#' in program
  144 | }#include <bits/stdc++.h>
      |  ^
a.cc: In function 'void unite(int, int)':
a.cc:58:53: error: reference to 'size' is ambiguous
   58 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |                                                     ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:55:4: note:                 'std::vector<int> size'
   55 | vi size(200001,1);
      |    ^~~~
a.cc:58:61: error: reference to 'size' is ambiguous
   58 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |                                                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:55:4: note:                 'std::vector<int> size'
   55 | vi size(200001,1);
      |    ^~~~
a.cc:58:79: error: reference to 'size' is ambiguous
   58 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |                                                                               ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:55:4: note:                 'std::vector<int> size'
   55 | vi size(200001,1);
      |    ^~~~
a.cc:58:90: error: reference to 'size' is ambiguous
   58 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |                                                                                          ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:55:4: note:                 'std::vector<int> size'
   55 | vi size(200001,1);
      |    ^~~~
a.cc: At global scope:
a.cc:144:3: error: 'include' does not name a type
  144 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:149:11: error: redefinition of 'const int INF'
  149 | const int INF = 1e9;
      |           ^~~
a.cc:6:11: note: 'const int INF' previously defined here
    6 | const int INF = 1e9;
      |           ^~~
a.cc:180:10: error: redefinition of 'std::ifstream fin'
  180 | ifstream fin("input.txt");
      |          ^~~
a.cc:37:10: note: 'std::ifstream fin' previously declared here
   37 | ifstream fin("input.txt");
      |          ^~~
a.cc:181:10: error: redefinition of 'std::ofstream fout'
  181 | ofstream fout("output.txt");
      |          ^~~~
a.cc:38:10: note: 'std::ofstream fout' previously declared here
   38 | ofstream fout("output.txt");
      |          ^~~~
a.cc:188:4: error: redefinition of 'long long int fast_exp(long long int, long long int)'
  188 | ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
      |    ^~~~~~~~
a.cc:45:4: note: 'long long int fast_exp(long long int, long long int)' previously defined here
   45 | ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
      |    ^~~~~~~~
a.cc:189:5: error: redefinition of 'int gcd(int, int)'
  189 | int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
      |     ^~~
a.cc:46:5: note: 'int gcd(int, int)' previously defined here
   46 | int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
      |     ^~~
a.cc:190:5: error: redefinition of 'int val(char)'
  190 | int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
      |     ^~~
a.cc:47:5: note: 'int val(char)' previously defined here
   47 | int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
      |     ^~~
a.cc:191:4: error: redefinition of 'long long int pows(int, int)'
  191 | ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
      |    ^~~~
a.cc:48:4: note: 'long long int pows(int, int)' previously defined here
   48 | ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
      |    ^~~~
a.cc:192:4: error: redefinition of 'long long int logx(long long int, long long int)'
  192 | ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
      |    ^~~~
a.cc:49:4: note: 'long long int logx(long long int, long long int)' previously defined here
   49 | ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
      |    ^~~~
a.cc:193:4: error: redefinition of 'long long int divisibles(long long int, long long int, long long int)'
  193 | ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
      |    ^~~~~~~~~~
a.cc:50:4: note: 'long long int divisibles(long long int, long long int, long long int)' previously defined here
   50 | ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
      |    ^~~~~~~~~~
a.cc:194:8: error: redefinition of 'std::string bitstring(int, int)'
  194 | string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
      |        ^~~~~~~~~
a.cc:51:8: note: 'std::string bitstring(int, int)' previously defined here
   51 | string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
      |        ^~~~~~~~~
a.cc:197:4: error: redefinition of 'std::vector<int> root'
  197 | vi root(200001,0);
      |    ^~~~
a.cc:54:4: note: 'std::vector<int> root' previously declared here
   54 | vi root(200001,0);
      |    ^~~~
a.cc:198:4: error: redefinition of 'std::vector<int> size'
  198 | vi size(200001,1);
      |    ^~~~
a.cc:55:4: note: 'std::vector<int> size' previously declared here
   55 | vi size(200001,1);
      |    ^~~~
a.cc:199:5: error: redefinition of 'int find(int)'
  199 | int find(int x){while(x!=root[x])x = root[x];return x;}
      |     ^~~~
a.cc:56:5: note: 'int find(int)' previously defined here
   56 | int find(int x){while(x!=root[x])x = root[x];return x;}
      |     ^~~~
a.cc:200:6: error: redefinition of 'bool same(int, int)'
  200 | bool same(int a,int b){return find(a)==find(b);}
      |      ^~~~
a.cc:57:6: note: 'bool same(int, int)' previously defined here
   57 | bool same(int a,int b){return find(a)==find(b);}
      |      ^~~~
a.cc:201:6: error: redefinition of 'void unite(int, int)'
  201 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |      ^~~~~
a.cc:58:6: note: 'void unite(int, int)' previously defined here
   58 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |      ^~~~~
a.cc: In function 'void unite(int, int)':
a.cc:201:53: error: reference to 'size' is ambiguous
  201 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |                                                     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:55:4: note:                 'std::vector<int> size'
   55 | vi size(200001,1);
      |    ^~~~
a.cc:201:61: error: reference to 'size' is ambiguous
  201 | void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}
      |                                                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))