akhauriyash/Code-Regression huggingface dataset:
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/

/+---test
4 6
#..#..
.....#
....#.
#.#...
---+/
/+---test
8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#
---+/

void main(string[] args) {
  long H, W;
  readf(" %d %d ", &H, &W);

  auto M = new bool[][](H);
  foreach (y; 0..H) {
    const s = readln.chomp;
    M[y] = s.map!(x => x == '#').array;
  }

  auto score = new long[][](H, W);
  foreach (y; 0..H) {
    long l;
    foreach (x; 0..W+1) {
      if (x == W || M[y][x]) {
        score[y][l..x] = x - l;
        l = x+1;
      }
    }
  }
  foreach (x; 0..W) {
    long t;
    foreach (y; 0..H+1) {
      if (y == H || M[y][x]) {
        foreach (i; t..y) score[i][x] += y - t - 1;
        t = y+1;
      }
    }
  }

  long ans;
  foreach (y; 0..H) foreach (x; 0..W) {
    ans.amax(score[y][x]);
  }
  ans.writeln;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  in(int, a, b);
  out(max({a + b, a - b, a * b}));
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int n;

void rfl(vector< int >& card) {
	vector< int > nxt;
	for_(i,0,n) {
		nxt.push_back(card[i]);
		nxt.push_back(card[n + i]);
	}
	card = nxt;
}

void cut(vector< int >& card, int k) {
	vector< int > nxt;
	for_(i,k,2*n) nxt.push_back(card[i]);
	for_(i,0,k) nxt.push_back(card[i]);
	card = nxt;
}

int main() {
	cin >> n;
	vector< int > card(2*n);
	for_(i,0,2*n) card[i] = i + 1;
	int m; cin >> m;
	for_(i,0,m) {
		int k; cin >> k;
		if (k) cut(card, k);
		else rfl(card);
	}
	for_(i,0,2*n) cout << card[i] << endl;
	return 0;
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A[101010];
i64 subm[101010];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i <= N; ++i) scanf("%lld", A + i);
	subm[N + 1] = 0;
	for (int i = 0; i <= N; ++i) subm[i] = A[i];
	for (int i = N - 1; i >= 0; --i) subm[i] += subm[i + 1];

	i64 ret = 0;
	i64 k = 1;
	for (int i = 0; i <= N; ++i) {
		if (k < A[i]) goto fail;
		ret += k;
		k -= A[i];
		k = min(k * 2, subm[i + 1]);
	}
	if (k != 0) goto fail;
	printf("%lld\n", ret);
	return 0;
fail:
	puts("-1");
	return 0;
}


Measured memory_bytes: 5328
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let mut ans = 0.0;
    for i in 1..=n {
        let mut x = i;
        let mut p = 0.0;
        while x < k {
            x *= 2;
            p += 1.0;
        }
        ans = ans + (1.0 / n as f64) * 0.5f64.powf(p);
    }
    println!("{:.12}", ans);
}


