akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define nl cout << endl
#define pb push_back
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define Sort(x) sort(all(x))
#define print_vector(my_vector_name) for(int i=0; i<my_vector_name.size(); i++) cout << my_vector_name[i] << " ";nl
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#define hang while (1)

int main() {
	fast;
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	Sort(a);
	cout << accumulate(a.begin(), a.begin()+k, 0);
	return 0;
}

//notes
/*
 value of INT_MAX and INT_MIN is fixed and they are
 INT_MAX = 2147483647
 INT_MIN = -2147483648
 use these format of input when number of inputs not provided
 *while(scanf("%lld",&n)!=EOF)
 *while using getline(cin,s) for taking input of a string which is 
 having white space characters just write cin>>ws; before geline(cin,s)
 to make it work properly
*/

/*
 use 2-D vector for representing the pair<int,pair<int,int> > kind of things
*/

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    long long H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) cout << 1 << endl;
    else if (H * W % 2 == 0) cout << H * W / 2 << endl;
    else cout << H * W / 2 + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define INF 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//��������
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
int lcm(int a,int b){//�Ǿ����ܿ�
  return (a*b)/gcd(a,b);
}
int b[1000000];
int c[1000000];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,d=0;
    cin>>a;
    for(int i=0;i<a+1;i++) cin>>b[i];
    for(int i=0;i<a;i++) cin>>c[i];
    for(int i=0;i<a;i++){
	if(b[i]<=c[i]){
	    d+=b[i];
	    c[i]-=b[i];
	    if(b[i+1]<=c[i]) d+=b[i+1],b[i+1]=0;
	    else b[i+1]-=c[i],d+=c[i];
	}
	else d+=c[i];
    }
    cout<<d<<"\n";
}


Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<iomanip>
#include<string>
#include<map>
#define PI 3.14159265
#define mod 998244353    
using namespace std;

 

void func(){
    long long n,ans = 0 ;
    cin >> n ;
    long long arr[n] , dp[n] = {0};

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

    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);
    
    for(int i = 2 ; i < n ; ++i){
      dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]) , dp[i - 2] + abs(arr[i - 2] - arr[i]));
    }
  cout << dp[n - 1] << "\n";
}
int main(){
    int t = 1 , cnt = 0 ;
  // cin >> t;
    
    while(t--){
        
        func();
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;

int getDigit(ll n) {
    int result = 0;
    while (n > 0) {
        result++;
        n /= 10;
    }
    return result;
}
int main(void) {
    ll N;cin>>N;
    int mi = 1e9;
    for (int i = 1; i <= sqrt(N); i++) {
        int cur;
        if (N % i == 0) {
            cur = max(getDigit(i), getDigit(N / i));
            if (mi > cur) mi = cur;
        }
    }
    cout << mi << endl; 
    return 0;
}

Measured memory_bytes: 256
n = int(input())
R = [int(input()) for i in range(n)]

minv = R[0]
max_profit = -1 * 10**9

for i in range(1, n):
    max_profit = max(max_profit, R[i] - minv)
    minv = min(minv, R[i])

print(max_profit)


Measured memory_bytes: 13596
#include <bits/stdc++.h>
using namespace std;
int main(){
        int N,D1,D2;
        int cnt = 0;
        int max = 0;
        cin >> N;

        for(int i = 0; i < N; i++){
                cin >> D1 >> D2;
                if(D1 == D2){
                        cnt++;
                }else{
                        cnt = 0;
                }
                if (max <= cnt){
                        max = cnt;
                }
        }
        if(max >= 3){
                cout << "Yes" << endl;
        }else{
                cout << "No" << endl;
        }
        return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
    int key;
    Node* prev;
    Node* next;
};

Node* nil;

void Init() {
    nil = (Node*)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil; 
}

void Insert(int key) {
    Node* x = (Node*)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next; //xのnextに挿入前の先頭のアドレスを書き込む
    nil->next->prev = x; //挿入前の先頭のprevをxに書き換える
    nil->next = x; //nilのnextをxに書き換える
    x->prev = nil; //xのprevにnilを書き込む
}

Node* ListSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key !=key) {
        cur = cur->next;
    }
    return cur;
}

