akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

//C問題
public class Main {
	public static void main(String[] args) {

		//レートで区分をわける
		//
		int rate[] = new int[10];

		//配列を0で初期化
		for(int cnt = 0;cnt < 10; cnt++) {
			rate[cnt] = 0;
		}

		//スキャナーを宣言する
	    Scanner sc = new Scanner(System.in);

	    //入力を受け取る
	    int N = Integer.parseInt(sc.next());
	    int a;

	    for(int cnt = 0; cnt < N; cnt++) {
	    	a = Integer.parseInt(sc.next());
	    	//レートで区分分け
	    	if((1 <= a)&&(a <= 399)){
	    		rate[0] = 1;
	    	}
	    	else if((400 <= a)&&(a <= 799)){
	    		rate[1] = 1;
	    	}
	    	else if((800 <= a)&&(a <= 1199)){
	    		rate[2] = 1;
	    	}
	    	else if((1200 <= a)&&(a <= 1599)){
	    		rate[3] = 1;
	    	}
	    	else if((1600 <= a)&&(a <= 1999)){
	    		rate[4] = 1;
	    	}
	    	else if((2000 <= a)&&(a <= 2399)){
	    		rate[5] = 1;
	    	}
	    	else if((2400 <= a)&&(a <= 2799)){
	    		rate[6] = 1;
	    	}
	    	else if((2800 <= a)&&(a <= 3199)){
	    		rate[7] = 1;
	    	}
	    	else if((3200 <= a)&&(a <= 4800)){
	    		rate[8] = rate[8] + 1;
	    	}
	    }

	    //スキャナーを閉じる
	    sc.close();
	    //色の合計
	    int sum = 0;

	    for (int cnt = 0;cnt < 10; cnt++) {
	    	sum = sum + rate[cnt];
	    }

	    //出力
	    //最小値
	    if((sum-rate[8]) == 0) {
	    	//sumが0の時
	    	System.out.print((sum-rate[8] + 1));
	    }
	    else {
	    	System.out.print((sum-rate[8]));
	    }

	    //最大値
	    System.out.print(" "+sum);
	}
}


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

int main(){
    
    double a,b,c,d,e,f,x,y;
    
    while(cin>>a>>b>>c>>d>>e>>f){
        
        y=(d*c-a*f)/(d*b-a*e);
        x=(e*c-b*f)/(e*a-b*d);
        
        if(x==-0)x=0;
        if(y==-0)y=0;
        cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
    }
}

Measured memory_bytes: 3240
#include<stdio.h>
int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if(abs(a-c)<=d) printf("Yes\n");
    else if(abs(a-b)<=d && abs(b-c)<=d) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 1616
import sys

iT = int(input())
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]

def fGcd(iX,iY):
    while iY:
        iX,iY= iY,iX%iY
    return iX

def fFunc(iA,iB,iC,iD):
    ig = fGcd(iB,iD)
    if iA < iB or iD < iB:
        return False
    elif iC >= iB :
        return True
    elif iC < iA % iB :
        return False

# これでも通る
    elif iB <= ig + iC :
# AtCoder の解法
#   elif iB <= iC +ig - iA % ig  :
        return True
    else:
        return False