Measured memory_bytes: 2700
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    int ans = 0;
    while(a[0] != a[1] || a[1] != a[2]){
        sort(a.begin(), a.end());
        if(a[0] != a[1]) a[0] += 2;
        else{
            a[0]++;
            a[1]++;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char S[120];
	double K;
	scanf("%s %lf",S,&K);
	int i,j,count=0;
	for(i=0;S[i]!='\0';i++){}
	
	for(j=0;j<i;j++){
		if(S[j]!='1')break;
		else count++;
	}
	if(i==1||K==1)printf("%c\n",S[0]);
	else if(count>=K)printf("1\n");
	else printf("%c\n",S[count]);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int n;
char s[105];
char ans[205];
int tot;
int c[105];
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		tot = 0;
		scanf("%s", s + 1);
		int cnt = 0;
		for(int i = 1; i <= n; i++)
		{
			if(s[i] == '(') cnt++;
			else if(s[i] == ')') {
				if(cnt > 0) cnt--;
				else if(cnt <= 0)
				{
					ans[++tot] = '(';
					cnt = 0;
				}
			}
		}

		for(int i = 1; i <= n; i++)
			ans[++tot] = s[i];

		cnt = 0;
		for(int i = n; i >= 1; i--)
		{
			if(s[i] == ')') cnt++;
			else if(s[i] == '(') 
			{
				if(cnt > 0) cnt--;
				else if(cnt <= 0)
				{
					ans[++tot] = ')';
					cnt = 0;
				}
			}
		}
		for(int i = 1; i <= tot; i++)
			printf("%c", ans[i]);
		printf("\n");
		memset(s, 0, sizeof(s));
		memset(ans, 0, sizeof(ans));
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	   {
	   	  cin>>x;
	   	  if(x%4==0) a++;
	   	  else 
	   	     if(x%2==0) b++;
	   	     else  
	   	        c++;
	   }
	if(b>0)c+=1;
	if(a+1>=c) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
  long long int n;
  cin >> n;
  long long int a[n],l,m;
  for(long long int i=0;i<n;i++){
     cin >> l;
     a[i]=l-i-1;
  }
  sort(a,a+n);
  if(n%2){
    m=a[n/2];
  }
  else{
    m=(a[n/2]+a[n/2-1])/2;
  }
  long long int ans=0;
  for(long long int i=0;i<n;i++){
    ans+=abs(a[i]-m);
  }
   cout <<ans<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
 
const int MAXN=1e5+5;
 
int n;
int a[MAXN<<1];
bool jud(int k)
{
	for(int i=0;i<n;i++)
	{
		if(a[n+i]<k&&a[n+i+1]<k) return false;
		if(a[n-i]<k&&a[n-i-1]<k) return false;
		if(a[n+i]>=k&&a[n+i+1]>=k) return true;
		if(a[n-i]>=k&&a[n-i-1]>=k) return true;
	}
	return a[1]>=k;
}
 
int main()
{
	int i;scanf("%d",&n);
	for(i=1;i<n<<1;i++) scanf("%d",a+i);
	int l=0,r=n<<1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(jud(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d",r);
	return 0;
}

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

namespace _1237
{
    public class Program

    {
        public static void Main(string[] args)
        {

            while (true)
            {
                int[] line = ReadIntAr();
                if (line[0] + line[1] == 0) break;

                int t = line[0];
                string num = line[1].ToString();
                int max = -1;
                bool multiFlg = false;
                bool overTFlg = false;
                List<int> max_items = new List<int>();

                for (int i = 0 ; i < Math.Pow(2, num.Length - 1) ; i++)
                {
                    List<int> nums = new List<int>();
                    int startIdx = 0;
                    int lengthGet = 0;
                    int sum = 0;
                    overTFlg = false;

                    for (int j = 0 ; j < num.Length ; j++)
                    {
                        lengthGet++;
                        if ((i >> j & 1) == 1 || j == num.Length - 1)
                        {
                            int item = int.Parse(num.Substring(startIdx, lengthGet));
                            nums.Add(item);
                            sum += item;
                            startIdx = j + 1;
                            lengthGet = 0;
                            if (sum > t)
                            {
                                overTFlg = true;
                                break;
                            }
                        }
                    }
                    if (overTFlg) continue;

                    if (max < sum)
                    {
                        max = sum;
                        max_items = nums;
                        multiFlg = false;
                    }
                    else if (max == sum)
                    {
                        multiFlg = true;
                    }
                }

                if (max == -1) Console.WriteLine("error");
                else if (multiFlg) Console.WriteLine("rejected");
                else Console.WriteLine("{0} {1}", max.ToString(), String.Join(" ",max_items.Select(x => x.ToString()).ToArray()));                
            }

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 16412
#include<bits/stdc++.h>
#include<iostream>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    string s;
    cin >> s;
    if(s == "0"){
        cout << "Yes" << endl;
        return 0;
    }
    int ans = 0;
    rep(i, s.size()){
        char tmp = s[i];
        ans += tmp - '0';
    }
    /* cout << ans << endl; */
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3652
Ss = [i for i in input()]
Aa = []
Zz= []
for s in range(len(Ss)):
    if Ss[s]=="A":
        Aa.append(s+1)
    if Ss[s]=="Z":
        Zz.append(s+1)
print(Zz[-1]-Aa[0]+1)

Measured memory_bytes: 12596
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
#define EPS 1e-9
using namespace std;
const ll INF = 1e9 + 15;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(0);
    double x;
    cin>>x;
    double ansa=-1,ansb=-1;
    rep(i,0,2001){
        rep(j,-1001,1001){
            if(pow(i,5)-pow(j,5)==x)ansa=i,ansb=j;
        }
    }
    cout<<ansa<<" "<<ansb<<"\n";
    return 0;   
}

Measured memory_bytes: 4436
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    if(n%2){
        cout<<0<<endl;
        return;
    }
    int c=5;
    int ans=0;
    n/=2;
    while(c<=n){
        ans+=n/c;
        c*=5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define LOSE 'l'

int		main(void)
{
	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P;
	cin >> T;
	map<char, int> m;
	m.insert(make_pair('r', P));
	m.insert(make_pair('s', R));
	m.insert(make_pair('p', S));
	int score = 0;
	for (int i = 0; i < N; i++)
	{
		if (i < K || T[i] != T[i-K])
			score += m.at(T[i]);
		else
			T[i] = LOSE;
	}
	cout << score << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

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

int A[N][3],dp[N][3];


int main(int argc, char const *argv[])
{
	crap;
	int n;
	cin>>n;
	f(i,1,n)
	{
		rep(j,3)
			cin>>A[i][j];
	}

	// rep(j,3)
	// {
	// 	dp[1][j]=A[1][j];
	// }

	f(i,1,n)
	{
		rep(j,3)
		{
			int ans;
			if (j==0)
				ans=max(dp[i-1][1],dp[i-1][2]);
			else if (j==1)
				ans=max(dp[i-1][0],dp[i-1][2]);
			else
				ans=max(dp[i-1][0],dp[i-1][1]);
			dp[i][j]=A[i][j]+ans;
		}
	}

	int ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, n, x, d, t, s, ans=0, po=0;
    scanf("%lld %lld %lld", &d, &t, &s);
    if(t*s>=d) printf("Yes");
    else printf("No");
    
}

Measured memory_bytes: 1708
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

map<vector<int>,int> dp;

vector<vector<int>> next(vector<int> pre){
  vector<vector<int>> res;
  int zero = pre[0];
  if(zero!=1&&zero!=5){
    vector<int> tmp = pre;
    swap(tmp[zero],tmp[zero-1]);
    tmp[0]=zero-1;
    res.push_back(tmp);
  }
  if(zero!=4&&zero!=8){
    vector<int> tmp = pre;
    swap(tmp[zero],tmp[zero+1]);
    tmp[0]=zero+1;
    res.push_back(tmp);
  }
  if(zero>4){
    vector<int> tmp = pre;
    swap(tmp[zero-4],tmp[zero]);
    tmp[0]=zero-4;
    res.push_back(tmp);
  }else{
    vector<int> tmp = pre;
    swap(tmp[zero],tmp[zero+4]);
    tmp[0]=zero+4;
    res.push_back(tmp);
  }
  return res;
}

void init(){
  vector<int> s = {1,0,1,2,3,4,5,6,7};
  queue<vector<int>> q;
  dp.clear();
  dp[s] = 0;
  q.push(s);
  while(!q.empty()){
    vector<int> tmp = q.front();q.pop();
    vector<vector<int>> n = next(tmp);
    for(int i=0;i<n.size();i++){
      if(dp.count(n[i])==0){
        dp[n[i]]=dp[tmp]+1;
        q.push(n[i]);
      }
    }
  }
}

int main(){
  init();
  vector<int> in(9);
  while(cin>>in[1]>>in[2]>>in[3]>>in[4]>>in[5]>>in[6]>>in[7]>>in[8] ){
    for(int i=1;i<in.size();i++){
      if(in[i]==0){
        in[0]=i;
      }
    }
    cout<<dp[in]<<endl;
    in.clear();
    in.resize(9);
  }
}

Measured memory_bytes: 3768
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, K, l[50];
    cin >> N >> K;
    REP(i, N) {
        cin >> l[i];
    }
    sort(l, l + N);
    reverse(l, l + N);
    int res = 0;
    REP(i, K) {
        res += l[i];
    }
    cout << res << endl;
    return 0;
}


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

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

 
void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            ans+=i;
        }
    }
    cout<<ans<<endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int d;
	cin>>d;
	if(d==25)
	cout<<"Christmas"<<endl;
	else if(d==24)
	cout<<"Christmas Eve"<<endl;
	else if(d==23)
	cout<<"Christmas Eve Eve"<<endl;
	else
	cout<<"Christmas Eve Eve Eve"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    string s, t;
    cin >> s >> t;

    int ans = 0;
    REP(i, SZ(s)) {
        ans += (s[i] != t[i]);
    }


    cout << ans << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
lint K, N;
constexpr lint INF = 100000000000;

template <typename T>
T power(T x, T n, T inf)
{
    T ans = 1;
    bool infflag = false;
    while (n>0)
    {
        n--;
        ans *= x;
        if (ans > inf) return inf;
        // if (n & 1)
        // {
        //     if (infflag) return inf;
        //     ans = ans * x;
        // }
        // x = x * x;
        // if (x >= inf || x < 0) infflag = true;
        // n >>= 1;
    }
    return ans;
}

void saiki(lint n, lint res)
{
    int tmp = K/2+1;
    while (res < -(power(K, n, INF)-1)/(K-1))
    {
        tmp++;
        res += 2 * (power(K, n, INF)-1)/(K-1);
    }
    while (res >= (power(K, n, INF)-1)/(K-1))
    {
        tmp--;
        res -= 2 * (power(K, n, INF)-1)/(K-1);
    }
    if (tmp == 0) return;
    cout << tmp << " ";
    if (n>1) saiki(n-1, res+1);
}


int main()
{
    cin >> K >> N;
    if (K == 1)
    {
        for (int i=0; i<(N+1)/2; i++) cout << 1 << " ";
        return 0;
    }
    if (K%2==0)
    {
        cout << K/2 << " ";
        for (int i=0; i<N-1; i++) cout << K << " ";
        return 0;
    }
    saiki(N, 0);
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<std::tuple<int, int, int>> data;
  int S = 0;
  for (auto i = 0; i < n; i++)
  {
    int w, s, v;
    std::cin >> w >> s >> v;
    data.emplace_back(w, s, v);
    cmx(S, s + w);
  }
  std::sort(data.begin(), data.end(), [](auto p, auto q){
    return std::get<0>(p) + std::get<1>(p)
         < std::get<0>(q) + std::get<1>(q);
  });
  auto dp = std::vector<lint>(S + 1, 0);
  for (auto i = 0; i < n; i++)
  {
    int w, s, v;
    std::tie(w, s, v) = data.at(i);
    for (auto j = s; j >= 0; j--)
    {
      cmx(dp.at(j + w), dp.at(j) + v);
    }
  }
  auto ret = *std::max_element(dp.begin(), dp.end());
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()


int main(){
  int a,b;
  cin >> a >> b;

  if(b%a){
    cout << b-a;
  }else{
    cout << a+b;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1;i <= n;i++) {
        for(int j = 1;j <= n;j++) {
            ll x = i * j;
            if(n - x > 0) ans++;
            else break;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<ll> v(1e6,10);
  vector<ll> seisi;
  ll a=0;
  seisi.push_back(a);
  a++;
  while(a<200){
    seisi.push_back(a+seisi[a-1]);
    a++;
  }
  FOR(i,1,seisi.size()){
    seisi[i]+=seisi[i-1];
  }
  //coutv(seisi,0,100);
  vector<ll> dp1(1e6,10);
  vector<ll> dp2(1e6,1e6);
  dp1[0]=0;
  dp2[0]=0;
  dp2[1]=1;
  FOR(i,1,seisi.size()){
    FOR(j,seisi[i],1e6){
      dp1[j]=min(dp1[j-seisi[i]]+1,dp1[j]);
      if(seisi[i]%2==1)dp2[j]=min(dp2[j],dp2[j-seisi[i]]+1);
    }
  }
  while(true){
    ll n;
    cin>>n;
    if(n==0)break;
    cout<<dp1[n]<<" "<<dp2[n]<<endl;
  }
}



Measured memory_bytes: 26272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,c)for(int i= 0;i< (int)c;i++)
const int inf= 1000000000; // 10^9
int main() {
  int N;
  cin>>N;
  vector<int>X(N);
  rep(i,N) cin>>X[i];
  int ans=inf;
  for(int i= 1;i<= 100;i++) {
    int cost= 0;
    rep(j,N)cost+= (X[j] -i) * (X[j] -i);
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
	int A,B,count=0;
	cin >> A >> B;
  	for(int i=A;i<=B;i++){
    	if(i/10000 == i%10 && i/1000-i/10000*10 == (i-i%10)%100/10){
        	count++;
        }
    }
  cout << count;
}


Measured memory_bytes: 256
//
//  main.c
//  ITP1_1_D
//
//
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int seconds, hour_sec, minute_sec, h, m, s;
    scanf("%d", &seconds);
    minute_sec = 60;
    hour_sec = minute_sec * minute_sec;
    h = seconds / hour_sec;
    m = (seconds % hour_sec) / minute_sec;
    s = seconds % hour_sec % minute_sec;
    
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 592
package main

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	D := make([]int, N)
	for i := 0; i < N; i++ {
		D[i] = nextInt()
	}
	if D[0] != 0 {
		fmt.Println(0)
		return
	}

	set := make(map[int]int)
	for _, v := range D {
		set[v]++
	}
	var maxKey int
	for k, _ := range set {
		maxKey = max(maxKey, k)
	}
	if maxKey != len(set)-1 {
		fmt.Println(0)
		return
	}

	sums := make([]int, len(set))
	for k, v := range set {
		sums[k] = v
	}

	if sums[0] != 1 {
		fmt.Println(0)
		return
	}
	var beforeValue int = 1
	var count int = 1
	for _, v := range sums {
		count *= modPow(beforeValue, v, 998244353)
		count = count % 998244353
		beforeValue = v
	}
	fmt.Println(count)
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    ll ans=n*800;
    n/=15;
    ans-=n*200;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> S(110),T(110);
  for(int i=0;i<H;i++)cin >> S[i];
  for(int i=0;i<H;i++)T[i]="";
  for(int i=0;i<W;i++){
    bool q=false;
    for(int j=0;j<H;j++){if(S[j][i]=='#')q=true;}
    if(q){for(int j=0;j<H;j++)T[j]+=S[j][i];}
  }
  for(int i=0;i<H;i++){
    bool w=false;
    for(int j=0;j<T[i].size();j++){if(T[i][j]=='#')w=true;}
    if(w){cout << T[i] << endl;}
  }
}

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

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    int R;
    cin >> R;
    //処理

    //出力処理
    cout <<  R * 2 * M_PI << endl;
    return 0;
}


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

bool graph[26][26];
bool visit[26];
int in[26], out[26];

void dfs(int s) {
	if (visit[s]) return;
	visit[s] = true;
	for (int i = 0; i < 26; i++) {
		if (graph[s][i]) {
			dfs(i);
		}
	}
}

bool connect(int s) {
	dfs(s);
	for (int i = 0; i < 26; i++) {
		if (!visit[i]) return false;
	}
	return true;
}

bool cycle() {
	for (int i = 0; i < 26; i++) {
		if (in[i] != out[i]) return false;
	}
	return true;
}

int main() {
	int n;
	while (cin >> n, n) {
		memset(graph, 0, sizeof(graph));
		memset(in, 0, sizeof(in));
		memset(out, 0, sizeof(out));
		memset(visit, 1, sizeof(visit));
		string s;
		for (int i = 0; i < n; i++) {
			cin >> s;
			graph[s[0]-'a'][s[s.size()-1]-'a'] = 1;
			in[s[s.size()-1]-'a']++;
			out[s[0]-'a']++;
			visit[s[0]-'a'] = visit[s[s.size()-1]-'a'] = false;
		}

		if (connect(s[s.size()-1]-'a') && cycle()) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#include <cstdio>
#include <chrono>
#include <random>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, -1, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 3002;
const long long int MINN = 1e5+10;
const long long int inf = 1e9+7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;
int n;
ld dp[MAXN][MAXN],a[MAXN];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS
    cin>>n;
    repA(i,1,n) cin>>a[i];
    dp[1][0]=1-a[1],dp[1][1]=a[1];
    repA(i,2,n){
        repA(j,0,i-1){
            dp[i][j]+=dp[i-1][j]*(1-a[i]);
            dp[i][j+1]+=dp[i-1][j]*a[i];
        }
    }
    ld sum=0;
    /*repA(i,1,3){
        repA(j,0,i) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    repA(i,n/2+1,n) sum+=dp[n][i];
    cout<<setprecision(17)<<sum<<endl;
    return 0;
}






Measured memory_bytes: 139264
using System;
class c
{
    static void Main()
    {
        var nmc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 0;
        for (int i = 0; i < nmc[0]; i++)
        {
            int judge = 0;
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            for (int j = 0; j < nmc[1]; j++)
            {
                judge += a[j] * b[j];
            }
            if (judge + nmc[2] > 0) ans++;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc152_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var P = CIn.ReadIntArray(N);

      var min = new int[N];
      min[0] = P[0];

      for (int i = 1; i < N; i++)
      {
        min[i] = Math.Min(min[i - 1], P[i]);
      }

      var ans = 1;

      for (int i = 1; i < N; i++)
      {
        if (min[i - 1] > P[i]) ans++;
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(long h, long w)
    {
      var array = new char[h, w];
      for (var i = 0L; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0L; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 36236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=3e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

lf dp[MAXn][MAXn][MAXn];
ll ct[3];
int main(){
  IOS();
  ll n;
  cin >> n;
  REP (i,n) {
    ll x;
    cin >> x;
    ct[--x]++;
  }
  pary(ct,ct+3);

  dp[0][0][0] = 0;
  REP (k,ct[2]+1) {
    REP (j,n+1) {
      REP (i,n+1) {
        ll tmp = i+j+k;
        if (!tmp || tmp > n) continue;
        dp[i][j][k] = 1.0;
        if (i) dp[i][j][k] += dp[i-1][j][k]*lf(i)/(lf)n;
        if (j) dp[i][j][k] += dp[i+1][j-1][k]*lf(j)/(lf)n;
        if (k) dp[i][j][k] += dp[i][j+1][k-1]*lf(k)/(lf)n;
        dp[i][j][k] *= lf(n)/(lf)tmp;
      }
    }
  }

  cout << fixed << setprecision(15) << dp[ct[0]][ct[1]][ct[2]] << endl;
}


Measured memory_bytes: 219392
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

#define PI 3.14159265359

signed main() {
    long double a,b,x;
    cin >> a >> b >> x;

    bool half = true;
    long double cap = a * a * b;
    if(x < (cap / 2)) half = false;

    long double h;
    if(half) h = x / (a * a);
    else h = x / (a * b);

    long double ans;

    if(half) {
        ans = 90.0 - atan(a / (2 * (b - h))) * 180 / PI;
    } else {
        ans = atan(b / (2 * h)) * 180 / PI;
    }

    cout << fixed << setprecision(10) << ans << endl;
}

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

int D;
long long G;
vector<int> ps, cs;

int main(){
  cin >> D >> G;
  ps.resize(D); cs.resize(D);
  for (int i = 0; i < D; i++) cin >> ps[i] >> cs[i];
  
  int answer = 1000;
  
  for (int bit = 0; bit < (1<<D); bit++) {
    long long total = 0;
    int num = 0;
    
    for (int i = 0; i < D; i++) {
      if (bit & (1<<i)) {
        total += 100 * (i + 1) * ps[i] + cs[i];
        num += ps[i];
      }
    }
    
    if (total >= G) {
      answer = min(answer, num);
    } else {
      for (int i = D - 1; i >= 0; i--) {
        if (!(bit & (1<<i))) {
          for (int j = 0; j < ps[i]; j++) {
            if (total < G) {
              total += 100 * (i + 1);
              num++;
            }
          }
        }
      }
      answer = min(answer, num);
    }
  }
  
  cout << answer << endl;
}

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

public class Main {

    //cord: x,y
    final static int dir[][] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

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

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            int n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
            int[][] square = new int[n][2];
            int min_x = 0, max_x = 0;
            int min_y = 0, max_y = 0;

            for (int i = 1; i < n; i++) {
                line = br.readLine();
                int t = Integer.parseInt(line.substring(0, line.indexOf(' ')));
                int d = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
                square[i][0] = square[t][0] + dir[d][0];
                square[i][1] = square[t][1] + dir[d][1];
                if (square[i][0] < min_x) {
                    min_x = square[i][0];
                } else if (square[i][0] > max_x) {
                    max_x = square[i][0];
                }
                if (square[i][1] < min_y) {
                    min_y = square[i][1];
                } else if (square[i][1] > max_y) {
                    max_y = square[i][1];
                }
            }
            System.out.println((max_x - min_x + 1) + " " + (max_y - min_y + 1));
        }
    }
}

Measured memory_bytes: 22384
import java.util.Scanner;

/**
 * @author yoshizaki
 * EDCP A
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        // 足場の数
        int node = scanner.nextInt();
        // 足場の高さの配列
        long[] height = new long[110000];
        // DP用配列
        long[] dp = new long[110000];
        long step = scanner.nextLong();
        // 足場の高さを取得
        for (int i = 0 ; i < node ; i++) height[i] = scanner.nextInt();
        // DP用配列の初期化
        for (int i = 0; i < 110000; i++) dp[i] = 100000000000000000l;
        // 初期条件 初めのコストはゼロ
        dp[0] = 0;
        
        for (int i = 0; i < node; i++) {
            for (int j =1; j <=step; j++) {
                long cost = dp[i] + Math.abs(height[i] - height[i+j]);
                if (dp[i + j] > cost) dp[i + j] = cost; 
            }
        }
        System.out.println(dp[node -1]);
    }
}

Measured memory_bytes: 50532
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> val = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int A = scanner.nextInt();
            val.add(A);
        }
        Map<Integer,Integer> maxLeft = new HashMap<>();
        Map<Integer,Integer> maxRight = new HashMap<>();
        maxLeft.put(0,0);
        maxLeft.put(1,val.get(0));
        for(int i=2; i<N; i++){
            int ml = Math.max(maxLeft.get(i-1), val.get(i-1));
            maxLeft.put(i, ml);
        }
        maxRight.put(N-1, 0);
        maxRight.put(N-2, val.get(N-1));
        for(int i=N-3; i>=0; i--){
            int mr = Math.max(maxRight.get(i+1), val.get(i+1));
            maxRight.put(i, mr);
        }
        // System.out.println(maxLeft);
        // System.out.println(maxRight);

        for(int i=0; i<N; i++){
            System.out.println(Math.max(maxLeft.get(i), maxRight.get(i)));
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int N;
vector<vector<ll>> a,dp;

ll dfs(int n, int m) {
  if (dp[n][m]!=-1) return dp[n][m];
  ll result = 0;
  rep(i,N) if ((m&(1<<i))&&a[n][i]) result = (result+dfs(n+1,m^(1<<i)))%MOD;
  return dp[n][m] = result;
}

int main() {
  cin >> N;
  a.resize(N,vector<ll>(N)); rep(i,N) rep(j,N) cin >> a[i][j];
  dp.resize(N+1,vector<ll>((1<<N),-1)); fill(all(dp[N]),1);

  ll result = dfs(0,(1<<N)-1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 377216
using System;

class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var b = int.Parse(Console.ReadLine());
        var c = int.Parse(Console.ReadLine());
        var x = int.Parse(Console.ReadLine()) / 50;

        var ans = 0;
        for (int i = 0; i <= a; i++)
        {
            if (i * 10 <= x)
            {
                for (int j = 0; j <= b; j++)
                {
                    var n = x - i * 10 - j * 2;
                    if (0 <= n && n <= c)
                    {
                        ans++;
                    }
                }
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    if N == 1:
        print("Hello World")
        return
    else:
        A = input_number()
        B = input_number()
        print(A + B)
        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
n = int(input())
P = list(map(int, input().split()))

res = 0
for i in range(1, n - 1):
    if P[i - 1] < P[i] < P[i + 1] or P[i + 1] < P[i] < P[i - 1]:
        res += 1

print(res)

Measured memory_bytes: 3060