void DeleteNode(Node* t) {
    if (t == nil) {
        return;
    }
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void DeleteKey(int key) {
    DeleteNode(ListSearch(key));
}

void DeleteFirst(){
    DeleteNode(nil->next);
}

void DeleteLast(){
    DeleteNode(nil->prev);
}

int main() {
    Init();

    int n;

    cin >> n;

    char c[20];
    int key;

    for (int i=0; i<n; i++) {
        scanf("%s%d", c, &key);
        if (c[0] == 'i') {
            Insert(key);
        }
        else if (c[0] == 'd') {
            if (strlen(c) > 6) {
                if (c[6] == 'F') {
                    DeleteFirst();
                }
                else if (c[6] == 'L') {
                    DeleteLast();
                }
            }
            else {
                DeleteKey(key);
            }
        }
    }

    Node* cur = nil->next; 
    int i = 0;
    while (true) {
        if (cur == nil) { 
            break; 
        }
        if (i > 0) { 
            cout << " "; 
        }
        cout << cur->key;
        cur = cur->next;
        i++;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 34412
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::fmt::Write;
use std::collections::{BinaryHeap, HashSet};

fn main() {
    input! {
        x: usize,
        y: usize,
        z: usize,
        k: usize,
        mut aaa: [usize; x],
        mut bbb: [usize; y],
        mut ccc: [usize; z],
    }
    aaa.sort();
    aaa.reverse();
    bbb.sort();
    bbb.reverse();
    ccc.sort();
    ccc.reverse();

    let ini: usize = aaa[0] + bbb[0] + ccc[0];
    let ini = (ini, 0, 0, 0);
    let mut heap = BinaryHeap::new();
    heap.push(ini);

    let mut visited = HashSet::new();
    visited.insert((0, 0, 0));

    let mut buf = String::new();

    for _ in 0..k {
        let &(score, i, j, l) = &heap.pop().unwrap();
        writeln!(buf, "{}", score).unwrap();
        for &(di, dj, dl) in [(1, 0, 0), (0, 1, 0), (0, 0, 1)].iter() {
            let ni = i + di;
            let nj = j + dj;
            let nl = l + dl;
            if ni == x || nj == y || nl == z {
                continue;
            }
            let key = (ni, nj, nl);
            if visited.contains(&key) {
                continue;
            }
            visited.insert(key);
            let new_sum = aaa[ni] + bbb[nj] + ccc[nl];
            heap.push((new_sum, ni, nj, nl));
        }
    }
    println!("{}", buf);
}

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

typedef long long ll;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);
//#define cerr if(false)cerr
#define PRINT(x) cerr<<"\n" << (#x) << " is " << (x) << endl;
//Erase duplicates in vector
#define REMOVE_DUP(x) x.erase(unique(x.begin(), x.end()), x.end());
#define UP toupper // lowercase to uppercase;
#define DOWN tolower
#define SZ(a) (int)a.size()
#define EB emplace_back
#define PB push_back
#define REP(i, a, b) for(int i=a; i<b; i++)
#define PER(i, a, b) for(int i=a; i>=b; i--)
ostream_iterator<int> output(cout, " ");
#define MOD 1e9+7
#define INF 10008

void solve(){
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	int sum = 0;
	
	for(auto &i : v){
		cin >> i;
		sum += i;
	}
	int search = sum / (4 * m);
	if(search * 4 * m != sum) search += 1;
	sort(v.begin(), v.end());
	
	int cnt = lower_bound(v.begin(), v.end(), search) - v.begin();
	if( n -cnt >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int32_t main(){
	FAST_IO;
	int t1 = 1; //cin >> t1;
	while(t1--)
		solve();
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout << fixed << setprecision(10);
    solve();
    return 0;
}


// Main Code
void solve() {
    int digit = 0;
    
    string TEN = "1";
    while (true) {
        TEN.push_back('0');
        cout << "? " << TEN << endl;
        string str;
        cin >> str;
        if (str == "N") {
            digit = sz(TEN) - 1;
            break;
        }
        if (sz(TEN) == 11) break;
    }
    
    if (!digit) {
        string NINE;
        while (true) {
            NINE.push_back('9');
            cout << "? " << NINE << endl;
            string str;
            cin >> str;
            if (str == "Y") {
                digit = sz(NINE);
                break;
            }
        }
    }
    
    ll left = 1, right = 1;
    rep(i, digit) {
        left *= 10;
        right *= 10;
    }
    left /= 10;
    left -= 1;
    while (right - left > 1) {
        ll mid = (right + left) / 2;
        cout << "? " << mid << "0" << endl;
        string str;
        cin >> str;
        if (str == "Y") right = mid;
        else left = mid;
    }
    
    cout << "! " << right << endl;
    return;
}


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

int main()
{

    //データ定義
    int n;
    int x;
    int i;
    int j;
    int k;
    int combination;

    //データ入力
    cin >> n >> x;

    //メイン処理
    while(n != 0 || x != 0){
        combination = 0;
        for(i = 1; i <= n; i++){
            for(j = i + 1; j <= n; j++){
                for(k = j + 1; k <= n; k++){
                    if((i + j + k) == x){
                        combination++;
                    }
                }
            }
        }
        //結果出力
        cout << combination << endl;
        //データ入力
        cin >> n >> x;
    }



    return 0;
}


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


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


Measured memory_bytes: 3108
N = int(input())
B = list(map(int, input().split()))

A = [B[0]]

for i in range(1, N-1):
    if B[i-1] >= B[i]:
        A.append(B[i])
    else:
        A.append(B[i-1])

A.append(B[N-2])
print(sum(A))



Measured memory_bytes: 2940
import java.util.Scanner;


public class Main {

	Main(){
		doIt();
	}
	
	void doIt(){
		Scanner sc = new Scanner(System.in);
		int[] weight = {2, 3, 5, 10, 12, 15};
		int[] price = {380, 550, 850, 1520, 1870, 2244};
		while(true){
			int goal = sc.nextInt();
			goal /= 100;
			
			int[] aw = new int[goal + 1];
			
			if(goal == 0) break;
			for(int i = 0; i <= goal; i++){
				for(int k = 0; k < 6; k++){
					if(goal < i + weight[k])break;
					if(i == 1) break;
					if(aw[i+weight[k]] == 0 || aw[i] + price[k] < aw[i+weight[k]]) {
						aw[i+weight[k]] = aw[i] + price[k];
					}
				}
			}
			System.out.println(aw[goal]);
		}
		
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main();
	}

}

Measured memory_bytes: 17208
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())

LOSE = -1
WIN = 1

dp = [0]*(k+1)
for i in range(a[0]):
    dp[i] = LOSE
    
for i in range(a[0], k+1):
    lost = True
    for ai in a:
        if i-ai < 0:
            continue
        
        if dp[i-ai] == LOSE:
            lost = False
            
    dp[i] = LOSE if lost else WIN
    
print('First') if dp[k] == WIN else print('Second')

Measured memory_bytes: 41836
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    bool ispallindrome(string s)
    {
        int i=0,j=s.length()-1;
        while(i<j)
        {
            if(s[i]!=s[j])
                return false;
            ++i,--j;
        }
        return true;
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ld a,b,c;
            ll l;
            cin>>l;
            a=(ld)1.0*l/3;
            printf("%.9Lf\n",a*a*a);
        }
        return 0;
    }


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

    uint64_t T[100] = {0};
    uint64_t c = 1;
    for (int i=0; i < N; i++) {
        cin >> T[i];
        c = c * (T[i] / __gcd(T[i], c));
    }

    cout << c << endl;
    return 0;
}


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

int main(){
  int n,ans1,ans2,ans;
  ans=0;
  ans1=0;
  ans2=0;
  cin>>n;
  vector<int> w(n);
  for(int i=0;i<n;i++){
  cin>>w.at(i);
  }
  for(int i=0;i<n;i++){
    for(int k=0;k<=i;k++){
      ans1+=w.at(k);
    }
    for(int k=n-1;k>i;k--){
      ans2+=w.at(k);
    }
    if(i==0){
      ans=max(ans1,ans2)-min(ans1,ans2);
    }
    else{
      ans=min(ans,max(ans1,ans2)-min(ans1,ans2));
    }
    ans1=0;
    ans2=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(int argc, char *argv[])
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  if(a==b) printf("%d",c);
  else if(b==c) printf("%d",a);
  else if(c==a) printf("%d",b);
  return 0;
}


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

int heap[500000];
int H;

int left(int i){ return i*2; }
int right(int i){ return i*2+1; }
int parent(int i){ return i/2; }

void maxHeapify(int i){
   int l=left(i);
   int r=right(i);
   int largest;
   if(l<=H && heap[i]<heap[l])
      largest=l;
   else
      largest=i;
   if(r<=H && heap[largest]<heap[r])
      largest=r;

   if(largest!=i){
      swap(heap[largest], heap[i]);
      maxHeapify(largest);
   }
}

void buildMaxHeap(){
   for(int i=H/2; i>0; i--)
      maxHeapify(i);
}

int main(){
   cin >> H;
   for(int i=1; i<H+1; i++) cin >> heap[i];
   buildMaxHeap();
   for(int i=1; i<H+1; i++){
      cout << " ";
      cout << heap[i];
   }
   cout << endl;
}


Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    ll a[n + 1], s[n + 2];
    s[0] = 0;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
        s[i + 1] = s[i] + a[i];
    }
    ll node = 1, ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += node;
        node -= a[i];
        if (node < 0) {
            cout << -1 << endl;
            return 0;
        }
        if (node == 0 && i != n) {
            cout << -1 << endl;
            return 0;
        }
        node *= 2;
        node = min(node, s[n + 1] - s[i + 1]);
    }
    cout << ans << endl;
}

