akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main() {
	long H, W, ans = LONG_MAX;
	cin >> H >> W;
	for (long i = 1; i < H; i++) {
		long a = LONG_MAX;
		pair<long, long> h1(i, H - i);
		pair<long, long> h2(h1.first / 2, h1.first - h1.first / 2);
		pair<long, long> h3(h1.second / 2, h1.second - h1.second / 2);
		pair<long, long> w(W / 2, W - W / 2);
		vector<long> s;
		s.push_back(h1.first * W);
		s.push_back(h1.second * w.first);
		s.push_back(h1.second * w.second);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		s.clear();
		s.push_back(h1.first * w.first);
		s.push_back(h1.first * w.second);
		s.push_back(h1.second * W);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		s.clear();
		s.push_back(h1.first * W);
		s.push_back(h3.first * W);
		s.push_back(h3.second * W);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		s.clear();
		s.push_back(h2.first * W);
		s.push_back(h2.second * W);
		s.push_back(h1.second * W);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		ans = min(a, ans);
	}
	for (long i = 1; i < W; i++) {
		long a = LONG_MAX;
		pair<long, long> h(H / 2, H - H / 2);
		pair<long, long> w1(i, W - i);
		pair<long, long> w2(w1.first / 2, w1.first - w1.first / 2);
		pair<long, long> w3(w1.second / 2, w1.second - w1.second / 2);
		vector<long> s;
		s.push_back(H * w1.first);
		s.push_back(h.first * w1.second);
		s.push_back(h.second * w1.second);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		s.clear();
		s.push_back(h.first * w1.first);
		s.push_back(h.second * w1.first);
		s.push_back(H * w1.second);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		s.clear();
		s.push_back(H * w1.first);
		s.push_back(H * w3.first);
		s.push_back(H * w3.second);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		s.clear();
		s.push_back(H * w2.first);
		s.push_back(H * w2.second);
		s.push_back(H * w1.second);
		if (none_of(s.begin(), s.end(), [](long& a) { return !a; })) {
			a = min(*max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end()), a);
		}
		ans = min(a, ans);
	}
	cout << ans;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pii> island(m);
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        island[i] = pii(b, a);
    }
    sort(island.begin(), island.end());

    int res = 0;
    int cur = 0;
    for (int i = 0; i < m; ++i) {
        if(cur > island[i].second) continue;
        cur = island[i].first;
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin>>s;
		cout <<((s[2]==s[3] && s[5]==s[4]) ?"Yes":"No");
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main() {
    long long int x,y;
    cin >> x >> y;
    long long int tmp = x;
    long long int ans = 1;
    while(tmp < y) {
        long long int tt = tmp * 2L;
        if(tt < tmp) break;
        tmp *= 2L;
        if(tmp <= y) {
            ans++;
        }
        if(tmp >= y) {
            break;
        }
    }
    cout << ans << endl;
}

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

// #define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define fill1(a,z) fill_n(a, sizeof(a)/sizeof(a[0]), z)
#define fill2(a,z) fill_n(a[0], sizeof(a)/sizeof(a[0][0]), z)
#define fill3(a,z) fill_n(a[0][0], sizeof(a)/sizeof(a[0][0][0]), z)
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) {for (auto x : v) {pr(x)} nl}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 100000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    //freopen("A.txt","r",stdin);
    //freopen("","w",stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    int n;
    cin >> n; 
    set<int> nums; 
    unordered_map<int,int> freqs; 
    for0(i,n) {
        int x; read(x); 
        if (freqs.find(x) == freqs.end())
            freqs[x] = 0; 
        freqs[x]++; 
        nums.insert(x); 
    }
    
    if (sz(nums) == 1) {
        if (*nums.begin() == 0)
            cout << "Yes" << endl;
        else 
            cout << "No" << endl; 
    }
    else if (sz(nums) == 2) {
        set<int>::iterator it = nums.begin(); 
        int a = *it; 
        int b = *(++it);
        int c; 
        if (freqs[a] == 2*freqs[b] and (a^b) == a)
            cout << "Yes" << endl; 
        else if (freqs[b] == 2*freqs[a] and (a^b) == b)
            cout << "Yes" << endl; 
        else 
            cout << "No" << endl; 
    }
    else if (sz(nums) == 3) {
        set<int>::iterator it = nums.begin(); 
        int a = *it; 
        int b = *(++it); 
        int c = *(++it); 
        if (freqs[a] == freqs[b] and freqs[b] == freqs[c] and ((a^b) == c))
            cout << "Yes" << endl; 
        else 
            cout << "No" << endl; 
    }
    else 
        cout << "No" << endl; 
    
    return 0;
}


