akhauriyash/Code-Regression huggingface dataset:
#!python3

def resolve():
    N = tuple(map(int,input()))

    if len(N) == 1:
        print(N[0])
        return

    n = len(N)
    dp = [[0]*10 for i in range(10)]

    n0, nx = N[0], N[-1]
    sx1 = (10**(n-1) - 1) // 9
    sx2 = (10**(n-2) - 1) // 9
    sxn = 0
    for i in range(1, n-1):
        sxn = sxn * 10 + N[i]
    for ax in range(1, 10):
        for a1 in range(1, n0):
            dp[a1][ax] = sx1

        for a1 in range(n0, 10):
            dp[a1][ax] = sx2

        dp[ax][ax] += 1

        dp[n0][ax] += sxn
        if ax <= nx:
            dp[n0][ax] += 1

    #for x in dp:
    #    print(x)

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += dp[i][j]*dp[j][i]
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int x, y;
			int[] a = new int[2];
			string[] s = Console.ReadLine().Split(' ');
			a[0] = int.Parse(s[0]);
			a[1] = int.Parse(s[1]);
			Array.Sort(a);
			x = a[1];
			y = a[0];
			int r;
			do
			{
				r = x % y;
				x = y;
				y = r;
			} while (r != 0);
			Console.Write("{0}\n", x);
		}
	}
}

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

#define int long long

 int Euclid(int x,int y){
    if(x < y){
        const int a = x;
        x = y;
        y = a;
    }
    int b = 100000;
        while(b){
            b = x % y;
            x = y;
            y = b;
            if(b == 0) break;
        }
    return x;
}


int lcm(int x,int y){
    int g = Euclid(x,y);
    return x / g * y;
}
signed main(){
    int n;
    cin >> n;
    int ans = 1LL;
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        ans = lcm(ans,t);
    }

    
    cout << ans << endl;
}

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

using namespace std;

int d[1 << 21], p = 1e9 + 7;
vector<int> a[22];
int f(int m, int c) {
	if (d[m] >= 0)
		return d[m];
	d[m] = 0;
	for (int i : a[c])
		if (m&i) (d[m] += f(m^i, c - 1)) %= p;
	return d[m];
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int x;
			cin >> x;
			if (x) a[i].push_back(1 << j);
		}
	}
	fill(d, d + (1 << n), -1);
	*d = 1;
	cout << f((1 << n) - 1, n - 1) << endl;
	return 0;
}


Measured memory_bytes: 8448
from collections import defaultdict
import sys

input = sys.stdin.buffer.readline
mod = 10 ** 9 + 7


def modinv(a, mod):
    return pow(a, mod - 2, mod)


# 素因数分解
def prime_factor(n):
    # (素因数, 数)のリストで出てくる
    d = defaultdict(int)
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            d[i] += 1
            n //= i
    if n != 1:
        d[n] += 1
    return list(d.items())


n = int(input())
if n == 1:
    print(1)
    exit()
A = list(map(int, input().split()))
LCM = defaultdict(int)
for i in range(n):
    temp = prime_factor(A[i])
    for key, value in temp:
        t = LCM[key]
        LCM[key] = max(t, value)
lcm = 1
for key, val in LCM.items():
    lcm *= pow(key, val)
ans = 0
for i in range(n):
    gyaku = modinv(A[i], mod)
    ans += lcm * gyaku
    ans %= mod
print(ans)


Measured memory_bytes: 51288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int out;
		if (A >= 13) {
			out = B;
		} else if (A <= 5) {
			out = 0;
		} else {
			out = B/2;
		}
		System.out.println(out);
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
from collections import deque

H, W = [int(x) for x in input().split()]
cell = [list(input()) for i in range(H)]

painted = deque()
for h in range(H):
    for w in range(W):
        if cell[h][w] == '#':
            painted.append([h, w, 0])

ans = 0
while len(painted) > 0:
    blackcell = painted.popleft()
    for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
        nh = blackcell[0] + dy
        nw = blackcell[1] + dx
        d = blackcell[2]
        if 0 <= nh < H and 0 <= nw < W and cell[nh][nw] == '.':
            cell[nh][nw] = '#'
            painted.append([nh, nw, d + 1])
        ans = d

print(ans)


Measured memory_bytes: 176092
N,K,Q = map(int,input().split())
A = []
score = [K-Q for i in range(N)]
for _ in range(Q):
    A.append(int(input()))

for j in range(Q):
    score[A[j]-1] += 1

for k in range(N):
    if score[k] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11784
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, Z, W;
vi A;

