akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void Print(int data[3][10]){
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 10; j++)
    {
        cout << " " << data[i][j];
    }
    cout << endl;
  }
}

int main(){
  int n, b, f, r, v;
  cin >> n;
  int ridge1[3][10] = {0},ridge2[3][10] = {0},ridge3[3][10] = {0},ridge4[3][10] = {0};

  for (int i = 0; i < n; i++)
  {
    cin >> b >> f >> r >> v;
    if(b == 1){
      ridge1[f-1][r-1] += v;
      if(ridge1[f-1][r-1] > 9){
        ridge1[f-1][r-1] = 9;
      }else if(ridge1[f-1][r-1] < 0){
        ridge1[f-1][r-1] = 0;
      }
    }
    else if(b == 2){
      ridge2[f-1][r-1] += v;
      if(ridge2[f-1][r-1] > 9){
        ridge2[f-1][r-1] = 9;
      }else if(ridge2[f-1][r-1] < 0){
        ridge2[f-1][r-1] = 0;
      }
    }
    else if(b == 3){
      ridge3[f-1][r-1] += v;
      if(ridge3[f-1][r-1] > 9){
        ridge3[f-1][r-1] = 9;
      }else if(ridge3[f-1][r-1] < 0){
        ridge3[f-1][r-1] = 0;
      }
    }
    else if(b == 4){
      ridge4[f-1][r-1] += v;
      if(ridge4[f-1][r-1] > 9){
        ridge4[f-1][r-1] = 9;
      }else if(ridge4[f-1][r-1] < 0){
        ridge4[f-1][r-1] = 0;
      }
    }
  }

  Print(ridge1);
  cout << "####################" << endl;
  Print(ridge2);
  cout << "####################" << endl;
  Print(ridge3);
  cout << "####################" << endl;
  Print(ridge4);
  
  return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
	double n;
	while(cin >> n){
	//	if(n==1) cout << "1.000000\n";
//		else{	
			int t;
			t=(n+1)/2;
			double m = t/n;
			printf("%.6f\n",m);	
//		}	
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int>G[2<<17];
int dep[2<<17];
void dfs(int u,int p,int d)
{
	dep[u]=d%2;
	for(int v:G[u])
	{
		if(v!=p)
		{
			dfs(v,u,d+1);
		}
	}
}
int ans[2<<17];
main()
{
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0,-1,0);
	vector<int>a[2];
	for(int i=0;i<N;i++)
	{
		a[dep[i]].push_back(i);
	}
	for(int k=0;k<2;k++)
	{
		int a1=a[k].size(),a2=a[(k+1)%2].size();
		int s0=3,s1=1,s2=2;
		bool ok=false;
		if(a1>=N/3+(N%3>=1)&&a2>=N/3+(N%3>=2))
		{
			ok=true;
			for(int u:a[k])
			{
				if(s1<=N)
				{
					ans[u]=s1;
					s1+=3;
				}
				else
				{
					ans[u]=s0;
					s0+=3;
				}
			}
			for(int u:a[(k+1)%2])
			{
				if(s2<=N)
				{
					ans[u]=s2;
					s2+=3;
				}
				else
				{
					ans[u]=s0;
					s0+=3;
				}
			}
		}
		else if(a1<=N/3)
		{
			ok=true;
			for(int u:a[k])
			{
				ans[u]=s0;
				s0+=3;
			}
			for(int u:a[(k+1)%2])
			{
				if(s0<=N)
				{
					ans[u]=s0;
					s0+=3;
				}
				else if(s1<=N)
				{
					ans[u]=s1;
					s1+=3;
				}
				else
				{
					ans[u]=s2;
					s2+=3;
				}
			}
		}
		else if(a2<=N/3)
		{
			ok=true;
			for(int u:a[(k+1)%2])
			{
				ans[u]=s0;
				s0+=3;
			}
			for(int u:a[k])
			{
				if(s0<=N)
				{
					ans[u]=s0;
					s0+=3;
				}
				else if(s1<=N)
				{
					ans[u]=s1;
					s1+=3;
				}
				else
				{
					ans[u]=s2;
					s2+=3;
				}
			}
		}
		if(ok)
		{
			if(s0-3>N||s1-3>N||s2-3>N)
			{
				return -1;
			}
			for(int i=0;i<N;i++)cout<<ans[i]<<(i+1==N?"\n":" ");
			return 0;
		}
	}
	cout<<-1<<endl;
}


Measured memory_bytes: 21236
#include <string>
#include <iostream>
using namespace std;
int main(){
  string s; cin >> s;
  long long int ans=0;
  long long int blk=0;
  for(int i=0;i<s.length();i++){
  	if(s[i]=='B') blk++;
    else ans += blk;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.Scanner;

public class Main {

    static int N, W;
    static int[] w;
    static int[] v;
    static boolean[][] vis;
    static long[][] memo;

    static long dp(int idx, int rem) {
        if(idx == N) return 0;
        if(vis[idx][rem]) return memo[idx][rem];
        long ans = 0;
        if(rem - w[idx] >= 0)
            ans = v[idx] + dp(idx + 1, rem - w[idx]);
        ans = Math.max(ans, dp(idx + 1, rem));
        vis[idx][rem] = true;
        return memo[idx][rem] = ans;
    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        w = new int[N];
        v = new int[N];
        vis = new boolean[N][W + 1];
        memo = new long[N][W + 1];
        for(int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        System.out.println(dp(0, W));
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<char> str(n);
  for(int i=0;i<n;i++){
    cin >> str.at(i);
  }
  int count = 1;
  for(int i=1;i<n;i++){
    if(str.at(i)!=str.at(i-1)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 384
fun main(args: Array<String>) = panasonic2020d()

fun panasonic2020d() {
    val n = readLine()!!.toInt()

    fun dfs(string: String, max: Char): List<String> {
        return if (string.length == n) {
            listOf(string)
        } else {
            ('a'..max).map { dfs(string + it, if (it == max) max + 1 else max) }.flatten()
        }
    }

    val answer = dfs("", 'a').joinToString(System.lineSeparator())

    println(answer)
}


Measured memory_bytes: 54676
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll n;   cin >> n;
    ll mod = 1e9+7;
    ll ans = 1;
    for (int i = 0; i < n; i++)
        ans = (ans * 10) % mod;
    
    ll tmp = 1, cnt = 1;
    for (int i = 0; i < n; i++) {
        tmp = (tmp * 9) % mod;
        cnt = (cnt * 8) % mod;
    }
    
    ans = (ans - tmp - tmp + cnt + 3*mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

int Gcd(int a, int b)
{
	return a % b == 0 ? b : Gcd(b, a % b);
}

int Gcd(int a, int b, int c)
{
	int d = Gcd(a, b);
	return Gcd(d, c);
}

int main()
{
	int k;
	std::cin >> k;
	
	int a[3] = {};
	int s = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int l = 1; l <= k; l++) {
				a[0] = i;
				a[1] = j;
				a[2] = l;
				std::sort(a, a + 3);
				s += Gcd(a[0], a[1], a[2]);
			}
		}
	}
	
	std::cout << s << std::endl;
	
	return 0;
}


Measured memory_bytes: 3160
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        
        int N=sc.nextInt();
        long[] a=new long[N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextLong();
        }
        Arrays.sort(a);
        
        long num=a[0];
        int count=0;
        int ans=0;
        for(int i=0;i<N-1;i++){
            count++;
            if(a[i]<a[i+1]){
                if(count>num){
                    ans+=count-num;
                }else if(count<num){
                    ans+=count;
                }
                count=0;
                num=a[i+1];
            }
        }
        count++;
        if(count>num){
            ans+=count-num;
        }else if(count<num){
            ans+=count;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 59084
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
using namespace std;

int main(){
  int N,M; cin >> N >> M;
  char A[N][N];
  char B[M][M];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin >> A[i][j] ;
    }
  }
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
      cin >> B[i][j] ;
    }
  }
  bool a= false;
  for(int i=0;i<=N-M;i++){
    for(int j=0;j<=N-M;j++){
      bool b=true;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(A[i+k][j+l] != B[k][l]) b=false;
        }
      }
      if(b) a=true;
    }
  }
  cout << (a?"Yes":"No") << endl;
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans=0;
long long q=0;
long long len[55];
map<int,long long> mp;
long long dfs(int step,long long num)//递归寻找 ,num代表要找的是前num片中有几个'P' 
{
	if(num==1&&step==0) return 1;//如果递归找到第0级就返回1吧 
	if(num==0||num==1) return 0;//如果这个汉堡没有要找的或者只剩皮的话就返回0吧 
	//cout<<"start "<<cc<<":"<<step<<" "<<num<<endl;
	long long sum=0;
	num--;//把最外面的一层包上去的皮去掉 
	long long mid=len[step-1];//折半 
	if(num<mid) return dfs(step-1,num);//如果要找的部分连比他低一级的汉堡都要小，那就直接往下找 
	if(num>=mid) sum+=mp[step-1];//如果能完全覆盖下一级的汉堡，那就直接加上预处理的值 
	num-=len[step-1];//搜索完第一部分了，去掉 
	if(num==0) return sum;//返回 
	sum++;num--;//把中间加上的一片去掉 
	if(num==0) return sum;
	if(num<mid) return dfs(step-1,num)+sum;
	if(num>=mid) sum+=mp[step-1];//同样的办法，就不赘述了 
	return sum;
}
int main()
{
	len[0]=1;
	for(int i=1;i<=50;i++) len[i]=len[i-1]*2+3;//记录每级汉堡有几层 
	mp[0]=1;
	for(int i=1;i<=50;i++) mp[i]=mp[i-1]*2+1;//记录每层汉堡有几个'P' 
	cin>>n>>k;
	cout<<dfs(n,k);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> l(n);
	for(auto &i:l) cin >> i;
	sort(l.begin(), l.end());
	Int ans = 0;
	for(Int i=0; i<n; ++i)
		for(Int j=0; j<n; ++j){
			if(i == j) continue;
			Int b = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin() - 1;
			Int a = upper_bound(l.begin(), l.end(), max(l[i]-l[j], l[j]-l[i])) - l.begin();
			Int c = b - a + 1;
			if(a <= i && i <= b) --c;
			if(a <= j && j <= b) --c;
			ans += c;
		}
	ans /= 6;
	cout << ans << "\n";
}

Measured memory_bytes: 256
def examA():
    abc = LI()
    ans = sum(abc) - max(abc)
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 3444
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main() {
    int x, y;
    cin >> x >> y;
    cout << x + (y / 2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


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

const int N=1000005;


void solve()
{
   
    int n;
    cin>>n;
    int dp[n+1]={0};
    dp[0]=0;
    dp[1]=1;
    int pre[n+1]={0};
    pre[1]=1;
    int k;
    cin>>k;
    pair<int,int> p[k];
    for(int i=0;i<k;i++)
        cin>>p[i].fi>>p[i].se;
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<k;j++)
        {
            int l=max((int)1,i-p[j].se),r=i-p[j].fi;
            if(l<=r)
            {
                dp[i]=(dp[i]+pre[r]-pre[l-1]+MOD)%MOD;
            }
            
        }
        pre[i]=(pre[i-1]+dp[i])%MOD;
    }
    cout<<dp[n]<<endl;
    
    
    
}

int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}



Measured memory_bytes: 6780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int B[100];
void Calc(){
	int N = rei();
	for(int i=0;i<N-1;i++){
		B[i] = rei();
	}
	long ans = 0;
	for(int i=0;i<N;i++){
		if(i == 0){
			ans += B[0];
		}
		else if(i == N-1){
			ans += B[N-2];
		}
		else{
			ans += min(B[i],B[i-1]);
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long; 
ll n;
ll head[500005],to[500005],nxt[500005],cnt;
int c[500005];
bool ok;
int w,b,cw,cb;
inline void add(int x,int y){
	to[++cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
inline void clr(int x,int cl){
	if(cl){
		w++;
	}
	else{
		b++;
	}
	c[x]=cl;
	vector<int> v;
	for(int i=head[x];i;i=nxt[i]){
		int y=to[i];
		if(c[y]!=-1){
			continue;
		}
		clr(y,cl^1);
	}
}
int main(){
	cin>>n;
	for(int i=1;i<n;++i){
		int a,b;
		cin>>a>>b;
		add(a,b); 
		add(b,a);
	}
	memset(c,-1,sizeof(c));
	clr(1,0);
	int rd=n/3;
	if(w>b){
		swap(w,b);
		cw=0,cb=1;
	}
	else{
		cw=1,cb=0;
	}
	if(w<=rd){
		int st=3,nd=1;
		for(int i=1;i<=n;++i){
			if(c[i]==cw){
				cout<<st<<' ';
				st+=3;
			}
			else{
				if(nd<=n){
					cout<<nd<<' ';
					nd++;
					if(nd%3==0){
						nd++;
					}
				}
				else{
					cout<<st<<' ';
					st+=3;
				}
			}
		}
	}
	else{
		int st=3,nd=1,rd=2;
		for(int i=1;i<=n;++i){
			if(c[i]==cw){
				if(nd<=n){
					cout<<nd<<' ';
					nd+=3;
				}
				else{
					cout<<st<<' ';
					st+=3;
				}
			}
			else{
				if(rd<=n){
					cout<<rd<<' ';
					rd+=3;
				}
				else{
					cout<<st<<' ';
					st+=3;
				}
			}
		}
	}
	cout<<'\n';
	return 0;
}

Measured memory_bytes: 15104
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

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

  bool f=false;
  while(n) {
    if (n%10==9){
      f=true;
      break;
    }
    n/=10;
  }
  if(f) cout <<"Yes"<<endl;
  else cout <<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	arr_s := strings.Split(s, "")
	arr_t := strings.Split(t, "")
	sort.Strings(arr_s)
	sort.Sort(sort.Reverse(sort.StringSlice(arr_t)))

	s = strings.Join(arr_s, "")
	t = strings.Join(arr_t, "")

	if s < t {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

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

    int n,arr[200005],k;
    vector<long long> sum;

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

    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        if(i==0)
            sum.push_back(arr[i]);
        else
            sum.push_back(sum[i-1]+arr[i]);
    }


    if(n<=k)
        cout<<0;
    else
        cout<<sum[n-k-1];
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<cmath>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> X(N), Y(N);
    rep(i, 0, N) cin >> X[i] >> Y[i];
    vector<int> idx(N);
    rep(i, 0, N) idx[i] = i;
    double sum = 0.0;
    do {
        double now_sum = 0.0;
        rep(i, 1, N) {
            now_sum += sqrt((X[idx[i]] - X[idx[i - 1]]) * (X[idx[i]] - X[idx[i - 1]]) + (Y[idx[i]] - Y[idx[i - 1]]) * (Y[idx[i]] - Y[idx[i - 1]]));
        }
        sum += now_sum;
    } while (next_permutation(all(idx)));
    double div_n = 1.0;
    rep(i, 1, N + 1) div_n *= (double)i;
    cout << fixed << setprecision(7);
    cout << sum / div_n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int compare (const void * a, const void * b) {
  return ( *(int*)a - *(int*)b );
}

int main () {

    int n, k, c = 0;
    
    scanf("%d%d", &n, &k);
    int p[n];
    
    for (int i = 0; i < n; ++i)
        scanf("%d", &p[i]);
        
    qsort (p, n, sizeof(int), compare);
    
    for (int i = 0; i < k; ++i)
        c += p[i];
        
    printf("%d\n", c);
    
    return 0;
}

Measured memory_bytes: 1748
a, b, c = map(int, raw_input().split())
# sqrt(a)+sqrt(b)<sqrt(c)
# a+2*sqrt(a*b)+b<c
# 4*a*b<(c-a-b)^2
print "Yes" if c-a-b>=0 and 4*a*b<(c-a-b)**2 else "No"


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9+7;
const ll nax = 1e4+7;
ll dp[nax][102][2];
string num;
ll d;
ll di(ll pos,ll sum,int f){
	if (pos==num.size()) {
		if (sum==0) return 1;
		return 0;
	}
	if (dp[pos][sum][f]!=-1) return dp[pos][sum][f];
	ll res=0,nf,lim;
	if (f==0) lim=(num[pos]-'0');
	else lim=9;
	for (ll i=0;i<=lim;++i){
		nf=f;
		if (i<lim) nf=1;
		res=(res+di(pos+1,(sum+i)%d,nf))%mod;
		}
	return dp[pos][sum][f]=res;
	
}
 
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>num>>d;
	ll res=(di(0,0,0)-1+mod)%mod;
	cout<<res<<"\n";
}

Measured memory_bytes: 20376
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        long N = sc.nextLong();
        long result = 0;
        for (long k = 1; k <= N; k++) {
            result += (N / k) * (1 + N / k) * k / 2;
        }
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 35848
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;



int main(){
    int N, tmp;
    vector<int> A;

    cin >> N;
    while(cin >> tmp){ 
        A.push_back(tmp);
    }
    int max, min;
    
    max = *max_element(A.begin(), A.end());
    min = *min_element(A.begin(), A.end());
    cout << abs(max - min) << endl;
    return 0;
}

Measured memory_bytes: 256
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot=1;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int deg[N],col[N],n,cnt,mx,pos;
void dfs(int u,int fa,int fc){
	int tc=1;
	go(u)if(v!=fa){
		if(tc==fc)++tc;
		col[i>>1]=tc++;
	}
	go(u)if(v!=fa)dfs(v,u,col[i>>1]);
}
int main(){
	scanf("%d",&n);
	for(R int i=1,u,v;i<n;++i){
		scanf("%d%d",&u,&v),add(u,v),add(v,u);
		++deg[u],++deg[v];
	}
	fp(i,1,n)if(cmax(mx,deg[i]))pos=i;
	printf("%d\n",mx);
	dfs(pos,0,0);
	fp(i,1,n-1)printf("%d\n",col[i]);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
#define x first
#define y second

template <typename T> struct BinaryIndexedTree {
    vector<T> data;
    BinaryIndexedTree(int sz) { data.assign(++sz, 0); }
    T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k)
            ret += data[k];
        return (ret);
    }
    void add(int k, T x) {
        for (++k; k < (int)data.size(); k += k & -k)
            data[k] += x;
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    FOR(i, 1, n + 1) { cin >> a[i]; }
    BinaryIndexedTree<int> fn(n + 1);
    vector<int> last(n + 1, -1), ans(q);
    vector<pair<int, int>> vec[n + 1];
    REP(i, q) {
        int l, r;
        cin >> l >> r;
        vec[r].emplace_back(l, i);
    }
    FOR(i, 1, n + 1) {
        fn.add(i, 1);
        if (last[a[i]] != -1) {
            fn.add(last[a[i]], -1);
        }
        last[a[i]] = i;
        int val = fn.sum(i);
        for (auto j : vec[i]) {
            ans[j.y] = val - fn.sum(j.x - 1);
        }
    }
    for (auto &x : ans) {
        cout << x << '\n';
    }
}
signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 33272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll H; cin >> H;
  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
  }
  string ans = "No";
  if (sum >= H) ans = "Yes";
  cout << ans << '\n';
  return 0;
}

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

void reader(int *x) {
	int k = getchar(); *x = k - '0';
	while (true) {
		k = getchar();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
bool b[200000], ok[100000];

void bfs(int u) {
	queue<int>que;
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		for (int v : E[p]) {
			if (d[v] == d[p] + 1 && !ok[v]) {
				ok[v] = true; cnt++; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);
	}
	queue<int>que;
	memset(d, -1, sizeof(d));
	d[0] = 0; que.push(0);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		for (int i : E[p]) {
			if (d[i] == -1) {
				d[i] = d[p] + 1; que.push(i);
			}
		}
	}
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = true;
	}
	ok[0] = true;
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] - d[u[i]] == 1) {
				E[u[i]].push_back(v[i]);
			}
		}
	}
	bfs(0);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {
			E[u[r[i]]].push_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = true;
				bfs(v[r[i]]);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 13604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> list(n);
    REP(i, n){
        cin >> list.at(i);
    };
    bool a = false;
    sort(ALL(list));
    REP(i, n-1){
        if(list.at(i)==list.at(i+1)){
            a = true;
            goto warp;
        }
    };
    warp:
    if(a){
        cout << "NO";
    }else{
        cout << "YES";
    };
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Program {

    static int Main(string[] args) {
        //List<int> list = new List<int>();

        string v = Console.ReadLine();
        //string[] vs = v.Split(' ');

        int n = int.Parse(v);

        long x = n;
        for (int i = n - 1; i >= 1; i--) {
            x = x * i;
        }
        Console.WriteLine(x);

        return 0;
    }
}



Measured memory_bytes: 9148
fn main() {
    let v: Vec<i32> = read_vec();
    println!(
        "{}",
        std::cmp::max(
            v.get(0).unwrap() * v.get(1).unwrap(),
            v.get(2).unwrap() * v.get(3).unwrap()
        )
    );
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import sys
import math

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, X, T = map(int, readline().split())
    ans = math.ceil(N/X) * T
    print(ans)



if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

const int N = (int)1e6 + 5;

int main() {
  ios :: sync_with_stdio(0);
  cin.tie(0);
  int a[5];
  for (int i = 0; i < 5; ++i) cin >> a[i];
  for (int i = 0; i < 5; ++i) {
    if (!a[i]) {
      cout << i + 1;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3596
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	string N;
	cin >> N;
	bool flag = false;
	for (char x : N) {
		if (x == '7') {
			flag = true;
			break;
		}
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int a[200005],d[200005],ans[200005],f[200005];
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        d[a[i]]=i;
    }
    for(i=n-1;i>=1;i--)
    {
        if(ans[i+1]==0)
        {
            if(d[i]>d[i+1])
            {
                ans[i]=1;
                f[i]=i+1;
            }
        }
        else
        {
            int aa=d[i],bb=d[i+1],cc=d[f[i+1]];
            if((aa<bb&&bb<cc)||(cc<aa&&aa<bb)||(bb<cc&&cc<aa))
            {
                ans[i]=ans[i+1];
                f[i]=f[i+1];
            }
            else
            {
                ans[i]=ans[i+1]+1;
                f[i]=i+1;
            }
        }
    }
    printf("%d\n",ans[1]);
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   map<int,int>mp;
   int n,m;
   cin>>n>>m;
   while(m--){
    int a,b;
    cin>>a>>b;
    mp[a]++;
    mp[b]++;
   }
   for(int i=1;i<=n;i++)
    cout<<mp[i]<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
const int D = 60;
ll to[D][200005];

signed main(){
	//cout << fixed << setprecision(10);
	vi n(3);
	rep(i,0,3)cin>>n[i];
	sort(all(n));
	rep(i,0,3){
		cout<<n[i];
		if(i!=2)cout<<" ";
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define ss second
#define ff first

 using namespace std;
 
 const ll MOD = 1000000007LL;
 
ll ar[500056],br[500056];


vector<ll> pec;
set<ll> st;
map<ll,ll> has,mark;


vector<pair<ll,ll> > vp;
ll maxi;



int main() 
{
	
//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
    
    ll n,p,t,j,a,x,y=0,k,l,m,z,b,c,e,f,q,s,flag=0,sum=0,res=0,num,g,h;
	ll i,u,v,w,ans=0,maxm=-1,r,minm=999999999999;
	bool fl=0;
	ll d;
	string str;
	
	map<ll,ll>::iterator it;
	
	c=0;
	
	cin>>n>>k;
	
	for(i=1;i<=n;i++)
	{
	cin>>ar[i];
	has[ar[i]]++;
   }
	
//	cout<<has.size()<<"\n";

	if(has.size()<=k)
	cout<<0;
	else
	{
		for(it=has.begin();it!=has.end();++it)
		pec.pb(it->ss);
		
		d=(int)(has.size())-k;
		
		sort(pec.begin(),pec.end());
		
		for(i=0;i<d;i++)
		ans+=pec[i];
		
		cout<<ans;
	}
	
    return 0;
}    




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

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<long, int>>ab(n);
  for(int i=0; i<n; i++)cin >> ab[i].first >> ab[i].second;
  sort(ab.begin(), ab.end());
  long ret=0, i=0;
  for(int i=0; i<n; i++){
    if(ab[i].second<m){
      ret+=ab[i].first*ab[i].second;
      m-=ab[i].second;
    }
    else {
      ret+=ab[i].first*m;
      break;
    }
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s,t,answer;
    cin >> s >> t;
    int sLen = s.size();
    int tLen = t.size();
    int dp[sLen+1][tLen+1];
    for (int i=0; i<=sLen; i++)
        for (int j=0; j<=tLen; j++)
            dp[i][j] = 0;

    for (int i=1; i<=sLen; i++) {
        for (int j=1; j<=tLen; j++) {
            if (s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }

    int i=sLen;
    int j=tLen;
    while (i>0 and j>0) {
        if (dp[i][j]==dp[i-1][j])
            i-=1;
        else if (dp[i][j]==dp[i][j-1])
            j-=1;
        else {
            answer=s[i-1]+answer;
            i-=1;
            j-=1;
        }
    }
    cout << answer;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	
	while(1) {
		cin1(n);
		if (n == 0) break;

		vvi dp(n,vi(n,0)); //dp[i][j] i??????j??????????????§?????°
		vi daruma(n,0);
		rep(i,0,n) {
			cin1(daruma[i]);
		}

		rep(i,1,n) {
			if (abs(daruma[i-1] - daruma[i]) <= 1) {
				dp[i-1][i] = 2;
			}
		}

		for (int i = 2; i <= n; i++) { //??????
			for (int l = 0; l < n - i + 1; l++) { //??????
				int r = l + i - 1;
				if (dp[l+1][r-1] == i - 2 and abs(daruma[l]-daruma[r]) <= 1) dp[l][r] = i; 
				for (int k = l; k < r; k++) {
					dp[l][r] = max(dp[l][r],dp[l][k] + dp[k+1][r]);	
				}
				
			}
		}

		cout(dp[0][n-1]);
	}
	return 0;
}

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

long long ans=-2000000000000000000ll;
int a,b,c,d;
vector<int> va,vb;

void checka(int x){
	if(a<=x&&x<=b) va.push_back(x);
}

void checkb(int x){
	if(c<=x&&x<=d) vb.push_back(x);
}

int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	checka(a);checka(b);checka(-1);checka(0);checka(1);
	checkb(c);checkb(d);checkb(-1);checkb(0);checkb(1);
	for(int i=0;i<va.size();i++) for(int j=0;j<vb.size();j++) ans=max(ans,1ll*va[i]*vb[j]);
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define sf scanf
#define pf printf
#define iAmSpeed ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){
    iAmSpeed;
    ll a, b, c;
    cin >> a >> b >> c;
    ll temp = a;
    a /= c;
    b /= c;
    if(temp % c == 0){
        cout << b - a + 1 << '\n';
    }
    else{
        cout << b - a << '\n';
    }
    return 0;
}


Measured memory_bytes: 3656
n = int(input())
ex = [False]*(n+1)
ex[1] = True
for i in range(2, n+1):
    v = i*i
    if v>n: break
    while(v<=n):
        ex[v]=True
        v*=i
for i in range(1, n+1)[::-1]:
    if ex[i]:
        print(i)
        break

Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define db(x) cerr << #x << " = " << x << endl;

typedef long long   ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll,  ll  > pll;

const ll   MOD       = 1000000007;
const ll   INF       = 1000000007;
const ll   N         = 1000002;
const ll   logN      = 20;
const ld   PI        = acos(-1);
const ll   HashPrime = 31;

inline void No() {
    cout << "NO\n";
}
inline void Yes() {
    cout << "YES\n";
}

#define fi first
#define se second

int n, h;
pii a[N], b[N];

void solve() {
  cin >> n >> h;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].fi >> a[i].se;
    b[i].fi = a[i].se;
    b[i].se = a[i].fi;
  }
  sort(a, a+n);
  sort(b, b+n);
  int t = a[n-1].fi;
  int ans = 0;
  for (int i = n-1; i >= 0; --i) {
    if (b[i].fi > t) {
      ans++;
      h -= b[i].fi;
    }
    if (h <= 0) {
      cout << ans << endl;
      return;
    }
  }
  cout << ans + (h+t-1)/t << endl;
}

int main() {
  ll t = 1;
//  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

ll calcNumOfCombination(ll n, ll r){
  ll num = 1;
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  map<ll, int> mp;
  rep(snip_i, n){
    cin >> v.at(snip_i);
    mp[v.at(snip_i)]++;
  }
  sort(v.begin(), v.end());
  ll sum = 0, me = -1;
  int mec = 0;
  for(int i = n-a; i < n; i++){
    sum += v.at(i);
    if(me == -1) me = v.at(i);
    if(v.at(i) == me) mec++;
  }
  double ave = (double)sum/a;
  printf("%.10f\n", ave);
  ll ans2;
  if(mec == a){
    ans2 = 0;
    rep2(i, mec, b+1){
      ans2 += calcNumOfCombination(mp[me], i);
      // cerr << ans2 << endl;
    }
  }else{
    ans2 = calcNumOfCombination(mp[me], mec);
  }
  cout << ans2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;
int n,a[maxn],b[maxn];
LL K;
bool check(LL Mid){
	LL ret=0;
	for(int i=1;i<=n;i++){
		ret+=max(0ll,a[n-i+1]-Mid/b[i]);
		if(ret>K) return 0;
	}
	return 1;
}
int main()
{
	scanf("%d%lld\n",&n,&K);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	sort(a+1,a+1+n),sort(b+1,b+1+n);
	LL l=0,r=1ll*a[n]*b[n],mid;
	while(l<r){
		mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l);
}

Measured memory_bytes: 1792
N = int(input())
P = [int(input()) for _ in range(N)]

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

for i in range(N):
    if S[P[i]-1]!=0:
        S[P[i]] = S[P[i]-1]+1
    else:
        S[P[i]] = 1
    
print(N-max(S))

Measured memory_bytes: 18856
N = int(input())
dp = [0]
for i in range(1,N+1):
    P = []
    j = 0
    while i >= 6**j:
        P.append(dp[i-6**j]+1)
        j += 1
    j = 0
    while i >= 9**j:
        P.append(dp[i-9**j]+1)
        j += 1
    dp.append(min(P))
print(dp[N])

Measured memory_bytes: 3860
n = gets.chomp.to_i
ans = 0

ary357 = ['3','5','7']

def retarys(int, ary)
  retary = []
  int.times {retary << ary}
  retary
end

2.step(8){|i|
  ans += ary357.product(*retarys(i,ary357)).count {|aa| (aa.uniq.size == 3) && (aa.inject(:+).to_i <= n)}
}
puts ans

Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long
#define MOD 1000000007

int N, M;
ll fa[500501], ifa[500501], dp[500501];

ll pw(ll a, ll n)
{
	ll ret = 1;
	while(n)
	{
		if (n&1) ret=ret*a%MOD;
		a=a*a%MOD;
		n >>= 1;
	}
	return ret;
}

ll inv(ll a)
{
	return pw(a, MOD-2);
}

ll C(ll n, ll r)
{
	return fa[n]*inv(fa[r])%MOD*inv(fa[n-r])%MOD;
}

// ll f(int n, int m)
// {
// 	if (n == 0) return 1;
// 	ll &ret = dp[n][m];
// 	if (ret != -1) return ret;
// 	ret = 0;

// 	ll a = 0, b = m-n;
// 	for(int i=1; i<=n; i++)
// 	{
// 		ret += f(n-i, m-i) * (a+b);
// 		ret %= MOD;
// 		if (i == 1) a++; // 예외 처리
// 		a *= n-i; b *= n-i;
// 		a %= MOD; b %= MOD;
// 	}
// 	return ret;
// }

int main()
{
	fa[0] = 1;
	for(int i=1; i<500501; i++)
		fa[i] = fa[i-1] * i % MOD;
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;

	dp[0] = 1; dp[1] = M-N;
	ll sum = dp[0];
	for(int i=2; i<=N; i++)
	{
		ll m = M-(N-i);
		sum *= i-1; sum += dp[i-1]; sum %= MOD;
		dp[i] = sum * (m-i+1) - dp[i-1]; dp[i] %= MOD;
	}
	ll res = dp[N];
	res *= fa[N]; res %= MOD;
	res *= C(M, N); res %= MOD;

	res %= MOD; res += MOD; res %= MOD;
	cout << res;
	return 0;
}

Measured memory_bytes: 11432
def main():
    import sys
    sys.setrecursionlimit(10 ** 9)

    input = sys.stdin.readline

    N = int(input())

    G =[[] for _ in range(N + 1)] #iさんが勝った相手のリストを要素とするリスト
    for i in range(2, N + 1):
        a = int(input())
        G[a].append(i)

    # print (G)

    def calc(x): #xからの移動先を検討
        tmp = 0
        lst = []
        for next_ in G[x]:
            y = calc(next_)
            lst.append(y)
        lst.sort()
        for i in lst:
            if tmp >= i:
                tmp += 1
            else: #tmp < i
                tmp = i
        return tmp + 1

    ans = calc(1) - 1

    print (ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 131376
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int k;
	string s;
	cin >> k >> s;
	int n = s.size();
	if (n <= k) cout << s << '\n';
	else {
		rep(i, k) cout << s[i];
		cout << "...\n";
	}
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline

def main():
    N, K = [int(x) for x in input().split()]
    S = input().strip()

    count, right, ans = 0, 1, 0
    if S[0] == '0':
        count += 1
    for i, v in enumerate(S):
        if i != 0 and S[i - 1] == '0' and S[i] == '1':
            count -= 1
        while count <= K and right < len(S):
            ans = max(ans, right - i)
            if S[right - 1] == '1' and S[right] == '0':
                count += 1
            right += 1
        if count <= K:
            ans = max(ans, right - i)

    print(ans)







if __name__ == '__main__':
    main()



Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];

        for (int i = 0; i < n; i++) {
            x[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            y[i] = scan.nextInt();
        }
        for (int p = 1; p <= 3; p++) {
            double D = 0.0;
            for (int i = 0; i < n; i++) {
                D += Math.pow(Math.abs(x[i] - y[i]), p);
            }
            System.out.println(Math.pow(D, 1.0 / p));
        }
        double infinity = 0.0;
        for (int i = 0; i < n; i++) {
            infinity = Math.max(infinity, Math.abs(x[i] - y[i]));
        }
        System.out.println(infinity);
    }
}

Measured memory_bytes: 26440
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	static final int MAXN = 10000001; 
    
    static int spf[] = new int[MAXN]; 
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
	
		sieve();
		
		int n=s.nextInt();
		
		long ans=0;
		
		for(int i=1;i<=n;i++)
		{
			HashMap<Integer,Long> map=new HashMap<>();
			
			int temp=i;
			
			while(temp>1)
			{
				
				if(map.containsKey(spf[temp]))
				{
					map.put(spf[temp],map.get(spf[temp])+1);
				}
				else
				{
					map.put(spf[temp],1l);
				}
				
				temp=temp/spf[temp];
			}
			
			long count=1;
			
			for(Map.Entry<Integer,Long> entry:map.entrySet())
			{
				count=count*(entry.getValue()+1);
			}
			
			ans=ans+(i*count);
		}
		
		System.out.println(ans);
		
	}
	
	public static void sieve() 
    { 
        spf[1] = 1; 
        for (int i=2; i<MAXN; i++) 
       
            // marking smallest prime factor for every 
            // number to be itself. 
            spf[i] = i; 
       
        // separately marking spf for every even 
        // number as 2 
        for (int i=4; i<MAXN; i+=2) 
            spf[i] = 2; 
       
        for (int i=3; i*i<MAXN; i++) 
        { 
            // checking if i is prime 
            if (spf[i] == i) 
            { 
                // marking SPF for all numbers divisible by i 
                for (int j=i*i; j<MAXN; j+=i) 
       
                    // marking spf[j] if it is not  
                    // previously marked 
                    if (spf[j]==j) 
                        spf[j] = i; 
            } 
        } 
    } 
	
}

Measured memory_bytes: 108908
#include <cstdio>
#include <algorithm>

#define sc(a) scanf("%d",&a)

int main()
{
	char temp[10];
	scanf("%s",&temp);
	if(temp[0]=='S')
	{
		printf("Cloudy\n");
	}
	else if(temp[0]=='C')
	{
		printf("Rainy\n");
	}
	else
	{
		printf("Sunny\n");
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		//define student positions
		int[] a = new int[N];
		int[] b = new int[N];
		Student[] st = new Student[N];
		for(int i = 0;i<N;i++)
			st[i] = new Student();

		for(int i=0; i<N;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			st[i].a=a[i];
			st[i].b=b[i];
		}
		//define checkpoint positions
		int[] c = new int[M];
		int[] d = new int[M];
		Chkpoint[] chkp = new Chkpoint[M];
		for(int i = 0;i<M;i++){
			chkp[i] = new Chkpoint();
			chkp[i].id = i+1;
		}
		
		for(int i = 0; i<M;i++){
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
			chkp[i].c = c[i];
			chkp[i].d = d[i];
		}
		
		for(int i=0; i<N;i++){
			int tmp1 =1000000000 ;
			int tmp2 = 0;
			for(int j=0;j<M;j++){
				 tmp2 = dist(st[i], chkp[j]);
				 if(tmp2<tmp1){
					 st[i].id=chkp[j].id;
					 tmp1=tmp2;
				 }
				
			}
			System.out.println(st[i].id);
		}
		sc.close();


	}

	
	static int dist(Student st, Chkpoint chkp){
		int d = Math.abs(st.a-chkp.c)+Math.abs(st.b-chkp.d);
		return d;
	}
	

}
	class Student{
		int id;
		int a;
		int b;
		
	}
	class Chkpoint{
		int id;
		int c;
		int d;
	}


Measured memory_bytes: 21844