akhauriyash/Code-Regression huggingface dataset:
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<plint> job(n);
    auto comp = [](plint p1, plint p2){return p1.snd < p2.snd;};
    priority_queue<plint, vector<plint>, decltype(comp)> pq(comp);
    REP(i, n){
        cin >> job[i].fst >> job[i].snd;
    }
    sort(ALL(job));
    int itr = 0;
    lint ans = 0;
    for(int i=m; i>=0; --i){
        int deadline = m - i;
        while(itr < n && deadline >= job[itr].fst){
            pq.push(job[itr]);
            ++itr;
        }
        if(!pq.empty()){
            auto t = pq.top();
            pq.pop();
            ans += t.snd;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3956
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _s(): return sys.stdin.readline().strip()


def _i(): return int(sys.stdin.readline().strip())


def main():
    n = _i()
    s = _s()
    c = {
        "R": [0] * (n + 1),
        "G": [0] * (n + 1),
        "B": [0] * (n + 1)
    }
    j = n
    for rgb in reversed(s):
        j -= 1
        for _rgb in "RGB":
            c[_rgb][j] = c[_rgb][j+1]
        c[rgb][j] += 1

    ans = 0
    rgb = {"R", "G", "B"}
    for i in range(n-2):
        c1 = s[i]
        for j in range(i+1, n-1):
            c2 = s[j]
            if c1 == c2:
                continue
            #
            c3 = (rgb - {c1, c2}).pop()
            ans += c[c3][j+1]
            k = 2 * j - i
            if k < n and s[k] == c3:
                ans -= 1
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 68572
#include <bits/stdc++.h>
#define IOS   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define qe	  998244353
#define MAXN  100005
#define mx    10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
//	#ifndef ONLINE_JUDGE
//    if (fopen("input.txt", "r"))
//    {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
//    }
//	#endif
	IOS;
	ll t,n,l,l1;
	ll i,j,m,mn,q,d,x,y,sum=0,r,p,k,c;
	string s,s1;
	cin>>n>>p;
	vl dp(MAXN,mod);
	dp[0]=0;
	ll w,v;
	rep(j,0,n){
		cin>>w>>v;
		inv(i,MAXN-1,v)dp[i]=min(dp[i],dp[i-v]+w);		
	}
	inv(i,MAXN-1,0)
		if(dp[i]<=p){
			cout<<i;break;
	}
}

Measured memory_bytes: 3988
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int k = s.nextInt(), x = s.nextInt();
            for (int i = x - k + 1; i < x; i++) w.print(i + " ");
            for (int i = x; i < x + k; i++) w.print(i + " ");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	int n, q, s[222222], t[222222], x[222222], d[222222],i,g[222222],l,r,c,l2,r2[222222],j,w[222222];
	cin >> n >> q;
	vector<pair<int,pair<int,int>>> m(n);
	for (i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> x[i];
		s[i] -= x[i];
		t[i] -= x[i];
		m[i] = make_pair(x[i], make_pair(s[i], t[i]));
	}
	sort(m.begin(), m.end());
	for (i = 0; i < q; i++) {
		cin >> d[i];
		g[i] = -1;
      w[i]=-1;
	}
	for (i = 0; i < n; i++) {
		s[i] = m[i].second.first;
		t[i] = m[i].second.second;
      if(s[i]<=d[q-1]&&t[i]>d[0]){
		l = 0;
		r = q - 1;
		while (l != r) {
			c = (l + r) / 2;
			if (s[i] <= d[c]) {
				if (l + 1 == r) {
					c = l;
					if (s[i] <= d[c])
						r--;
					else
						l++;
				}
				else {
					r = c;
				}
			}
			else {
				if (l + 1 == r) {
					c = l;
					if (s[i] <= d[c])
						r--;
					else
						l++;
				}
				else {
					l = c;
				}
			}
		}
		l2 = l;
		l = 0;
		r = q - 1;
		while (l != r) {
			c = (l + r) / 2;
			if (t[i] > d[c]) {
				if (l + 1 == r) {
					c = r;
					if (t[i] > d[c])
						l++;
					else
						r--;
				}
				else {
					l = c;
				}
			}
			else {
				if (l + 1 == r) {
					c = r;
					if (t[i] > d[c])
						l++;
					else
						r--;
				}
				else {
					r = c;
				}
			}
		}
		r2[i] = l;
		for (j = l2; j <= r2[i]; j++) {
			if (g[j] != -1)
				j = w[j];
			else 
				g[j] = m[i].first;
				w[j] = max(w[j],r2[i]);
		}
      }
	}
	for (i = 0; i < q; i++)
		cout << g[i] << endl;
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,x;
  	cin>>k>>x;
  	k--;
  	int l=x-k;
  	int h=x+k;
  	for(int i=l;i<=h;i++){
    	cout<<i<<" ";
    }
  	cout<<endl;
  	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/agc032/tasks/agc032_a

//参考
//https://drken1215.hatenablog.com/entry/2019/03/24/091900

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<LL> B;
 
vector<LL> ans;
 
void solve(){
    for(int i=0;i<N;i++){
        int pivot = -1;
        //Bを後ろから順に見ていき
        //B[j]==jとなるようなものがあったらその時点でループを打ち切る
        for(int j=B.size()-1;j>=0;j--){
            if(B[j]==j+1){
                pivot = j;
                break;
            }
        }
        if(pivot == -1){
            ans = vector<LL>(1,{-1});
            return;
        }

        ans.push_back(pivot + 1);
        B.erase(B.begin() + pivot);
    }
    reverse(ans.begin(),ans.end());
}
 
int main(){
    cin >> N;
    B = vector<LL>(N);
    for(int i=0;i<N;i++) cin >> B[i];
 
    solve();
 
    for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n, g;
    cin >> n >> g;
    vector<int> vp(n, 0), vc(n, 0), vt(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> vp[i] >> vc[i];
        vt[i] = vp[i] * (i + 1) * 100 + vc[i];
    }
    int t = (1 << n);
    vector<int> v(t, 0);
    int res = 0x3f3f3f3f;
    for (int i = 0; i < t; i++) {
        int index = i;
        for (int j = 0; j < n; j++) {
            if (index % 2 == 1) {
                v[i] = v[i - (1 << j)] + vt[j];
                break;
            }
            index /= 2;
        }
        int c = 0;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) > 0) {
                c += vp[j];
            }
        }
        for (int j = 0; j < n; j++) {
            if (v[i] >= g) {
                res = min(res, c);
                break;
            }
            if ((i & (1 << j)) == 0 && v[i] + vp[j] * (j + 1) * 100 >= g) {
                int diff = g - v[i];

                res = min(res, c + diff / (j * 100 + 100) + (diff % (j * 100 + 100) > 0 ? 1 : 0));
            }
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 3592
N, M = map(int, input().split())
a, b, c = [0] * M, [0] * M, [0] * M
d = [-1e20] * N
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

d[0] = 0
for i in range(N-1):
    for j in range(M):
        d[b[j]] = max((d[b[j]], d[a[j]] + c[j]))

isCycle = False
for i in range(N-1):
    if isCycle:
        break
    for j in range(M):
        if b[j] == N-1 and d[b[j]] < d[a[j]] + c[j]:
            isCycle = True
            break
        d[b[j]] = max((d[b[j]], d[a[j]] + c[j]))
if isCycle:
    print('inf')
else:
    print(d[N-1])


Measured memory_bytes: 50264
#include <iostream>
using namespace std;

int main(void){
    int x, w;
    while(true){
        cin >> w;
        x = 1150;
        if(w == -1){
            break;
        }
        if(w <= 10){
            x += 0;
        }
        else if(w <= 20){
            x += (w-10)*125;
        }
        else if(w <= 30){
            x += (w-20)*140 + 1250;
        }
        else if(w > 30){
            x += (w-30)*160 + 1250 + 1400;
        }
        cout << 4280 - x << endl;
    }
}


Measured memory_bytes: 3080
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] num = new long[100];

        for(int i =0;i<100;i++){
            if(i==0){
                num[i]=2;
            }else if(i==1){
                num[i]=1;
            }else{
            num[i] = num[i-1]+num[i-2];
        }
    }

        System.out.println(num[n]);
        

    }
}



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