Measured memory_bytes: 7332
import sys
sys.setrecursionlimit(10**5*5)
n=int(input())
ab=[[]for _ in range(n)]
for _ in range(n-1):
	a,b=map(int,input().split())
	ab[a-1].append(b-1)
	ab[b-1].append(a-1)
c=list(map(int,input().split()))
c.sort()
print(sum(c)-c[-1])
ans=[-1]*n
cnt=0
node=[]
visited=[0]*n
ans=[-1]*n
def dfs(x):
	global cnt
	ans[x]=c[-cnt-1]
	visited[x]=1
	for next in ab[x]:
		if visited[next]==0:
			cnt+=1
			dfs(next)
dfs(0)
print(*ans)



Measured memory_bytes: 13680
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll a, b; cin >> a >> b;

    if (abs(a - b) % 2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a + b) / 2 << endl;
    }
    
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int count = Integer.parseInt(sc
				.nextLine());

		for (int i = 0; i < count; i++) {

			String output = new BigDecimal(sc
					.nextLine()).add(
							new BigDecimal(sc
									.nextLine()))
							.toString();

			if (output.length() > 80) {
				output = "overflow";
			}

			System.out.println(output);
		}
	}
}

Measured memory_bytes: 26316
S=input()
n=int(input())


onecount=0
for i in range(len(S)):
    if S[i]=="1":
        onecount+=1
    else:
        break


if len(S)==1:
    ans=S[0]

elif n<=onecount:
    ans=1
else:
    ans=S[onecount]
    
print(ans)

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

int main(){
  long long n,k,count=0;
  cin >> n >> k;
  count = k;
  r(i,n-1)count*=k-1;
  cout << count << endl;
}

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

int main(int argc, const char * argv[])
{
    int m[100][6];
    int tmp, n;
    int flag = 0;
    int count = 0;
    int i, j, k;
    int ii, jj, kk;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d %d %d %d %d %d", &m[i][0], &m[i][1], &m[i][2], &m[i][3], &m[i][4], &m[i][5]);
    }

    for(ii = n; ii > 1; ii--){
        for(jj = count+1; jj < ii; jj++){

        

            for(i = 0; i < 4; i++){
                tmp = m[jj][0];
                m[jj][0] = m[jj][4];
                m[jj][4] = m[jj][5];
                m[jj][5] = m[jj][1];
                m[jj][1] = tmp;

                for(j = 0; j < 4; j++){        
                    tmp = m[jj][0];
                    m[jj][0] = m[jj][2];
                    m[jj][2] = m[jj][5];
                    m[jj][5] = m[jj][3];
                    m[jj][3] = tmp;

                    for(k = 0; k < 4; k++){
                        tmp = m[jj][0];
                        m[jj][0] = m[jj][4];
                        m[jj][4] = m[jj][5];
                        m[jj][5] = m[jj][1];
                        m[jj][1] = tmp;

                        if(memcmp(m[count], m[jj], sizeof(int) * 6) == 0 ){
                            flag = 1;
                        }
                    }
                }
            }
        }
        count++;
    }

    if(flag){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 2104
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
val K = sc.nextInt()

fun main(args: Array<String>) {
    var ans = 1
    for (i in 0 until N) {
        ans = Math.min(ans + K, ans * 2)
    }
    println(ans)
}


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

static const int maxN = 2e5 + 10;

int n, k;
int a[maxN];
long long b[maxN], c[maxN];

class FenwickTree {
private:
    long long t[maxN];
public:
    void update(int x) {
        for (; x < maxN; x += x & -x)
            t[x]++;
    }
    long long get(int x) {
        long long res = 0;
        for (; x > 0; x -= x & -x)
            res += t[x];
        return res;
    }
} bit;

void Enter() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
}