/*
まず完全二分木を考える。
完全二分木の深さをnとして、深さiの頂点から出ている辺をひとつ消した場合、その影響はどれほどか？
上の場合、2^(n - i) - 1個の頂点が消えることになる。

長さn + 1の整数列Aの末尾から逆算して考える。
A_nがmである時、つまり深さnの頂点の数がmである時、深さn - 1の頂点の数をkとすると、ceil(m / 2) <= k <= m + A_(n - 1)がなりたつ。

同様に考えていくと、A_(n - 2)をlとして、深さlの頂点の数をjとすると、ceil(k / 2) <= j <= k + A_(n - 2)がなりたつ。

つまり、

n - 1 : ceil(A_n / 2) ~ A_n + A_(n - 1)
n - 2 : ceil(A_n / 4) ~ A_n + A_(n - 1) + A_(n - 2)
    0 : ceil(A_n / (2^n)) ~ 整数列Aの総和

となる。
しかし、深さ0の頂点の数は絶対に1なので、

0 : 1
1 : 1 ~ 2
2 : 1 ~ 4
n : 1 ~ 2^n

これも同時になりたつ。
まとめると、

0 : 1
1 : 1 ~ min(整数列Aの総和 - A_0, 2)
i : 1 ~ min(整数列Aの総和 - A_0からA_(i - 1)の総和, 2^i)

こうなる。

*/

