akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;


int main()
{
  ll K;
  cin >> K;
  if (K < 2)
  {
    cout << 2 << endl;
    cout << K + 1 << ' ' << 0 << endl;
  }
  else if (K >= 50)
  {
    cout << 50 << endl;
    ll div = K / 50;
    ll remain = K % 50;
    vector<ll> ans(50, 0);
    for (ll i = 0; i < 50; ++i)
    {
      ans.at(i) = i + div;
    }
    for (ll i = 0; i < 50; ++i)
    {
      if (i < remain)
      {
        ans.at(i) += 50 - remain + 1;
      }
      else
      {
        ans.at(i) -= remain;
      }
    }
    for (ll i = 0; i < 50; ++i)
    {
      cout << ans.at(i) << ' ';
    }
    cout << endl;
  }
  else
  {
    cout << K << endl;
    for (ll i = 0; i < K; ++i)
    {
      cout << i + 1 << ' ';
    }
    cout << endl;
  }
}
// 100000000010000000


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <algorithm>
#include <complex>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <istream>
//-----------------------------------------------------define--------------------------------------------------------------------//
#define PB push_buck
#define MP make_pair
#define MAX 100000
//-------------------------------------------------------typedef----------------------------------------------------------------//
typedef long long ll;

using namespace std;

int n,k;
int v, w;
//------------------------------------------------------------------------------------------------------------------------------//
int main() {
	cin >> n >> k;
	v = k;
	for (int i = 1; i < n; i++) {
		v *= (k - 1);
	}
	cout << v << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);