for eR in aR:
    if fFunc(*eR) :
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  ll h,w;
  cin >> h >> w;
  vector<ll> a(3);
  
  ll ans = 1LL << 60;
  
  for(int i = 1; i <= h;i++){
    a[0] = i * w;
    a[1] = (h-i) * (w / 2);
    a[2] = h*w - a[0] - a[1];
    //printf("i=%d,(%lld,%lld,%lld)",i,a[0],a[1],a[2]);
    sort(a.begin(),a.end());
    chmin(ans, abs(a[2] - a[0]));
    //printf(" ans=%lld\n",ans);
  }

  for(int i = 1; i <= h;i++){
    a[0] = i * w;
    a[1] = (h-i)/2 * w;
    a[2] = h*w - a[0] - a[1];
    //printf("i=%d,(%lld,%lld,%lld)",i,a[0],a[1],a[2]);
    sort(a.begin(),a.end());
    chmin(ans, abs(a[2] - a[0]));
    //printf(" ans=%lld\n",ans);
  }
  
  for(int i = 1; i <= w;i++){
    a[0] = i * h;
    a[1] = (w-i) * (h / 2);
    a[2] = w*h - a[0] - a[1];
    //printf("i=%d,(%lld,%lld,%lld)",i,a[0],a[1],a[2]);
    sort(a.begin(),a.end());
    chmin(ans, abs(a[2] - a[0]));
    //printf(" ans=%lld\n",ans);
  }
  for(int i = 1; i <= w;i++){
    a[0] = i * h;
    a[1] = (w-i)/2 * h;
    a[2] = w*h - a[0] - a[1];
    //printf("i=%d,(%lld,%lld,%lld)",i,a[0],a[1],a[2]);
    sort(a.begin(),a.end());
    chmin(ans, abs(a[2] - a[0]));
    //printf(" ans=%lld\n",ans);
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

char *dic = "abcdefghijklmnopqrstuvwxyz.?! ";

int main() {
	for(string line; cin >> line;) {
		if(line.length() & 1) {
			cout << "NA" << endl;
			continue;
		}
		bool ok = true;
		int n = line.length();
		for(int i = 0; i < n; i += 2) {
			int c = line[i] - '0';
			if(c > 6 || c == 0) ok = false;
			c = line[i + 1] - '0';
			if(c > 5 || c == 0) ok = false;
		}
		if(!ok) {
			cout << "NA" << endl;
			continue;
		}
		for(int i = 0; i < n; i += 2) {
			cout << dic[5 * (line[i] - '0' - 1) + (line[i + 1] - '0' - 1)];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;

ll gcd(ll a, ll b) {
    if (a%b == 0) return b;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a*b/gcd(a,b);
}

int main() {
    ll A,B; cin >> A >> B;
    cout << lcm(A,B) << endl;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long p = sc.nextLong();

        long ans = 1;
        if(n == 1){
            System.out.println(p);
            return;
        }
        for (long i = 2; Math.pow(i, n) <= p; i++) {
            long x = p;
            long cnt = 0;
            while (x % i == 0) {
                x /= i;
                cnt++;
                if (cnt >= n) {
                    ans = Math.max(ans, i);
                    break;
                }
            }
            if (cnt >= n) {
                ans = Math.max(ans, i);
            } else {
                ans = Math.max(ans, 1);
            }
        }
        System.out.println(ans);
    }
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

const int MOD=1e9+7;
vll modfac(2020,1);

ll modpow(ll m,ll n,ll p) {
  if(n==0) return 1;
  ll res=modpow(m,n/2,p);
  if(n%2==0) res=(res*res)%p;
  else res=(((res*res)%p)*m)%p;
  return res;
}

int main() {
  ll S; cin>>S;
  ll ans=0;
  for(int i=1;i<=2020;i++) {
    modfac[i]=modfac[i-1]*i%MOD;
  }

  for(ll i=1;3*i<=S;i++) {
    ans+=((modfac[S-3*i+i-1]*modpow(modfac[S-3*i],MOD-2,MOD))%MOD*modpow(modfac[i-1],MOD-2,MOD))%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


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

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

    int N; cin >> N;
    for (int i = 1; i <= 9; i++) {
        if (N <= 111 * i) {
            cout << 111 * i << "\n";
            break;
        }
    }
}

Measured memory_bytes: 256
from sys import stdin

class SegmentTree:
    # 初期化処理
    # f : SegmentTreeにのせるモノイド
    # default : fに対する単位元
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
        self.default = default
        self.dat = [default]*(self.size*2) # 要素を単位元で初期化
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res
def bc(x):
    return bin(x).count("1")

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
q = int(stdin.readline().rstrip())

lamb_or = lambda x,y : x|y
seg = SegmentTree(n,lamb_or,0)

for i,x in enumerate(s):
    seg.update(i,1 << ord(x)-97)

for _ in range(q):
    c,x,y = [x for x in stdin.readline().rstrip().split()]
    if c == '1':
        x = int(x)
        seg.update(x-1,1 << ord(y)-97)
    elif c == '2':
        x = int(x)
        y = int(y)
        print(bc(seg.query(x-1,y)))


Measured memory_bytes: 70472
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
6
)");
#define cin input
#endif

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

	cout << n * (n - 1) / 2 - n / 2 << endl;

	REP (i, n)
		REP (j, i)
			if (i + j + 2 != n / 2 * 2 + 1)
				cout << i + 1 << ' ' << j + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
def mode_value(arr)
  n, mv = 0, []
  
  100.times do |i|
    if n < arr[i]
      n, mv = arr[i], [i + 1]
    elsif n == arr[i]
      mv << i + 1
    end
  end
  
  return mv
end

arr = Array.new(100, 0)

arr[$_.to_i - 1] += 1 while gets

puts mode_value(arr)

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

int main() {
  int N , i , n;
  cin >> N ;
  
  for (i = 1; i <= N; i++){
    if (i < 10) n++;
  	if (i >= 100 && i < 1000) n++;
  	if (i >= 10000 && i < 100000) n++;
  }

cout << n << endl ;
}

Measured memory_bytes: 256
import sys
N,A,B=map(int, raw_input().split()) 
H=[ int(sys.stdin.readline()) for i in range(N) ] 

def func(n , T):
	sa=A-B
	k=0
	for x in T:
		x-=n*B
		if x>0:
			if x%sa==0:
				k+=x/sa
			else:
				k+=(x/sa+1)
		
			if n<k:
				return False
	else:
			return True

l=0
r=max(H)/B+1
while l!=r:
	m=(r+l)/2
	if func(m,H):
		r=m
	else:
		l=m+1
	#print l,r,m,func(m,H)

print l



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


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    goukei = sum(A)/(4*M)

    ans = [_a for _a in A if _a >= goukei]

    if len(ans) >= M:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 2e5+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int to[maxn<<1],net[maxn<<1],h[maxn],e=1;
inline void add(int x,int y){
	to[++e]=y;net[e]=h[x];h[x]=e;
}

int k,m,n;
int fa[maxn],ans[maxn],a[maxn],vis[maxn],st[maxn],top=0;
void dfs(int x){
	int flag=0,p;
	p=lower_bound(st,st+n,a[x])-st;
	flag=st[p];
	st[p]=a[x];
	ans[x]=lower_bound(st,st+n,2e9)-st;
	for(register int i=h[x];i;i=net[i]){
		int y=to[i];
		if(y==fa[x])continue;
		fa[y]=x;
		dfs(y);
	}
	st[p]=flag;
	return;
}

int main(){
	n=read();
	for(register int i=0;i<=n;i++)st[i]=2e9+10;
	for(register int i=1;i<=n;i++)a[i]=read();
	for(register int i=1;i<n;i++){int x=read(),y=read();add(x,y);add(y,x);}
	dfs(1);
	for(register int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 25076
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

ten = {'r':p, 's':r, 'p':s}
ans = 0
add = []
for i in range(n):
    if i + 1 > k and t[i - k] == t[i] and add[i - k]:
        add.append(False)
    else:
        ans += ten[t[i]]
        add.append(True)
print(ans)


Measured memory_bytes: 4212
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    cin>>n;
    int count_AC=0,count_WA=0,count_TLE=0, count_RE=0;
    while(n--){
        
        string s;
        cin>>s;
        
        if(s=="AC")count_AC++;
        else if(s=="WA")count_WA++;
       else if(s=="TLE")count_TLE++;
       else if(s=="RE")count_RE++;
    }
    cout<<"AC x "<<count_AC<<"\n";
     cout<<"WA x "<<count_WA<<"\n";
      cout<<"TLE x "<<count_TLE<<"\n";
       cout<<"RE x "<<count_RE<<"\n";
}

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

int main(){
  int N;
  int K;
  cin>>N>>K;
  double p[N];
  for (int i=0;i<N;i++){
    double temp=i+1;
    int j=0;
    while (temp<K){
      temp=temp*2;
      j++;
    }
    p[i]=pow(2,j);
  }
  double ans=0;
  for (int i=0;i<N;i++){
    ans=ans+1/p[i];
  }
  ans=ans/N;
  cout<<(setprecision(10))<<ans<<endl;
  return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int fastpow(int x,int a){
	if(a<=0) return 1;
	int ret=1;
	while(a){
		if(a&1) ret=ret*1LL*x%mod;
		x=x*1LL*x%mod;a>>=1;
	}
	return ret;
}
int dp[2][2005];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int now=0;
	dp[now][1]=1;
	for(int i=2;i<=n;i++){
		memset(dp[now^1],0,sizeof(dp[0]));
		for(int j=1;j<=i;j++)
			dp[now^1][j]=(dp[now][j]+dp[now^1][j-1])%mod;
		now^=1;
	}
	cout<<dp[now][k]*1LL*fastpow(2,n-k-1)%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

typedef struct{
    int num;
    int p;
    int y;
    char str[20];
}group_t;


int asc_p(const void *a,const void *b){return ((group_t*)a)->p - ((group_t*)b)->p;}
int asc_y(const void *a,const void *b){return ((group_t*)a)->y - ((group_t*)b)->y;}
int asc_num(const void *a,const void *b){return ((group_t*)a)->num - ((group_t*)b)->num;}
//int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}


int main(){
    int n,m;
    group_t gp[200000];

    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d %d",&gp[i].p,&gp[i].y);
        gp[i].num=i;
    }
    //qsort(gp,m,sizeof(group_t),asc_p);
    qsort(gp,m,sizeof(group_t),asc_y);

    for(int i=0;i<m;i++){
        //printf("%d %d\n",gp[i].p,gp[i].y);
    }

    int cnt[200000]={};
    for(int i=0;i<m;i++){
        sprintf(gp[i].str,"%06d%06d",gp[i].p,++cnt[gp[i].p-1]);
    }

    qsort(gp,m,sizeof(group_t),asc_num);
    for(int i=0;i<m;i++){
        printf("%s\n",gp[i].str);
    }
    return 0;
}

Measured memory_bytes: 10192
/*  Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e5+10;

int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
double a[N];
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    double sum=0.0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=(double)(1/a[i]);
    }

    double k=(1/sum);
    cout<<fixed<<setprecision(12)<<k<<endl;


}

Measured memory_bytes: 256
# coding: utf-8

def linear_search(key, A):
    for i, v in enumerate(A):
        if v == key:
            # print(v, key)
            return i
    return 'Not Found'

def linear_search_sentinel(key, A):
    i = 0
    n = len(A)
    A.append(key)
    while A[i] != key:
        i += 1
    if i == n:
        return 'Not Found'
    return i


if __name__ == "__main__":
    # n = 10
    # S = list(map(int, '5 6 7 8 9 10 1 2 3 4'.split()))
    # q = 7
    # T = list(map(int, '100 11 5 6 1 12 33'.split()))
    n = int(input())
    S = list(map(int, input().strip().split()))
    q = int(input())
    T = list(map(int, input().strip().split()))


    c = 0
    for k in T:
        if linear_search(k, S) != 'Not Found':
            c += 1
    print(c)


Measured memory_bytes: 6552
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) {cout<<n<<"\n" ; return ;}
#define po(n) cout << n <<"\n " 
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#ifndef ONLINE_JUDGE
//#ifndef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#else
//#define debug(x...)
//#endif
//#define int ll 
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
long const M=1e9+7;
const long mxN =1e5+2 ;
const ll INF =1e18;
void solve(){ 
  int n,k; cin>> n >> k;
  vi v(n) ;
  For(i,n)cin >> v[i] ;
  sort(all(v));
  int ans =0 ;
  For(i,k)
    ans+=v[i] ;
  cout << ans << endl ;
  
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  // ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}


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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	ll N; cin >> N;
	cout << (N * (N - 1)) / 2 << endl;
	return 0;
}

Measured memory_bytes: 3636
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;


     string str;

   bool flag=true;


         cin>>n;

         cin>>str;

           i=0;

          while(i<n && str[i]=='R')i++;

          while(i<n && str[i]=='W')i++;

          if(i==n)cout<<0<<endl;

          else
          {
              ll i=0;
              ll j=n-1;

              while(i<j)
              {
                  if(str[j]=='W')
                  {
                      j--;
                  }
                  else if(str[i]=='R')i++;

                  else
                  {
                      i++;
                      j--;
                      cnt++;
                  }
              }

              cout<<cnt<<endl;
          }


}


Measured memory_bytes: 3768
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }
        int[] a = new int[n];
        a[0] = 0; a[1] = Math.abs(h[1] - h[0]);
        for(int i = 2; i < n; i++){
            a[i] = Math.min(a[i-2] + Math.abs(h[i] - h[i-2]), a[i-1] + Math.abs(h[i] - h[i-1]));
        }
        System.out.println(a[n-1]);
    }
}

Measured memory_bytes: 49876
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash() {
    ll n;
    cin>>n;
    ll a[n];
    for (ll i = 0; i < n; i++) {
        cin>>a[i];
    }
    ll currMoney = 1000;
    ll currStocks;
    ll ans = 1000;
    for (ll i = 0; i < n - 1; i++) {
        if (a[i + 1] > a[i]) {
            currStocks = (currMoney / a[i]);
            currMoney = (currMoney % a[i]);

            currMoney += (currStocks * a[i + 1]);
            currStocks = 0;
        }
    }
    ans = max(ans, currMoney);
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int a,b,c,d;
signed main(){
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    int ans=-LLINF;
    ans=max(b*c,max(a*d,max(a*c,b*d)));
    printf("%lld\n",ans);
}

Measured memory_bytes: 1732
from sys import stdin

class Dice:
    def __init__(self, nums):
        self.labels = {
            "1" : nums[0],
            "2" : nums[1],
            "3" : nums[2],
            "4" : nums[3],
            "5" : nums[4],
            "6" : nums[5]
        }
        self.pos = {
            "E" : "3",
            "W" : "4",
            "S" : "2",
            "N" : "5",
            "T" : "1",
            "B" : "6"
        }

    def roll(self, query):
        for q in query:
            if q == "E":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["W"], self.pos["T"], self.pos["E"], self.pos["B"]
            elif q == "W":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["E"], self.pos["B"], self.pos["W"], self.pos["T"]
            elif q == "S":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["N"], self.pos["T"], self.pos["S"], self.pos["B"]
            elif q == "N":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["S"], self.pos["B"], self.pos["N"], self.pos["T"]

nums = [int(x) for x in stdin.readline().rstrip().split()]
queries = stdin.readline().rstrip()
d = Dice(nums)
d.roll(queries)
print(d.labels[d.pos["T"]])


Measured memory_bytes: 5620
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
		
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int k=sc.nextInt();
		int x[]=new int[100];
		int c=Math.min(a,b);
		int i=0;
		while(true) {
			if(a%c==0&&b%c==0) {
				x[i]=c;
				
				if(i==k-1) {
					break;
				}
				i++;
				
			}
			c--;
		}
		System.out.println(x[k-1]);
	}

	
	
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}


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

int n, m;   char vec[2002][2002]={'0'};
int ans1[2002][2002]={0}, ans2[2002][2002]={0}, ans3[2002][2002]={0};

void calc(){
    for(int i=1;n>=i;i++){
        for(int j=1;m>=j;j++){
            (vec[i][j]=='1' and vec[i][j-1]=='1') ? ans1[i][j]=ans1[i][j-1]+1 : ans1[i][j]=ans1[i][j-1];
        }
    }

    for(int j=1;m>=j;j++){
        //ans2[0][j]=(vec[0][j]=='1');
        for(int i=1;n>=i;i++){
            (vec[i][j]=='1' and vec[i-1][j]=='1')  ? ans2[i][j]=ans2[i-1][j]+1 : ans2[i][j]=ans2[i-1][j];
        }
    }

    for(int i=1;n>=i;i++){
        for(int j=1;m>=j;j++){
            vec[i][j]=='1' ? ans3[i][j]=ans3[i][j-1]+1 : ans3[i][j]=ans3[i][j-1];
        }
    }
}

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int q;  cin >> n >> m >> q;
    for(int i=1;n>=i;i++){
        for(int j=1;m>=j;j++){
            cin >> vec[i][j];
        }
    }
    calc();
    for(int i=0;q>i;i++){
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        int res1=0, res2=0, res3=0;
        for(int j=x1;x2>=j;j++){
            res1+=ans1[j][y2]-ans1[j][y1];
            res3+=ans3[j][y2]-ans3[j][y1-1];
        }
        for(int j=y1;y2>=j;j++){
            res2+=ans2[x2][j]-ans2[x1][j];
        }
        cout << res3-res2-res1 << "\n";
        //cout << res1 << " " << res2 << " " << res3 << "\n";
    }
}

/*
    for(int i=1;n>=i;i++){
        for(int j=1;m>=j;j++){
            cout << vec[i][j] << " ";
        }
        cout << "\n";
    }
    cout << "\n";
    for(int i=1;n>=i;i++){
        for(int j=1;m>=j;j++){
            cout << ans1[i][j] << " ";
        }
        cout << "\n";
    }
    cout << "\n";
    for(int i=1;n>=i;i++){
        for(int j=1;m>=j;j++){
            cout << ans2[i][j] << " ";
        }
        cout << "\n";
    }
    cout << "\n";
    for(int i=1;n>=i;i++){
        for(int j=1;m>=j;j++){
            cout << ans3[i][j] << " ";
        }
        cout << "\n";
    }
*/

Measured memory_bytes: 52736
import math
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
x,y = map(int,input().split())
sum = 0
if x%2 == 1:
  for k in range((x+1)//2):
    k = 2*k +1
    l = (x-k)//2
    if l+2*k == y:
      sum += cmb(k+l,l,mod)
      sum = sum%mod
  print(sum)
if x%2 == 0:
  for k in range(x//2):
    k = 2*k
    l = (x-k)//2
    if l+2*k == y:
      sum += cmb(k+l,l,mod)
      sum = sum%mod
  print(sum)

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

using namespace std;



int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	unordered_map<int, int> l;
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		l[t]++;
	}

	vector<int> keys;

	for(auto i = l.begin(); i != l.end(); i++) {
		keys.push_back(i->first);
	}

	sort(keys.begin(), keys.end());

	int ans = 0;

	for(int i = 2; i < keys.size(); i++){
		for(int j = 1; j < i; j++){
			for(int k = 0; k < j; k++) {
				if(keys[k] + keys[j] > keys[i]) {
					// cout << keys[i] << ' ' << keys[j] << ' ' << keys[k] << '\n';
					ans += l[keys[i]] * l[keys[j]] * l[keys[k]];
				}
			}
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3564
# 入力
N,K = list(map(int, input().split()))
D = list(map(int, input().split()))

availbale_numbers = [0,1,2,3,4,5,6,7,8,9]

for i in D:
    availbale_numbers.remove(i)

for item1 in availbale_numbers:
    if(N <= int(('').join([str(item1)]))):
         print(('').join([str(item1)]))
         exit()

for item1 in availbale_numbers:
    for item2 in availbale_numbers:
        if(N <= int(('').join([str(item1),str(item2)]))):
            print(('').join([str(item1),str(item2)]))
            exit()

for item1 in availbale_numbers:
    for item2 in availbale_numbers:
        for item3 in availbale_numbers:
            if(N <= int(('').join([str(item1),str(item2),str(item3)]))):
                print(('').join([str(item1),str(item2),str(item3)]))
                exit()

for item1 in availbale_numbers:
    for item2 in availbale_numbers:
        for item3 in availbale_numbers:
            for item4 in availbale_numbers:
                if(N <= int(('').join([str(item1),str(item2),str(item3),str(item4)]))):
                    print(('').join([str(item1),str(item2),str(item3),str(item4)]))
                    exit()

Nmin = min(availbale_numbers)
if(Nmin==0):
    print(f'{availbale_numbers[1]}{Nmin}{Nmin}{Nmin}{Nmin}')
else:
    print(f'{Nmin}{Nmin}{Nmin}{Nmin}{Nmin}')

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

using namespace std;

const int LOGSZ = 17;

int tree[(1<<LOGSZ) + 1];
int n = (1<<LOGSZ);

void add(int x, int v){
  while(x<=n){
    tree[x] += v;
    x+= (x & -x);
  }
}

int get(int x){
  int ans = 0;
  while(x){
    ans += tree[x];
    x-= (x & -x);
  }
  return ans;
}


int rsq(int x, int y){
    return get(y) - get(x - 1);
}


int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n,q;
  cin>>n>>q;
  for(int i = 0; i < q; i++){
    int com, x, y;
    cin>>com>>x>>y;
    if(com)
      cout<<rsq(x,y)<<"\n";
    else
      add(x,y);
  }
}

Measured memory_bytes: 3520
import itertools
n = int(input())
list_f = []
for i in range(n):
  temp = list(map(int, input().split()))
  list_f.append(temp)
list_p = []
for i in range(n):
  temp = list(map(int, input().split()))
  list_p.append(temp)
  
cand = list(itertools.product([0, 1], repeat=10))
cand = cand[1:]
max_p = -float("inf")
for c in cand:
  temp = 0
  for idx, one_f in enumerate(list_f):
    count_same = sum([1 for i, j in enumerate(c) if j == 1 and one_f[i] == 1])
    temp += list_p[idx][count_same]
  if temp > max_p:
    max_p = temp
print(max_p)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, int>
using namespace std;
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 imos[5100][5100];
const int INF = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(n + 2), y(n + 2);
    x[n] = INF, y[n] = INF;
    x[n + 1] = -INF, y[n + 1] = -INF;
    vector<int> xs(n), ys(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        xs[i] = x[i];
        ys[i] = y[i];
    }
    // 始点と終点を入れとく
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    y.erase(unique(y.begin(), y.end()), y.end());
    for (int i = 0; i < n; i++) {
        int nx = lower_bound(x.begin(), x.end(), xs[i]) - x.begin();
        int ny = lower_bound(y.begin(), y.end(), ys[i]) - y.begin();
        imos[ny + 1][nx + 1]++;
    }
    for (int i = 0; i < y.size(); i++) {
        for (int j = 0; j < x.size(); j++) {
            imos[i + 1][j + 1] += imos[i + 1][j] + imos[i][j + 1] - imos[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1 = lower_bound(x.begin(), x.end(), x1) - x.begin();
        y1 = lower_bound(y.begin(), y.end(), y1) - y.begin();
        x2 = lower_bound(x.begin(), x.end(), x2 + 1) - x.begin();
        y2 = lower_bound(y.begin(), y.end(), y2 + 1) - y.begin();
        cout << imos[y2][x2] - imos[y2][x1] - imos[y1][x2] + imos[y1][x1] << endl;
    }
    return 0;
}


Measured memory_bytes: 102884
/*
    Written by Kabir Kanha Arora
    @kabirkanha
 */

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long sum = 0;
        for (int i = 1; i < n; ++i) {
            sum += (n - 1) / i;
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 35640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N, Y;
  scanf("%d %d", &N, &Y);

  int m, g, s;
  int ok = 0;
  for ( m = 0; m <= (Y / 10000); m++ ) {
    int r = Y - 10000 * m;
    for ( g = 0; g <= (r / 5000); g++ ) {
      s = (r - g * 5000) / 1000;
      if ( m + g + s == N ) {
        printf("%d %d %d\n", m, g, s);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int const nax = 1e5 + 10;
int n;
pair<int,int> a[nax], b[nax];
int p[nax];

int main(){
    scanf("%d", &n);
    for(int i = 1 ;i <= n ;i++){
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    for(int i = 1 ;i <= n; i++){
        scanf("%d", &b[i].first);
        b[i].second = i;
    }
    #define no return !printf("No");
    #define yes return !printf("Yes");
    sort(a + 1 , a + 1 + n);
    sort(b + 1 , b + 1 + n);
    for(int i = 1 ;i <= n ; i ++){
        if(a[i].first > b[i].first) no;
    }
    for(int i = 1 ;i <=  n ; i ++){
        if(i > 1 && a[i].first <= b[i-1].first)
            yes;
        p[a[i].second] = b[i].second;
    }
    int x = 1, it = 0;
    do{
        x = p[x];
        it ++;
    }while(x != 1);
    if(it == n)
        no
    else yes
    /// only one cycle -> answer is no
}


Measured memory_bytes: 2176
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())

total = A.sum()
answer = [0] * N
answer[0] = total - A[1::2].sum() * 2
A = A.tolist()
for i in range(1, N):
    answer[i] = A[i-1]*2 - answer[i-1]
print(*answer)

Measured memory_bytes: 23108
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	cin >> n;
	vi v(n);
	ll w[8] = { 0 };
	REP(i, n) cin >> v[i];
	sort(ALL(v));
	REP(i, n)
	{
		if (v[i] < 400) {
			w[0]++;
		} else if (v[i] < 800) {
			w[1]++;
		} else if (v[i] < 1200) {
			w[2]++;
		} else if (v[i] < 1600) {
			w[3]++;
		} else if (v[i] < 2000) {
			w[4]++;
		} else if (v[i] < 2400) {
			w[5]++;
		} else if (v[i] < 2800) {
			w[6]++;
		} else if (v[i] < 3200) {
			w[7]++;
		} else {
			sum++;
		}
	}
	REP(i, 8)
	{
		if (w[i] != 0) {
			ans++;
		}
	}
	k = ans + sum;
	if (ans == 0) {
		cout << 1 << ' ' << k << endl;
	} else {
		cout << ans << ' ' << k << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = -1000000;
        int min = 1000000;
        long sum =0;
        sc.nextLine();
        for(int i=0;i<n;i++){
            int a = sc.nextInt();
            if(a > max)max=a;
            if(a < min)min=a;
            sum+=a;
        }
        System.out.print(min +" "+ max +" "+sum);
        System.out.println();
    }
}


Measured memory_bytes: 40788
#include<cstdio>
#include<algorithm>
using namespace std;
int A[1000+2];
void Init() {
	for(int i=1;i<=999;i++)
		A[i]=A[i-1]+i;
}
int Abs(int x) {return x<0?-x:x;}
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	Init();
	int a,b;
	scanf("%d %d",&a,&b);
	int x;
	for(int i=1;i<=999;i++) {
		if(A[i]-a==A[i+1]-b) {
			x=A[i]-a;
			break;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  int mas[w+1];
  memset(mas,0,sizeof(mas));
  for(int i=0,sum=0,a;i<h;i++,sum=0){
    for(int j=0;j<w;j++){
      cin >> a;
      cout << (j!=0?" ":"") << a;
      sum += a;
      mas[j]+=a;
    }
    cout << " " << sum << endl;
    mas[w] += sum;
  }
  for(int i=0;i<=w;i++){
    cout << (i!=0?" ":"") << mas[i];
  }
  cout << endl;
}


Measured memory_bytes: 3136
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
LL p[N];
LL tot[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	cout << a * b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

for _ in range(k):
    b=[0]*n
    for i in range(n):
        b[max(0,i-a[i])]+=1
        if i+a[i]<n-1:
            b[i+a[i]+1]-=1    
    f=0
    tmp=0
    for i in range(n):
        tmp+=b[i]
        a[i]=tmp
        if tmp!=n:
            f=1
    if f==0:
        break
print(*a)


Measured memory_bytes: 156224
class PriorityQueue
 
  def initialize(capacity)
    @items = Array.new(capacity)
    @size = 0
  end
 
  def push(x)
    n = @size
    @items[n] = x
    @size += 1
    while n != 0
      p = (n - 1) / 2
      if @items[n] > @items[p]
        @items[p], @items[n] = @items[n], @items[p]
      end
      n = p
    end
  end
 
  def pop
    result = @items[0]
    @items[0] = @items[@size - 1]
    @size -= 1
 
    n = 0
    loop do
      left = 2 * n + 1
      break if left >= @size
 
      right = left + 1
      if (right < @size) && (@items[right] > @items[left])
        c = right
      else
        c = left
      end
 
      break unless @items[c] > @items[n]
 
      @items[n], @items[c] = @items[c], @items[n]
      n = c
    end
    result
  end
 
  def empty?
    @size == 0
  end
 
  def size
    @size
  end
end
n,m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

q = PriorityQueue.new(n)
a.each do |x|
  q.push x
end

m.times do
  x = q.pop
  q.push x / 2
end

ans = 0
q.size.times do
  ans += q.pop
end

puts ans


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

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

    double cnt;
    double ma = n;
    for(int i = 1;i <= n;i++){
        if(i % 2 == 1) cnt+=1;
    }

    printf("%.12lf\n", cnt/ma);

    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
lb, ub = 0, N
while ub - lb > 1:
    m = (lb + ub) // 2
    idx = [0] * N
    not_use = set()
    ok = True
    while True:
        count = [0] * (M+1)
        for i in range(N):
            if idx[i] == -1:
                continue
            while idx[i] < M and A[i][idx[i]] in not_use:
                idx[i] += 1
            if idx[i] == M:
                ok = False
                break
            count[A[i][idx[i]]] += 1

        if not ok:
            break
        if max(count) <= m:
            break
        for i in range(1, M+1):
            if count[i] > m:
                not_use.add(i)
    if ok:
        ub = m
    else:
        lb = m
print(ub)







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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<((a>b)?a-1:a)<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 10:13:10 2020

@author: Kanaru Sato
"""

N = int(input())
H = list(map(int, input().split()))
record = 0
count = 0

for i in range(0,N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        record = max(count,record)
        count = 0

ans = max(record,count)

print(ans)

Measured memory_bytes: 15020
import java.io.*;
import java.util.*;

public class Main {
    void run() {
        int A = readInt();
        int B = readInt();
        int C = readInt();
        int ans = 0;
        for (int i = A; i <= B; ++i) {
            if (C % i == 0) ans++;
        }
        sysout.println(ans);
    }

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

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

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

int main () {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int count=0;

    for (int i=0; i<=A; i++) {
        for (int j=0; j<=B; j++) {
            for (int k=0; k<=C; k++) {
                if (i*500+j*100+k*50==X) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

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

static const int mod = 1000000007;

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

    // check validity
    vector<int> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    sort(A.begin(), A.end());

    if (N % 2 == 0){  // if N is even
        for(int i=0; i<N; i=i+2){
            if (A[i] != i+1 | A[i+1] != i+1){                
                cout << 0 << endl;
                return 0;
            }
        }             
    }
    else{ // if N is even
        if (A[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        for(int i=1; i<N; i=i+2){
            if (A[i] != i+1 | A[i+1] != i+1){
                cout << 0 << endl;
                return 0;
            }
        }
    }

    int ret = 1;
    for (int i=0; i<(N/2); i++)
        ret = (ret * 2) % (mod);
    cout << ret << endl;
}


Measured memory_bytes: 640