akhauriyash/Code-Regression huggingface dataset:
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,l,r,m,ans,ai,aj
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    call merge_sort(a,1,n)
    ans=0
    do i=1,n-2
        ai=a(i)
        do j=i+1,n-1
            aj = a(j)
            l=j
            r=n+1

            do while (r-l > 1)
                m = (l+r)/2
                if (a(m) < ai+aj) then
                    l=m
                else
                    r=m
                end if
            end do
            ans=ans+l-j
        end do
    end do
    print'(i0)', ans
contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst,lst
        integer(int32):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst, mdl, lst
        integer(int32),allocatable:: tmp(:)
        integer(int32):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(int32),intent(inout):: x,y
        integer(int32):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program name

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

int main() {
    int n;

    cin >> n;

    if(n <= 0 || n > 999)
        return 0;

    int so = n % 10;

    if (so == 2 || so == 4 || so == 5 || so == 7 || so == 9)
    {
        cout << "hon";
    }
    else if (so == 0 || so == 1 || so == 6 || so == 8)
        cout << "pon";
    else
        cout << "bon";

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

vector<int>prime;
bool mark[N];
int res=0;
void sieve()
{
     int sq = sqrt(N);for(int i =4;i<=N;i+=2)mark[i]=true;
    for(int i=3;i<=sq;i+=2)if(!mark[i])for(ll j=i*i;j<=N;j+=2*i)mark[j]=true;
    for(int i=2;i<=N;i++)if(!mark[i])prime.push_back(i);
}
void primedivisors(ll n) {
    for(int i=0; prime[i]*1ll*prime[i]<=n; i++) {
    //  error(i,prime[i]);
        if(n%(ll)prime[i]==0ll) {
            int c=0;
            while(n%(ll)prime[i]==0ll) {
                n/=(ll)prime[i];
                ++c;
            }
            for(int k=1; ;++k){
              c-=k;
              if(c>=0)res++;
              else{
                break;
              }
            }
        }
        
    }
    if(n>1) {
      res++;
    }
}

int main()
{
    sieve();
    int t=1,te=0;
    //Int(t);
    while(t--){
        ll n;
        Int(n);
        primedivisors(n);

        printf("%d\n",res);
        //printf("Case %d: ",++te);
    }
    return 0;
}






Measured memory_bytes: 4860
#include<stdio.h>

int sum(int N, int s[]){
	int sum=0;
	int i;
	for(i=0;i<N;i++){
		sum=sum+s[i];
	}
	
	return sum;
}

int main(void){
	int N,i,min=101;
	int s[100];
	int point;
	
	scanf("%d",&N);
	
	i=0;
	
	while(i<N){
		scanf("%d",&s[i]);
		if(s[i]%10!=0 && min>s[i]){
			min=s[i];
		}
		i++;
	}        
	
	point=sum(N,s);
	
	if(point%10!=0){
		printf("%d\n",point);
	}else if(min!=101){
		printf("%d\n",point-min);
	}else{
		printf("0\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
import sys,math,collections
from collections import defaultdict

#from itertools import permutations,combinations
    
def file():
    sys.stdin = open('input.py', 'r')
    sys.stdout = open('output.py', 'w') 
def get_array():
    l=list(map(int, input().split()))
    return l
def get_ints():   
    return map(int, input().split())
    #return a,b
def get_3_ints():   
    a,b,c=map(int, input().split())
    return a,b,c    
def sod(n):
    n,c=str(n),0
    for i in n: 
        c+=int(i)
    return c    
def isPrime(n):
    if (n <= 1):
        return False
    if (n <= 3):
        return True
    if (n % 2 == 0 or n % 3 == 0):
        return False
    i = 5
    while(i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6
  
    return True
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    floor = -1
    while left <= right:
        mid = (left + right) // 2
        if A[mid] == x:
            return A[mid]
        elif x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            left = mid + 1
            
    return floor
def chk(aa,bb):
	f=0
	for i in aa:
		for j in bb:
			if(j[0]>=i[0] and j[1]<=i[1]):
				f+=1
			elif(j[0]<=i[0] and j[1]>=i[1]):	
				f+=1
			elif(i[0]==j[1] or i[1]==j[0]):
				f+=1
			else:
				continue
	return f	
def maxSumRangeQuery(nums, req):
    l=[0]*(len(nums)+1)
    nums.sort(reverse=True)
    for i in req:
        l[i[0]]+=1
        l[i[1]+1]-=1
    for i in range(1,len(l)):
        l[i]+=l[i-1]
    l=l[:-1]    
    
    d=collections.defaultdict(list)
    for i in range(len(l)):
        d[l[i]].append(i)
    di=collections.OrderedDict(sorted(d.items()))   
        #print(di)
    k=0
    ans=[0]*len(nums)
    for i in di:
        for j in di[i]:
            ans[j]=nums[len(nums)-k-1]
            k+=1
        #return ans        
    c=0
    for i in req:
        st=ans[i[0]:i[1]+1]
        c+=sum(st)
    return c%(10**9+7)
			

#file()
def main():
	c=0
	a,b=get_ints()
	while(a>0):
		a-=b
		c+=1
	print(c)	
		
#[1, 1, 1, 0]
#[1, 2, 2, 1]
#[1, 3, 2, 1]




				





		


	





        
            
        























    

    
    

        











        
        

        























































                

            







            
            
































        








if __name__ == '__main__':
    main()

Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << '\n';
    else if (S == "Cloudy") cout << "Rainy" << '\n';
    else cout << "Sunny" << '\n';
}


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

#define ll long long

int main() {
//#ifndef ONLINE_JUGDE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    int cA=0,cB=0,cC=0,cD=0;
    int n;
    cin>>n;
    while(n--){
    	string s;
    	cin>>s;
    	if(s=="AC")
    		cA++;
    	else if(s=="WA")
    		cB++;
    	else if(s=="TLE")
    		cC++;
    	else
    		cD++;
	}
	cout<<"AC"<<" "<<"x"<<" "<<cA<<"\n";
	cout<<"WA"<<" "<<"x"<<" "<<cB<<"\n";
	cout<<"TLE"<<" "<<"x"<<" "<<cC<<"\n";
	cout<<"RE"<<" "<<"x"<<" "<<cD<<"\n";
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n;cin >> n;
    vpl a(n),b(n);
    rep(i,n)cin >> a[i].fi >> a[i].se;
    rep(i,n)cin >> b[i].fi >> b[i].se;
    sort(all(a));sort(all(b));
    vl check(n,1);
    ll ans=0;
    rep(i,n){
        ll x=b[i].fi,y=b[i].se;
        ll tmp=-1,p;
        rep(j,n){
            if(a[j].fi>=x)break;
            if(!check[j])continue;
            if(a[j].se<y){
                if(chmax(tmp,a[j].se))p=j;
            }
        }
        if(tmp!=-1){
            ans++;
            check[p]=0;
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # return: articulation points, bridges
    # The graph must be connected.
    def lowlink(adj, root=1):
        N = len(adj) - 1
        order = [N + 1] * (N + 1)
        low = [N + 1] * (N + 1)
        AP = []
        bridge = []

        st = [root]
        cnt = 1
        par = [0] * (N + 1)
        seq = []
        while st:
            v = st.pop()
            if order[v] != N+1:
                continue
            order[v] = cnt
            seq.append(v)
            low[v] = cnt
            cnt += 1
            for u in adj[v]:
                if order[u] < cnt:
                    if par[v] != u:
                        low[v] = min(low[v], order[u])
                        continue
                else:
                    par[u] = v
                    st.append(u)

        child = [[] for _ in range(N + 1)]
        for v in range(1, N + 1):
            child[par[v]].append(v)

        seq.reverse()
        for v in seq:
            for u in child[v]:
                low[v] = min(low[v], low[u])

        # bridge
        for p in range(1, N+1):
            for c in child[p]:
                if order[p] < low[c]:
                    bridge.append((p, c))

        # articulation point
        for v in range(1, N + 1):
            if v == root:
                if len(child[v]) > 1:
                    AP.append(v)
            else:
                for c in child[v]:
                    if order[v] <= low[c]:
                        AP.append(v)
                        break

        return AP, bridge

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        a += 1
        b += 1
        adj[a].append(b)
        adj[b].append(a)

    AP, bridge = lowlink(adj)
    ans = []
    for u, v in bridge:
        u -= 1
        v -= 1
        if u > v:
            u, v = v, u
        ans.append((u, v))
    ans.sort(key=lambda x: x[1])
    ans.sort(key=lambda x: x[0])
    for u, v in ans:
        print(u, v)


if __name__ == '__main__':
    main()



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

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}


template<class T> class Math
{
public:
    vector<T>fact,invfact;
    Math( int n )
    {
        fact.resize(n);
        invfact.resize(n);
        fact[0] = invfact[0] = 1;
        for(int i=1;i<n;i++)
        {
            fact[i] = mod( i * fact[i-1] );
            invfact[i] = modinv( fact[i] );
        }
    }
    T modinv( T x, T m = MOD )
    {
        return expo(x,m-2,m);
    }
    T expo( T base, T exp, T m = MOD )
    {
        T res = 1;
        while( exp )
        {
            if( exp&1 )
                res = mod( res*base, m );
            base = mod( base*base, m );
            exp >>= 1;
        }
        return res;
    }
    T choose( T n, T k )
    {
        if( k < 0 || k > n ) return 0;
        T ans = fact[n];
        ans = mod( ans * invfact[n-k] );
        ans = mod( ans * invfact[k] );
        return ans;
    }
};


int main() 
{
    #ifdef gupta_samarth
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio();

    // sols of x1 + x2 + .... xn = s
    // xi >= 3

    // y1 + y2 + y3 + ... + yn = s - 3*n 
    // yi >= 0

    // 3*n <= s

    Math<ll> m(3005);

    int sum;
    cin>>sum;

    ll ans = 0;
    for(int num=1;3*num<=sum;num++)
    {
        ll now = m.choose(sum-2*num-1,num-1);
        add( ans, mod(now) );
    }
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using P = std::tuple<int,int>;
using ll = long long;

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

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

    int N, K, X, Y;
    std::cin >> N >> K >> X >> Y;
    std::cout << (std::min(N, K) * X + std::max(N-K, 0) * Y) << std::endl;
}


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

int main(){
    int n;
    cin >> n;
    n %= 10;
    if(n==2||n==4||n==5||n==7||n==9){
        cout << "hon" << endl;
    }else if(n==0||n==1||n==6||n==8){
        cout << "pon" <<endl;
    }else if(n==3){
        cout << "bon" << endl;
    }
    return 0;
}

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

int main(){
    map<string,int> memo;
    int n;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if(memo.count(s)){
            memo[s]++;
        }else{
            memo[s] = 1;
        }
    }
    int max=0;
    for(auto x :memo){
        if(x.second>max){
            max = x.second;
        }
    }

    for(auto it = memo.begin();it != memo.end();it++){
        if(it->second == max){
            cout << it->first << endl;
        }
    }
}


Measured memory_bytes: 19232
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

vector<int> divisor(int n){
    vector<int> res;
    for(int i = 1; i * i <= n; i++){
    if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }
    vector<int> d = divisor(sum);
    sort(d.rbegin(), d.rend());
    for(auto x : d){
        vector<P> b(n);
        int over = 0;
        int need = 0;
        rep(i, 0, n){
            b[i].first = a[i] % x;
            b[i].second = (x - a[i] % x) % x;
            over += b[i].first;
            need += b[i].second;
        }
        sort(b.begin(), b.end());
        int sum = 0;
        rep(i, 0, n){
            sum += b[i].first;
            need -= b[i].second + b[i].first;
            if(need <= 0){
                break;
            }
        }        
        // cout << x << ' ' << sum << endl;
        if(sum <= k){
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k;
long double ans;
int main() {
    cin>>n>>k;
    for (int i=1; i<=n; i++) {
        if (i<k) {
            int ind=i,cnt=0;
            while (ind<k) {
                ind*=2; cnt++;
            }
            //takes cnt flips of coin of heads to get >=k
            ans+=(1/(((long double)(n))*((long double)(1<<cnt))));
        }
        else ans+=(1/((long double)(n)));
    }
    cout<<fixed<<setprecision(12)<<ans<<'\n';
}

Measured memory_bytes: 3720
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n/10==9||n%10==9){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
int map[14][14];
void hoge(int x,int y) {
	map[x][y] = 0;
	if (map[x - 1][y] == 1)hoge(x - 1, y);
	if (map[x + 1][y] == 1)hoge(x + 1, y);
	if (map[x][y - 1] == 1)hoge(x, y - 1);
	if (map[x][y + 1] == 1)hoge(x, y + 1);
}
int main() {
	std::string s[12];
	int ans = 0;
	while (!std::cin.eof()) {
		for (int i = 0; i < 12; ++i)std::getline(std::cin,s[i]);
		ans = 0;
		for (int i = 1; i < 13; ++i) {
			for (int j = 1; j < 13; ++j) {
				map[i][j] = s[i - 1][j - 1]-'0';
			}
		}
		for (int i = 1; i < 13; ++i) {
			for (int j = 1; j < 13; ++j) {
				if (map[i][j] == 1) { ++ans; hoge(i,j); }
			}
		}
		std::cout << ans << std::endl;
		std::getline(std::cin, s[0]);
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;

	string result;
	for (int i = 0; i < s.size(); i++) {
		if ((i + 1) % 2 == 1) {
			result += s[i];
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 640
def main():
    n, m = map(int, input().split())
    questions = [[0, False] for _ in range(n)]
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if not questions[p][1]:
            if s == "WA":
                questions[p][0] += 1
            else:
                questions[p][1] = True
    ac = 0
    wa = 0
    for wa_num, is_accepted in questions:
        if is_accepted:
            ac += 1
            wa += wa_num
    print(ac, wa)


if __name__ == '__main__':
    main()



Measured memory_bytes: 13172
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int a,b,c;
  cin>>a>>b>>c;
  cout << min(c, b/a) << endl;

  return 0;
}


Measured memory_bytes: 256
k=int(input())
lun=[1,2,3,4,5,6,7,8,9]
for i in range(10**5+1):
    if len(lun)>=k:
        break
    di=lun[i]%10
    for j in range(max(0,di-1),min(9,di+1)+1):
        lun.append(lun[i]*10+j)
print(lun[k-1])

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int n, m;
char grid[405][405];
bool vis[405][405];
int black, white;
ll ans;

void dfs(int i, int j) {
	if (grid[i][j] == '#') black++;
	else white++;
	vis[i][j] = true;
	if (grid[i-1][j] != grid[i][j] && grid[i-1][j] != '$' && !vis[i-1][j]) dfs(i-1, j);
	if (grid[i+1][j] != grid[i][j] && grid[i+1][j] != '$' && !vis[i+1][j]) dfs(i+1, j);
	if (grid[i][j-1] != grid[i][j] && grid[i][j-1] != '$' && !vis[i][j-1]) dfs(i, j-1);
	if (grid[i][j+1] != grid[i][j] && grid[i][j+1] != '$' && !vis[i][j+1]) dfs(i, j+1);
}

int main() {
	reset(grid, '$');
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		getchar();
		for (int j = 1; j <= m; j++) {
			scanf("%c", &grid[i][j]);
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (vis[i][j]) continue;
			black = 0;
			white = 0;
			dfs(i, j);
			// printf("%d %d\n", black, white);
			ans += 1ll * black * white;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 15488
import java.util.*;

public class Main {
	static Scanner In = new Scanner(System.in);
	public static void main(String[] args) {
		while(true){
			int player = In.nextInt();
			int winner = In.nextInt();
			int per = In.nextInt();
			if(player == 0 && winner == 0 && per == 0)break;
			int sum = 0;
			int[] ticket = new int[player + 1];
			for(int i = 1; i < player + 1; i++){
				ticket[i] = In.nextInt();
				sum += ticket[i];
			}
			sum = sum * (100 - per);
			if(ticket[winner] == 0)System.out.println(0);
			else System.out.println(sum / ticket[winner]);
		}
	}

}

Measured memory_bytes: 27700
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1 = 1e5 + 5;
const int MX2 = 1e6 + 5;
const li inf = 4e18;
const li mod = 1e9 + 7;

li power(li a, li b) { li res = 1; while (b) { if (b % 2) res = (res * a) % mod;
a = (a * a) % mod; b /= 2; } return res; }

li mmi(li a) { return power(a, mod - 2); }

li cntbit(li n) { li cnt = 0; while (n) { n &= (n - 1); cnt++; } return cnt; }

void solve() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		ans += x - 1;
	}
	cout << ans;
}

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a, i; 
  int x[50];
  
  scanf("%d",&a);

  x[0]=x[1]=1;
  for(i=2;i<=a;i++)x[i]=x[i-1]+x[i-2];
  
  printf("%d\n", x[a]);

  return 0;
}



Measured memory_bytes: 2112
#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;
static const int INF (1<<30);

int main() {
  int N, x; cin >> N >> x;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];

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

    ll mod = a[i] + a[i-1] - x;
    if (mod > 0) {
      ans += mod;
      if (a[i] < mod) {
        a[i-1] -= mod - a[i];
        a[i] = 0;
      } else {
        a[i] -= mod;
      }
    }

  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	k := getNextInt64(scanner)
	aa := make([]int64, n)
	bb := make([]int64, m)
	sa := make([]int64, n+1)
	sb := make([]int64, m+1)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
		sa[i+1] = sa[i] + aa[i]
	}
	for i := 0; i < m; i++ {
		bb[i] = getNextInt64(scanner)
		sb[i+1] = sb[i] + bb[i]
	}
	var ans int
	for i := 0; i < n+1; i++ {
		l := -1
		r := m + 1
		for l+1 < r {
			c := l + (r-l)/2
			if sa[i]+sb[c] > k {
				r = c
				continue
			}
			l = c
		}
		if l == -1 {
			continue
		}
		if ans < i+l {
			ans = i + l
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 15088
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

N = int(input())

ans = [0] * (10**5)

for i, j, k in product(list(range(1, 101)), repeat=3):
    tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
    ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 9800
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c)
  {
    Yes
  }
  else
  {
    No
  }

}
return 0;
}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    k = int(input())
    queue = list(range(1, 10))
    cnt = 0
    for v in queue:
        cnt += 1
        if k == cnt:
            print(v)
            return
        r = v % 10
        for d in range(r - 1, r + 2):
            if 0 <= d <= 9:
                queue.append(v * 10 + d)
resolve()

Measured memory_bytes: 91052
program arc068
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,cnt(1:100000),i
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    cnt(:) = 0
    do i=1,n
        cnt(a(i))=cnt(a(i))+1
    end do
    where (cnt > 0)
        cnt=cnt-1
    end where
    ! print'(*(i0,1x))', cnt(1:50)
    ! print'(i0)', sum(cnt(:))

    print'(i0)', n - 2*((sum(cnt))/2 + mod(sum(cnt),2))
end program arc068

Measured memory_bytes: 1536
X, Y = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod):
    X = 1
    Y = 1
    for i in range(1,r+1):
        X = (X*(n-i+1))%mod
        Y = (Y*i)%mod
    return (X*pow(Y, mod-2, mod))%mod

if (X+Y)%3 != 0 :
    print(0)
elif X < (X+Y)//3 or Y < (X+Y)//3 :
    print(0)
else :
    i = X - (X+Y)//3
    print(comb((X+Y)//3, i, mod))


Measured memory_bytes: 38512
#include<iostream>
#include<vector>
#include<cassert>
#include<set>
using namespace std;
static const int MAX = 100;

vector<int> G[MAX+1];
vector<int> R[MAX+1];
vector<int> ans;
bool V[MAX+1];
int W[MAX+1];

int N, M, cnt;

void dfs(int u){
  V[u] = true;
  cnt++;

  for ( int i = 0; i < G[u].size(); i++ ){
    int v = G[u][i];
    if ( !V[v] ) dfs(v);
  }
  ans.push_back(u);
}

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

  for ( int i = 1; i <= N; i++ ) {
    V[i] = false;
    W[i] = -1;
  }

  int s, t;
  for ( int i = 0; i < M; i++ ){
    cin >> s >> t;
    W[s] = t;
    G[t].push_back(s);
    R[s].push_back(t);
  }

  cnt = 0;
  dfs(2);
  for ( int i = 0; i < N; i++ ) cout << ans[i] << endl;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  int count1=2;
  int count2=1;
  for(int i=0;i<3;i++){
    cin>>a;
    if(a==7){
      count2--;
    }else if(a==5){
      count1--;
    }}
  if(count1==0&&count2==0){
    cout<<"YES"<<"\n";
  }
  else{
    cout<<"NO"<<"\n";
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
	string s;
	cin >> k >> s;
	int p=s.size();
	string y;
	if(k>=p){
		cout << s << endl;
	}
	else{
		for (int i = 0; i < k; ++i)
		{
			cout << s.at(i);
			if(i==k-1){
			    cout <<  "...";
			}
		}
		
	}

}

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

using namespace std;
using ll = long long;
int main() {
	ll n, k, ans = 1;
	const ll mod = 7 + 1e9;
	cin >> n >> k;
	vector<int> s(n + 2);
	rep (i, n + 1) s[i + 1] = (s[i] + i + 1) % mod;;
	for (int i = k; i <= n; i++) {
		ans = (ans + 1 + s[n] - s[n - i] - s[i - 1]) % mod;
	}
	if (ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4052
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b,gyo0=0,gyo1=0,re0=0,re1=0,h,w,count;
    string s;
    cin>>s;
    rep(i,19){
        if(i==5 || i==13){
            cout<<' ';
        }
        else{
            cout<<s[i];
        }
    }
    cout<<'\n';
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M,SUM;
  cin >> N >> M;
  SUM=0;
  vector<int> a(M);
    for (int i = 0 ;i<M;i++){
      cin >> a.at(i);
      SUM=SUM+a.at(i);
    }
    if(SUM>N){
      cout << -1 << endl;
    }
    else {
      cout << N-SUM << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int const MAX_N = 5005;
int const MAX_S = 5005;

bool dp[MAX_N][MAX_S];
int n,k;
vector<int> a;
bool need(int x) {
    Fill(dp, false);
    dp[0][0] = 1;
    rep(i,n) {
        rep(j,k) {
            if(!dp[i][j]) continue;
            dp[i+1][j] = 1;
            if(i == x) continue;
            if(j + a[i] < k) dp[i+1][j + a[i]] = 1;
        }
    }
    bool ok = false;
    rep(j,k) if(dp[n][j] && j + a[x] >= k) ok = true;
    return ok;
}


int main()
{
    cin >> n >> k;
    a.resize(n);
    rep(i,n) {
        cin >> a[i];
        chmin(a[i],k);
    }
    sort(a.begin(),a.end());

    int l = -1, r = n;
    while(r - l > 1) {
        int mid = (l + r)/2;
        if(need(mid)) r = mid;
        else l = mid;
    }

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 28072
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int N=105;
int h[N][2],n,rd[N],h2[N][2],mrk[N],T,Ans,tag[N];
vector<int> w1[N],w2[N];
struct graph{
	int t,w[N],ne[N],la[N],rd[N];
	void link(int x,int y){
		w[++t]=y;
		ne[t]=la[x];
		la[x]=t;
		rd[y]++;
	}
	void clear(){
		for (int i=1;i<=n;i++)la[i]=rd[i]=0;
		t=0;
	}
	int go(){
		vector<int> d;
		for (int i=1;i<=n;i++)
			if (!rd[i])d.push_back(i);
		for (int i=0;i<d.size();i++){
			int x=d[i];
			for (int y=la[x];y;y=ne[y]){
				int z=w[y];
				if (!--rd[z])d.push_back(z);
			}
		}
		clear();
		return d.size()==n;
	}
}G;
void dfs(int x,int fa,vector<int> *w,int rev){
	if (!tag[x]&&!tag[fa]){
		if (!rev)G.link(x,fa);
		else G.link(fa,x);
	}
	for (int z:w[x])
		if (z!=fa)dfs(z,x,w,rev);
}
void check(int x,int ans){
	static int d[N],l,r;
	for (int i=1;i<=n;i++)mrk[i]=tag[i]=0,w1[i].clear(),w2[i].clear();
	l=0,r=1;d[1]=x;
	for (int i=1;i<n;i++){
		int x=h[i][0],y=h[i][1];
		w1[x].push_back(y);
		w1[y].push_back(x);
		x=h2[i][0],y=h2[i][1];
		w2[x].push_back(y);
		w2[y].push_back(x);
	}tag[x]=1;
	while (l<r){
		int x=d[++l];
		for (auto z:w1[x])
			if (!tag[z])mrk[z]=x;
		for (auto z:w2[x])
			if (mrk[z]==x)d[++r]=z,tag[z]=1;
	}
	ans-=r;
	dfs(x,0,w1,0);
	dfs(x,0,w2,1);
	if (G.go())Ans=min(Ans,ans);
}
int main(){
	for (cin>>T;T--;){
		cin>>n;
		Ans=n+1;
		for (int i=1;i<=n;i++)rd[i]=0;
		for (int i=1;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			h[i][0]=x,h[i][1]=y;
			rd[x]++,rd[y]++;
		}
		for (int i=1;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			h2[i][0]=x,h2[i][1]=y;
		}
		for (int i=1;i<=n;i++){
			if (rd[i]!=1){
				check(i,n);
				continue;
			}
			int z=0,q=0,x;
			for (int j=1;j<n;j++)
				if (h[j][0]==i||h[j][1]==i)z=j,q=h[j][0]==i;
			for (int j=1;j<=n;j++){
				if (i==j)continue;
				x=h[z][q];
				h[z][q]=j;
				check(i,(x!=j)+n);
				h[z][q]=x;
			}
		}
		cout<<(Ans>n?-1:Ans)<<endl;
	}
}

Measured memory_bytes: 256
import math

(a,b,c)=  map(int,input().split())

h = math.sin(math.radians(c)) * b
L = a + b +math.sqrt(a*a+b*b-(2*a*b*math.cos(math.radians(c))))
S = h * a / 2
print (S)
print (L)
print (h)



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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C>>D;
  while(1){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<int>>p(N,vector<int>(2));
  for(int i=0;i<M;i++){
    int a;
    string S;
    cin>>a>>S;
    if(p.at(a-1).at(0)==0&&S=="WA"){
      p.at(a-1).at(1)++;
    }
    else if(p.at(a-1).at(0)==0&&S=="AC"){
      p.at(a-1).at(0)++;
    }
  }
  int A=0,Z=0;
  for(int i=0;i<N;i++){
    if(p.at(i).at(0)==1){
      A+=p.at(i).at(0);
      Z+=p.at(i).at(1);
    }
  }
  cout<<A<<" "<<Z<<endl;
    
}

Measured memory_bytes: 5760
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

    public static void main(String[] arg) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        String revLine;
        while ((line = in.readLine()) != null) {
            revLine = "";
            for (int i = line.length() - 1; i >= 0; i--) {
                revLine = revLine + line.charAt(i);
            }
            System.out.println(revLine);
        }
    }

}

Measured memory_bytes: 15016
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

bool check(long long val, long long lb, long long ub, vector<long long> &a) {
    for (int i = 0; i < a.size(); i++) {
        int t = a[i];
        val = (val / t) * t;
    }
    return lb <= val && val <= ub;
}



int main() {
    int k;
    cin >> k;
    vector<long long> a(k);
    for (int i = 0; i < k; i++) {
        cin >> a[i];
    }
    long long lb = 0, ub = 1000000000000000;
    while (ub - lb > 1) {
        long long half = (lb + ub) / 2;
        if (check(half, 0, 2, a))
            lb = half;
        else
            ub = half;
    }
    if (!check(lb, 2, 2, a)) {
        cout << -1 << endl;
    }
    else {
        long long ans_ub = lb;
        ub = lb, lb = 0;
        while (ub - lb > 1) {
            long long half = (lb + ub) / 2;
            if (check(half, 2, 2, a))
                ub = half;
            else
                lb = half;
        }
        long long ans_lb = ub;
        cout << ans_lb << " " << ans_ub << endl;
    }


    return 0;
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    path = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, readline().rstrip().split())
        path[a-1].append(b-1)
        path[b-1].append(a-1)
    for i in range(N):
        print(len(path[i]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(unused_macros)]
// use proconio::input;
use std::cmp::Ordering::*;
use std::collections::{BTreeMap, BTreeSet};
use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

macro_rules! answer {
    ($out:ident, $ans:expr) => {
        writeln!($out, "{}", $ans)
    };
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let n: usize = scan.token();
    let k: usize = scan.token();
    let mut a: Vec<_> = (0..n).map(|_| scan.token::<i32>()).collect();
    a.sort();


    answer!(out, a.into_iter().take(k).sum::<i32>())
}

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

/// Mostly copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse [Scanner]");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

// aka #![feature(bool_to_option)]
trait BoolThen {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T>;
}

impl BoolThen for bool {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T> {
        if self {
            Some(f())
        } else {
            None
        }
    }
}

trait BoolToYes {
    fn yes(self) -> &'static str;
}

impl BoolToYes for bool {
    fn yes(self) -> &'static str {
        if self {
            "YES"
        } else {
            "NO"
        }
    }
}


Measured memory_bytes: 2180
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			HashMap<Integer, Integer> map = new HashMap<>();
			for(int i =0; i < n; i++){
				data[i] = sc.nextInt();
				if(map.containsKey(data[i])){
					map.put(data[i], map.get(data[i]) + 1);
				}
				else{
					map.put(data[i], 1);
				}
			}
			int sum = 0;
			for(int key: map.keySet()){
				int value = map.get(key);
				if(value >= key){
					sum += value - key;
				}
				else{
					sum += value;
				}
			}
			System.out.println(sum);
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 64560
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll k; cin>>k;

    vector<ll> ans;
    queue<ll> q;
    for (int i = 1; i < 10; ++i) q.push(i);

    while (ans.size() < k) {
        ll cur = q.front(); q.pop();
        ans.push_back(cur);
        ll yo = cur%10;
        for (ll i = max(0ll, yo-1ll); i <= min(9ll,yo+1ll); ++i) {
            ll next = cur*10+i;
            q.push(next);
        }
    }

    sort(ans.begin(), ans.end());
    cout << ans[k-1] << '\n';

    return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

int x, y;
int f[505];

int main() {
  //assert(freopen("input.txt","r",stdin));
  //assert(freopen("output.txt","w",stdout));

  cin >> x >> y;
  int ans = 0;

  f[1] = 300000;
  f[2] = 200000;
  f[3] = 100000;

  if (x == y && x == 1) {
    ans = f[1] * 2 + 400000;
  } else {
    ans = f[x] + f[y];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100 * 10000 + 47;


int W[MAX];
bool U[MAX];
int X[MAX];

int main()
{
    
    //freopen("in.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    
    int n;
    cin >> n;
    string S, T;
    cin >> S >> T;
    int idx = n - 1;
    FILL(W, -1);
    RFOR(i, n, 0)
    {
        while(idx >= 0 && (idx > i || S[idx] != T[i]))--idx;
        W[i] = idx;
        U[idx] = 1;
        X[idx] = max(X[idx], i);
    }
    
    if (S == T)
    {
        cout << 0 << endl;
        return 0;
    }
    
    FOR(i, 0, n)
        if (W[i] == -1)
        {
            cout << -1 << endl;
            return 0;
        }
    
    vector<PII> V;
    
    FOR(i, 0, n)
        if (U[i])V.PB(MP(i, X[i]));
    
    int ans = 0;
    
    FOR(i, 0, SZ(V))
    {
        int L = i, R = SZ(V);
        while(R - L > 1)
        {
            int M = (R + L) / 2;
            if (V[M].first + i >= V[i].second + M)
                R = M;
            else L = M;
        }
        ans = max(ans, R - i);
    }
    cout << ans << endl;
    
    
}





Measured memory_bytes: 21756