int main() {  // TODO
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll s = 0;

  ll ans = 0;
  rep1(N) {
    ll a;
    cin >> a;
    ll aa = a % MOD;
    ans = (ans % MOD) + ((aa % MOD) * s);
    s = (s % MOD) + (a % MOD);
  }

  cout << ans % MOD << endl;

  return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

ll dp[51][51][51*51];

int main(){
    ll N, A; cin >> N >> A;
    vector<ll> x(N+1);
    for(int i=1; i<=N; i++) cin >> x[i];

    dp[1][0][0] = 1;
    dp[1][1][x[1]] = 1;

    // 配るdpを書きます
    for(int i=1; i<N; i++){
        for(int j=0; j<=i; j++){
            for(int k=0; k<=2500; k++){
                if(dp[i][j][k] == 0) continue;

                // x_(i+1)は選ばない
                dp[i+1][j][k] += dp[i][j][k];

                // x_(i+1)を選ぶ
                dp[i+1][j+1][k+x[i+1]] += dp[i][j][k];

            }
        }
    }

    ll ans = 0;
    for(int j=1; j<=N; j++) ans += dp[N][j][j*A];
    cout << ans << endl;

}

Measured memory_bytes: 50048
#include <iostream>
#include <vector>

using namespace std;

typedef struct {
	int num;
	int index;
} NwI;

void msort(vector<NwI> &vec, int left, int right);
void merge(vector<NwI> &vec, int left, int mid, int right);
void printVec(vector<NwI> &vec);


int main() {
	int N;
	vector<NwI> input;
	vector<int> medians;

	cin >> N;
	medians.resize(N);
	input.resize(N);

	for (int i = 0; i < N; i++) {
		cin >> input[i].num;
		input[i].index = i;
	}

	msort(input, 0, N - 1);

	for (int i = 0; i < N; i++) {
		if (i < N / 2) {
			medians[input[i].index] = input[N / 2].num;
		} else {
			medians[input[i].index] = input[N / 2 - 1].num;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << medians[i] << endl;
	}

	return 0;
}

void msort(vector<NwI> &vec, int left, int right) {
	if (left < right) {
		int m = (left + right) / 2;

		if (m >= left) msort(vec, left, m);
		if (m+1 <= right) msort(vec, m+1, right);

		merge(vec, left, m, right);
	}
}

void merge(vector<NwI> &vec, int left, int mid, int right) {
	vector<NwI> v;
	int i, j;

	i = left;
	j = mid + 1;

	while (i <= mid and j <= right) {
		if (vec[i].num < vec[j].num) {
			v.push_back(vec[i]);
			i++;
		} else {
			v.push_back(vec[j]);
			j++;
		}
	}

	if (i <= mid) {
		while (i <= mid) {
			v.push_back(vec[i]);
			i++;
		}
	}

	if (j <= right) {
		while(j <= right) {
			v.push_back(vec[j]);
			j++;
		}
	}

	for (int c = 0; c <= (right - left); c++) {
		vec[left + c] = v[c];
	}
}

void printVec(vector<NwI> &vec) {
	for (auto itr = vec.begin(); itr != vec.end(); itr++) {
		cout << (*itr).num << " " << flush;
	}
	cout << endl;
}


Measured memory_bytes: 5656
n = int(input())
a = [int(x) for x in input().split()]

noon = 0
noz = 0
ms = 10**9
s = 0
for x in a:
    if x < 0:
        noon += 1
    elif x == 0:
        noz += 1
    ms = min(ms, abs(x))
    s += abs(x)

if noz == 0:
    if noon % 2 != 0:
        ans = s - 2 * ms
    else:
        ans = s
else:
    ans = s

print(ans)





Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    if(t.substr(0, n) == s) {
        print("Yes");
    } else {
        print("No");
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000
int n,s[2005],m[2005],ans=INF,dp[2005];
vector<int>g[2005];
bool q[2005];
void dfs(int v,int p){
	if(q[v])s[v]=1;
	else s[v]=0;
	dp[v]=0;
	m[v]=0;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(u==p)continue;
		dfs(u,v);
		s[v]+=s[u];
		m[v]+=min(dp[v]-m[v]*2,dp[u]+s[u]-m[u]*2);
		dp[v]+=s[u]+dp[u];
		m[v]+=m[u];
	}
}
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
		char c;
		scanf(" %c",&c);
		if(c=='1')q[i]=true;
	}
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		g[--a].PB(--b);
		g[b].PB(a);
	}
	for(int i=0;i<n;i++){
		dfs(i,-1);
		int w=0;
		for(int j=0;j<g[i].size();j++){
			int u=g[i][j];
			w+=dp[u]+s[u];
		}
		if(w%2!=0)continue;
		bool ok=true;
		for(int j=0;j<g[i].size();j++){
			int u=g[i][j];
			if(dp[u]+s[u]>w/2&&dp[u]+s[u]-w/2>m[u])ok=false;
		}
		if(ok)ans=min(ans,w/2);
	}
	if(ans==INF)ans=-1;
	printf("%d\n",ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int array_sum_from_i(vector<int> &data, int i) {
  // ベースケース
  if (i == data.size()) {
    return 0;  // 対象の要素がないので総和は0
  }
  // 再帰ステップ
  int s = array_sum_from_i(data, i + 1);  // i+1番目以降の要素の総和
  return data.at(i) + s;  // 「i番目以降の要素の総和」=「i番目の要素」+ s
}
 
// dataの全ての要素の総和を計算する
int array_sum(vector<int> &data) {
  return array_sum_from_i(data, 0);
}
int main() {
  int n,m;
    cin>>n>>m;
  vector <int>a(n);
  for (int i = 0; i < n; i++) {
    cin>>a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  if (array_sum(a)%(4*m)==0){
  if (a.at(m-1)< array_sum(a)/(4*m)){
    cout<<"No"<<endl;
  }
    else {
      cout<<"Yes"<<endl;
    }
  }
      else {
  if (a.at(m-1)< 1+array_sum(a)/(4*m)){
    cout<<"No"<<endl;
  }
    else {
      cout<<"Yes"<<endl;
    }
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b)
    {
        return b;
    }
    return a; 
}

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

int main() {
    ll n; scanf("%lld", &n);
    vector<ll> l(n);
    rep(i, n) {
        scanf("%lld", &l[i]);
    }

    sort(l.begin(), l.end());
    ll ans = 0;
    for (ll a = 0; a < n-2; a++)
    {
        /* code */
        for (ll b = a+1; b < n-1; b++)
        {
            /* code */
            // c の動ける範囲の右端を求める
            ll k = lower_bound(l.begin(), l.end(), l[a] + l[b]) - l.begin();

            // k から [j+1, k)
            ans += max(k- (b+1), (ll)0);
            // cout << ans << " " << k << endl;
        }
    }
    // cout << count << endl;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);

    ll ans = 0;
    int i, j;
    for (i = 1; i <= n; i++) {
        int m = n / i;
        ans += (ll)i * m*(m + 1) / 2;
    }
    printf("%lld\n", ans);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

void solveA(){
  string s;
  cin >> s;

  int m=10*(s[5]-48) + s[6] -48;
  int d=10*(s[8]-48) + s[9] -48;

  if(m<=4 && d<=30){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }
}
void solveB(){
  int n;
  cin >> n;
  double ans = 0.0;

  double x;
  string u;
  for(int i=0;i<n;i++){
    cin >> x >> u;
    if(u=="JPY"){
      ans += x;
    }
    else{
      ans += x*380000;
    }
  }
  cout << ans << endl;

}
void solveC(){

  
}

void solveD(){
}

int main(){
  solveB();
}


Measured memory_bytes: 256
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	char name[101];
	int length,value;
};

struct Data{
	Data(int arg_left,int arg_sum_value){
		left = arg_left;
		sum_value = arg_sum_value;
	}
	bool operator<(const struct Data &arg) const{
		return left > arg.left;
	}

	int left,sum_value;
};

int N;
Info info[100];
char line[201];
int case_number = 1,line_length;


void func(){

	int tmp_length;
	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].name,&info[i].value);
		for(tmp_length = 0; info[i].name[tmp_length] != '\0'; tmp_length++);
		info[i].length = tmp_length;
	}

	scanf("%s",line);
	for(tmp_length = 0; line[tmp_length] != '\0'; tmp_length++);
	line_length = tmp_length;


	int max_value[line_length+1];
	for(int i = 0; i <= line_length; i++)max_value[i] = 0;

	priority_queue<Data> Q;
	Q.push(Data(0,0));

	bool FLG;

	while(!Q.empty()){

		if(Q.top().left == line_length){
			Q.pop();
		}else if(Q.top().sum_value < max_value[Q.top().left]){
			Q.pop();
		}else{

			for(int i = 0; i < N; i++){
				if(Q.top().left+info[i].length-1 >= line_length)continue;

				FLG = true;
				for(int k = 0; k < info[i].length; k++){
					if(line[Q.top().left+k] != info[i].name[k]){
						FLG = false;
						break;
					}
				}


				if(FLG){
					if(max_value[Q.top().left+info[i].length] < Q.top().sum_value+info[i].value){
						max_value[Q.top().left+info[i].length] = Q.top().sum_value+info[i].value;
						Q.push(Data(Q.top().left+info[i].length,max_value[Q.top().left+info[i].length]));
					}
				}
			}

			Q.pop();
		}
	}

	int digit = max_value[line_length];

	int dp[digit+1];

	for(int i = 1; i <= digit; i++){
		dp[i] = BIG_NUM;
	}

	dp[0] = 0;

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

		FLG = true;
		for(int k = 0; k < N; k++){
			if(k == i)continue;

			if(info[k].value == info[i].value && info[k].length < info[i].length){
				FLG = false;
				break;
			}
		}

		if(!FLG)continue;

		for(int k = info[i].value; k <= digit; k++){
			if(dp[k-info[i].value] != BIG_NUM){
				dp[k] = min(dp[k],dp[k-info[i].value]+info[i].length);
			}
		}
	}

	printf("Case %d: %d\n",case_number,dp[digit]);

	case_number++;
}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3280
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    auto gcd = [&](long long a, long long b) {
        while (a != 0) {
            b %= a;
            swap(a, b);
        }
        return b;
    };
    int g = 0;
    for (auto x : A) {
        g = gcd(g, x);
    }
    cout << g << '\n';
    
    return 0;
}

