akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define reps(i,j,n) for(int i = (j) ; i < (int)(n) ; ++i)    
#define rep(i,n) reps(i,0,n)  
#define each(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)  
  
#define all(v) (v).begin(), (v).end()  
#define pb(x) push_back(x)  
#define sz(x) (int)((x).size())  
#define UNQ(s) {sort(ALL(s));(s).erase(unique(ALL(s)),(s).end());}   
#define fr first  
#define sc second  
  
typedef pair< int , int > Pi;  
typedef pair< int , Pi > Pii;

  
typedef long long int64;  
const int INF = 1 << 30;  
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is>>a.first>>a.second; }  
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os<<a.first<<" "<<a.second; }  
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ rep(i,sz(vc)) is >> vc[i]; return is;}  
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ rep(i,sz(vc)) os << vc[i] << endl; return os; }  

main(){
  int N, M, S, dp[50][3001];


  while(cin >> N >> M >> S, N){

    fill_n( *dp, 50 * 3001, 0);

    dp[0][0] = 1;

    for(int i = 1; i <= M; i++){
      for(int j = N * N; j > 0; j--){
        for(int k = S; k >= i; k--){ // マスまでの総和
          (dp[j][k] += dp[j - 1][k - i]) %= 100000;
        }
      }
    }

    cout << dp[N * N][S] << endl;
  }
  return(0);
}

Measured memory_bytes: 1744
N = int(input())
list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
ans = 0
if N <= 81:
    for i in range(9):
        if N%int(list[i]) == 0 and N/int(list[i]) in list:
            ans += 1
        else:
            ans = ans
    if ans != 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int h,w;scanf("%d%d",&h,&w);
   char s[51][51];
   for(int i = 0;i < h;i++){
      scanf("%s",s[i]);
   }
   int ans[51][51] = {0};
   for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
         for(int k = -1;k < 2;k++){
            for(int l = -1;l < 2;l++){
               if(s[i+k][j+l] == '#')ans[i][j]++;
            }
         }
      }
   }
   for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
         if(s[i][j]=='#')printf("#");
         else printf("%d",ans[i][j]);
      }
      printf("\n");
   }
}

Measured memory_bytes: 256
#include <stdio.h>
int H;

int left(int x){return 2*x;}
int right(int x){return 2*x+1;}
void maxHeapify(int A[], int i);
void buildMaxHeap(int A[]);

int main(){
  int i;
  int A[500000];
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  puts("");

  return 0;
}