void Init() {
    b[0] = c[0] = -k;
    for (int i = 1; i <= n; ++i) {
        b[i] = b[i - 1] + a[i] - k;
        c[i] = b[i];
    }
    sort(c, c + n + 1);
    for (int i = 0; i <= n; ++i) b[i] = lower_bound(c, c + n + 1, b[i]) - c + 1;
}

void Process() {
    long long answer = 0;
    bit.update(b[0]);
    for (int i = 1; i <= n; ++i) {
        answer += bit.get(b[i]);
        bit.update(b[i]);
    }
    printf("%lld\n", answer);
}

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

    Enter();
    Init();
    Process();

    return 0;
}


Measured memory_bytes: 5760
a,b,c,d = map(int,input().split())
a -= 1
def gcd(x,y):
    X = max(x,y)
    Y = min(x,y)
    if Y == 0:
        return X
    else:
        return gcd(Y,X%Y)

p = (b-b//c-b//d+b//(c*d//gcd(c,d)))
q = (a-a//c-a//d+a//(c*d//gcd(c,d)))
print(p-q)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int max = a;
        if (max < b)
            max = b;
        if (max < c)
            max = c;
        System.out.println(max * 10 + a + b + c - max);
    }
}


Measured memory_bytes: 23892
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a;
  cin >> a;
  if (a == 1){
    cout << "Hello World";
  } else {
    int b,c;
    cin >> b >> c;
    cout << b+c;
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
    mut h:u64
    }

    let mut ans: u64 = 1;
    let mut x = 1;
    while h > 1 {
        h /= 2;
        x = x * 2;
        ans += x;
    }
    println!("{}", ans)
}


Measured memory_bytes: 2108
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
#include <algorithm>
	#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
#include <map>
#include <cmath>