Measured memory_bytes: 640
from collections import deque

def main():
 n,q=map(int,input().split())

 tree=[[] for i in range(n)]
 for i in range(n-1):
  i,j=map(int,input().split())
  tree[i-1].append(j-1)
  tree[j-1].append(i-1)

 cnt=[0 for i in range(n)]
 for i in range(q):
  p,x=map(int,input().split())
  cnt[p-1]+=x

 seen=set([0])

 dq=deque()
 dq.append(0)

 while dq:
  x=dq.popleft()
  for i in tree[x]:
#  if cnt[i]==-1:
   if i not in seen:
    seen.add(i)
    dq.append(i)
    cnt[i]+=cnt[x]

 print(*cnt)

if __name__ == "__main__":
  main()

Measured memory_bytes: 62804
from itertools import combinations

N,K=list(map(int,input().split()))

node=(N-1)*(N-2)//2

if K>node:
    print(-1)
    exit(0)

g=[[] for _ in range(N+1)]
M=0

for i in range(2,N+1):
    g[1].append(i)
    M+=1

cnt=node-K

for u,v in combinations(range(2,N+1),2):
    if cnt==0:
        break
    g[u].append(v)
    
    M+=1
    cnt-=1


print(M)
for i in range(1,N+1):
    for j in g[i]:
        print('{} {}'.format(i,j))