Measured memory_bytes: 5196
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    H, W = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(input()) for i in range(H)) #改行行列

    cnt=[[[0]*W for _ in range(H)] for _ in range(4)]
    for i in range(0,H):
        mj=-1
        for j in range(0,W):
            if S[i][j]=="#":
                mj=j
                continue
            cnt[0][i][j]=(j-mj-1)
    for i in range(0,H):
        mj=W
        for j in range(W-1,-1,-1):
            if S[i][j]=="#":
                mj=j
                continue
            cnt[1][i][j]=(mj-j-1)

    for i in range(0,W):
        mj=-1
        for j in range(0,H):
            if S[j][i]=="#":
                mj=j
                continue
            #printe(j,i)
            cnt[2][j][i]=(j-mj-1)
    for i in range(0,W):
        mj=H
        for j in range(H-1,-1,-1):
            if S[j][i]=="#":
                mj=j
                continue
            cnt[3][j][i]=(mj-j-1)
    
    ans=0
    for i in range(0,H):
        for j in range(0,W):
            if S[i][j]=="#":
                continue
            x=cnt[0][i][j]+cnt[1][i][j]+cnt[2][i][j]+cnt[3][i][j]+1    
            ans=max(x,ans)
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 489820
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string.h>

const int N=101;
int v[N][N];
std::vector<int> g[N];
int used[N];

