akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

void fact(long long n, map<long long, long long> &m) {
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            long long cnt = 0;
            while (n % i == 0) cnt++, n /= i;
            m[i] += cnt;
        }
    }
    if (n != 1) m[n]++;
}

long long mod = 1e9 + 7;

int main() {

    long long N;
    cin >> N;

    map<long long, long long> m;
    for (long long i = 1; i <= N; i++) fact(i, m);

    long long ans = 1;
    for (auto x: m) ans *= (x.second + 1), ans %= mod;
    cout << ans << endl;

    return 0;
}
















































Measured memory_bytes: 256
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


N, X = map(int, input().split())

zahyo = list(map(int, input().split()))

zahyo.append(X)
zahyo.sort()

distant = []
for i in range(N):
    distant.append(zahyo[i+1] - zahyo[i])
# print(zahyo)
# print(distant)
ans = distant[0]
for i in range(1, N):
    ans = gcd(ans, distant[i])

print(ans)


Measured memory_bytes: 14224
#include <bits/stdc++.h>

using namespace std;

#define MAX_N  101
#define MAX_W   100001
int N, W;
vector<vector<long long> >  Lookup(MAX_N,vector<long long> (MAX_W,-1));
vector<int> wei(MAX_N);
vector<long long> val(MAX_N);

long long Knapsack(int c,int  n){
	if(c==0|| n==0)return 0;
	else
	if(Lookup[n][c]!=-1) return 	Lookup[n][c];
	else
	if(c-wei[n]>=0)
		return Lookup[n][c] = max(Knapsack(c-wei[n],n-1)+val[n],Knapsack(c,n-1));
	else return Knapsack(c,n-1);
	}
void fillDp(){
	for(int i =0;i<MAX_N;i++){
		for (int j=0;j<MAX_W;j++)
			Lookup[i][j]=-1;
	}	
}