//#include <bits/stdc++.h>
using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	int num = 0;
	if (m == 0) {
		if (n == 1) {
			cout << 0;
			num = 1;
		}
		else if (n == 2) {
			cout << 10;
			num = 1;
		}
		else if (n == 3) {
			cout << 100;
			num = 1;
		}
	}
	vector<int> b(m);
	vector<int>c(m);
	if (m != 0) {
		for (int i = 0; i < m; i++) {
			cin >> b[i] >> c[i];
			if (i > 0) {
				for (int k = 0; k < i; k++) {
					if (b[i] == b[k] && c[i] != c[k]) {
						num = 1;
						cout << "-1";
						break;
					}
				}
			}
			if (n != 1 && (b[i] == 1 && c[i] == 0)) {
				num = 1;
				cout << "-1";
				break;
			}
		}

		if (num == 0) {
			if (n == 1) {
				cout << c[0];
				num = 1;
			}

			else if (n == 2) {
				for (int i = 10; i < 100; i++) {
					int no = 0;
					for (int j = 0; j < m; j++) {
						if (b[j] == 1) {
							if (i / 10 != c[j]) {
								no = 1;
							}
						}
						else if (b[j] == 2) {
							if (i % 10 != c[j]) {
								no = 1;
							}
						}
					}
					if (no == 0) {
						cout << i;
						num = 1;
						break;
					}
				}
			}

			else if (n == 3) {
				for (int i = 100; i < 1000; i++) {
					int no = 0;
					for (int j = 0; j < m; j++) {
						if (b[j] == 1) {
							if (i / 100 != c[j]) {
								no = 1;
							}
						}
						else if (b[j] == 2) {
							if ((i / 10) % 10 != c[j]) {
								no = 1;
							}
						}
						else if (b[j] == 3) {
							if (i % 10 != c[j]) {
								no = 1;
							}
						}
					}
					if (no == 0) {
						cout << i;
						num = 1;
						break;
					}
				}
			}

		}
		if (num == 0) {
			cout << " -1";
		}
	}


	return 0;

}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll m = 1e9 + 7;
#define MODS(a, b) ( (ll(a)%m + ll(b)%m)  % m)
#define MODM(a, b) (((ll(a)%m)*(ll(b)%m)) % m)
int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    vector<int> as = a;
    for (int i = n-2; i >= 0; i--) {
        as[i] = MODS(as[i], as[i+1]);
    }
    for (int i = 0; i < n-1; i++) {
        ans = MODS(ans, MODM(a[i], as[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4884
#include <vector>
#include <iostream>
using namespace std;
class UnionFind {
private:
	int size_; vector<int> g; vector<vector<int> > v;
public:
	UnionFind() : size_(0), g(vector<int>()), v(vector<vector<int> >()) {};
	UnionFind(int size__) : size_(size__) {
		g.resize(size__); v.resize(size__);
		for (int i = 0; i < size__; i++) g[i] = i, v[i] = { i };
	};
	int size() { return size_; }
	int root(int x) { return g[x]; }
	int size(int x) { return v[x].size(); }
	bool same(int x, int y) { return g[x] == g[y]; }
	void unite(int x, int y) {
		x = g[x], y = g[y];
		if (x == y) return;
		if (v[x].size() < v[y].size()) swap(x, y);
		v[x].insert(v[x].end(), v[y].begin(), v[y].end());
		for(auto &e : v[y]) g[e] = x;
		v[y].clear();
	}
	bool operator==(const UnionFind& u) { return g == u.g; }
	bool operator!=(const UnionFind& u) { return g != u.g; }
	int operator[](int x) { return g[x]; }
};
int n, q, c, x, y;
int main() {
	cin >> n >> q;
	UnionFind u(n);
	for(int i = 0; i < q; i++) {
		cin >> c >> x >> y;
		if(c) cout << (u.same(x, y) ? 1 : 0) << endl;
		else u.unite(x, y);
	}
}

Measured memory_bytes: 3728
// Problem : D - Dice in Line
// Contest : AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define sort(v) sort(v.begin(),v.end())
#define sortc1(v) sort(v.begin(),v.end(),cmp1)
#define sortc2(v) sort(v.begin(),v.end(),cmp2)
#define sortc3(v) sort(v.begin(),v.end(),cmp3)
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define inf LLONG_MAX
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,k;cin>>n>>k;
//double sum=0;
vi v(n);cin>>v;
double d[n];
for(int i=0;i<n;i++)
d[i]=(v[i]+1)/2.0;
double ans=0;
for(int i=0;i<k;i++)
ans+=d[i];
int ptr=0;
double fans=ans;
for(int i=k;i<n;i++)
{
	ans+=d[i]-d[ptr++];
	fans=max(fans,ans);
}
cout<<setprecision(9)<<fans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 3328
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOut(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	apf := make([]map[int]int, n)
	p := make(map[int]int)
	for i := 0; i < n; i++ {
		q := PrimeFactors(a[i])
		apf[i] = make(map[int]int)
		for k, v := range q {
			p[k] = larger(p[k], v)
			apf[i][k] = v
		}
	}
	ans := 0
	z := 1
	for k, v := range p {
		z *= repeatPow(k, v, lp)
		z %= lp
	}
	for i := 0; i < n; i++ {
		ans += z * modinv(a[i], lp)
		ans %= lp
	}
	fmt.Println(ans)
}
func PrimeFactors(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2]++
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i]++
			n = n / i
		}
	}
	if n > 2 {
		pfs[n]++
	}
	return pfs
}
func repeatPow(x, y, d int) int {
	if y == 0 {
		return 1
	} else if y == 1 {
		return x
	} else {
		z := repeatPow(x, y/2, d)
		if y%2 == 0 {
			return z * z % d
		} else {
			return z * z % d * x % d
		}
	}
}
func modinv(a, m int) int {
	b, u, v := m, 1, 0
	for {
		t := a / b
		a -= t * b
		u -= t * v
		a, b, u, v = b, a, v, u
		if b == 0 {
			break
		}
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}


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

int main() {
	string S,T;
  cin >> S >> T;
  int count = 0;
  if(S.length() + 1 != T.length()){
  	cout << "No" << endl;
  }
  else{
  	for(int i = 0; i < S.size(); i ++){
    	if(S[i] != T[i]){
        	count++;
        }
    }
    if(count == 0){
    	cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
  
}

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

#define MAX 1005
#define INF INT_MAX
#define vi vector<int>
#define pb push_back

int vis[MAX], par[MAX], dist[MAX];
int n, ans = INF;
vi cycle, g[MAX];

void reset() {
    for (int i = 0; i <= n; i++) vis[i] = dist[i] = par[i] = 0;
}

void bfs(int v) {
    int flag = 0; // cycle not found yet

    queue<int> q;

    q.push(v);
    vis[v] = 1;

    while (!(q.empty())) {
        int u = q.front(); q.pop();
        for (int child : g[u]) {
            if (vis[child]) {
                if (child == v) {
                    int cur = dist[u] + 1;
                    if (cur < ans) {
                        ans = cur;
                        cycle.clear();

                        int vert = u;
                        cycle.pb(u);

                        while (vert != v) {
                            vert = par[vert];
                            cycle.pb(vert);
                        }
                    }

                    flag = 1; // cycle found
                    break;
                }
            }
            else {
                vis[child] = 1;
                par[child] = u;
                dist[child] = dist[u] + 1;

                q.push(child);
            }
        }
        if (flag) break;
    }
}

int main() {
    int m; scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int u, v; scanf("%d%d", &u, &v);
        g[u].pb(v);
    }

    for (int u = 1; u <= n; u++) {
        bfs(u);

        if (u == n) break;
        reset();
    }

    if (ans == INF) cout << -1;
    else {
        printf("%d\n", ans);
        for (int v : cycle) printf("%d\n", v);
    }
  
    return 0;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a;
	for(int i = 0; i < n; i++){
		int p;
		cin >> p;
		a.push_back(p);
	}
	sort(a.begin(), a.end());
	int ans = 0;	
	for(int i = 0; i<k; i++){
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define P 1000000007
#define M 2048

int a[202020],b[202020];
int mat[2*M][2*M];

int binom[2*M][2*M];

main(){
	for(int i=0;i<2*M;i++)for(int j=0;j<2*M;j++)binom[i][j]=(i==0||j==0?1:(binom[i-1][j]+binom[i][j-1])%P);
	
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		mat[-a[i]+M][-b[i]+M]++;
	}
	
	/*
	for(int i=-3;i<=3;i++){
		for(int j=-3;j<=3;j++)printf("%d ",mat[i+M][j+M]);
		puts("");
	}
	puts("");
	*/
	for(int i=1;i<2*M;i++){
		for(int j=1;j<2*M;j++){
			mat[i][j]+=mat[i-1][j];mat[i][j]%=P;
			mat[i][j]+=mat[i][j-1];mat[i][j]%=P;
		}
	}
	
	/*
	for(int i=-3;i<=3;i++){
		for(int j=-3;j<=3;j++)printf("%d ",mat[i+M][j+M]);
		puts("");
	}
	*/
	int ans=0;
	for(int i=0;i<n;i++){
		ans=(ans+mat[a[i]+M][b[i]+M])%P;
	}
	for(int i=0;i<n;i++){
		ans=(ans-binom[2*a[i]][2*b[i]])%P;
		ans=(ans+P)%P;
	}
	
	ans=(ans*(long long)((P+1)/2))%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 132736
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll 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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    bool flag = false;
    if (N % 10 == 9) flag = true;
    if (N / 10 == 9) flag = true;
    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>

int main() {
	long long n;

	std::cin >> n;

	std::vector<std::pair<long long, long long> > v(n);

	for (long long i = 0; i < n; i++)
	{
		long long a;
		std::cin >> a;

		v[i] = { a, i + 1 };
	}

	std::sort(v.begin(), v.end());

	for (long long i = 0; i < n; i++)
	{
		std::cout << v[i].second << " ";
	}

	return 0;
}


Measured memory_bytes: 2432
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	k := getNextInt(scanner)
	if k < 10 {
		fmt.Fprintln(writer, k)
		return
	}
	q := make([]int64, 0)

	for i := 1; i < 10; i++ {
		q = append(q, int64(i))
	}

	for k > 1 {
		p := q[0]
		q = q[1:]
		k--
		m := int(p % 10)
		for i := 0; i < 3; i++ {
			if m+i-1 < 0 {
				continue
			}
			if m+i-1 > 9 {
				continue
			}
			q = append(q, p*10+int64(m+i-1))
		}
	}
	fmt.Fprintln(writer, q[0])
}


Measured memory_bytes: 7936
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b,ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m-1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}



int main() {
	ll n;
	cin >> n;
	n = abs(n);
	ll sum = 0;
	ll ans = 0;
	for (int i = 1;;i++) {
		sum += i;
		if (sum >= n) {
			ans = i; 
			break;
		}
	}
	cout << ans << endl;
}


  


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

int main() {
  string HEISEI = "Heisei";
  string TBD = "TBD";

  string S; //yyyy/mm/dd
  cin >> S;

  int yyyy, mm, dd;
  yyyy = stoi(S.substr(0, 4));
  mm = stoi(S.substr(5, 2));
  dd = stoi(S.substr(8, 2));

  //cout << yyyy << mm << dd << endl;

  if (yyyy < 2019) {
    cout << HEISEI << endl;
  } else if (yyyy == 2019 && mm < 4) {
    cout << HEISEI << endl;
  } else if (yyyy == 2019 && mm == 4 && dd <= 30) {
    cout << HEISEI << endl;
  } else {
    cout << TBD << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin>>S;
  int n=S.size();
  //nagasa
  bool ok=true;
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(S.at(i)=='L'){
        ok=false;

      }
    }
      else{
        if(S.at(i)=='R'){
         ok=false;
          
        }
       }  
    }
  
   if(ok){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
    
} 





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

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	for (int i = 0;i < N;++i) {
		int A;
		cin >> A;
		int day = 1;
		while (day <= D) {
			X += 1;
			day += A;
		}
	}
	cout << X << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


void solve(int&ans, vvi&ca, int n, int m, int x, vi&w, int i)
{
	if(i==n)
	{
		for(int j=1;j<=m;j++)
		{
			if(w[j]<x) return;
		}
		if(ans<0) ans=w[0];
		if(ans>w[0]) ans=w[0];
		return;
	}
	solve(ans, ca, n, m, x, w, i+1);
	vi t=w;
	for(int j=0;j<=m;j++)
	{
		t[j]+=ca[i][j];
	}
	solve(ans, ca, n, m, x, t, i+1);
}


int main(void)
{
	int n, m, x;
	while(scanf("%d%d%d", &n, &m, &x)==3)
	{
		vvi ca(n);
		for(auto&mca:ca) mca.resize(m+1);
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<=m;j++) scanf("%d", &ca[i][j]);
		}
		int ans=-1;
		vi w(m+1, 0);
		solve(ans, ca, n, m, x, w, 0);
		printf("%d\n", ans);
	}
	return 0;
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  ll S,W;
  cin >> S >> W;
  
  if(W<S){
    cout << "safe";
  }else{
    cout << "unsafe";
  }

  return 0;
}

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