Measured memory_bytes: 74484
H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7

factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)

tmp = 1
for i in range(H + W):
    tmp = tmp * (i + 1) % MOD
    factorials[i+1] = tmp

inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials))

def modcomb(m, n, mod):
    return factorials[m] * inv_factorials[n] % MOD * inv_factorials[m - n] % MOD
 
# total = modcomb(H + W - 2, W - 1, MOD)
total = 0
 
# for i in range(B):
for i in range(B, W):
    total += modcomb(H - A - 1 + i, i, MOD) * modcomb(A - 1 + W - 1 - i, W - 1 - i, MOD) % MOD
    total %= MOD
 
print(total)

Measured memory_bytes: 88692
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const int N = 1e5+9, M = 3e6+9, OO = 0x3f3f3f3f,MOD = 1e9 + 7;
int n;
vector<int>adj[N];
LL memo[N][2];
LL solve(int v,int c,int p)
{

  LL &ret = memo[v][c];
  if(~ret) return ret;
  ret = 1;

  for(auto ch : adj[v])
  {
    if(ch!=p)
    {
      if(c==0) ret = (ret*(solve(ch,0,v)+solve(ch,1,v)))%MOD; 
      else     ret = (ret*(solve(ch,0,v)))%MOD;
    }
  }


  return ret%MOD;
}