int main() {
    cin >> N >> Z >> W;
    A.resize(N);
    rep(i, N) cin >> A[i];

    if (N == 1) {
        write(abs(A[0] - W));
    }
    else if (N == 2) {
        int ans = max(abs(A[0] - A[1]), abs(A[2] - W));
        write(ans);
    }
    else {
        int ans = max(abs(A[N - 1] - W), abs(A[N - 2] - A[N - 1]));
        write(ans);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 using namespace std; 
  int main() { 
    long long n;
    cin>>n;
  long cnt=0;
  while(n>0){
      if(n==1){
          cnt++;
          n=0;
      }else if(n>1){
          n=ceil(n/2);
          cnt=(cnt+1)*2;
      }
  }
  cout<<cnt;
     }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<ll> l(N,0);
    vector<ll> r(N,0);
    for(ll i=0;i<N;i++)
    cin>>l[i]>>r[i];
    multiset<P> L;//P(L,R)後ろから取り出す
    multiset<P> R;//P(R,L)前から取り出す
    for(ll i=0;i<N;i++){
        L.insert(P(l[i],r[i]));
        R.insert(P(r[i],l[i]));
    }
    multiset<P> L2=L;//P(L,R)後ろから取り出す
    multiset<P> R2=R;//P(R,L)前から取り出す
    ll ans=0;
    ll now=0;
    while(1){
        if(L.empty())break;
        P x=*prev(L.end());
        if(x.first<=now)break;
        ans+=x.first-now;
        now=x.first;
        L.erase(prev(L.end()));
        R.erase(R.lower_bound(P(x.second,x.first)));

        if(R.empty())break;
        x=*R.begin();
        if(x.first>=now)break;
        ans+=now-x.first;
        now=x.first;
        R.erase(R.begin());
        L.erase(L.lower_bound(P(x.second,x.first)));

    }
    ans+=llabs(now);

    ll ans2=0;
    now=0;
    while(1){
        if(R2.empty())break;
        P x=*R2.begin();
        if(x.first>=now)break;
        ans2+=now-x.first;
        now=x.first;
        R2.erase(R2.begin());
        L2.erase(L2.lower_bound(P(x.second,x.first)));

        if(L2.empty())break;
        x=*prev(L2.end());
        if(x.first<=now)break;
        ans2+=x.first-now;
        now=x.first;
        L2.erase(prev(L2.end()));
        R2.erase(R2.lower_bound(P(x.second,x.first)));

    }
    ans2+=llabs(now);
    print(max(ans,ans2))
    
    return 0;
}


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

int main(){
long long n,m;
 cin>>n>>m;
if(n>1&&m>1){
  cout<<(n-2)*(m-2)<<endl;
}
  else if(m==1&&n==1){
    cout<<1<<endl;
  }
  else{
    cout<<max(m,n)-2<<endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W; //H...updown,W...rightleft
    cin >> H;
    cin >> W;
    int kumo[H][W] = {0};
    for(int i = 0;i < H;i++){
        char yoko[W+3] = {0};
        cin >> yoko;
        int k = -1;
        for(int j = 0;j < W;j++){
            if(yoko[j] == 'c'){
                k = 0;
                kumo[i][j] = k;
            }
            else if(k == -1){
                kumo[i][j] = k;
            }
            else{
                k++;
                kumo[i][j] = k;
            }
        }
    }
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cout << kumo[i][j];
            if(j != W-1){
                cout << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}
/*AOJ?????????*/

Measured memory_bytes: 3116
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] input = sc.next().split("");
        List<String> list = Arrays.asList(input);
        Set<String> set = new HashSet<>(list);

        if(set.size() == 3){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

#define loop(i,n) for(int i=0;i<n;i++)
int n,m;
int p[1002];
int pp[1111111];

signed main(){
  while(cin>>n>>m,n){
    loop(i,n)cin>>p[i];
    p[n++]=0;
    loop(i,n)loop(j,n){
      pp[i*n+j]=m-p[i]-p[j];
    }
    sort(pp,pp+n*n);
    int res=0;
    loop(i,n)loop(j,n){
      int s=p[i]+p[j];
      int t=*lower_bound(pp,pp+n*n,s);
      if(t>0)res=max(res,s-t+m);
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 7076
N, K = map(int, input().split())
P = [x-1 for x in map(int, input().split())]
C = list(map(int, input().split()))

ans = -100_000_000_000
for i in range(N):
    n = 0
    socre_sum = 0
    now = i
    while True:
        n += 1
        socre_sum += C[now]
        now = P[now]
        if i == now:
            break
    score = 0
    now = i
    for j in range(1, n+1):
        score += C[now]
        now = P[now]
        if j > K:
            break
        ans = max(ans, score+max(0, socre_sum)*((K-j)//n))
print(ans)

Measured memory_bytes: 74168
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vll vector<ll>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template<typename T>
void vecin(vector<T>& v, int n = 0){
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n-1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}
void print(string s){
    cout << s << endl;
}
struct edge{
    int to, from;
};

int main()
{
    ciosup;
    int n;
    cin >> n;
    vint b(n-1),a(n);
    vecin(b);
    ll ans = 0;
    ans += b[0];
    FOR(i,1, n-1)
    {
        ans += min(b[i], b[i - 1]);
    }
    ans += b[n - 2];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n,m;
string s;
int color[500100];
struct segment_tree{//线段树
	int a[2000100];
	bool put[2000100];
	void push(int x){//标记下传 
		if(put[x]){
			a[x*2]=a[x*2+1]=a[x];
			put[x]=false;
			put[x*2]=put[x*2+1]=true;
		}
	}
	void calc(int x){//计算 
		a[x]=a[x*2]|a[x*2+1];
	}
	void build(int x,int l,int r){//建以x为根的树 
		if(l<r){
			int y=(l+r)>>1;
			build(x*2,l,y);//左子树递归
			build(x*2+1,y+1,r); //右子树递归
			a[x]=a[x*2]|a[x*2+1];
			put[x]=false;
		}
		else{
			a[x]=(1<<color[l]);
			put[x]=true;
		}
	}
	void modify(int x,int l,int r,int ll,int rr,long long v){
		if(r<ll||l>rr)//不相干的两个区间 
			return;
		if(ll<=l&&rr>=r){//正好重叠 
			a[x]=v;
			put[x]=true;
			return;
		}
		push(x);
		int y=(l+r)>>1;
		modify(x*2,l,y,ll,rr,v);//左子树递归
		modify(x*2+1,y+1,r,ll,rr,v); //右子树递归
		calc(x);
	}
	int get(int x,int l,int r,int ll,int rr){
		if(r<ll||l>rr)//不相干的两个区间 
			return 0;
		if(ll<=l&&rr>=r){//正好重叠 
			return a[x];
		}
		push(x);
		int y=(l+r)>>1;
		int ret=get(x*2,l,y,ll,rr);//左子树递归
		ret|=get(x*2+1,y+1,r,ll,rr); //右子树递归
		calc(x);
		return ret;
	}
}seg;
int ii;
string cc;
int ccc;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>s>>m;
	for(int i=0;i<n;i++)
		color[i+1]=(s[i]-'a');
	seg.build(1,1,n);
	int tp,aa,bb;
	for(int i=1;i<=m;i++){
		cin>>tp;
		if(tp==1){
			cin>>ii>>cc;
			ccc=cc[0]-'a';
			seg.modify(1,1,n,ii,ii,(1<<ccc));
		}
		else{
			cin>>aa>>bb;
			cout<<__builtin_popcountll(seg.get(1,1,n,aa,bb))<<endl;
		}
	} 
	return 0;
}


Measured memory_bytes: 12700
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    while(cin>>n>>m,n,m){
    	bool num[100000]={};
    	int co=0;
    	for(int i=0,x;i<m;i++){
    		cin>>x;
    		if(x==0)co++;
    		else num[x]=1;
    	}
    	int ans=0;
    	for(int i=1;i<=n-ans;i++){
    		bool first=0;
    		if(num[i]){
    			for(int j=i+1,now=1,fin=co;;j++,now++){
    				if(!num[j]){
    					if(!first)i=j;
    					if(fin>0)fin--;
    					else {
    						ans=max(ans,now);
    						break;
    					}
    					first=1;
    				}
    			}
    		}
    	}
    	cout<<ans<<endl;
    }
}

Measured memory_bytes: 1264
n, c, k = map(int, input().split())
t_l = []
for _ in range(n):
    t_l.append(int(input()))
t_l.sort()
ans = 0
cnt = 0
for t in t_l:
    if cnt == 0:
        t1 = t
    if t <= t1 + k:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
    else:
        cnt = 1
        ans += 1
        t1 = t
if cnt != 0:
    ans += 1
print(ans)

Measured memory_bytes: 81040
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) ((x)&(-x))
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000+10;
const double eps = 1e-9;
//const int maxm = 2510000+10;
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll x,y; cin>>x>>y;
    int ans=0;
    for (ll v=x;v<=y;v*=2,ans++);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
A = []
B = []
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(m):
    B.append(int(input()))

for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j]*B[j]
    print (c)



Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n;
    cin >> n;
    vector<ll> v(n+1);
    for (int i=1; i<=n; i++) {
        for (int j=i; j<=n; j+=i) {
            v[j]++;
        }
    }
    ll ans = 0;
    for (int i=1; i<=n; i++) {
        ans += v[i]*i;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81376
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 11:26:39 2019
D - 連結 / Connectivity
実行時間制限: 2 sec / メモリ制限: 256 MB
 
配点 : 
400 点
@author: justwah
"""
from collections import Counter
import sys

input = sys.stdin.readline
 
class UnionFind:
    def __init__(self, N):
        self.rank = [0]*N
        self.parent = [i for i in range(N)]
        self.n = N
        
    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]
        
    def merge(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a == b:
            return
        if self.rank[a] < self.rank[b]:
            self.parent[a] = b
        else:
            self.parent[b] = a
            if self.rank[a] == self.rank[b]:
                self.rank[a] +=1
                
    def same(self, a, b):
        return self.root(a) == self.roob(b)
 
 
n, k, l = map(int, input().split())
 
uf_road = UnionFind(n)
for _ in range(k):
    p, q = map(int, input().split())
    uf_road.merge(p-1, q-1)

uf_rail = UnionFind(n)
for _ in range(l):
    r, s = map(int, input().split())
    uf_rail.merge(r-1, s-1)
    
ctr = Counter()
for i in range(n):  # make a list to count number of cities that both road and rail-wise are in the same group
    r1 = uf_road.root(i)
    r2 = uf_rail.root(i)
    ctr[(r1,r2)] += 1

ans = []
for i in range(n): # print the group size of that city when looped
    r1 = uf_road.root(i)
    r2 = uf_rail.root(i)
    ans.append(ctr[(r1,r2)])

print(*ans)   # * is for unpack the list

Measured memory_bytes: 56300
#include <iostream>

int D, N;

bool check(int x) {
  int cnt = 0;
  while (x % 100 == 0) {
    cnt++;
    x /= 100;
  }
  return cnt == D;
}

int main() {
  std::cin>>D>>N;
  int cnt = 0;
  int x = 1;
  while (cnt < N) {
    if (check(x))
      cnt++;
    x++;
  }
  --x;
  std::cout<<x<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, x;
  cin >> k >> x;
  if (500 * k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		int res = 0;
		for (int i = 0, j = str.length - 1; i < j;) {
			if (str[i].equals(str[j])) {
				++i;
				--j;
			} else if (str[i].equals("x")) {
				++res;
				++i;
			} else if (str[j].equals("x")) {
				++res;
				--j;
			} else {
				System.out.println("-1");
				return;
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 41756
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int cnt = 0;
    for (int i=0;i<n;i++){
        int a;
        cin >> a;
        int tmp=1;
        while (tmp<=d){
            cnt += 1;
            tmp += a;
        }
    }
    cout << cnt+x << endl;
}

Measured memory_bytes: 256
class UnionFindTree:
    def __init__(self, n):
        self.__parents = [-1] * n

    def find(self, x):
        p = self.__parents
        if p[x] < 0:
            return x
        parent = self.find(p[x])
        p[x] = parent
        return parent

    def union(self, x, y):
        p = self.__parents
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if p[x] > p[y]:
            x, y = y, x
        p[x] += p[y]
        p[y] = x

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

    def size(self, x):
        return -self.__parents[self.find(x)]


def spline(func_=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func_, iter_)


def main():
    n, m = spline()
    chains = UnionFindTree(n)
    f = lambda x: int(x) - 1
    bridges = [tuple(spline(func_=f)) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    for i in range(m - 2, -1, -1):
        x, y = bridges.pop()
        tmp = ans[i + 1]
        if not chains.same(x, y):
            tmp -= chains.size(x) * chains.size(y)
            chains.union(x, y)
        ans[i] = tmp
    print(*ans, sep='\n')


if __name__ == "__main__":
    main()


Measured memory_bytes: 20072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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 ll LINF = 1LL<<58;
const ll mod = 1000000007;

vector<bool> get_prime(int n){
    vector<bool> prime(n + 1, true);
  
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
  
    for(int i = 2; i * i <= n; i++){
        if(prime[i]){
            for(int j = i + i; j <= n; j += i) prime[j] = false;
        }
    }
    return prime;
}

int main(){
    int n = 100010;
    vector<bool> prime = get_prime(n);
    vector<int> like(n, 0), likesum(n, 0);
    for(int i = 1; i < n; i++){
        if(prime[i] && (i+1)%2==0 && prime[(i+1)/2]) like[i]++;
        likesum[i] = likesum[i-1] + like[i];
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << likesum[r] - likesum[l-1] << endl;
    }
    return 0;
}

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

#define pi 2 * acos(0.0)

using namespace std;

int main()
{
    int i, n, m, x;

    //map <int, int> p;

    cin >> n;

    int p[n + 1];

    for(i = 0; i <= n; i++)
        p[i] = 0;

    for(i = 1; i < n; i++)
    {
        cin >> x;
        p[x]++;
    }

    for(i = 1; i <= n; i++)
        cout << p[i] << endl;

    return 0;
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int x,y;
    cin >> x >> y;
    cout << abs(x-y) << endl;
    return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e8
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

bool dp_yoko[16001];
bool dp_tate[16001];
bool dp_tmp[16001];

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    vector<int> yoko;
    vector<int> tate;
    int idx = 0;
    int kosu = 0;

    REP(i, s.length()) {
        if(s[i] == 'T') {
            if(idx == 0) {
                yoko.push_back(kosu);
                idx = 1;
            } else {
                tate.push_back(kosu);
                idx = 0;
            }
            kosu = 0;
        } else {
            kosu++;
        }
    }

    if(idx == 0) {
        yoko.push_back(kosu);
        idx = 1;
    } else {
        tate.push_back(kosu);
        idx = 0;
    }    

    dp_yoko[8000] = dp_tate[8000] = true;

    REP(i, yoko.size()) {
        int susumu = yoko[i];
        REP(j, 16001) {
            dp_tmp[j] = dp_yoko[j];
        }
        REP(j, 16001) {
            dp_yoko[j] = false;
        }
        REP(j, 16001) {
            if(j + susumu < 16001) {
                //if(dp_tmp[j]) cout << "a " << j+susumu << endl; 
                dp_yoko[j + susumu] |= dp_tmp[j];
            }
            if(0 <= j - susumu && i!=0) {
                //if(dp_tmp[j]) cout << "b " << j-susumu << endl;
                dp_yoko[j - susumu] |= dp_tmp[j];
            }
        }
    }

    REP(i, tate.size()) {
        int susumu = tate[i];
        REP(j, 16001) {
            dp_tmp[j] = dp_tate[j];
        }
        REP(j, 16001) {
            dp_tate[j] = false;
        }
        REP(j, 16001) {
            if(j + susumu < 16001) dp_tate[j + susumu] |= dp_tmp[j];
            if(0 <= j - susumu) dp_tate[j - susumu] |= dp_tmp[j];
        }
    }

    if(dp_tate[8000+y] && dp_yoko[8000+x]) cout << "Yes" << endl;
    else cout << "No" << endl;

    //REP(i, 10) cout << dp_yoko[8000+i-5] << " ";
    //cout << endl;
    //REP(i, 10) cout << dp_tate[8000+i-5] << " ";
    //cout << endl;

    return 0;
}
 

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

/*  char dummyA[100],dummyB[100];

int inputA(char sp[],int MS){
  int stc = 0;
  while(stc < MS+1){                    //５０文字以内でループ
    scanf("%c",&sp[stc]);               //一文字ずつスキャン
  if(sp[stc]>='a' && sp[stc]<='z'){     //小文字アルファベット以外はループを抜ける
    if(sp[stc] == '\n' || stc == 50){                //改行が来たらNULLに置き換え
      if(stc == 0) break;               //そもそも何も入力してなかったらループ抜ける
      sp[stc] = '\0';
      return stc;
    }else {stc++;}
   }else {break;}
  }
  //  scanf("%s",dummyA);
  //rewind(stdin);                        
  //exit(0);
  return 50;
 }

int inputB(char sp[],int MS,int limit){
  int stc = 0;
  limit++;
  while(stc < MS+1 && stc < limit){
    scanf("%c",&sp[stc]);
    if(sp[stc] == '\n'){
      if(stc != limit-2 && stc != limit-1 || stc == 50) break;
      sp[stc] = '\0'; 
      return 0;
    }
    else {stc++;}
  }
  //scanf("%s",dummyB);
  //rewind(stdin);
  //exit(0);
  return -1;
 }

int main(void){
  char a[51],b[51];
  int a1 = 0;
  int b1 = 0;
  int MS = 50;
  
  int inputANum = inputA(a,MS);
  inputB(b,MS,inputANum);
  
  for(int i = 0; i < 50; i++){
    if(a[a1] == '\0' || a[a1] == '\n' || b[b1] == '\n') {
      printf("\n");
      exit(0);
      }
   printf("%c%c",a[a1],b[b1]);
   a1++;
   b1++;
   //break;
  }
 }*/

int main(void){
  char a[100],b[100];
  char dummy;
  int a1 = 0;
  int b1 = 0;
  scanf("%s",a);
  scanf("%c",&dummy);
  scanf("%s",b);
   
  /*for(int i = 0; i < 50; i++){
    if(b[b1] == '\n') {
      printf("\n");
      //break;
      exit(0);
      }
   printf("%c%c",a[a1],b[b1]);
   a1++;
   b1++;
  }
  printf("\n");
  return 0;
}*/
  char AB[200];
  for(int i = 0; i<50; i++){
    AB[2*i] = a[i];
    AB[2*i + 1] = b[i];
  }
  printf("%s\n",AB);
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

ll n,m,k; 
ll a[200005],b[200005];
ll a_sum[200005],b_sum[200005];


int main()
{
    cin >> n >> m >> k;
    
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    int ans = 0;
    a_sum[0] = a[0];
    b_sum[0] = b[0];
    for(int i = 1; i <= n; i++) a_sum[i] = a_sum[i-1] + a[i];
    for(int i = 1; i <= m; i++) b_sum[i] = b_sum[i-1] + b[i];

    for(int i = 0; i < n; i++){
        ll tmp = 0;
        if(a_sum[i] > k) break;
        else{
            ll key = k - a_sum[i];
            auto iter = upper_bound(b_sum, b_sum+m, key);
            int idx_l = distance(b_sum,iter);
            //cout << i+1 << ' ' << idx_l << endl;
            ans = max(ans,i+1+idx_l);
        }
    }
  
    int cnt = 0;
    for(int i = 0; i < m; i++){
        if(b_sum[i] <= k) cnt++;
    }
    cout << max(ans,cnt) << endl;
}

Measured memory_bytes: 9748
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>


using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
//const ll MOD=1000000007;
const ll MOD=998244353;
using mint = modint998244353;
//using mint = modint1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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

vector<ll> MP,P;
struct S{
  mint ans,len;
};

struct F{
  mint c,d;
};

S op(S s_l,S s_r){
  return {s_l.ans*MP[s_r.len.val()]+s_r.ans,s_l.len+s_r.len};
}

S e(){
  return {0,0};
}

S mapping(F f,S s){
  return {f.c*s.ans+f.d*P[s.len.val()],s.len};
}

F composition(F f,F g){
  return {f.c*g.c,f.c*g.d+f.d};
}

F id(){
  return {1,0};
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);
  
  ll N,Q; cin>>N>>Q;
  MP=vector<ll>(N+1);
  MP[0]=1; rep(i,N) MP[i+1]=MP[i]*10%MOD;
  P=vector<ll>(N+1); 
  P[0]=0; rep(i,N) P[i+1]=(P[i]*10+1)%MOD;
  vector<S> vec(N,S{1,1});
  lazy_segtree<S,op,e,F,mapping,composition,id> seg(vec);
  
  rep(i,Q){
    int l,r,d; cin>>l>>r>>d; l--; r--;
    F f={0,d};
    seg.apply(l,r+1,f);
    cout<<seg.all_prod().ans.val()<<'\n';
  }
  
  return 0;
}


Measured memory_bytes: 14060
import itertools

NN = 202020
MOD = 10**9+7
# MOD = 998244353
INF = float("inf")

n, k = map(int, input().split())
psum = list(itertools.accumulate([i for i in range(n+1)]))
rsum = list(itertools.accumulate([i for i in reversed(range(n+1))]))
# print(psum)
# print(rsum)

ans = 0
for i in range(k, n+2):
    ans = (ans + rsum[i-1] - psum[i-1] + 1)%MOD
    # print(rsum[i-1] - psum[i-1] + 1, ans)
print(ans)

Measured memory_bytes: 109404
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n int

    fmt.Scan(&n)

    L := make([]int, 2*n)

    for i := 0; i < 2*n; i++ {
        fmt.Scan(&L[i])
    }
    sort.Sort(sort.IntSlice(L))

    var ans int
    for i := 0; i < 2*n; i += 2 {
        ans += L[i]
    }

    fmt.Println(ans)
}


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

#define ll   long long

int main() {

    int r,D,x0;
    cin >> r >> D >> x0;

    int x = x0;
    for(int i=0; i<10; i++){
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    double T, X;
    cin >> T >> X;

    cout << T / X << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

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

    int i = 0;
    long long x = 1;
    string s = (n != 0 ? "" : "0");

    while (n != 0) {
        if (n % (x * -2) != 0) {
            s = "1" + s;
            n -= x;
        } else {
            s = "0" + s;
        }
        x *= -2;
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

long long merge(long long[], int, int, int);
long long mergesort(long long[], int, int);

int main()
{
	int n;
	long long *s, count;
	scanf("%d", &n);
	s = new long long[n];
	for (int i = 0; i < n; i++)
		scanf("%d", s + i);
	count = mergesort(s, 0, n);
	for (int i = 0; i < n; i++)
	{
		if (i)
			printf(" ");
		printf("%lld", s[i]);
	}
	printf("\n%lld\n", count);
	delete[] s;
	return 0;
}

long long merge(long long a[], int left, int mid, int right)
{
	int n1, n2, i = 0, j = 0;
	long long *l, *r;
	n1 = mid - left;
	n2 = right - mid;
	l = new long long[n1 + 1];
	r = new long long[n2 + 1];

	for (int i = 0; i < n1; i++)
		l[i] = a[left + i];
	for (int i = 0; i < n2; i++)
		r[i] = a[mid + i];
	r[n2] = l[n1] = 20000000000;
	for (int k = left; k < right; k++)
		if (l[i] <= r[j])
		{
			a[k] = l[i];
			i++;
		}
		else
		{
			a[k] = r[j];
			j++;
		}

	delete[] l;
	delete[] r;
	return right - left;
}

long long mergesort(long long a[], int left, int right)
{
	long long count = 0;
	if (left + 1 < right)
	{
		int mid;
		mid = (left + right) / 2;
		count += mergesort(a, left, mid);
		count += mergesort(a, mid, right);
		count += merge(a, left, mid, right);
	}
	return count;
}


Measured memory_bytes: 10120
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  int ans = 0;
  for(int i = 0;i < N;i++) {
    char c = S.at(i);
    while(i < N-1 && S.at(i+1) == c) i++;
    ans++;
  }

  cout << ans << endl;
}




Measured memory_bytes: 512
#include <stdio.h>
int main(void){
  int A,B,C;
  scanf("%d%d%d", &A,&B,&C);
  if(A == 5&&B == 5&&C == 7){
     printf("YES\n");
  }else if(A == 5&&B == 7&&C == 5){
     printf("YES\n");
  }else if(A == 7&&B == 5&&C == 5){
	 printf("YES\n");
  }else{
	 printf("NO\n");
  }
  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    for(int bit=0;bit<(1<<3);++bit){
        int res=s[0]-'0';
        for(int i=0;i<3;++i){
            int t=s[i+1] - '0';
            if(bit&(1<<i)){
                res+=t;
            }else{
                res-=t;
            }
        }
        if(res==7){
            cout << s[0];
            for(int i=0;i<3;++i){
                if(bit&(1<<i)){
                    cout << "+";
                }else{
                    cout << "-";
                }
                cout << s[i+1];
            }
            cout << "=7" << "\n";
            return 0;
        }
    }
}   

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}



int main(void){
	ll n,a,b;
	cin>>n>>a>>b;
	vector<ll>v(n);
	map<ll,ll>m1,m2;
	for(int i=0;i<n;i++){
		cin>>v[i];
		m1[v[i]]++;
	}
	double ans = 0.0;
	sort(v.begin(),v.end(),greater<ll>());
	set<ll>s;
	for(int i=0;i<a;i++){
		ans+=(double)v[i];
		s.insert(v[i]);
		m2[v[i]]++;
	}
	printf("%.10lf\n",(double)ans/a);
	if(s.size()>1){
		ll ans1 = 1;
		for(auto itr = m2.begin();itr!=m2.end();++itr){
			ll v = itr->first;
			ll num = itr->second;
			ll ue = 1;
			ll shita = 1;
			for(ll i=1;i<=num;i++){
				ue*=(m1[v]-i+1);
				shita*=i;
				if(ue%shita==0){
					ue = ue/shita;
					shita = 1;
				} 
			}
			ans1*=ue;
		}
		cout<<ans1<<endl;
	}
	else{
		ll ans1 = 0;
		ll cnt = m1[v[0]];
		for(ll i=a;i<=b;i++){
			if(cnt<i)break;
			ll ue = 1;
			ll shita = 1;
			for(ll j=1;j<=i;j++){
				ue*=(cnt-j+1);
				shita*=j;
				if(ue%shita==0){
					ue = ue/shita;
					shita = 1;
				}
			}
			ans1+=ue;
		}
		cout<<ans1<<endl;
	}
    return 0;
}

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

int main(){

    int N;
    cin >> N;
    char S;
    int flag = 0;
    for(int i=0; i<N; i++){
        

        cin >> S;
        if(S == 'Y'){
            flag = 1;
        }
    }

    if(flag == 1){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = gets.split.map &:to_i
x3, y3, x4, y4 = 0
dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

puts "#{x3} #{y3} #{x4} #{y4}"

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

typedef pair<int, int> P;

const int INF = 1e8;

/*int func(int now, int t, int b) {
	if ( now == n ) return 0;
	if ( dp[now][t][b] != INF ) return dp[now][t][b];

	int add;
	int ret = func(now+1, t+
	}*/

int main() {
	int n;
	while ( cin >> n, n ) {
		vector<P> v(n);
		int dp[40][4];
		for ( int i = 0; i < n; i++ ) {
			cin >> v[i].second >> v[i].first; 
		}
	
		sort(v.begin(), v.end());

		fill_n(*dp, 40*4, INF);

		if ( v[0].first < v[0].second ) {
			cout << "NG " << 1 << endl;
			continue;
		}
		dp[0][1] = v[0].second;

		for ( int i = 1; i < n; i++ ) {
			for ( int j = 0; j < 3; j++ ) {				
				if ( dp[i-1][j] == INF ) continue;
				if ( v[i-1].first + (v[i-1].second)*(j+1) + v[i].second <= v[i].first ) {
					dp[i][1] = min(dp[i][1], dp[i-1][j] + v[i-1].second + v[i].second);
				}
				if ( v[i-1].first + abs(v[i-1].second-v[i].second)*(j+1) <= v[i].first ) {
					dp[i][j+1] = min(dp[i][j+1], dp[i-1][j] + abs(v[i-1].second-v[i].second));
				}
			}
			if ( dp[i-1][3] != INF ) {
				if ( v[i-1].first + (v[i-1].second)*(4) + v[i].second <= v[i].first ) {
					dp[i][1] = min(dp[i][1], dp[i-1][3] + v[i-1].second + v[i].second);
				}
			}
		}
	
		int ans = INF;
		for ( int i = 0; i < 4; i++ ) {
			ans = min(ans, dp[n-1][i]);
		}

		if ( ans == INF ) {
			int i;
			for ( i = 0; i < n; i++ ) {
				int mi = INF;
				for ( int j = 0; j < 4; j++ ) mi = min(mi, dp[i][j]);
				if ( mi == INF ) break;
			}
			cout << "NG ";
			cout << i+1 << endl;
		} else {
			cout << "OK ";
			cout << ans+v[n-1].second << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>

int main()
{
  int a,b,c,x;

  scanf("%d %d %d" , &a , &b , &c);

  if( a > b )
    {
      x = a;
      a = b;
      b = x;
    }
  if( b > c )
    {
      x = b;
      b = c;
      c = x;
    }
  if( a > b )
    {
      x = a;
      a = b;
      b = x;
    }

  printf("%d %d %d\n" , a , b , c);

  return 0;
}


Measured memory_bytes: 2044
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<P>> v(n);
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            int x, y;
            cin >> x >> y;
            --x;
            v[i].emplace_back(x, y);
        }
    }
    int ans = 0;
    rep(S,(1<<n)){
        int score = 0;
        vector<bool> user(n, false);
        rep(i,n){
            if(S>>i & 1){
                ++score;
                user[i] = true;
            }
        }
        bool ok = true;
        rep(i,n){
            if(!user[i]) continue;
            rep(j,v[i].size()){
                if(user[v[i][j].first] != (v[i][j].second == 1)){
                    ok = false;
                    break;
                }
            }
        }
        if(ok) chmax(ans, score);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
    int m, d, w, days[] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
    string wdays[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
    while(cin >> m >> d) {
        if(m || d) {
            cout << wdays[(days[m - 1] + d - 1) % 7] << endl;
        }
    }
}



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

using namespace std;

int min_index(vector<int> vec){
	vector<int>::iterator iter = min_element(vec.begin(), vec.end());
	int index = distance(vec.begin(), iter);
	return index;
}

int main(){
	int N;
	int T;

	cin >> N >> T;

	int c[N];
	int t[N];

	for (int n=0; n<N; n++){
		cin >> c[n] >> t[n];
	}

	vector<int> val_c;
	vector<int> val_t;

	for (int n=0; n<N; n++){
		if (t[n] <= T){
			val_c.push_back(c[n]);
			// val_t.push_back(t[n]);
		}
	}

	if (val_c.size() == 0){
		cout << "TLE" << endl;
		return 0;
	}

	int min_id = min_index(val_c);
	cout << val_c[min_id] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a.at(i).at(j);
        }
    }

    for (int i = 0; i < w+2; i++) cout << '#';
    cout << endl;
    for (int i = 0; i < h; i++) {
        cout << '#';
        for (int j = 0; j < w; j++) {
            cout << a.at(i).at(j);
        }
        cout << '#' << endl;
    }
    for (int i = 0; i < w+2; i++) cout << '#';
    cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <utility>
#include <valarray>

using namespace std;

int main()
{
    int A, B;
    scanf("%d %d\n", &A, &B);
    printf("%d\n", (A + B) % 24);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, n, k, s;
  scanf("%lld%lld%lld", &n, &k, &s);
  if(s == 1e9) {
    for(i = 0; i < k; ++i) printf("%lld ", s);
    for(; i < n; ++i) printf("%lld ", 1);
  } else {
    for(i = 0; i < k; ++i) printf("%lld ", s);
    for(; i < n; ++i) printf("%lld ", s + 1);
  }
  return 0;
}

Measured memory_bytes: 1280
n = gets.to_i
a = Array.new(n) { Array.new n, 0 }
n.times do
  u, _, *vs = gets.split.map(&:to_i)
  vs.each do |v|
    a[u-1][v-1] = 1
  end
end
a.each do |r|
  puts r.join ' '
end

Measured memory_bytes: 8880