int dfs(int v)
{
	used[v]=1;
	int res=0;
	for (auto &to : g[v]){
        if (used[to])
			continue;
        res=std::max(res,dfs(to)+1);
    }
	used[v]=0;
	return res;
}

int main()
{
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		
		memset(v,0,sizeof(v));
		for(int i=0;i!=N;++i)
			g[i].clear();
		
		for(int i=0;i!=n;++i){
			int x,y;
			scanf("%d%d",&x,&y);
			--x,--y;
			v[x][y]=v[y][x]=1;
		}
		
		for(int i=0;i!=N;++i)
		{
			for(int j=0;j!=N;++j){
				if(v[i][j])
					g[i].push_back(j);
			}
		}
		
		int ans=2;
		for(int i=0;i!=N;++i)
			ans=std::max(ans,dfs(i)+1);
		
		printf("%d\n",ans);
	}	
	return 0;
}

Measured memory_bytes: 1240
<?php
fscanf(STDIN, '%d', $n);

for($i=1; $i<=9; $i++){
    if(($n % $i) === 0 && ($n/$i) <= 9) {
        echo 'Yes'.PHP_EOL;
        break;
    }
    if($i===9){
        echo 'No'.PHP_EOL;
    }
}


Measured memory_bytes: 4728
def abc_145_c
    n = gets.chomp.to_i
    xy = []
    for i in 1..n
        xy.push(gets.chomp.split(/\s/).map{|x| x.to_f})
    end

    ave = 0.0
    brr = [*0..n-1].permutation(n).to_a
    brr.each do |arr|
        for i in 0..(arr.length-2)
            ave += Math.sqrt((xy[arr[i]][0] - xy[arr[i+1]][0])*(xy[arr[i]][0] - xy[arr[i+1]][0]) + 
                             (xy[arr[i]][1] - xy[arr[i+1]][1])*(xy[arr[i]][1] - xy[arr[i+1]][1]))
        end
    end

    puts ave/brr.length
end

abc_145_c

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