int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%d",&n);
  for(int i=0;i<n-1;++i)
  {
    int u,v;
    scanf("%d%d",&u,&v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  printf("%lld\n",(solve(1,0,-1)+solve(1,1,-1))%MOD);
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 17152
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n,T,ans = 10000,tmp;
    cin >> n >> T;
    int c[n],t[n];
    for(int i = 0;i < n;i++){
        cin >> c[i] >> t[i];
    }
    for(int i = 0;i < n;i++){
        if(t[i] <= T){
            if(ans > c[i]){
                ans = c[i];
            }
        }
    }
    if(ans == 10000){
        cout <<"TLE"<<endl;
        return 0;
    }else{
        cout << ans<< endl;
        return 0;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

left = X - (K - 1)
right = X + (K - 1)

out_str = ''
for i in range(left, right+1):
    if i == right:
        out_str += str(i)
    else:
        out_str += str(i) + ' '
print(out_str)


Measured memory_bytes: 2940
if __name__ == '__main__':
	W = str(input())
	T = " "
	d = str(input())
	T += d + " "
	while d != "END_OF_TEXT":
		d = str(input())
		T += d+" "
	c = 0
	T = T.lower().replace("\"","").replace("\'","")
	while True:
		if T.find(" "+W+" ") == -1:
			break
		else:
			T=T.replace(" "+W+" "," ",1)	
			c += 1	
	print(c)


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s,t;
int S[105],T[105],TT[105];
int main(void){
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        S[i]=s[i];
    }
    for(int i=0;i<t.size();i++){
        T[i]=t[i];
    }
    sort(S,S+s.size()); sort(T,T+t.size());
    for(int i=0;i<t.size();i++){
        TT[i]=T[t.size()-i-1];
    }
    for(int i=0;i<s.size();i++){
        //cout<<S[i]<<" "<<TT[i]<<endl;
        if(S[i]>TT[i]){
            cout<<"No"<<endl;
            return 0;
        }else if(S[i]<TT[i]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(s.size()==t.size()){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    
}


Measured memory_bytes: 256
def matching(A, B, N, M) :
  if N == M : 
    for j in range(N) : 
      match = 0
      if A[j] != B[j] :
        break
      match += 1
    if match == M : 
      return True
    else :
      return False
  for i in range(N - M) : 
    for j in range(N - M) :
      match = 0
      for m in range(M) :
        if A[j + m][i : M + i] != B[m] :
          break
        match += 1
      if match == M : 
      	return True
  return False
      
          
N, M = tuple(map(int, input().split()))
A = list()
B = list()

for i in range(N) :
  A.append(input())
  
for i in range(M) :
  B.append(input())
  
if matching(A, B, N, M) :
  print('Yes')
else : 
  print('No')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		if (num % 2 == 0 && num % 3 != 0 && num % 5 != 0)
		{
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for(int i = 0; i < n; i++) {
        	l[i] = sc.nextInt();
        }

        Arrays.sort(l);


        long c = 0;
        for(int i = 0; i < n-2; i++) {
        	for(int j = i+1; j < n-1; j++) {
        		int cMax = l[i] + l[j];
        		int cMin = Math.abs(l[i] - l[j]);

        		for(int k = j+1; k < n; k++) {
        			while(k < n && cMin >= l[k]) {
        				k++;
        			}

        			while(k < n && l[k] < cMax) {
        				c++;
        				k++;
        			}
        			break;
        		}
        	}
        }


        System.out.println(c);

    }


}

Measured memory_bytes: 27108
Sa = input()
Sb = input()
Sc = input()
now = Sa[0]
Sa = Sa[1:]

for i in range(len(Sa)+len(Sb)+len(Sc)):
  if now == "a":
    if len(Sa) == 0:
      print("A")
      break
    else:
      now = Sa[0]
      Sa = Sa[1:]

  elif now == "b":
    if len(Sb) == 0:
      print("B")
      break
    else:
      now = Sb[0]
      Sb = Sb[1:]
  elif now == "c":
    if len(Sc) == 0:
      print("C")
      break
    else:
      now = Sc[0]
      Sc = Sc[1:]

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i = 0;i < n; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 26624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define int long long
bool chs(int n)
{
    int a = (int) sqrt((double) n);
    if(a * a == n || (a+1) * (a+1) == n) return true;
    else return false;
}
int32_t main()
{
    int n,d,a=0;
    cin>>n>>d;
    int mat[11][11];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
            cin>>mat[i][j];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int s=0;
            for(int k=0;k<d;k++)
            {
                s+=(mat[i][k]-mat[j][k])*(mat[i][k]-mat[j][k]);
            }
            if(chs(s)) a++;
        }
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007

bool check(int input, vector<int>& data )
{
  string str = to_string(input);
  

  for (size_t i = 0; i < str.size(); i++)
  {
    for (int j = 0; j < data.size(); j++)
    {
      if(str[i] == data[j] + '0')
      {
        return 0;
      }
    }
    
  }

  return 1;
  

}

void solve(void)
{

  int N,K;
  cin>>N>>K;
  vector<int> data(K,0);
  for (int i = 0; i < K; i++)
  {
    cin>>data[i];
  }
  int price = N;
  while(true)
  {
    if(check(price,data)) break;
    price++;
  }
  cout<<price;
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

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

int main(){
    int n;
    const int N = 1e6;

    vector<bool> is_prime(N,true);
    is_prime[0] = false;
    is_prime[1] = false;

    for(int i=2;i*i<N;i++){
        if(is_prime[i]){
            for(int j=i*2;j<N;j+=i){
                is_prime[j] = false;
            }
        }
    }

    vector<int> cnt_prime(N,0);
    for(int i=1;i<N;i++){
        if(is_prime[i]) cnt_prime[i]++;
        cnt_prime[i] += cnt_prime[i-1];
    }

    while(cin >> n){
        cout << cnt_prime[n] << endl;
    }

}


Measured memory_bytes: 6532
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back


void input(){
    int n;
    cin >> n;
    int ans = 0;
    while(n >= 1){
        int k = n;
        int cnt = 0;
        do{
           k/= 10;
           ++cnt;
        }while(k > 0);
        if(cnt & 1)++ans;
        --n;
    }
    cout << ans << endl;
}
int main()
{
 input();
 return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int a[200];
  
  for (int i = 0; i < n; i++) cin >> a[i];
  
  int count = 0;
  
  while (true) {
    bool odd_exist = false;
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 != 0) odd_exist = true;
    }
    
    if (odd_exist) break;
    
    for (int i = 0; i < n; i++) {
        a[i] /= 2;
    }
    count++;
  }
  cout << count << endl;
}  
      


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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r * R <= N; r++) {
    for (int g = 0; r * R + g * G <= N; g++) {
      int tmp = N - r * R - g * G;
      if (tmp % B == 0) ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3528
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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 int INF = 1<<30;
const int mod = 1000000007;

int main(){
	int n, a;
	cin >> a >> n;
	cout << (a*3+n)/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	int num[10] = {512,256,128,64,32,16,8,4,2,1};
	int N;

	while (cin >> N) {
		vector<int> ans;
		rep(i,10) {
			if (N >= num[i]) {
				ans.push_back(num[i]);
				N = N - num[i];
			}
		}
		reverse(all(ans));
		rep(i,ans.size()) {
			if (i == ans.size()-1) {
				cout << ans[i];
			}
			else {
				cout << ans[i] << " ";
			}
		}
		cout << endl;
	}

	return 0;
}

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

#define endl '\n'
#define int long long

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n; cin >> n;
	vector<int> a(n), b(n), cnt(n + 1, 0);
	for(int i = 0; i < n; i ++) {
		cin >> a[i];
		cnt[a[i]] ++;
	}
	for(int i = 0; i < n; i ++) {
		cin >> b[i];
		cnt[b[i]] ++;
	}
	int m = *max_element(cnt.begin(), cnt.end());
	if(m > n) {
		cout << "No" << endl;
	}
	else {
		reverse(b.begin(), b.end());
		int l = 0, r = n - 1;
		for(int i = 0; i < n; i ++) {
			if(a[i] == b[i]) {
				if(a[i] != b[l] and a[l] != b[i]) {
					swap(b[l], b[i]);
					l ++;
				}
				else {
					swap(b[r], b[i]);
					r --;
				}
			}
		}
		cout << "Yes" << endl;
		for(int i : b) cout << i << " ";
	}

	return 0;
}

Measured memory_bytes: 7948
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N, Ma, Mb, ans=INF;
	int a[50], b[50], c[50];

	cin >> N >> Ma >> Mb;
	rep(i,N){
		cin >> a[i] >> b[i] >> c[i];
	}

	int dp[2][505][505];
	Fill( dp, (int)INF );
	dp[0][0][0] = 0;
	rep(i,N){
		//cout << "i = " << i << endl;
		//rep(y,4) rep(x,4){
		//	if( x == 0 ) cout << endl;
		//	cout << dp[N%2][x][y] << " ";
		//} cout << endl;
		rep(x,405) rep(y,405){
			chmin( dp[(i+1)%2][x+a[i]][y+b[i]], dp[i%2][x][y] + c[i]);
			chmin( dp[(i+1)%2][x][y], dp[i%2][x][y] );
		}
	}

	rep(y,405) rep(x,405){
		if( x == 0 || y == 0 ) continue;
		int g = __gcd(x,y);
		if( x/g == Ma && y/g == Mb ){
			chmin( ans, dp[N%2][x][y] );
		}
	}

	if(ans == INF) ans = -1;
	cout << ans << endl;

	return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  map<int, int> num;
  for (int i = 0; i < n; i++) {
    int key;
    cin >> key;
    num[key] += 1;
    if (num[key] == 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

const int MAX_V = 210;
struct edge{
	int to, cap, rev;
	edge(int to,int cap, int rev):to(to),cap(cap),rev(rev){}
};
vector<vector<edge> > G(MAX_V); //グラフの隣接リスト表現
bool used[MAX_V]; //DFSで既に調べたかどうかのフラグ

void add_edge(int from, int to, int cap){
		G[from].push_back(edge(to,cap,G[to].size()));
		G[to].push_back(edge(from,0,G[from].size() - 1));
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if( !used[e.to] && e.cap > 0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d > 0){
				e.cap -=d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int maxflow(int s, int t){
	int flow = 0;
	for(;;){
		fill(used,used + MAX_V,false);
		int f = dfs(s,t,INF);
		if(f == 0)return flow;
		flow += f;
	}
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int s = 2*N, t = s + 1;
  pair<int, int> r[102], b[102];
  REP(i,N){
    cin >> r[i].first >> r[i].second;
  }
  REP(i,N){
    cin >> b[i].first >> b[i].second;
  }
  REP(i,N){
    REP(j,N){
      if(r[i].first < b[j].first && r[i].second < b[j].second){
        add_edge(i, j + N, 1);
      }
    }
  }
  REP(i,N){
    add_edge(s, i, 1);
  }
  REP(i,N){
    add_edge(N + i, t, 1);
  }
  cout << maxflow(s, t) << endl;
  return 0;
}


Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_N 100000

ll dp[MAX_N + 1][3] = {};//最大値を求める→0で初期化

int main(){
	int n;
	cin >> n;
	int a[n][3];
	REP(i,n) REP(j,3) cin >> a[i][j];
	REP(i,n){
		REP(j,3){
			REP(k,3){
				if(j == k) continue;
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j]);
			}
		}
	}
	ll ans = 0;
	REP(i,3) ans = max(ans, dp[n][i]);
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int m;
  cin >> m;
  cout << 48 - m << endl;

  



  return 0;
}


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


int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  rep(i, N) cin >> a[i];
  int cnt = 0;
  sort(a, a + N);
  rep(i, N){
    x -= a[i];
    cnt++;
    if (x < 0){
      cnt--;
      break;
    }
  }
  if (x > 0) cnt--;
    
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


const int max_comb=250000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}


ll func(int n, int m, int K)
{
    ll ans = 0;

    int k;
    for(k=1; k<=n-1; k++) {
        ll ans0 = (ll)k*(n-k)*m %MOD *m %MOD *comb(n*m-2,K-2) %MOD;
        ans = (ans + ans0)%MOD;
    }

    return ans;
}

int main(int argc, char* argv[])
{
    int n,m,K;
    scanf("%d%d%d", &n, &m, &K);

    pre_comb();
    
    ll ans0 = func(n, m, K);
    ll ans1 = func(m, n, K);

    printf("%lld\n", (ans0+ans1)%MOD);

    return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define fi first
#define se second

int32_t main()
{
	int n;
	cin >> n;
	map<string, int> mapa;
	for(int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		mapa[s]++;
	}
	int mx = 0;
	for(auto it : mapa)
		mx = max(it.second, mx);
		
	vector<string> ans;
	
	for(auto it : mapa)
		if(mx == it.second)
			ans.push_back(it.first);
		
	sort(ans.begin(), ans.end(), [](string a, string b)
	{
		for(int i = 0; i < min(a.size(), b.size()); i++)
			if(a[i] < b[i])
				return true;
			else if(a[i] > b[i])
				return false;
		return a.size() < b.size();
	});
	
	for(auto it : ans) cout << it << '\n';
	
	
	
	return 0;
}

Measured memory_bytes: 26992
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

namespace mp = boost::multiprecision;


auto modC2(ll n, ll r){
    mp::cpp_int ret = 1;
    // long double ret = 1;
    for(int i=n-r+1;i<=n;i++){
        ret *= i;
    }
    for(int i=1;i<=r;i++){
        ret /= i;
    }
    return ret;
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> vs(n);
    for(int i=0;i<n;i++){
        cin >> vs[i];
    }
    sort(vs.rbegin(), vs.rend());
    ll sum = 0, last = -1, lastcnt = 0, lastcnt2 = 0;
    for(int i=0;i<a;i++){
        sum += vs[i];
        if(last == vs[i]){
            lastcnt++;
        }else{
            lastcnt = 1;
        }
        last = vs[i];
    }
    lastcnt2 = lastcnt;
    for(int i=a;i<b&&vs[i]==vs[0];i++){
        lastcnt2++;
    }
    int cnt = 0;
    for(int i=0;i<n;i++){
        cnt += vs[i] == last;
    }
    double avg = 1.0 * sum / a;
    cout << fixed << setprecision(10) << avg << '\n';
    // cout << cnt << '\n';
    mp::cpp_int ans = 0;
    for(int i=lastcnt;i<=lastcnt2;i++){
        ans += modC2(cnt, i);
        // prints(cnt, i, modC2(cnt, i));
    }
    // cout << modC(cnt, lastcnt, M) << '\n';
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  string s;
  cin>>s;
  int cnt=0;
  for(i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i]) cnt++;
  }
  cout<<cnt<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int a,b,c=0;
  	cin>>a>>b;
  	for(int i=0;i<b;i++){
  		int j;
  		cin>>j;
  		c+=j;
	  }
  	if(c>a){
  		cout<<"-1";
  		return 0;
	  }
	  cout<<a-c;
  	return 0;
}

Measured memory_bytes: 3592
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

counter = Counter(A)
ans = sum(A)
for i in range(Q):
  b, c = map(int, input().split())
  count_b = counter[b]
  counter[b] -= count_b
  counter[c] += count_b
  ans = ans - b*count_b + c*count_b
  print(ans)

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

long long A[100005];

int main(){
    long long M;
    scanf("%lld", &M);

    long long sum = 0;
    for(int i = 0; i < M; i ++){
        scanf("%lld", &A[i]);
        sum += A[i];
    }

    if( sum%(M*(M+1)/2) != 0){
        printf("NO");
        return 0;
    }

    long long N = sum / (M*(M+1)/2);

    bool legit = true;
    for(int i = 0; i < M; i ++){
        long long temp = (A[(i+1)%M] - A[i] - N);
        temp = -temp;
        if(temp % M != 0 || temp < 0){
            legit = false;
            break;
        }else{
        }
    }

    if(legit){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 1024
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

LCM = lcm_list(A)
ans = 0

for i in range(N):
    ans+=LCM//A[i]
print(ans%mod)

Measured memory_bytes: 6108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 21474836

int N;
int A[3][3];
int b[10];

int main() {

	rep(i, 3)rep(j, 3)cin >> A[i][j];

	cin >> N;

	rep(i, N) {
		cin >> b[i];
	}
	
	rep(k, N) {
		rep(i, 3)rep(j, 3)if(A[i][j]==b[k])A[i][j] =-1;
	}

	bool ans = false;
	rep(i, 3) {
		if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1) 
		{
			ans = true;
		}
	}

	rep(i, 3) {
		if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1)
		{
			ans = true;
		}
	}

	if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1)
	{
		ans = true;
	}

	if (A[2][0] == -1 && A[1][1] == -1 && A[0][2] == -1)
	{
		ans = true;
	}

	if(ans)cout << "Yes" <<endl;
	else cout << "No" << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define f first
#define s second
#define N 100000
using namespace std;
typedef pair <int,int> P;
typedef long long ll;

int main(){
  int n,m,hp[101];
  
  while(cin>>n,n){
    for(int i=0;i<n;i++) cin>>hp[i];

    vector <P> mg[2];  
    cin>>m;
    for(int i=0,cost,dam;i<m;i++){
      string name,type;
      cin>>name>>cost>>type>>dam;
      if(dam)mg[type=="All"].push_back(P(dam,cost));
    }

    int dp[2][N+10]={};
    for(int i=0;i<2;i++)for(int j=1;j<N+10;j++)dp[i][j]=INF;
 
    for(int k=0;k<2;k++)
      for(int i=0;i<mg[k].size();i++)
	for(int j=mg[k][i].f;j<=(N/mg[k][i].f+1)*mg[k][i].f;j++)
	  dp[k][min(N,j)]=min(dp[k][min(N,j)],dp[k][j-mg[k][i].f]+mg[k][i].s);

    for(int j=N;j>=0;j--)dp[0][j]=min(dp[0][j],dp[0][j+1]);

    ll ans=INF;      
    for(int i=0;i<=N;i++){
      ll cost=dp[1][i];
      for(int j=0;j<n;j++)cost+=dp[0][max(0,hp[j]-i)];
      ans=min(ans,cost);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2004
import random
def main():
    D = int(input())
    c = list(map(int,input().split()))
    s = []
    for d in range(D):
        s.append(list(map(int,input().split())))
    
    last = [0 for i in range(26)]
    
    v = 0
    
    for d in range(D):
        print(random.randint(1,26))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9672
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll white[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>s;
    rep(i,n){
        if(s[i]=='.')white[i+1]++;
    }
    rep(i,n+2){
        white[i+1]+=white[i];
    }
    ans=white[n];
    rrep(i,1,n+1){
        ll cost;
        cost=i-white[i]+white[n]-white[i];
        ans=min(ans,cost);
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 2196
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>

int main() {
	int m, f, r;
	char rank[5][2] = {"A", "B", "C", "D", "F"};
	int flug;
	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m + f + r == -3)break;
		if (m + f >= 80) flug = 0;
		else if (m + f >= 65) flug = 1;
		else if (m + f >= 50) flug = 2;
		else if (m + f >= 30 && r >= 50) flug = 2;
		else if (m + f >= 30 && r <= 50) flug = 3;
		else flug = 4;
if(m==-1||f==-1) flug = 4;
		printf("%s\n", rank[flug]);
	}
	return 0;
}

Measured memory_bytes: 2608