int main(int argc, char** argv) 
{
	cin>>N>>W;
	for (int i =1;i<=N;i++){
		cin>>wei[i]>>val[i];
	}
	//fillDp();
	cout<<Knapsack(W,N)<<endl;

	return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> v(N),vmc(N);
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
	}
	for (int i = 0; i < N; ++i) {
		int c;
		cin >> c;
		vmc[i] = v[i] - c;
	}
	sort(vmc.begin(),vmc.end());

	int res = 0;
	for (int i = 0; i < N && vmc[N-i-1] > 0; ++i) {
		res += vmc[N-i-1];
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int n,m,a;
vector<int> t;

void funcr(){
  vector<int> u=t;
  t.clear();
  for(int i=0;i<n;i++){
    t.push_back(u[i]);
    t.push_back(u[n+i]);
  }
}

void funck(int x){
  vector<int> u=t;
  t.clear();
  for(int i=x;i<2*n;i++){
    t.push_back(u[i]);
  }
  for(int i=0;i<x;i++){
    t.push_back(u[i]);
  }
}

int main(){
  cin>>n>>m;
  for(int i=1;i<=n*2;i++)t.push_back(i);
  for(int i=0;i<m;i++){
    cin>>a;
    if(a==0)funcr();
    else funck(a);
  }
  for(int i=0;i<2*n;i++){
    cout<<t[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    
    ll N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N,0);

    for (ll i = 1; i < N; i++) {
        cin >> A.at(i);

        B.at(A.at(i)-1) += 1;
    }

    for (ll i = 0; i < N; i++) {
        cout << B.at(i) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4780
# -*- coding: utf-8 -*-

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


n = int(input())

a = (list(map(int, input().split())))

if n==2:
    print(max(a))
    exit()
'''
L = [gcd(a[0], a[1])]
R = [gcd(a[n-2], a[n-1])]
'''
L = [0 for i in range(n+1)]
R = [0 for i in range(n+1)]
for i in range(1,n+1):
    L[i] = gcd(L[i-1], a[i-1])

for i in range(n)[::-1]:
    R[i] = gcd(R[i+1], a[i])

m = [0 for i in range(n)]

for i in range(n):
    m[i] = gcd(L[i], R[i+1])

print(max(m))


Measured memory_bytes: 14400
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;

int main(){
  int a,b,c;
  cin >>a>>b>>c;

  

  if(a==b &&b==c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int n, k, a[maxN];

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> k;
	REP(i, n) {
		cin >> a[i];
	}
	REP(_, k) {
		vi ile(n + 1), b(n);
		REP(i, n) {
			ile[max(0, i - a[i])]++;
			ile[min(i + a[i] + 1, n)]--;
		}
		int sum = 0;
		REP(i, n) {
			sum += ile[i];
			b[i] = sum;
		}
		REP(i, n) a[i] = b[i];
		sum = 0;
		REP(i, n) {
			if (a[i] == n) sum++;
		}
		if (sum == n) break;
	}
	REP(i, n) cout << a[i] << " ";
	return 0;
}
 


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;

int d[11111], a[1111], b[1111];
int main() {
    int h, n;
    cin >> h >> n;
    fill(d + 1, d + h + 1, 1e9);
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    for(int i = 1; i <= h; i++)
        for(int j = 0; j < n; j++)
            d[i] = min(d[i], d[max(i - a[j], 0)] + b[j]);
    cout << d[h] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define ff(i, a, b) for(int i = a; i <= b; i++)
#define fo(i, a, b) for(int i = a; i < b; i++)
#define fod(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int INF = 1e9, N = 100010;
const ll INFL = 1e18;

typedef pair <long long, long long> ii;
typedef vector <int> vi;
typedef vector <ii> vii;

int n, w, h, X, Y;
long long ansx, ansy;
long long x[N], y[N];
ii a[N];
long long ans = INFL;

long long res(int X, int Y) {
	long long res = 0;
	long long mx = 0;
	ff(i, 1, n) res += abs(X - a[i].fi) + abs(Y - a[i].se), mx = max(mx, abs(X - a[i].fi) + abs(Y - a[i].se));
	res *= 2; res -= mx;
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin >> w >> h >> n;
	ff(i, 1, n) cin >> x[i] >> y[i], a[i].fi = x[i], a[i].se = y[i];
	sort(x + 1, x + n + 1); sort(y + 1, y + n + 1);
	int cent = ((n + 1)>>1);
	if (n & 1) {
		X = x[cent], Y = y[cent];
		ans = res(X, Y);
		ansx = X; ansy = Y;
	}
	else {
		X = x[cent], Y = y[cent];
		if (ans > res(X, Y)) { ans = res(X, Y); ansx = X; ansy = Y; }
		X = x[cent], Y = y[cent+1];
		if (ans > res(X, Y)) { ans = res(X, Y); ansx = X; ansy = Y; }
		X = x[cent+1], Y = y[cent];
		if (ans > res(X, Y)) { ans = res(X, Y); ansx = X; ansy = Y; }
		X = x[cent+1], Y = y[cent+1];
		if (ans > res(X, Y)) { ans = res(X, Y); ansx = X; ansy = Y; }
	}
	printf("%lld\n%lld %lld\n", ans, ansx, ansy);
}

Measured memory_bytes: 4356
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);

  int i,ans;
  ans=0;
  for(i=0; i<2; i++){
    if(a>b){
      ans += a;
      a--;
    }
    else{
      ans+=b;
      b--;
    }
  }

  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main() {
  int n,k,s;
  cin >> n >> k >> s;
  int c=1e9-1;
  rep(i,n){
    if(i<k){
      cout << s << " ";
    }else{
      cout << c << " ";
    }
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long


int main(){
    IOS;

    long int n,w;
    cin>>n>>w;

    vector<long int> prices(n), weights(n);
    for(long int i = 0; i < n; i++)
        cin>>weights[i]>>prices[i];
    
    vector<vector<long int>> dp(w+1,vector<long int>(n+1));
    for(long int i = 1; i <= w; i++)
        for(long int j = 1; j <= n; j++)
            if(weights[j-1] > i)
                dp[i][j] = dp[i][j-1];
            else
                dp[i][j] = max(max(dp[i][j],dp[i-weights[j-1]][j-1] + prices[j-1]),dp[i][j-1]);
            

    cout<<dp[w][n];
    return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[1000010];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}


int main() {
    long long l, r;
    cin >> l >> r;
    
    long long mul = 2019;
    long long pw = 1;
    while (mul * pw < l) {
        pw++;
    }
    mul *= pw;
    if (mul >= l && r > mul) {
        cout << 0;
    }
    else {
        long long ans = 2020;
        for (long long i = l; i < r; i++) {
            for (long long j = l + 1; j <= r; j++) {
                ans = min(ans, ((i * j) % 2019));
            }
        }
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
    i64 a, b, k;
    cin >> a >> b >> k;
    i64 x = max(i64(0), a - k), y = max(i64(0), b - max(i64(0), k - a));
    cout << x << ' ' << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//

bool calc(ll mid, vector<ll> a, vector<ll> f, ll n, ll k){
    ll cnt = 0;
    rep(i, n){
        ll now = a[i] * f[i];
        if(now > mid){
            cnt += a[i] - mid / f[i];
        }
    }
    return cnt <= k;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//

    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> f[i];
    }
    sort(ALL(a));
    sort(ALL(f), greater<ll>());

    ll l = -1;
    ll r = pow(10, 12)+1;
    ll ans = 0;
    while(r - l > 1){
        ll mid = (r+l)/2LL;
        if(calc(mid, a, f, n, k)){
            r = mid;
            ans = mid;
        }
        else{
            l = mid;
        }
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6584
import  math
N,D = map(int, input().split(' '))
x = [list(map(int,input().split(' '))) for i in range(N)]

result = 0

for i in range(len(x)):

    for i1 in range(i,len(x)):

        tmp1 = x[i]
        tmp2 = x[i1]

        ans = 0
        for i2 in range(len(tmp1)):
            ans = ans + (tmp1[i2]-tmp2[i2])**2
        ans = math.sqrt(ans)

        if ans.is_integer() and 0 < ans:
            result  = result + 1
print(result)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using llint = long long;

using pint = pair<llint, llint>;

int n, m;

vector<int> a;
vector<pint> cards;

int main() {
    cin >> n >> m;

    a.resize(n);
    cards.resize(m+n);

    for (int i = 0; i < n; ++i) cin >> a.at(i);

    for (int i = 0; i < m; ++i) cin >> cards.at(i).second >> cards.at(i).first;
    for (int i = m; i < m+n; ++i) cards.at(i) = pint(a.at(i-m), 1);

    sort(cards.begin(), cards.end(), greater<pint>());

    int rn = n;
    llint ans = 0;

    for (int i = 0; i < m+n; ++i)
    {
        if (rn <= cards.at(i).second)
        {
            ans += cards.at(i).first * rn;
            break;
        }

        ans += cards.at(i).first * cards.at(i).second;
        rn -= cards.at(i).second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
char S[40000];

int ary[10][40000];
int ary_cnt[10] = {};

signed main()
{
	cin >> N;
	cin >> S;

	int len = strlen(S);
	for (int i = 0; i < len; i++)
	{
		int n = S[i] - '0';
		ary[n][ary_cnt[n]] = i;
		ary_cnt[n]++;
	}

	int ans = 0;
	REP(n1, 10) REP(n2, 10) REP(n3, 10)
	{
		int a = 0;
		bool is_found = false;
		for (int i = 0; i < ary_cnt[n1]; i++)
		{
			if (ary[n1][i] >= a)
			{
				is_found = true;
				a = ary[n1][i] + 1;
				break;
			}
		}
		if (!is_found) continue;
		is_found = false;
		for (int i = 0; i < ary_cnt[n2]; i++)
		{
			if (ary[n2][i] >= a)
			{
				is_found = true;
				a = ary[n2][i] + 1;
				break;
			}
		}
		if (!is_found) continue;
		is_found = false;
		for (int i = 0; i < ary_cnt[n3]; i++) 
		{
			if (ary[n3][i] >= a)
			{
				is_found = true;
				break;
			}
		}
		if (!is_found) continue;

		ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 512
cmdic = {'North':0,'East':1,'West':3,'South':2,'Right':4,'Left':5}
roll = int(raw_input())
valis = []
while roll > 0:
    val = 1
    num = 1
    adj = [None,[2,4,5,3],[6,4,1,3],[2,1,5,6],[2,6,5,1],[1,4,6,3],[5,4,2,3]]
    for i in range(roll):
        cmd = cmdic[raw_input()]
        if cmd < 4:
            r1 = adj[num][(cmd+3)%4]
            r2 = adj[num][(cmd+1)%4]
            r3 = adj[num][(cmd+2)%4]
            if cmd == 1 or cmd == 3:
                adj[7-num] = adj[7-num][2:]+adj[7-num][:-2] 
                adj[r3] = adj[r3][2:]+adj[r3][:-2]
            num = adj[num][cmd]
            adj[r1] = adj[r1][-1:]+adj[r1][:-1]
            adj[r2] = adj[r2][1:]+adj[r2][:1]
        else:
            if cmd == 4:
                adj[num] = adj[num][-1:]+adj[num][:-1]
                for n in adj[num]:
                    adj[n] = adj[n][-1:]+adj[n][:-1]
                adj[7-num] = adj[7-num][1:]+adj[7-num][:1]
            if cmd == 5:
                adj[num] = adj[num][1:]+adj[num][:1]
                for n in adj[num]:
                    adj[n] = adj[n][1:]+adj[n][:1]
                adj[7-num] = adj[7-num][-1:]+adj[7-num][:-1]
        val += num
    valis.append(val)
    roll = int(raw_input())
for v in valis: print v

Measured memory_bytes: 4488
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
int n;
struct node {
	vector<int> v;
};
node tree[123456];
bool b[123456]; vector<int>path;
bool p(int k) {
	for (int i = 0; i < tree[k].v.size(); i++) {
		int p1 = tree[k].v[i];
		if (p1 == n) {
			return 1;
		}
		else if (!b[p1]) {
			path.push_back(p1);
			b[p1] = 1;
			if (p(p1)) {
				return 1;
			}
			path.pop_back();
			b[p1] = 0;
		}
	}
	return 0;
}
int q(int k) {
	int r = 0;
	for (int i = 0; i < tree[k].v.size(); i++) {
		int p1 = tree[k].v[i];
		if (!b[p1]) {
			b[p1] = 1;
			r += q(p1);
		}
	}
	return r + 1;
}
signed main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b; cin >> a >> b;
		tree[a].v.push_back(b);
		tree[b].v.push_back(a);
	}
	b[1] = 1; b[n] = 1;
	path.push_back(1);
	p(1);
	path.push_back(n);
	int F = 0, S = 0;
	for (int i = 0; i < (path.size() + 1) / 2; i++) F += q(path[i]);
	for (int i = (path.size() + 1) / 2; i < path.size(); i++) S += q(path[i]);
	cout << (F > S ? "Fennec\n" : "Snuke\n");
}

Measured memory_bytes: 12020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k; cin >> n >> k;
  vector<ll> A(n), sum(n+1);
  rep(i, n) {
    cin >> A[i];
    sum[i+1] = sum[i] + A[i];
  }
  rep(i, n+1) sum[i] -= k*i;
  vector<ll> sum2(n+1);
  copy(all(sum), begin(sum2));
  sort(all(sum2));
  sum2.erase(unique(all(sum2)), end(sum2));
  auto get = [&](ll x) {
    return lower_bound(all(sum2), x) - begin(sum2);
  };
  BinaryIndexedTree<int> bit(n+1);
  ll ans = 0;
  rep(i, n+1) {
    int j = get(sum[i]);
    ans += bit.sum(j);
    bit.add(j, 1);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 8712
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 100100
using namespace std;

int P[MAX], V[MAX] = { 0 , };
int main()
{
	P[100000] = 100003;
	for (int i = 2; i <= 100000; i++) {
		if (V[i] != 0) continue;
		for (int j = i + i; j <= 100000; j += i) {
			V[j] = 1;
		}
	}
	for (int i = 99999; i >= 2; --i) {
		if (V[i] == 0) P[i] = i;
		else P[i] = P[i + 1];
	}
	int x; scanf("%d", &x);
	printf("%d", P[x]);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;
#define index_of(as, x) distance(as.begin(), lower_bound(as.begin(), as.end(), x))

// http://www.prefield.com/algorithm/dp/lis_fast.html
vector<int> lis_fast(const vector<int> &a) {
    const int n = a.size();
    vector<int> A(n, INT_MAX);
    vector<int> id(n);
    for (int i = 0; i < n; ++i) {
        id[i] = index_of(A, a[i]);
        A[id[i]] = a[i];
    }
    int m = *max_element(id.begin(), id.end());
    vector<int> b(m + 1);
    for (int i = n - 1; i >= 0; --i)
        if (id[i] == m) b[m--] = a[i];
    return b;
}

int main() {

    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    vector<int> ans = lis_fast(v);
    cout << ans.size() << endl;

}




Measured memory_bytes: 4428
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int a,b;
    cin>>a>>b;
    ll maxgcd=__gcd(a,b);
    cout<<a/maxgcd*b<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int f (int a) {
    int num;
    if (a % 2 == 0) {
        num = a / 2;
    }
    else {
        num = 3 * a + 1;
    }
    return num;
}

int main () {
    int s;
    std::cin >> s;
    int a[1000000];
    a[0] = s ;
    int n = 1;
    for (int i = 0; i == 0; ++n) {
        a[n] = f(a[n - 1]);
        for(int j = 0;j < n ; ++j) {
            if (a[n] == a[j]) {
                ++i;
            }
        }
    }
    std::cout << n << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll n, p=2019;
	string s;
	cin >> s;
	n=s.length();
	ll ans=0;
		map<ll, ll> mp;
		++mp[0];
		ll t=0, p2=1;
		for(ll i=n-1; i>=0; --i) {
			t=(t+(s[i]-'0')*p2)%p;
			ans+=mp[t];
			mp[t]++;
			p2=p2*10%p;
		}
	cout << ans;
}


Measured memory_bytes: 3744
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type Edge struct {
	to, cost int
}

// 辺のリストで表現されるグラフ
type Graph struct {
	Edges [][]Edge // Edge[i][j]: 頂点iのj番目の辺
}

// 頂点数nのリスト型グラフを返す
func NewGraph(n int) *Graph {
	g := &Graph{
		Edges: make([][]Edge, n),
	}
	for i := 0; i < n; i++ {
		g.Edges[i] = make([]Edge, 0)
	}
	return g
}

// 辺の追加
func (g *Graph) AddEdge(from, to, cost int) {
	g.Edges[from] = append(g.Edges[from], Edge{to, cost})
}

func topologicalSort(n int, g *Graph, indegree []int) []int {
	sorted := make([]int, 0)

	que := make([]int, 0)
	for i := 0; i < n; i++ {
		if indegree[i] == 0 {
			que = append(que, i)
		}
	}

	for len(que) > 0 {
		v := que[0]
		que = que[1:]
		for _, e := range g.Edges[v] {
			u := e.to
			indegree[u]--
			if indegree[u] == 0 {
				que = append(que, u)
			}
		}
		sorted = append(sorted, v)
	}
	return sorted
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	g := NewGraph(n)
	indegree := make([]int, n) // 入次数
	for i := 0; i < n-1+m; i++ {
		a, b := nextInt()-1, nextInt()-1
		g.AddEdge(a, b, 1)
		indegree[b]++
	}

	sorted := topologicalSort(n, g, indegree)
	// mp[v]: 頂点vのソート後のインデックス
	mp := map[int]int{}
	for i, v := range sorted {
		mp[v] = i
	}
	mp[-1] = -1

	par := make([]int, n)
	for i := range par {
		par[i] = -1
	}
	for v, edges := range g.Edges {
		for _, e := range edges {
			if mp[v] > mp[par[e.to]] {
				par[e.to] = v
			}
		}
	}
	for _, p := range par {
		puts(p + 1)
	}
}


Measured memory_bytes: 22624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
  int n;
  cin >> n;

  FOR(i,1,50000){
    if((int)(i*1.08)==n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 3620
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.count = [1] * (n + 1)

    # find
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # union
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.count[x] += self.count[y]

    # size
    def size(self, x):
        return self.count[self.par[x]]

    # same
    def issame(self, x, y):
        return self.find(x) == self.find(y)

n,m=map(int,input().split())
UF=UnionFind(n)
for i in range(m):
    x,y,z=map(int,input().split())
    UF.union(x,y)
cnt=0
S=set()
for i in range(1,n+1):
    x=UF.find(i)
    if x not in S:
        cnt+=1
        S.add(x)
print(cnt)

Measured memory_bytes: 17576
n = int(input())
o = [input().split(" ") for _ in range(n)]

def func(n, o):
    dic = {}
    for i in range(n):
        if o[i][0] == "insert":
            dic[o[i][1]] = 1
        else:
            print("yes" if o[i][1] in dic else "no")

func(n, o)


Measured memory_bytes: 303796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
const int INFTY = 1e9+7;

int main() {
  int N;
  cin >> N;

  vector<P> factor;
  vector<bool> prime(55556, true);
  for (int i=2; i<240; i++) {
    if (prime[i]) {
      for (int j=2*i; j<55556; j+=i) {
        prime[j] = false;
      }
    }
  }

  cout << 2;
  --N;
  int j = 0;
  while (N != 0) {
    int k = j*10+7;
    if (prime[k]) {
      cout << " " << k;
      --N;
    }
    ++j;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int h,w,z;
vector<vi> now;
void f(int p){
    int t = now[0][0];
    if(t == p)return;
    queue<pii> q;
    q.push(pii(0,0));
    now[0][0] = p;
    while(q.size()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        rep(i,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
            if(now[nx][ny] == t)q.push(pii(nx,ny)),now[nx][ny] = p;
        }
    }

}

signed main(void) {
    while(cin >> h >> w >> z, h){
        z--;
        vector<vi> in(h,vi(w));
        rep(i,h)rep(j,w)cin >> in[i][j],in[i][j]--;
        int ans = 0;
        rep(a,6)rep(b,6)rep(c,6)rep(d,6){
            now = in;
            f(a);
            f(b);
            f(c);
            f(d);
            f(z);

            rep(i,h){
                //rep(j,w)cout << " " << now[i][j];cout << endl;
            }



            int sum = 0;
            queue<pii> q;
            q.push(pii(0,0));
            now[0][0] = -1;
            //cout << endl;
            while(q.size()){
                int x = q.front().first;
                int y = q.front().second;
                //cout << x << " " << y << endl;
                sum++;
                q.pop();
                rep(i,4){
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if(nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
                    if(now[nx][ny] == z)q.push(pii(nx,ny)),now[nx][ny] = -1;
                }
            }
            //cout << a << " " << b << " " << c << " " << d << " " << sum << endl;

            ans = max(ans,sum);
        }
        cout << ans << endl;
    }

}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c;cin>>a>>b>>c;
	cout << c<< " " << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 11000000;
int f[maxn];
void run_case()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j += i)
        {
            f[j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += 1ll * i * f[i];
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 42668
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;
const long long L_INF = 9223372036854775807;
const int INF = 10000;
const int MAX = 50;

int main() {
	int R, G;

	cin >> R >> G;
	cout << G * 2 - R << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;



//defines...
#define ll  long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;




//typedefs...
typedef pair<ll,ll>pll;

//const..
//const ll fx[]={0,1,0,-1};
//const ll fy[]={1,0,-1,0};
const ll mod=1e9+7;


//......Algo.....

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/
//to remove suffix of a number from a set of string
/*
for(int k=1; k<j.size(); k++)
                if(temp.count(string(j.begin()+k,j.end())))
					temp.erase(string(j.begin()+k,j.end()));
 */
ll bigmod(ll base ,ll power,ll mod)
{
    if(power==0) return 1;
    else if(power%2)
    {
        ll p1=base%mod;
        ll p2=(bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else
    {
        ll p=(bigmod(base,power/2,mod)%mod);
        return (p*p)%mod;
    }
}
ll dp[1000000];
void oka()
{
    memset(dp,0,sizeof dp);
    ll n,i,j,k;
    cin>>n;
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            for(k=1;k<=100;k++)
            {
                dp[i*i+j*j+k*k+i*j+i*k+j*k]++;
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<dp[i]<<endl;
    }


}
/*I'll paint it on the walls
     cause I'm the one at fault
    I'll never fight again and
         this is how it ends .*/






int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    run
    ll t;
   t=1;
  //cin>>t;
    while(t--){

    oka();
    }



}


Measured memory_bytes: 11352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string N;
    cin >>N;
    char p='#';
    ll cnt=0;
    ll mx=0;
    rep(i,4){
        if(N[i]==p){
            cnt++;
        }else{
            cnt=1;
        }
        p=N[i];
        chmax(mx,cnt);
    }
    if(mx>=3){
        cout<<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int3(n, m, r);
    vector<int> root(r);
    for (int i = 0; i < r; i++) {
        cin >> root[i];
        root[i]--;
    }
    sort(all(root));

    vvi graph(n, vi(n, INF));
    rep(i, m) {
        int3(a, b, c);
        a--; b--;
        graph[a][b] = min(graph[a][b], c);
        graph[b][a] = min(graph[b][a], c);
    }
    rep(i, n) graph[i][i] = 0;
    rep(k, n) rep(i, n) rep(j, n) 
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);

    int ans = INF;
    do {
        int tmp = 0;
        Rep(i, r) {
            tmp += graph[root[i-1]][root[i]];
        }
        ans = min(ans, tmp);
    } while (next_permutation(all(root)));

    std::cout << ans << std::endl;




    return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////


LL nCk(LL N, LL k) {
	LL ans = 1;
	for (int i = 1; i <= k; ++i) {
		ans *= (N - i+1);
		ans /= i;
	}

	return ans;
}

void solve() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<LL> V(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
	}
	sort(V.begin(), V.end());
	LD sum = 0;
	for (int i = N-1; i>=N-1-A+1 ; --i) {
		sum += V[i];
	}

	//
	LL ans = 0;
	if (V[N - 1] == V[N - A]) {
		int index = lower_bound(V.begin(), V.end(), V[N - 1]) - V.begin();
		for (int i = A; i <= min(N - index,B); ++i) {
			ans += nCk(N - index, i);
		}
	}
	else {

		int indexL = lower_bound(V.begin(), V.end(), V[N - A]) - V.begin();
		int indexR = lower_bound(V.begin(), V.end(), V[N - A]+1) - V.begin();
		int CC = indexR - indexL;//取る元集団。
		int toru = indexR - (N - A);
		ans = nCk(CC, toru);
	}

	cout << sum / A << endl;
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll x[1050][1050];
ll x_sum[1051][1051];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, W, K;
    cin >> H >> W >> K;

    REP(i, H){
    	string S;
    	cin >> S;
    	REP(j, W){
    		x[i][j] = S[j] - '0';
    	}
    }

    REP(i, H+1)REP(j, W+1) x_sum[i][j] = 0;
	REP(i, H)REP(j, W) x_sum[i+1][j+1] = x_sum[i+1][j] + x[i][j];
	REP(i, H)REP(j, W) x_sum[i+1][j+1] += x_sum[i][j+1];

	/*
	REP(i, H+1){
		REP(j, W+1){
			cerr << x_sum[i][j] << " ";
		}
		cerr << endl;
	}
	*/

	ll ans = (1ll<<60);

	REP(mask, (1ll)<<(H+1)){
		if((mask>>0 & 1) == 0) continue;
		if((mask>>(H) & 1) == 0) continue;
		//cerr << num2bit(mask, H+1) << endl;
		vector<ll> cut;
		REP(i, H+1){
			if(mask>>i & 1) cut.push_back(i);
		}
		sort(cut.begin(), cut.end());
		//cerr << cut << endl;

		ll res = 0;
		ll now = 0;

		while(now != W){
			ll lb = now;
			ll ub = W+1;

			while(ub-lb>1){
				ll md = (lb+ub)/2;
				bool ok = true;
				REP(k, (int)cut.size()-1){
					ll h1 = cut[k];
					ll h2 = cut[k+1];
					ll cum = x_sum[h2][md] - x_sum[h1][md] - x_sum[h2][now] + x_sum[h1][now];
					if(cum>K) ok = false;
				}
				if(ok) lb = md;
				else  ub = md;
			}

			if(now == lb){
				res = (1ll<<60);
				break;
			}
			now = lb;
			if(now != W) res++;
		}

		ll geta = (int)cut.size() - 2;
		chmin(ans, res+geta);
	}

	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)


void solve(long long N){
  long long min_dist=1000000000001LL;
  for(long long i=1;i<=1000000;i++){
    if(N%i!=0)continue;
    long long j=N/i;
    long long dist=(i-1)+(j-1);
    min_dist=min(min_dist,dist);
  }
  cout<<min_dist<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll V, T;
string S;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> K;
    vector<int> a(N), b(N + 1);
    cin >> a;
    int cnt = 0;
    int k = 0;
    while (cnt != N && k < K) {
        cnt = 0;
        k++;
        REP(i, N) {
            int l = max(i - a[i], 0);
            int r = min(i + a[i] + 1, int(N));
            b[l]++;
            b[r]--;
        }
        REP(i, N) {
            b[i + 1] += b[i];
        }
        REP(i, N) {
            a[i] = b[i];
        }
        fill(ALL(b), 0);
        cnt = count(ALL(a), N);
    }
    REP(i, N) {
        cout << a[i] << " ";
    }
}


Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll w, h, n; cin >> w >> h >> n;
  ll xl=0, xr=w, yd=0, yu=h;
  REP(_, n) {
    ll x, y, a; cin >> x >> y >> a;
    if (a==1) chmax(xl, x);
    else if (a==2) chmin(xr, x);
    else if (a==3) chmax(yd, y);
    else if (a==4) chmin(yu, y);
  }
  if (xl >= xr || yd >= yu) cout << 0 << endl;
  else cout << (xr-xl) * (yu-yd) << endl;
  return 0;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 166
//A - A?C
//

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()

using ll = long long;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
    string s;

    cin >> s;

    if (s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int t[101], ans[101];

int main()
{
  int n, m, sumInit, x, p;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    // ドリンクを飲まない場合のトータル時間を計算しておく
    sumInit += t[i];
  }

  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> p;
    ans[i] = sumInit + p - t[x];
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 256
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
using namespace std;
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 105
int n,a[N],ans;
int main(){
	n=read();
	rep (i,1,n) a[i]=read();
	for (int i=1,j;i<=n;i=j+1){
		j=i;int tmp=1;
		while (j<n&&a[j+1]==a[i]) j++,tmp++;
		ans+=tmp/2;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 768