int main() {
  string S;
  int K;
  cin >> S >> K;
  int count1 = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != '1') break;
    count1 += 1;
  }
  
  if (count1 >= K) {
    cout << 1 << endl;
    return 0;
  }
  cout << S[count1] << endl;
}

Measured memory_bytes: 256
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = input()
print(s[0::2])


Measured memory_bytes: 3700
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		int H[]=new int[N];
		long sum=0;
		if(N<=K){
			System.out.println(0);
			System.exit(0);
		}
		for(int i=0;i<N;i++){
			H[i]=stdIn.nextInt();
			sum+=H[i];
		}
		Arrays.sort(H);
		for(int i=0;i<K;i++){
			sum-=H[N-1-i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 63456
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a==b) cout << "Draw" << "\n";
  else if(a==1) cout << "Alice" << "\n";
  else if(b==1) cout << "Bob" << "\n";
  else if(a>b) cout << "Alice" << "\n";
  else cout << "Bob" << "\n";
  return 0;
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define mii map<int,int>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  map<int, int> a, b;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    a[t]++;
  }
  int m; cin >> m;
  for (int i = 0; i < m; i++) {
    int t; cin >> t;
    b[t]++;
  }
  for (auto &i : b) {
    if (a[i.fi] < i.sc) {
      cout << "NO" << '\n';
      return;
    }
  }
  cout << "YES" << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 28568
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,K; cin>>N>>K;
    vector<int> l(N);
    REP(i,N) cin>>l[i];
    Sort(l);
    Reverse(l);
    int ans =0;
    REP(i,K) ans += l[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace 気象予報士
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] condi = new string[hw[0]];
            int[][] ans = new int[hw[0]][];
            int count = 0;
            for (int i = 0; i < condi.Length; i++)
            {
                condi[i] = Console.ReadLine();
                ans[i] = new int[hw[1]];
            }
            for (int i = 0; i < hw[0]; i++)
            {
                for (int j = 0; j < hw[1]; j++)
                {
                    count = j;
                    while(count >= 0)
                    {
                        if (condi[i][count] == 'c') { ans[i][j] = j - count; break; }
                        count--;
                    }
                    if (count < 0) { ans[i][j] = -1; }
                }
            }
            for (int i = 0; i < hw[0]; i++)
            {
                for (int j = 0; j < hw[1] - 1; j++)
                {
                    Console.Write(ans[i][j]+" ");
                }
                Console.WriteLine(ans[i][hw[1] - 1]);
            }
        }
    }
}