using namespace std;

using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<bool>> mat(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            mat[i][j] = s[j] == '#';
        }
    }
    vector<vector<int>> dp(H, vector<int>(W, 1e7));
    dp[0][0] = mat[0][0];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i > 0) {
                if (mat[i][j] && mat[i][j] != mat[i - 1][j])
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
                else
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
            if (j > 0) {
                if (mat[i][j] && mat[i][j] != mat[i][j - 1])
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
                else
                    dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            }
        }
    }
    cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,n;
  cin>>h>>w>>n;
  cout<<min((ll)ceil((double)n/h),(ll)ceil((double)n/w))<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  ll N,K,S;
  cin >> N >> K >> S;
  if(N==K){
    rep(i,N){
      if(i==N-1){
        cout << S << endl;
        continue;
      }
      cout << S << " ";
    }
    return 0;
  }
  if(S==1000000000){
    rep(i,N){
      if(i<K){
        if(i==N-1){
          cout << S << endl;
          continue;
        }
        cout << S << " ";
      }
      else{
        if(i==N-1){
          cout << 1 << endl;
          continue;
        }
        cout << 1 << " ";
      }
    }
    return 0;
  }
  if(S==1){
    rep(i,N){
      if(i<K){
        if(i==N-1){
          cout << 1 << endl;
          continue;
        }
        cout << 1 << " ";
      }
      else{
        if(i==N-1){
          cout << 2 << endl;
          continue;
        }
        cout << 2 << " ";
      }
    }
    return 0;
  }
  rep(i,N){
    if(i>K){
      if(i==N-1){
        cout << S+1 << endl;
        continue;
      }
      cout << S+1 << " ";
      continue;
    }
    if(i%2==0){
      if(i==N-1){
        cout << 1 << endl;
        continue;
      }
      cout << 1 << " ";
    }
    else{
      if(i==N-1){
        cout << S-1 << endl;
        continue;
      }
      cout << S-1 << " ";
    }
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
int A[12][12];
int main() {
 int N,M,X;
 cin>>N>>M>>X;
 vector<int>C(N);
 
for (int i = 0; i < N; ++i){
     cin>>C[i];
     for(int j=0;j<M;j++){
         cin>>A[i][j];
     }
}

int ans=INF;
for(int s=0;s<(1<<N);s++){
    int cost=0;
    vector<int>skill(M);
    for(int i=0;i<N;i++){
        if(s>>i&1){
            cost+=C[i];
            for(int j=0;j<M;j++){skill[j]+=A[i][j];}
        }}
        bool U=true;
        for(int j=0;j<M;j++){if(skill[j]<X){U=false;}}
        if(U){ans=min(ans,cost);}
    }
if(ans==INF){cout<<-1<<endl;}
else{cout<<ans<<endl;}
return 0;
}

Measured memory_bytes: 3608
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let (n, k) = {
        let t: Vec<usize> = read_vec();
        (t[0], t[1])
    };
    let a: Vec<usize> = read_vec();
    for i in 0..n - k {
        println!("{}", if a[k + i] > a[i] {"Yes"} else {"No"});
    }
}