int main()
{
    int A, B;
    int ans = 0;
    cin >> A >> B;
    for (int num = A; num <= B; num++)
    {
        string str = to_string(num);
        bool flag = true;
        for (int i = 0; i < str.size(); i++)
        {
            if (str[i] != str[(str.size() - 1) - i])
            {
                flag = false;
                break;
            }
        }

        if (flag)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n, a=0; cin >> n;
  string s; cin >> s;
  
  for(int i = 0; i < n-2; i++){
  	if(s[i] == 'A'){
    	if(s[i+1] == 'B' && s[i+2] == 'C') a++;
    	
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){


    cin >> s;

    rep(i,0,sz(s)-1){
	if(s[i] == s[i+1]){
	    P("Bad");
	    ret 0;
	}
    }
    P("Good");
    return  0;
}


Measured memory_bytes: 256
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]
cmax=max(c)
c_index = c.index(cmax)
for i in range(d):
  ans = [0]*26
  for j in range(26):
    ans[j] = s[i][j]+c[j]
  print(ans.index(max(ans))+1)



Measured memory_bytes: 68528
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val xList = mutableListOf<Long>()
    val yList = mutableListOf<Long>()
    val zList = mutableListOf<Long>()

    for (i in 0 until n) {
        val (x, y, z) = readLine()!!.split(" ").map(String::toLong)
        xList.add(x)
        yList.add(y)
        zList.add(z)
    }
    val list1 = mutableListOf<Long>()
    val list2 = mutableListOf<Long>()
    val list3 = mutableListOf<Long>()
    val list4 = mutableListOf<Long>()
    val list5 = mutableListOf<Long>()
    val list6 = mutableListOf<Long>()
    val list7 = mutableListOf<Long>()
    val list8 = mutableListOf<Long>()

    for (i in 0 until n) {
        list1.add(xList[i] + yList[i] + zList[i])
        list2.add(xList[i] + yList[i] + zList[i] * -1)
        list3.add(xList[i] + yList[i] * -1 + zList[i])
        list4.add(xList[i] * -1 + yList[i] + zList[i])
        list5.add(xList[i] + yList[i] * -1 + zList[i] * -1)
        list6.add(xList[i] * -1 + yList[i] + zList[i] * -1)
        list7.add(xList[i] * -1 + yList[i] * -1 + zList[i])
        list8.add(xList[i] * -1 + yList[i] * -1 + zList[i] * -1)

    }
    var max = 0L
    max = Math.max(max, list1.sortedDescending().slice(0..(m - 1)).sum())
    max = Math.max(max, list2.sortedDescending().slice(0..(m - 1)).sum())
    max = Math.max(max, list3.sortedDescending().slice(0..(m - 1)).sum())
    max = Math.max(max, list4.sortedDescending().slice(0..(m - 1)).sum())
    max = Math.max(max, list5.sortedDescending().slice(0..(m - 1)).sum())
    max = Math.max(max, list6.sortedDescending().slice(0..(m - 1)).sum())
    max = Math.max(max, list7.sortedDescending().slice(0..(m - 1)).sum())
    max = Math.max(max, list8.sortedDescending().slice(0..(m - 1)).sum())

    println(max)
}


Measured memory_bytes: 41592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
pair<int,int> x[510];
int ans[250010];
queue<int> Q;
int main(){
	int n;
	cin>>n;
	lol(i,n*n)ans[i]=-1;
	lol(i,n){
		int a;cin>>a;
		a--;
		ans[a]=i+1;
		x[i]=make_pair(a,i+1);
	}
	sort(x,x+n);
	int pnt=0;
	bool ok=true;
	lol(i,n){
		int lim=x[i].first;
		int t=x[i].second,cnt=x[i].second-1;
		while(cnt){
			if(pnt>=lim){
				ok=false;
				goto loop;
			}
			if(ans[pnt]==-1){
				cnt--;
				ans[pnt]=t;
			}
			pnt++;
		}
	}
	pnt=n*n-1;
	for(int i=n-1;i>=0;i--){
		int lim=x[i].first;
		int t=x[i].second,cnt=n-x[i].second;
		while(cnt){
			if(pnt<=lim){
				ok=false;
				goto loop;
			}
			if(ans[pnt]==-1){
				cnt--;
				ans[pnt]=t;
			}
			pnt--;
		}
	}
	loop:;
	if(ok){
		cout<<"Yes"<<endl;
		lol(i,n*n){
			if(i)cout<<" ";
			cout<<ans[i];
		}
		cout<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


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

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();

        long[] A = new long[N+1];
        long[] B = new long[M+1];
        for (int i = 0; i < N; i++) {
            A[i+1] = A[i]+sc.nextInt();
        }
        TreeMap<Long,Integer> s = new TreeMap<>();
        s.put(0L,0);
        for (int i = 0; i < M; i++) {
            B[i+1] = B[i]+sc.nextInt();
            s.put(B[i+1],i+1);
        }

        int ans = 0;
        for (int i = 0; i <=N ; i++) {

            if(A[i]>K){
 //               ans = Math.max(ans,i);
            }else if(A[i]==K){
                  ans = Math.max(ans,i);
            }else{
                int books = binarySearch(A[i],K,s);
                ans = Math.max(ans,books+i);
            }
        }

        System.out.println(ans);
    }

    //a-B[i]<= K , find max books
//    static
//    int binarySearch(long a,int K, long[] B){
//        int l = 0;
//        int r = B.length;
//
//        while(l+1<r){
//            int mid = (l+r)/2;
//            if(a+B[mid]<=K){ //OK
//                l=mid;
//            }else{//NG
//                r=mid;
//            }
//        }
//        return l;
//    }
    static
    int binarySearch(long a,int K, TreeMap<Long,Integer> B){
        if(B.containsKey(K-a)){
            return B.get(K-a);
        }else{
            Long books =  B.lowerKey(K-a);
            if(books==null){
                return 0;
            }else{
                return B.get(books);
            }
        }
    }
}

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

using namespace std;

#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005


int main()
{
	int t;
	map<char,int>m;
	string ch;
	cin >> t >> ch;
	for(int i =0; i < t; i++)
	{
		m[ch[i]]++;
	}
	for(auto it : m)
	{
		if(it.second%2!=0)
		{
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private final int MAX_N = 100;

    private int N;
    private int[] array = new int[MAX_N];

    public Main(Scanner sc) {
        N = sc.nextInt();
        array = new int[N];
        for (int i = 0; i < N; i++) {
            array[i] = sc.nextInt();
        }
    }

    private void printArray() {
        System.out.print(array[0]);
        for (int i = 1; i < N; i++) {
            System.out.print(" " + array[i]);
        }
        System.out.println();
    }

    public void insertSort() {
        printArray();
        for (int currIx = 1; currIx < N; currIx++) {
            int value = array[currIx];
            int tmpIx = currIx-1;
            while (tmpIx >= 0 && array[tmpIx] > value) {
                array[tmpIx+1] = array[tmpIx];
                tmpIx--;
            }
            array[tmpIx+1] = value;
            printArray();
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main sorter = new Main(sc);
        sorter.insertSort();
    }
}



Measured memory_bytes: 32096
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	x := getNextInt64(scanner)
	y := getNextInt64(scanner)

	fmt.Fprintln(writer, solve(x, y))

	writer.Flush()
}

func solve(x, y int64) uint {
	var i uint
	for i = 1; x<<i <= y; i++ {
	}

	return i
}


Measured memory_bytes: 640
//**************************
//*** writer  :  Alan Hu **
//************************

//傅思程你敢抄我程序？？？ 
//傅思程你敢抄我程序？？？	                
//傅思程你敢抄我程序？？？ 

#include<bits/stdc++.h>

using namespace std;
     
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
int n,k,ans=1e9,lb=0,ub;
int a[100010];
 
int main()
{
	cin>>n>>k;
	rept(i,0,n) cin>>a[i];
	ub=k-1;
	for(;ub<n;lb++,ub++)
	{
		int res=0;
		if ((a[lb]<=0 && a[ub]<=0) || (a[lb]>=0 && a[ub]>=0)) res=max(abs(a[lb]),abs(a[ub]));
		else res=(min(-a[lb],a[ub]))*2+max(-a[lb],a[ub]);
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

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

long long dp[1000001][3];
long long n, h[1000001][3];

long long go(long long k, long long jour) {
    if(jour == n) return 0;
    if(dp[jour][k] != -1) return dp[jour][k];
    if(k == 0){
        return dp[jour][k] = max(go(1 , jour+1) + h[jour][1], go(2 ,jour+1) + h[jour][2]);
    } else if(k == 1){
        return dp[jour][k] = max(go(0 , jour+1) + h[jour][0], go(2 ,jour+1) + h[jour][2]);
    } else {
        return dp[jour][k] = max(go(0 , jour+1) + h[jour][0], go(1 ,jour+1) + h[jour][1]);
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin >> h[i][j];
        }
    }
//    if(n == 1) cout << max(h[0][0], max(h[0][1], h[0][2]));
//    else
    cout << max(go(0, 0), max(go(1, 0), go(2, 0)));
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
    cout<<fixed<<setprecision(10);

        ll n,q; cin>>n>>q;
        UnionFind tree = UnionFind(n);
        rep(_,q){
            ll t,u,v;
            cin>>t>>u>>v;
            if(t == 0){
                tree.unite(u,v);
            }else{
                if(tree.find(u) == tree.find(v)) puts("1");
                else puts("0");
            }
        }

    return 0;

}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
   long double A,B,C;
   cin >> A >> B >> C;
   if(A + B + 2 * pow(A*B,0.5) < C){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
bool isprime(int p) {
	if (p == 1) return false;
    for (int i = 2; i < p; i++) {
			if (p%i == 0) return false;
	}
	return true;
}
int n;
int main() {
	cin >> n;
	for (int i = 31; i <= 55555; i += 30) {
		if (isprime(i)) {
			if (i != 31) cout << " ";
			cout << i;
			n--;
		}
		if (n == 0) break;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		long[] v = new long[n];
		for(int i = 0; i < n; i++){
		    v[i] = sc.nextLong();
		}
		Arrays.sort(v);
		
		// 計算
		long result = 0;
		long sum = 0;
		double ave = 0;
		int min = 0;
		int max = 0;
		int all = 0;
		for(int i = 0; i < n; i++){
		    if(i+1 <= a){
		        sum += v[n-1-i];
		        ave = (double)sum/(i+1);
		        if(i > 0 && v[n-i] == v[n-1-i]){
		            min++;
		            max++;
		            all++;
		        }else{
		            min = 1;
		            max = 1;
		            all = 1;
		        }
		    }else if(i+1 <= b && ave < v[n-1-i]){
		        sum += v[n-1-i];
		        ave = (double)sum/(i+1);
		        if(i > 0 && v[n-i] == v[n-1-i]){
		            min++;
		            max++;
		            all++;
		        }else{
		            min = 1;
		            max = 1;
		            all = 1;
		        }
		    }else if(i+1 <= b && ave == v[n-1-i]){
		        if(i > 0 && v[n-i] == v[n-1-i]){
		            max++;
		            all++;
		        }else{
		            break;
		        }
		    }else if(v[n-i] == v[n-1-i]){
		        all++;
		    }
		}
		
		for(int i = min; i <= max; i++){
		    result += combination(all, i);
		}
		
		// 出力
		System.out.println(ave);
		System.out.println(result);
	}
	
	public static long combination(long n, long k) {
	    if (n < k || n < 0 || k < 0) return 0;
	    long res = 1;
	    if(k > n-k) k = n-k;
	    for(int i = 1; i <= k; i++){
	        res *= n-k+i;
	        res /= i;
	    }
		return res;
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    vector<int> s(3);
    rep(i, n) {
        int p;
        cin >> p;
        if(p <= a) s[0]++;
        else if(p <= b) s[1]++;
        else s[2]++;
    }
    cout << min(s[0], min(s[1], s[2])) << endl;
    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n); int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());
    if (a.at(m - 1) * 4 * m >= sum) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		string s[n];
		REP(i,n){
			cin>>s[i];
		}
		string news[n];
		int maxlen=0;
		for(int i=0;i<n;i++){
			string x="";
			string z=s[i];
			for(int j=0;j<z.length();j++){
				if(j==0){
					x=z[0];}
				else if(z[j-1]=='a'||z[j-1]=='i'||z[j-1]=='u'||z[j-1]=='e'||z[j-1]=='o'){
					x+=z[j];

				}
			}
			news[i]=x;
			if(x.length()>maxlen){
				maxlen=x.length();
			}
			


		}
		int flag2=0;
		for(int i=1;i<=maxlen;i++){
			string next[n];
			for(int j=0;j<n;j++){
				string x=news[j];
				if(x.length()<i){
					next[j]=x;
				}
				else{
					string z="";
					for(int k=0;k<i;k++){
						z+=x[k];
					}
					next[j]=z;
				}
				
			}
			sort(next,next+n);
			int flag=1;
			for(int z=0;z<n-1;z++){
				if(next[z]==next[z+1]){
					flag=0;
				}
			}
			if(flag==1){
				cout<<i<<endl;
				flag2=1;
				break;
			}

		}
		if(flag2==0){
			cout<<-1<<endl;
		}



	}


	return 0;
}



Measured memory_bytes: 3112
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  // (sx, sy)→(tx, ty)
  for (int i = 0; i < ty - sy; i++) cout << "U";
  for (int i = 0; i < tx - sx; i++) cout << "R";
  // (tx, ty)→(sx, sy)
  for (int i = 0; i < ty - sy; i++) cout << "D";
  for (int i = 0; i < tx - sx; i++) cout << "L";
  // (sx, sy)→(tx, ty)
  cout << "L";
  for (int i = 0; i < ty - sy + 1; i++) cout << "U";
  for (int i = 0; i < tx - sx + 1; i++) cout << "R";
  cout << "D";
  // (tx, ty)→(sx, sy)
  cout << "R";
  for (int i = 0; i < ty - sy + 1; i++) cout << "D";
  for (int i = 0; i < tx - sx + 1; i++) cout << "L";
  cout << "U";

  cout << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 384