Measured memory_bytes: 16452
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
struct Sieve {
  // Eratosthenes sieve in [0,i)
  int n;
  vector<int> mpfac;  // minimum prime factor
  vector<int> primes;
  ////////////////////////////////////////////////
  Sieve(int _n) : mpfac(_n) {
    n = _n;
    for (int i = 0; i < n; ++i) {
      mpfac[i] = i;
    }
    for (int i = 2; i * i < n; ++i) {
      if (mpfac[i] != i) continue;
      for (int j = i * i; j < n; j += i) {
        if (mpfac[j] == j) mpfac[j] = i;
      }
    }
    for (int i = 2; i < n; ++i) {
      if (mpfac[i] == i) {
        primes.push_back(i);
      }
    }
  }
  ////////////////////////////////////////////////
  map<int, int> factorize(int m) {
    map<int, int> res;
    while (m > 1) {
      res[mpfac[m]]++;
      m /= mpfac[m];
    }
    return res;
  }
  ////////////////////////////////////////////////
  long long fm(int m) {
    map<int, int> res;
    while (m > 1) {
      res[mpfac[m]]++;
      m /= mpfac[m];
    }
    long long r = 1LL;
    for (auto itr = res.begin(); itr != res.end(); ++itr) {
      r *= (ll)(itr->second + 1);
    }
    return r;
  }
};
////////////////////////////////////////////////
// std::vector<int> sieve(int n) {
//   std::vector<int> res(n);
//   std::iota(res.begin(), res.end(), 0);
//   for (int i = 2; i * i < n; ++i) {
//     if (res[i] < i) continue;
//     for (int j = i * i; j < n; j += i)
//       if (res[j] == j) res[j] = i;
//   }
//   return res;
// }
// ////////////////////////////////////////////////
// ll fac(int n, const std::vector<int>& min_factor) {
//   map<int, int> res;
//   while (n > 1) {
//     res[min_factor[n]]++;
//     n /= min_factor[n];
//     // 割った後の値についても素因数を知っているので順次求まる
//   }
//   ll r = 1LL;
//   REPvec(itr, res) { r *= (itr->second + 1LL); }
//   return r;
// }
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  Sieve S(n + 1);
  ll ans = 0;
  REP(i, n + 1) { ans += (ll)i * S.fm(i); }
  cout << ans << endl;
}


Measured memory_bytes: 46480
function Main(input){
    var day = parseInt(input);
    var eveCount = 25 - day;
    var output = 'Christmas';
    for(var i = 0; i < eveCount ; i ++ ){
        output += ' Eve';
    }
    console.log(output);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 21064