Measured memory_bytes: 6616
#include <cstdio>
#include <algorithm>
#define rep(i, a, b) for (int i = a; i <= b ; ++ i) 
const int N = 8e5 + 5 ; 
using namespace std ;
int n, k, a[N] ; char s[N] ;
int main() {
	scanf("%d%d%s", &n, &k, s + 1) ;
	rep(i, 1, n) a[i] = (s[i] == 'A') ^ (i & 1) ;
	int he = 1, ta = n, c = (n & 1) ^ 1 ;
	rep(i, 1, min(2 * n, k)) if (a[he] & 1) ++ he, a[++ ta] = c ; else a[he] ^= 1 ;
	if (k > 2 * n) {
		if ((n & 1) && (k & 1)) a[he] ^= 1 ;
	}
	rep(i, he, ta) printf((a[i] ^ ((i - he + 1) & 1)) ? "A" : "B") ;
}

Measured memory_bytes: 2560
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Tue Apr  3 01:13:14 2018
//
package main

import (
	"fmt"
)

var N, A, B int

func main() {
	fmt.Scan(&N, &A, &B)
	if B < A {
		fmt.Println(0)
		return
	}
	if A != B && N == 1 {
		fmt.Println(0)
		return
	}

	fmt.Println(A + (N-1)*B - ((N-1)*A + B) + 1)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  int N; cin >> N;
  rep(i, N) {
    cin >> Input[i];
  }
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j< N; j++) {
      // cout << Input[i] << " " << Input[j] << endl;
      ans += Input[i] * Input[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

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


	ll N;
	cin >> N;

	vector<pair<string, pair<ll, ll> > >A(N);

	rep(i, N) {
		cin >> A[i].first >> A[i].second.first;
		A[i].second.first = 100 - A[i].second.first;
		A[i].second.second = i;
	}

	sort(A.begin(), A.end());


	rep(i, N) {
		cout << A[i].second.second + 1 << endl;
	}



	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<numeric>
#include<cmath>
int main(){
    long long N;
    std::cin >> N;
    long long ans = 0;
    for(long long i = 1; i * i <= N; ++i){
        if((N - i) % i == 0 and (N - i) / i > i)
            ans += (N - i) / i;
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const int sz = 1e6+5;
string status[sz];
int cnt_wa[sz];

int main() {
	int N, M;
	sci(N), sci(M);
	int penalty = 0;

	for (int i = 0; i < M; ++i) {
		int num;
		string stats;
		cin >> num >> stats;
		if (status[num] == "AC") continue;
		status[num] = stats;
		cnt_wa[num] += status[num] == "WA";
	}

	int correct = 0;
	for (int i = 1; i <= N; ++i) {
		correct += status[i] == "AC";
		penalty += status[i] == "AC" ? cnt_wa[i] : 0;
	}

	printf("%d %d\n", correct, penalty);
	return 0;
}

Measured memory_bytes: 14976
n = STDIN.gets.to_i
 
max = -2000000000
min = STDIN.gets.to_i
 
(2..n).each { |i|
  x = STDIN.gets.to_i
 
  max = if max > x - min then max else x - min end
  min = if x < min then x else min end
}
puts max

Measured memory_bytes: 8792
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [a, b] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  const k = (a + b) / 2

  if (Number.isInteger(k)) {
    return k
  } else {
    return 'IMPOSSIBLE'
  }
}

console.log(ans())


Measured memory_bytes: 7500
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(); //問題数を決定
		int []time = new int[N]; //各問題にかかる時間を格納する配列オブジェクトを生成
		int T=0;
		for(int i=0;i<N;i++){//所要時間決定
			T = T + (time[i] = sc.nextInt());
		}
		
		int M=sc.nextInt();//ドリンクの数を決定
		
		int sumtime = 0; //合計時間を入れる
		for(int i=0;i<M;i++){
			sumtime = T - (time[sc.nextInt()-1] - sc.nextInt()); //要素０も参照できるようにする
			System.out.println(sumtime);
		}
	}
}


Measured memory_bytes: 21844
var
    a:array[1..3] of Integer;
    flag5,flag7,i:Integer;
begin
    readln(a[1],a[2],a[3]);
    for i := 1 to 3 do
    begin
        if a[i]=5 then 
        begin
            flag5:=flag5+1;
        end
        else if a[i]=7 then
        begin
            flag7:=flag7+1;
        end;
    end;
    if (flag5=2) and (flag7=1) then 
    begin
        writeln('YES');
    end
    else 
    begin
        writeln('NO');
    end;
    readln;
end.

Measured memory_bytes: 128
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vl a(n);
        rep(i, n) {
            cin >> a[i];
            a[i]--;
        }
        vector<bool> pa(n, false);
        ll ans = 0;
        rep(i, n) {
            if (!pa[i] && i == a[a[i]]) {
                if (!pa[a[i]]) {
                    pa[a[i]] = pa[i] = true;
                    ans++;
                }
            }
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC82(void);
void ABC83(void);
void ABC84(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC84();
}

void ABC84(){
    int a,b,i,c=0;
    string s;
    cin>>a>>b>>s;
    for(i=0;i<a;i++){
        if(s[i]>='0'&&s[i]<='9')c++;
    }
    if(s[i]=='-')c++;
    cerr<<c<<endl;
    for(i=a+1;i<b+a+1;i++){
        if(s[i]>='0'&&s[i]<='9')c++;
    }
    cerr<<c<<endl;
    if(c==a+b+1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int count = 0;

        for (int i = 1; i <= n; i++) {
            if(((int) Math.log10(i) + 1) % 2 == 1) {
                count++;
            }
        }
        System.out.println(count);
    }

}



Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
  int n;
  scanf("%d", &n);
  if(n%2 != 0) {
    printf("No");
    return 0;
  }
  char s[n+1];
  scanf("%s", &s);
  int flag = 0;

  for(int i=0; i<n/2; i++){
    if(s[i]!=s[i+n/2]) flag = 1;
  }
  if (flag==1) printf("No");
  else printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>
#include <utility>
#include <cassert>
#include <algorithm>
#include <cstring>

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> sums;
  int sum = 0;
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    sum += tmp;
    sums.push_back(sum);
  }
  auto it = lower_bound(sums.begin(), sums.end() - 1, sum / 2);
  int ans = abs(sum - *it * 2);
  if(it != sums.begin()) {
    int tmp = abs(sum - *(it - 1) * 2);
    if(tmp < ans) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int main() {
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	double area = 1.*w*h/2;
	ll flag = 0;
	if(w%2==0&&h%2==0&&w/2==x&&h/2==y){
		flag = 1;
	}
	printf("%20.20f %lld\n", area, flag);
	return 0;
}

Measured memory_bytes: 256
S = input()

is_easy = True

for i in range(len(S)):
    if i % 2 == 0: # 奇数文字目
        if S[i] not in 'RUD':
            is_easy = False
    else:
        if S[i] not in 'LUD':
            is_easy = False

print('Yes' if is_easy else 'No')

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
ll ctoi(char c) {
    if (c == '0')return 0;
    else if (c == '1')return 1;
    else if (c == '2')return 2;
    else if (c == '3')return 3;
    else if (c == '4')return 4;
    else if (c == '5')return 5;
    else if (c == '6')return 6;
    else if (c == '7')return 7;
    else if (c == '8')return 8;
    else if (c == '9')return 9;
    else return -1;
}
int main() {
    ll n;
    cin >> n;
    string S, T, U;
    cin >> S >> T >> U;
    ll ans = 0;
    rep(i, n) {
        if (S[i] == T[i] && T[i] != U[i])ans++;
        else if (S[i] == U[i] && T[i] != S[i])ans++;
        else if (T[i] == U[i] && T[i] != S[i])ans++;
        else if (S[i] == U[i] && U[i] == T[i])continue;
        else ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  for(int i = 0; i < n; i++) cin >> q[i];
  vector<int> b = p;
  sort(b.begin(), b.end());
  vector<int> v;
  int num = 1;
  do {
    bool w = true;
    for(int i = 0; i < n; i++) {
      if(p[i] != b[i]) {
        w = false;
      	break;
      }
    }
    if(w == true) v.push_back(num);
    w = true;
    for(int i = 0; i < n; i++) {
      if(q[i] != b[i]) {
        w = false;
      	break;
      }
    }
    if(w == true) v.push_back(num);
    num++;
    if(v.size() == 2) {
      break;
    }
  }while(next_permutation(b.begin(), b.end()));
  cout << abs(v[0]-v[1]) << endl;
  return 0;
}
         

Measured memory_bytes: 256
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let A = get!(usize; N);

    // 最大値をとるインデックスkを一つ求める
    // A_i (i != k) を除く最大要素は A_k である
    // A_k を除く最大要素は素直に求めればよい
    let k = (0..N).max_by_key(|&i| A[i]).unwrap();

    for i in 0..N {
        let ans = if i == k {
            (0..N).map(
                |i|
                if i == k {
                    0
                } else {
                    A[i]
                }
            )
            .max()
            .unwrap()
        } else {
            A[k]
        };
        println!("{}", ans);
    }
}


Measured memory_bytes: 7676
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;

    int cnt = 0;
    int fcnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'a') {
            if (cnt < A + B) {
                cout << "Yes" << endl;
                cnt++;
            } else {
                cout << "No" << endl;
            }
        } else if (S[i] == 'b') {
            if (cnt < A + B && fcnt < B) {
                cout << "Yes" << endl;
                cnt++;
                fcnt++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int ans = 0;
	rep(i,s.size()){
		if(s.at(i) == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 T+=R[::-1]
 return T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63912
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy\n";
  if (s == "Cloudy") cout << "Rainy\n";
  if (s == "Rainy") cout << "Sunny\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u){
  for(int v=nt[u]; v<n; v++){
    nt[u] = v+1;
    if(M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r){
  for(int i=0;i<n;i++) nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while(!S.empty()){
    int u = S.top();
    int v = next(u);
    if(v!=-1){
      if(color[v]==WHITE){
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    }else{
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs(){
  for(int i=0;i<n;i++){
    color[i]=WHITE;
    nt[i]=0;
  }
  tt=0;

  for(int u=0;u<n;u++){
    if(color[u]==WHITE) dfs_visit(u);
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main(){
  int u,k,v;

  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) M[i][j]=0;
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  dfs();

  return 0;
}


Measured memory_bytes: 3120
import java.util.Scanner;
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            //while (sc.hasNext()) {
                int x = sc.nextInt();
                System.out.println(id(x));
            //}
        sc.close();
 
    }
    
    private static String id(int x){
        StringBuilder sb = new StringBuilder();
        
        int n = x / 100;
           // System.out.print(n);
        sb.append("ai1333");
        
            for (int t = 0; t < n ; t++) {
                sb.append("3");
            }
            
        return sb.toString();
    }
    
}



Measured memory_bytes: 26376
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>

using u4t = std::uint32_t;
using i4t = std::int32_t;
using u8t = std::uint64_t;
using i8t = std::int64_t;
u8t combination(u8t n, u8t r) {
  if (n-r<r) r = n-r;
  u8t ret=1;
  for(u8t i =1;i<=r;i++)
    ret = ret*(n+1-i)/i;
  return ret;
}

int main() {
  u8t N, A, B;
  std::cin >> N >> A >> B;
  std::vector<u8t> v;
  for (int i=0;i<N;i++){
    double aa;
    std::cin >> aa;
    v.push_back(aa);
  }

  std::sort(v.begin(), v.end());

  u8t avgxn = std::accumulate(v.end() - A, v.end(), (u8t) 0);
  u8t count = 0;
  {
    int index = v.size() - A;
    int index1 = index, index2 = index+1;
    while(index1>0 && v[index1-1] == v[index])index1--;
    while(index2<v.size() && v[index2] == v[index])index2++;
    count+= combination(index2 - index1,index2-index);
  }

  int w = A;
  while(++w <= B && v[v.size()-w] * A == avgxn) {
    int index = v.size() - w;
    int index1 = index, index2 = index+1;
    while(index1>0 && v[index1-1] == v[index])index1--;
    while(index2<v.size() && v[index2] == v[index])index2++;
    count+= combination(index2 - index1,index2-index);
  }

  std::printf("%.6f\n",(double) avgxn / (double) A);
  //std::cout << (double) avgxn / (double) A << std::endl;
  std::cout << count << std::endl;
  // std::cerr << factorial(5)<< std::endl;
  // std::cerr << factorial(10)<< std::endl;
  //for(int i=0;i<=5;i++)std::cerr << combination(5,i)<< std::endl;
  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
tmp = list(map(int, input().split()))
A = []
for i, a in enumerate(tmp, start=1):
    A.extend([i] * a)
y, x = 0, 0
dy, dx = [0, 1, 0, -1], [1, 0, -1, 0]
k = 0
f = [[None] * W for i in range(H)]
for a in A:
    f[y][x] = a
    ny, nx = y + dy[k], x + dx[k]
    if ny < 0 or ny == H or nx < 0 or nx == W or f[ny][nx] != None:
        k = (k + 1) % 4
    y, x = y + dy[k], x + dx[k]
for s in f:
    print(*s)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  int l  = s.size();
  for(int i =97;i<=122;i++){
    bool c = true;
    char a = i;
    for(int j=0;j<l;j++){
      if(s.at(j) == a){
        c = false;
        break;
      }
    }
    if(c){
      cout << a << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}
        


Measured memory_bytes: 512
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

// cout<<fixed<<setprecision(15)
static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

//点またはベクトル
class Point{
  public:
  double x,y;
  
  Point(double x=0, double y=0): x(x),y(y) {}
  
  Point operator+(Point p){return Point(x+p.x,y+p.y);}
  Point operator-(Point &p){return Point(x-p.x,y-p.y);}
  Point operator*(double a){return Point(a*x,a*y);}
  Point operator/(double a){return Point(x/a,y/a);}
  
  bool operator<(const Point &p) const{
    return x != p.x ? x<p.x : y<p.y;
  }
  
  bool operator==(const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};
typedef Point Vector;
//ベクトルの二乗和と絶対値
double norm(Point p){return p.x*p.x+p.y*p.y;}
double abs(Point p){return sqrt(norm(p));}
//線分または直線
struct Segment{Point p1,p2;};
typedef Segment Line;
//円
class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(), double r=0.0): c(c), r(r) {}
};
//多角形
typedef vector<Point> Polygon;
//内積
double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
//外積
double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
//直交判定
bool isOrthgonal(Vector a,Vector b){return equals(dot(a,b), 0.0);}
//平行判定
bool isParallel(Vector a,Vector b){return equals(cross(a,b), 0.0);}
//射影
Point project(Segment s,Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/norm(base);
  return s.p1+base*r;
}
//反射
Point reflect(Segment s,Point p){return p+(project(s,p)-p)*2.0;}
//反時計周りCounter-Clockwise
int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>EPS) return COUNTER_CLOCKWISE;
  if(cross(a,b)<-EPS) return CLOCKWISE;
  if(dot(a,b)<-EPS) return ONLINE_BACK;
  if(norm(a)<norm(b)) return ONLINE_FRONT;
  return ON_SEGMENT;
}
//線分の交差判定
bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
bool intersect(Segment s1,Segment s2){return intersect(s1.p1,s1.p2,s2.p1,s2.p2);}
//点と点の距離
double getDisPP(Point a,Point b){return abs(a-b);}
//直線と点の距離
double getDisLP(Line l,Point p){return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);}
//線分と点の距離
double getDisSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2);
  return getDisLP(s,p);
}
//線分と線分の距離
double getDisSS(Segment s1,Segment s2){
  if(intersect(s1,s2)) return 0.0;
  return min(min(getDisSP(s1,s2.p1),getDisSP(s1,s2.p2)),
             min(getDisSP(s2,s1.p1),getDisSP(s2,s1.p2)));
}

int main(){
  Point p0,p1,p2,p3;
  int q;
  cin>>q;
  
  Segment s1,s2;
  rep(i,q){
    cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
    s1.p1=p0,s1.p2=p1,s2.p1=p2,s2.p2=p3;
    cout<<fixed<<setprecision(15)<<getDisSS(s1,s2)<<endl;
  }
    
  return 0;
}


Measured memory_bytes: 3280
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];

			//答えの出力
			var ans = 'a' <= N[0] && N[0] <= 'z' ? "a" :"A";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 25840