void maxHeapify(int A[], int i){
  int l,r,tmp;
  int largest;
  l = left(i);
  r = right(i);
  if(l <= H && A[l] > A[i]){
    largest = l;
  } else {
    largest = i;
  }
  if(r <= H && A[r] > A[largest]){
    largest = r;
  }
  if(largest !=i){
    tmp = A[i];
    A[i]=A[largest];
    A[largest]= tmp;
    maxHeapify(A,largest);
  }

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 200;
char s[N];
int n;
int a[N], b[N];

int main(int argc, char** argv) {
	//freopen("in.txt", "r", stdin);
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	
	cin>>n>>s;
	
	for(int i=1;i<=n;i++) {
		a[i] = a[i - 1] + (s[i - 1] == 'W');
		//cout<<a[i]<<" ";
	}	
	for(int i=n-2;i>=0;i--) {
		b[i] = b[i + 1] + (s[i + 1] == 'E');
	}
	int ans = N + 200;
	for(int i=0;i<n;i++) {
		ans = min(a[i] + b[i], ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2944
n,m = gets.chomp.split(" ").map(&:to_i);

class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end 
 
  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent
 
    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end 
  end 
 
  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
    # 3項演算子（xx ? yy : zz　の意味は　if xx then yy else zz end ）
    end 
 
  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end 
 
  def count_parent
    rtn = 0 
    @parent.each_with_index do |p, index|
      rtn += 1 if p == index
    end 
    rtn 
  end 
end
 
union = UnionFind.new n
 
# クエリの回数だけ、入力受け取りを回す
m.times do
  a, b = gets.split.map{|x| x.to_i-1}
  union.unite(a, b)
end
 
puts union.count_parent - 1 

Measured memory_bytes: 15820
#include <stdio.h>

int sum;
void a(int x,int y){
    if(x % y)
        return;
    sum++;
    a(x/y,y);
}

int main(void){
    int num,num1,sum1;
    for(;sum=0,sum1=0,scanf("%d",&num),num1=num,num;){
        while(num){
            a(num,2);
            num--;
        }
        sum1=sum;sum=0;
        while(num1){
            a(num1,5);
            num1--;
        }
        if(sum <= sum1)
            printf("%d\n",sum);
        else
            printf("%d\n",sum1);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main() {
    int n,k;
    cin>>n>>k;
    int a[n];
    int ans=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]>=k){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
}

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

using namespace std;

int d[105];
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>d[i];
    sort(d,d+n);
    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(d[i]>d[i-1])
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  cin >> n;
  int ans = n;
  while(true){
    if(ans % 2 == 0 && ans % n == 0){
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    file = sys.stdin.readline
    N, A, B, C = map(int, file().split())
    mod = 7 + 10 ** 9
    nfact = [1] * (2 * N)
    nrev = [1] * (2 * N)
    Apow, Bpow, Hpow = [A] * (2 * N), [B] * (2 * N), [A + B] * (2 * N)
    Apow[0] = 1
    Bpow[0] = 1
    Hpow[0] = 1
    Crev = (pow(100 - C, mod - 2, mod) * 100) % mod
    for i in range(2, 2 * N):
        nfact[i] = (nfact[i-1] * i) % mod
        Apow[i] = (Apow[i-1] * A) % mod
        Bpow[i] = (Bpow[i-1] * B) % mod
        Hpow[i] = (Hpow[i-1] * (A + B)) % mod
    nrev[2 * N - 1] = pow(nfact[2 * N - 1], mod - 2, mod)
    Hpow[2 * N - 1] = pow(Hpow[2 * N - 1] , mod - 2, mod)
    for i in reversed(range(1, 2 * N - 1)):
        nrev[i] = (nrev[i + 1] * (i + 1)) % mod
        Hpow[i] = (Hpow[i + 1] * (A + B)) % mod

    ans = 0
    for i in range(N, 2 * N):
        ans += (((nfact[i-1] * nrev[N-1] * nrev[i-N]) % mod) * ((Apow[N]*Bpow[i-N] + Apow[i-N]*Bpow[N]) % mod) * i * Hpow[i] * Crev) % mod
        ans %= mod
    print(ans)

    return

if __name__ == "__main__":
    solve()

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

int main(){
    pair<pair<string, int>,int>p[110];
    char in[120];
    int a; cin>>a;
    for(int i = 0; i < a;i++){
        int t;cin>>in>>t;
        string tmp=in;
        p[i]=make_pair(make_pair(in, -t), i);
    }
    sort(p, p+a);
    for(int i = 0; i < a; i++)cout<<p[i].second+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() << x; }
template<typename T> void db(T x , T y){ debug() << x <<" "<< y; }
template<typename T> void db(T x , T y , T z){ debug() << x <<" "<< y <<" "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() << x <<" " << y <<" "<< z <<" "<< a; }

const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
vector<int>can;
void div(int n){
  for(int i=2;i*i<=n;i++){
    if(n % i == 0){
      if(n / i == i){
        can.push_back(i);
      }
      else{
        can.push_back(i);
        can.push_back(n/i);
      }
    }
  }
  can.push_back(n);
}

int check(int n , int k){

  while(n % k == 0) n/= k;
  if(n % k == 1) return 1;
  return 0;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int N ;
  cin >> N;

  if(N == 2){
    cout << 1 << '\n';
    return 0;
  }
  div(N);div(N-1);
  int ans = 0;
  for(auto i : can){
    if(check(N , i)) ans++;
  }
  cout << ans << '\n';
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  for (int i = 0; i < H;i++){
    for (int j = 0; j < W;j++){
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < W + 2;i++){
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H;i++){
    for (int j = 0; j < W + 2;j++){
      if(j==0 ||j==W+1){
        cout << "#";
      } else {
        cout << s[i][j - 1];
      }
    }
    cout << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
}


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

int main(){
    vector<ll> p;
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> g(n,vector<ll>(n,0));
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        g[a][b]=1;
        g[b][a]=1;
    }
    rep(i,n-1)p.push_back(i+1);
    ll ans=0;
    do{
        bool f=true;
        ll prev=0;
        rep(i,n-1){
            if(g[prev][p[i]]==0){
                f=false;
                break;
            }
            prev=p[i];
        }
        if(f)ans++;
    }while(next_permutation(p.begin(), p.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin>>n;
	vector<double> p(n+1);
	rep(i,1,n+1) cin>>p[i];
	vector<vector<double>> dp(n+1);
	rep(i,0,n+1) dp[i].resize(n+1,0);
	dp[0][0]=1;
	rep(i,1,n+1)rep(j,0,i+1){
		if(j>0)dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		else dp[i][j]=dp[i-1][j]*(1-p[i]);
	}
	double ans=0;
	rep(i,n/2+1,n+1) ans+=dp[n][i];
	cout.precision(10);
	cout<<fixed<<ans<<endl;
	return 0;
}

Measured memory_bytes: 71808
#include<bits/stdc++.h>
#define lop(i,n,a) for(int i=0;i<n;i+=a)
#define rep(i,n,a) for(int i=a;i<n;i++)
#define inarr(arr,n) lop(i,n,1)cin>>arr[i]
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define endl "\n"
#define eb emplace_back
#define fr first
#define sc second
#define pii pair<int,int>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret return 0
#define pi 3.1415926536
#define hell 1000000007
using namespace std;
// syntax for min priority_queue of pairs
// priority_queue<pair<ll,ll>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
int solve(){
  ll n;cin>>n;
  if(n&1)cout<<0<<endl;
  else{
      ll i=10;
      ll sum=0;
      while(n>=i){
       sum=sum+n/i;
       i*=5;
      }
      cout<<sum<<endl;
  }
  ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k;
   cin>>n;
   char a[n];
   cin>>a;
   cin>>k;
   char x=a[k-1];
   for(int i=0;i<n;i++)
   {
       if(a[i]!=x)
        a[i]='*';
   }
   cout<<a<<endl;
   return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    DESC(a);

    int ans = 1000000000;
    REP(i, n) {
        int tmp = a[i];
        int count = 0;
        while (tmp % 2 == 0) { 
            tmp /= 2;
            count++;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){ 
    ll n,m;
    cin >> n >> m;
    ll a[m] = {};
    if(m == 1 || n >= m){
        cout << 0 << endl;
        return 0;
    }

    rep(i,0,m){
        cin >> a[i];
    }

    sort(a,a+m);

    ll b[m-1] = {};
    ll ans = 0;
    rep(i,0,m-1){
        b[i] = a[i+1] - a[i]; 
        ans += b[i];
    }

    sort(b,b+m-1,greater<ll>());

    rep(i,0,n-1){
        ans -= b[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N, T; cin >> N >> T;
VI t(N); rep(i, 0, N) cin >> t[i];

int64_t time = T;
rep(i, 1, N) time += min(T, t[i] - t[i-1]);

cout << time << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 1792
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0] * N
E[0] = sum(P[:K])

for i in range(1, N-K):
  E[i] = E[i-1] + P[i+K-1] - P[i-1]

E[N-K] = sum(P[N-K:])
maxE = max(E)
#print(E)
print((maxE - K) / 2.0 + K)



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

int a, b, c, x, ans;

int main() {
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; ++i) {
		for(int j = 0; j <= b; ++j) {
			for(int k = 0; k <= c; ++k) {
				if(i * 500 + j * 100 + k * 50 == x) {
					ans++;
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll h,n,a,i,sum=0;
    cin>>h>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        sum += a;
    }
    cout<<(sum>=h ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>

constexpr int MIN = std::numeric_limits<int>::min();

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::pair<int, int>> segs(n);
    for (auto& seg : segs) {
        int x, l;
        std::cin >> x >> l;
        seg = std::make_pair(x - l, x + l);
    }

    std::sort(segs.begin(), segs.end(),
              [](const auto& lhs, const auto& rhs) {
                  return lhs.second < rhs.second;
              });

    int ans = 0, prev = MIN;
    for (const auto& seg : segs) {
        if (prev <= seg.first) {
            ++ans;
            prev = seg.second;
        }
    }

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

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N ,M;
   cin >> N >> M;
   int A[N];
   int S=0;
   for(int i = 0; i < N ; i++) cin >> A[i];
   for(int i = 0; i < N; i++) S+=A[i];
   int cnt = 0;
   for(int i = 0; i < N ; i++){
      if(A[i]*4*M>=S){
         cnt++;
      }
   }
   if(cnt >= M)cout << "Yes" << endl;
   else cout << "No" << endl;

   return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;


class P
{
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    var w = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
    int[] sum = new int[n+1];
    for(int i = 1; i <= n; ++i) {
      sum[i] += sum[i-1] + w[i-1];
    }
    int min = int.MaxValue;
    for (int i = 1; i < n; ++i) {
      // Console.WriteLine(sum[i]);
      // Console.WriteLine(sum[n] - sum[i+1]);
      min = Math.Min(Math.Abs(sum[i] - (sum[n] - sum[i])), min);
    }
    Console.WriteLine(min);
  }
}

/*
foreach (int i in Enumerable.Range(0, n))
foreach文でループを回せる！！！！
 */

Measured memory_bytes: 13396
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var spl   = input.ReadLine().Split(' ');
        var s     = spl[0];
        var t     = spl[1];

        string r = "";
        for(int i=0; i<n; i++) {
            r += s[i];
            r += t[i];
        }

        return r;
    }
}


Measured memory_bytes: 11092
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  string s;
  cin >> s;
  int l = s.size();
  rep(i,l)cout << "x";
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1};
int dx[] = {1, -1, 0, 0};

struct Node {
    int parent = -1, sibling = -1, degree = 0,
     depth = 0, height = 0;
    vector<int> children;
    string pos = "internal node";
};
Node node[25];
void Depth(int i, int now, int dep) {
    //cout << i << " " << now << " " << dep << endl;
    if (node[now].parent == -1) {
        node[i].depth = dep;
        return;
        
    }
    if (dep > 100) return;
    Depth(i, node[now].parent, dep + 1);
}
void dfs(int i, int now, int dep) {
    if (node[now].children.size() == 0) {
        node[i].height = max(node[i].height, dep);
        return;
    }
    rep(k, node[now].children.size()) {
        dfs(i, node[now].children[k], dep + 1);
    }
    
}
int main() {
    int n; cin >> n;
    rep(i, n) {
        int id, l, r; cin >> id >> l >> r;
        
        if (l != -1) {
            node[l].parent = id;
            node[l].sibling = r;
            node[id].degree++;
            node[id].children.push_back(l);
        }
        if (r != -1) {
            node[r].parent = id;
            
            node[r].sibling = l;
            node[id].degree++;
            node[id].children.push_back(r);
        }
        
    }
    rep(i, n) {
        /*
        //if (node[i].sibling != -1) continue;
        
        rep(j, n) {
            if (i != j && node[i].parent == node[j].parent) {
                node[i].sibling = j;
                node[j].sibling = i;
            }
        }
         */
        if (node[i].degree == 0) {
            node[i].pos = "leaf";
        }
        if (node[i].parent == -1) {
            node[i].pos = "root";
        }
        Depth(i, i, 0);
    }
    rep(i, n) { //全てのdepが求まってから
        dfs(i, i, 0);
        /*cout << node[i].height << endl;
        node[i].height = node[i].height - node[i].depth;*/
    }
    rep(i, n) {
        cout << "node " << i;
        cout << ": parent = " << node[i].parent;
        cout << ", sibling = " << node[i].sibling;
        cout << ", degree = " << node[i].degree;
        cout << ", depth = " << node[i].depth;
        cout << ", height = " << node[i].height;
        cout << ", " << node[i].pos << endl;
    }
}



Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<ll>t(n),a(n);
	rep(i,n)cin>>t[i]>>a[i];
	ll x=1,y=1;
	rep(i,n){
		ll maxv=max(x/t[i]+(x%t[i]!=0),(y/a[i])+(y%a[i]!=0));
		t[i]*=maxv;
		a[i]*=maxv;
		x=t[i];y=a[i];
	}
	cout<<x+y<<endl;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXN = 1010;
const int MOD = 1001;

int F[MAXN];

void init() {
    F[0] = 1;
    F[1] = 2;
    for (int i = 2; i < MAXN; i++) {
        F[i] = (F[i-1] + F[i-2]) % MOD;
        if (F[i] < 0) F[i] += MOD;
    }
}

int par[MAXN];
void union_init() {
    for (int i = 0; i < MAXN; i++) par[i] = i;
}

int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    par[x] = y;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main(void) {
    init();
    int V, d;
    while (cin >> V >> d) {
        union_init();
        for (int i = 1; i <= V; i++) {
            for (int j = i+1; j <= V; j++) {
                if (abs(F[i] - F[j]) < d) {
                    unite(i, j);
                }
            }
        }
        int ans = 0;
        for (int i = 1; i <= V; i++) {
            if (par[i] == i) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
N=int(input())
alise=0
bob=0
a_list=list(map(int,input().split()))
a_sort=sorted(a_list)[::-1]
a_sort.append(0)
for i in range(N//2+N%2):
    alise+=a_sort.pop(0)
    bob+=a_sort.pop(0)
print(alise-bob)

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

vector<int> dp;

int q(int x) {
	if (dp[x]) return dp[x];
	cout << x << endl;
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	if (s == "Male") return dp[x] = -1;
	return dp[x] = 1;
}

bool f(int s, int t) {
	int o = (s - t) & 1;
	if (o) return q(s) == q(t);
	return q(s) != q(t);
}

int main() {
	int N;cin >> N;
	dp.resize(N);
	int s = 0, t = N / 2;
	if (!f(s, t)) swap(s, t);
	for (;;) {
		int m = s > t ? (s+t+N)/2 : (s+t)/2;
		if (m > N) m -= N;
		if (f(s, m)) t = m;
		else s = m;
	}
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;
const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmax(const T &a, T b){if(a < b){a=b; return true;} return false;}
template<typename T> bool chmin(const T &a, T b){if(a > b){a=b; return true;} return false;}

int main(){
    int N; cin >> N;
    vector<ll> L(N);
    for(auto &x : L) cin >> x;
    ll ans=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            for(int k=j+1; k<N; k++){
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
                ll len=max(L[i], max(L[j], L[k]));
                ll total=L[i]+L[j]+L[k];
                if(len < total-len) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

ll maxVec(vector<ll> &v) {
	ll ans = -INF;
	rep(i, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}


int main() {
	ll n;
	cin >> n;
	vector<double> p(n, 0);
	vector<vector<double>> dp(n + 1, vector<double>(n + 1,0));
	rep(i, n) {
		cin >> p[i];
	}

	dp[0][0] = 1;
	/*
	rep(i, n + 1) {
		if (i == 0)continue;
		rep(j, n + 1) {
			dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
			if (j - 1 >= 0)dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
		}
	}
	*/
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}

	/*
	rep(i, n + 1) {
		rep(j, n + 1) {
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}
	*/

	double ans = 0;
	for (ll i = (n + 1) / 2; i < n + 1; i++) {
		ans += dp[n][i];
	}
	printf("%.10g", ans);
}

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

int main() {
    map<int, int> route;
    int N, T;
    cin >> N >> T;

    int c, t;
    for (int i=0; i<N; i++) {
        cin >> c >> t;
        route[c] = t;
    }
    for (auto i=route.begin(); i!=route.end(); i++) {
        if (i->second <= T) {
            cout << i->first << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if(a==f&&b==e&&c==d){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	long long int a, b, c, k;

	cin >> a >> b >> c >> k;

	if (k % 2 == 1) {
		if (abs(a - b) >= 1000000000000000000) {
			cout << "Unfair" << endl;
		}
		else {
			cout << -(a - b) << endl;
		}
	}
	else {
		if (abs(a - b) >= 1000000000000000000) {
			cout << "Unfair" << endl;
		}
		else {
			cout << (a - b) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);



	int N, M, a[200001], b[200001];
	string S;
	vector<int> henn[200001];
	cin >> N >> M >> S;
	rep1(i, M) {
		cin >> a[i] >> b[i];
		henn[a[i]].push_back(b[i]);
		henn[b[i]].push_back(a[i]);
	}


	int bosshuu[200001] = {};
	//int ikeruB[200000] = {};

	int hetta = 1;
	int checkzumi[200001] = {};
	vector<int> youcheck;
	rep1(i, N) youcheck.push_back(i);

	while (hetta) {
		hetta = 0;
		vector<int> youcheck2;

		for(int i: youcheck) {
			if (bosshuu[i] == 0) {
				int ikeruA = 0;
				int ikeruB = 0;
				for (int ii = 0; ii < henn[i].size(); ii++) {
					if (bosshuu[henn[i][ii]] == 0) {
						if (S[henn[i][ii] - 1] == 'A') ikeruA = 1;
						else ikeruB = 1;
					}
					else {
						henn[i].erase(henn[i].begin() + ii);
						ii--;
					}
				}
				if (ikeruA == 0 || ikeruB == 0) {
					bosshuu[i] = 1;
					hetta++;
					rep(ii, henn[i].size()) youcheck2.push_back(henn[i][ii]);
				}
			}
		}
		youcheck.erase(youcheck.begin(), youcheck.end());
		for (int i: youcheck2) youcheck.push_back(i);
	}

	int kotae = 0;
	rep1(i, N) if (bosshuu[i] == 0) kotae = 1;

	if (kotae == 1) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	Would you please return 0;
}

Measured memory_bytes: 14920
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,s;
	cin>>a>>b>>c;
	s=max(a,max(b,c))*10+a+b+c-max(a,max(b,c));
	cout<<s<<endl;
	return 0;
} 

Measured memory_bytes: 256
open Printf
open Scanf

let id x = x
let pair x y = x, y

let n, t = scanf "%d %d" pair

let vs = Array.init n (fun _ -> scanf " %d %d" pair)

let f c' t' = if t' <= t then c' else 2000

let () =
  Array.sort (fun (ac, at) (bc, bt) -> f ac at - f bc bt) vs;
  let (a, b) = vs.(0) in
  if b <= t then printf "%d\n" a else printf "TLE\n"


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int S;
	cin >> S;
	int h, m, s;
	s = S % 60;
	S /= 60;
	m = S % 60;
	S /= 60;
	h = S % 60;
	S /= 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 3252
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
void solve()
{
    int a[6];
    rep1(i,5){
        cin>>a[i];
    }
    rep1(i,5){
        if(!a[i]){
            cout<<i;
            return;
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
char s[4];
  char t[4];
  int a=0;
  scanf("%s",&s);
  scanf("%s",&t);
  if(s[0]==t[0]){a++;}
    if(s[1]==t[1]){a++;}
    if(s[2]==t[2]){a++;}
  printf("%d",a);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    vector<long> b(n);
    vector<long> c(n);
    
    long long takahashi=0;
    long long aoki=0;
    
    for(long i=0 ; i<n ; i++){
        cin >> a[i] >> b[i];
        c[i] = a[i]+b[i];
    }
    
    vector<int> index(c.size());
    iota(index.begin(), index.end(), 0);
    sort(index.begin(), index.end(), [&](int x, int y){return c[x] > c[y];});
    
    for(long i=0 ; i<n ; i++){
        if(i%2==0){
            takahashi += a[index[i]];
        }else{
            aoki += b[index[i]];
        }
    }
    cout << takahashi-aoki;
}


Measured memory_bytes: 2944
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

ll dp[110][500][110];

int main() {
	int i, j, k, n, W; cin >> n >> W;
	vector <ll> w(n), v(n);
	for (i = 0; i < n; i++)cin >> w[i] >> v[i];
	int w1 = w[0];

	for (i = 0; i < n; i++)w[i] -= w1;

	for (i = 0; i < 110; i++) {
		for (j = 0; j < 500; j++) {
			for (k = 0; k < 110; k++) {
				dp[i][j][k] = -1;
			}
		}
	}
	dp[0][0][0] = 0;

	for (i = 0; i < n; i++) {
		for (j = 0; j < 500; j++) {
			for (k = 0; k <= i; k++) {
				if (dp[i][j][k] < 0)continue;
				dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
				if ((ll)(j + w[i] + w1*(k+1) <= W)) {
					dp[i + 1][j + w[i]][k+1] = max(dp[i + 1][j + w[i]][k+1], dp[i][j][k] + v[i]);
				}
			}
		}
	}
	
	ll ans = 0;
	for (i = 0; i < 500; i++) {
		for (j = 0; j <= n; j++) {
			if (dp[n][i][j] < 0)continue;
			if (i + w1 * j <= W)ans = max(ans, dp[n][i][j]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 47488
def main():
    n, m = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]

    sa = sum(A)
    cnt = 0
    x = sa // (4 * m) - 1 if sa % (4 * m) == 0 else sa // (4 * m)
    for a in A:
        if a > x:
            cnt += 1

    print('Yes' if cnt >= m else 'No')

if __name__ == "__main__":
    main()


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

int main()
{
	int a, b;
	while(cin >> a >> b)
	{
		int sum = a + b;
		int ans = 0;
		while(sum)
		{
			ans++;
			sum /= 10;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

vvl arr(51, vl(51, -1));

ll comb(ll n, ll r){
  if((n == r) || (r == 0)) return 1;
  if(arr[n][r] != -1) return arr[n][r];

  ll ans = comb(n - 1, r) + comb(n -1 , r - 1);
  arr[n][r] = ans;

  return ans;
}

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  vl v(N);
  map<ll, ll> cnt;
  rep(i, N){
    cin >> v[i];
    cnt[v[i]]++;
  }

  stable_sort(v.begin(), v.end(), greater<ll>());

  ll sum = 0;
  rep(i, A) sum += v[i];

  ld max_ave = (ld)sum / (ld)A;
  cout << fixed << setprecision(10) << max_ave << endl;

  ll ans = 0;

  rep2(i, A, B + 1){
    if(sum * i % A != 0) continue;

    ll s2 = sum * i / A;
    rep(j, i) s2 -= v[j];
    if(s2 > 0) continue;

    ll n = cnt[v[i - 1]];
    ll r = 0;
    while((v[i - r -1] == v[i - 1]) && (r <= i - 1)) r++;

    ll pat = comb(n, r);
    ans += pat;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

using T = ll;
const int MAX_V = 2e5;
//演算の内容
T f(T a, T b){return min(a,b);}
//何で初期化するか
T other = INF;

struct segment_tree{
    int n;
    T seg[2*MAX_V];
    //要素数N(0〜N-1)の初期化されたセグメント木を構築
    segment_tree(int N){
        n = 1;
        while(n < N) n *= 2;
        fill_n(seg, 2*n-1, other);
    }
    //i番目の要素をxに変更(0番目から数える)
    void update(int i, T x){
        i += n-1;
        seg[i] = x;
        while(i > 0){
            i = (i-1)/2;
            seg[i] = f(seg[2*i+1], seg[2*i+2]);
        }
    }
    //query(a, b)で[a, b)における演算の結果を取得
    T query(int a, int b, int i = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return other;
        elif(a <= l && r <= b) return seg[i];
        else{
            T vl = query(a, b, 2*i+1, l, (l+r)/2);
            T vr = query(a, b, 2*i+2, (l+r)/2, r);
            return f(vl, vr);
        }
    }
};

struct edge{
    int from;
    ll cost;
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<edge> es[N];
    segment_tree seg(N);
    seg.update(0, 0);
    rep(i, M){
        int L, R;
        ll C;
        cin >> L >> R >> C;
        L--, R--;
        edge e = {L, C};
        es[R].pb(e);
    }
    rep(i, N){
        if(es[i].empty()) continue;
        ll tmp = INF;
        for(auto &e: es[i]){
            ll m = seg.query(e.from, i);
            tmp = min(tmp, m+e.cost);
        }
        seg.update(i, tmp);
    }
    ll res = seg.query(N-1, N);
    if(res == INF) cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 8704
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

const ll mod=1e9+7;

int main(){
    char c;
    cin >> c;
    if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 3584
fn func(input_str: &str) -> u32 {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = (n as f64).log10() as usize + 1;
    let mut cand = vec![vec![String::new()]; 10];
    let c_s = ["3", "5", "7"];
    let mut ans = 0;
    for i in 1..m+1 {
        let mut buf = Vec::new();
        for s in cand[i - 1].iter() {
            for &c in &c_s[..] {
                let ns = s.clone() + c;
                let x: usize = ns.parse().unwrap();
                if c_s.iter().all(|c| ns.contains(c)) 
                    && x <= n {
                    ans += 1;
                }
                buf.push(ns);
            }
        }
        cand[i] = buf;
    }
    ans
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	long long cost=p*a;
	int alt=p-c;
	if(alt<=0)cost=min((int)cost,b);
	else{
		cost=min((int)cost,b+alt*d);
	}
	cout<<cost<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
  
int main(){
  double a, b, c, d, e, f;
  while( cin >> a >> b >> c >> d >> e >> f){
    double y = ( a * f - c * d) / ( a * e - b * d);
    double x = ( c - b * y ) / a;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
  return 0;
}


Measured memory_bytes: 3288
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	double d,w,h;
	int n,r;
	double dt;
	while(1){
		scanf("%lf %lf %lf",&d,&w,&h);
		if(d==0&&w==0&&h==0) break;
		dt=min(sqrt(d*d+w*w),min(sqrt(w*w+h*h),sqrt(h*h+d*d)));
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d",&r);
			r*=2;
			if(r>dt) printf("OK\n");
			else printf("NA\n");
		}
	}
}


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

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

    if(fopen("input_muntu.in", "r")) {
        freopen("input_muntu.in", "r", stdin);
        freopen("output_muntu.out", "w", stdout);
    }
    
    int x, y; cin >> x >> y;
    int price[] = {(int)3e5, (int)2e5, (int)1e5}, sum = 0;

    if(x < 4) sum = sum + price[x - 1];
    if(y < 4) sum = sum + price[y - 1];
    if(x == 1 && y == 1) sum = sum + (int)4e5;
    cout << sum << endl;
    
    return 0;
}

// compile and run : g++ wtf.cpp -o wtf -std=c++11 && wtf

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
#include <stack>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//const int MOD = 1e9 + 7;

template <class T>
T GCD(T a, T b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

template <class T>
T LCM(T a, T b)
{
    return (a * b) / GCD(a, b);
}

template <class T>
T max_(std::vector<T> vec)
{
    std::sort(all(vec));
    return vec.at(vec.size() - 1);
}
template <class T>
T min_(std::vector<T> vec)
{
    std::sort(all(vec));
    return vec.at(0);
}

void ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

using namespace std;

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

int main(){
    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1) + m * (m - 1)) /2 << endl;
}

Measured memory_bytes: 256