akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int DP[n];
    DP[0]=0;
    for (int i =1;i<n;i++)
    {
        int cnt =max(0,i-k);
        DP[i]= 0x3f3f3f3f;
        for (int j=cnt;j<i;j++)
        {
            DP[i]=min(DP[i],abs(arr[i]-arr[j])+DP[j]);
        }
    }
    cout<<DP[n-1];
    return 0;
}


Measured memory_bytes: 4328
#!/usr/bin/env run-cargo-script

#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, StdinLock, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn solve(n: u32, a: u32, b: u32) -> u32 {
    (1..n + 1)
        .filter(|i| {
            let s = format!("{}", i)
                .as_bytes()
                .iter()
                .map(|&d| (d - b'0') as u32)
                .sum();
            a <= s && s <= b
        })
        .sum()
}

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next(), sc.next()));
}

struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}

trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
//abc053_b.cpp
//Sun Oct 21 20:00:33 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;

	int apos = -1;
	int zpos = -1;
	for (int i=0;i<s.size();i++){
		if (s[i] == 'A' && apos == -1){
			apos = i;
		}else if (s[i] == 'Z' && zpos < i){
			zpos = i;
		}
	}
	cout << zpos - apos + 1 << endl;
}

Measured memory_bytes: 640
n = input()
op_cnt = len(n) - 1  # 隙間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # 予め、["-", "-", "-"]というリストを作っておく
    for j in range(op_cnt):
        if (i >> j) & 1:  # 順に右シフトさせ、最下位bitが1かどうか確認
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を"+"で上書き
    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break


Measured memory_bytes: 3060
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,k=0,ct=0,res=0;string s;char pre='$';
    cin>>n>>k;
    cin>>s;
    for(int i=0;i<s.length();++i)
    {
    	if(s[i]!=pre)
    	{
    		pre=s[i];
    		++ct;
    	}
    	if(i-1>=0&&s[i]=='L'&&s[i-1]=='L')
    		++res;
    	if(i+1<s.length()&&s[i]=='R'&&s[i+1]=='R')
    		++res;
    }
    ct=(ct-1)/2;
    if(k>ct)
    	res=n-1;
    else
    	res+=2*k;
    cout<<res<<endl;
}

Measured memory_bytes: 512
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    StopWatch sw;
    sw.start();
    long K = lread();
    long x = 7 % K;
    foreach (i; 0 .. 1_000_000_000)
    {
        if (1900 < sw.peek.msecs())
        {
            writeln(-1);
            return;
        }
        if (x == 0)
        {
            writeln(i + 1);
            return;
        }
        x = x * 10 + 7;
        x %= K;
    }
}


Measured memory_bytes: 3720
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = str(input())

for i in range(N-K):
  if T[i] == T[i+K]:
    if len(T) > i+K:
      T = T[:i+K] + '*' + T[i+K+1:]
    else:
      T = T[:i+K] + '*'

score = 0
for i in range(N):
  if T[i] == 'r':
    score += P
  elif T[i] == 's':
    score += R
  elif T[i] == 'p':
    score += S
    
print(score)
    

Measured memory_bytes: 11144
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N,Y;
  cin>>N>>Y;
  for(int x=0;x<=2000;x++){
    for(int y=0;y<=2000;y++){
      int z=N-x-y;
      if(Y==10000*x+5000*y+1000*z && z>=0){
        cout<<x<<" "<<y<<" "<<z<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
}

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

int main() {
        int n;
		cin>>n;
        int lw;
		cin>>lw;
        int w[n+1];
        int v[n+1];
        for (int i = 1; i <= n; i++) {
            cin>>w[i];
            cin>>v[i];
        }
        long dp[n+1][100001];
        for(int i=0;i<n+1;i++){
            for(int j=1;j<100001;j++){
                dp[i][j]=lw+1;
            }
        }
        for (int i=1;i<=n;i++){
            for (int j=0;j<100001;j++) {
                if(v[i]>j){
                    dp[i][j]=dp[i-1][j];
                } 
				else{
                    dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
                }
            }
        }
        for (int i = 100000; i > 0; i--) {
            if (dp[n][i] <= lw) {
                cout<<i<<endl;
                break;
            }
        }
	return 0;
}


Measured memory_bytes: 79104
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int m,d;
	cin>>m>>d;
	int res=0;
	rb(i,1,m){
		rb(j,1,d){
			if(j>=10){
//				cout<<i<<" "<<j<<endl;
				if((j%10)*(j/10)==i&&(j%10)>=2&&(j/10)>=2) res++; 
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

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

int main()
{
  char o[51]={},e[51]={};
  int i,j=0,k=0;
  
  scanf("%s %s",o,e);
  
  for(i=1;i<=(strlen(o)+strlen(e));i++)
  {
    if(i%2==1)
    {
      printf("%c",o[j]);
      j++;
    }
    else
    {
      printf("%c",e[k]);
      k++;
    }
  }
  
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;

#define DEG2RAD(deg) deg * M_PI / 180

int main()
{
    int a, b, c;
    double s, l, h;

    cin >> a >> b >> c;

    s = 0.5 * a * b * sin(DEG2RAD((double)c));
    l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(DEG2RAD((double)c)));
    h = b * sin(DEG2RAD((double)c));

    cout << fixed << setprecision(8) << s << endl;
    cout << fixed << setprecision(8) << l << endl;
    cout << fixed << setprecision(8) << h << endl;

    return 0;
}

Measured memory_bytes: 1264
import java.util.Scanner;

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


    	int sum = 0;
    	for (int i = 0; i < N_array.length; i++) {
			sum += Character.getNumericValue(N_array[i]);
		}

    	if (Integer.parseInt(N) % sum == 0){
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    ll A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    
    ll dp[N][2];
    
    dp[0][0] = 0;
    dp[0][1] = -(10<<21);
    
    for(int i = 0; i < N; i++){
        dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
        dp[i+1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i]);
    }
    
    cout << dp[N][0] << endl;
    
    
}


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

int main()
{
    int x,a,b,s1=0,s2=0;
    scanf("%d%d%d",&x,&a,&b);
    if(1<=x && x<=1000 && 1<=a && a<=1000 && 1<=b && b<=1000)
    {
        s1 = abs(x-a);
        s2 = abs(x-b);
        if(s1<s2) printf("A");
        else printf("B");
    }

return 0;
}

Measured memory_bytes: 1640
N = int(input())
S = str(input())
def rot(s, num):
    ans = []
    for i in range(len(s)):
        temp = ord(s[i])
        if 65 <= temp + num <= 90:
            ans.append(chr(temp + num))
        else:
            ans.append(chr(65 + (temp + num) - 91))
    temp_ans = "".join(ans)
    return temp_ans
print(rot(s = S, num = N))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll ans = 0;
void dfs(ll x)
{
    ans++;
    for(int i = 3; i <= x - 3; i++)
    {
        dfs(i);
    }
}
ll dp[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    //dfs(n);
    dp[0] = 1;
    for(int i = 3; i <= n; i++)
    {
        for(int j = 3; j <= i; j++)
        {
            dp[i] += dp[i - j];
            dp[i] = dp[i] % mod;
        }
    }
    cout << dp[n] << "\n";
    return 0;
}


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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD (int)10e9+7
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

const int mxN = 1e5+5;

int n;
int h, temp;

int dp[mxN];
int stones[mxN];
int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    memset(dp, 0x3f, sizeof(int)*mxN);
    
    cin >> n;

    for(int i = 0; i<n;i++) cin >> stones[i];
    
    dp[0]=0;

    for(int i=0; i<n; i++) {
        for(int x : {i+1, i+2}) {
            if(x<n) {
                min_self(dp[x], dp[i]+abs(stones[i]-stones[x]));
            }
        }
    }
    cout << dp[n-1] << endl;
    


    return 0;

}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  double R; cin >> R;
  cout << setprecision(22) << 2*R*3.14159265359 << endl;
  return 0;
}


Measured memory_bytes: 3744
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
 
for i in range(N):
  A[i] = -A[i]
  
heapq.heapify(A)
 
for _ in range(M): 
    hoge = -heapq.heappop(A)
    hoge = hoge // 2
    heapq.heappush(A, -hoge)
 
print(-sum(A))

Measured memory_bytes: 14180
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int a, p;
    cin >> a >> p;
    p += a * 3;
    P(p/2);


    return 0;
}


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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;
const double PI = acos(-1);

#ifndef tejasp
#define trace(...) {}
#define cotra(...) {}
#define end_routine() {}
#define localsys 0
#define endl '\n'
#endif

#define MAXN 100010
vvi adj(MAXN);
vl val(MAXN,mod);
vll lim(MAXN,{-INF,INF});

pll dfs1(int v, int p)
{
    forr(x,adj[v])
    {
        if(x!=p)
        {
            auto cur=dfs1(x,v);
            lim[v].ff=max(lim[v].ff,cur.ff);
            lim[v].ss=min(lim[v].ss,cur.ss);
        }
    }
    return make_pair(lim[v].ff-1,lim[v].ss+1);
}

bool flag=0;

void dfs2(int v, int p)
{
    if(val[v]==mod)
    {
        if(val[p]+1>=lim[v].ff&&val[p]+1<=lim[v].ss)
            val[v]=val[p]+1;
        else if(val[p]-1>=lim[v].ff&&val[p]-1<=lim[v].ss) 
            val[v]=val[p]-1;
        else flag=1;
    }
    trace(v,val[v],lim[v],val[p],flag)
    forr(x,adj[v]) if(x!=p) dfs2(x,v);
}

int tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0, ans=0;
    cin>>n;
    fol(i,1,n)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    cin>>k;
    fol(i,0,k)
    {
        cin>>u>>v;
        lim[u]={v,v};
        val[u]=v;
    }
    dfs1(1,0);
    fol(i,1,n+1) if(lim[i].ff>lim[i].ss) return cout<<"No"<<endl, 0;
    if(val[1]==mod) val[1]=lim[1].ff;
    dfs2(1,0);
    if(flag) return cout<<"No"<<endl, 0;
    cout<<"Yes"<<endl;
    fol(i,1,n+1) cout<<val[i]<<endl;
    return 0;
}

signed main()
{
    #ifdef tejasp
            freopen("input.txt", "rt", stdin);
            freopen("output.txt", "wt", stdout);
    #endif
    if(!localsys) { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
    end_routine();
    if(localsys) system("pause");
}


Measured memory_bytes: 13440
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    for (ll i = K; i <= N+1; i++) {
        ll l = (i - 1) * i / 2;
        ll r = (2 * N - i + 1) * i / 2;
        ans += (r - l) + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <time.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 250
# define eps 1e-3
# define MAXM 500005
# define MOD 1000000007
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(c-b==b-a)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}























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

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef complex<double> CD;

#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define F first
#define S second

void R(int &x) { scanf("%d", &x); }
void R(LL &x) { scanf("%lld", &x); }
void R(ULL &x) { scanf("%llu", &x); }
void R(double &x) { scanf("%lf", &x); }
void R(LD &x) { scanf("%Lf", &x); }

template <typename T> void R(T &t) { cin >> t; }
template <typename T> void R(vector<T> &ar) {
  for (auto &it : ar)
    R(it);
}

template <typename T, typename... Args> void R(T &t, Args &... args) {
  R(t);
  R(args...);
}

void W(const char &c) { putchar(c); };
void W(const int &x) { printf("%d", x); }
void W(const LL &x) { printf("%lld", x); }
void W(const ULL &x) { printf("%llu", x); }
void W(const double &x) { printf("%lf", x); }
void W(const LD &x) { printf("%Lf", x); }

template <typename T> void W(const T &t) { cout << t; }
template <typename T> void W(const vector<T> &ar) {
  for (size_t i = 0; i < ar.size(); ++i) {
    W(ar[i]);
    putchar(" \n"[i + 1u == ar.size()]);
  }
}
template <typename T, typename... Args>
void W(const T &t, const Args &... args) {
  W(t);
  W(args...);
}

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

string s;
LL ans = 0;
int main() {
  cin >> s;
  int n = s.size() - 1;
  REP(i, (1 << n)) {
    vector<int> v;
    v.push_back(0);
    REP(j, n) if (i & (1 << j))
      v.push_back(j + 1);
    v.push_back(n + 1);
    REP(j, int(v.size()) - 1) {
      LL t = 0;
      for (int k = v[j]; k < v[j + 1]; ++k) {
        t = t * 10 + s[k] - '0';
      }
      ans += t;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int max = 0;

        for(int i = 0; i < N; i++) {
            String s1 = S.substring(0,i);
            String s2 = S.substring(i,N);

            boolean[] e1 = new boolean[26];
            boolean[] e2 = new boolean[26];
            for(int j = 0; j < s1.length(); j++) {
                e1[s1.charAt(j) - 'a'] = true;
            }
            for(int j = 0; j < s2.length(); j++) {
                e2[s2.charAt(j) - 'a'] = true;
            }
            int sum = 0;
            for(int j = 0; j < 26; j++) {
                sum += (e1[j] && e2[j] ? 1:0);
            }
            max = Math.max(sum,max);
        }
        System.out.println(max);


    }
}

Measured memory_bytes: 23124
package main

import "fmt"

func main() {
	var n, d, x int
	fmt.Scan(&n, &d, &x)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	sum := 0
	for _, v := range a {
		for i := 0; i*v+1 <= d; i++ {
			sum++
		}
	}
	fmt.Println(sum + x)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#define ll long long
#define endl '\n'
using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    auto arr = new int[N+1]();
    for(int i = 1; i <= N; i++)
        cin >> arr[i];
    int ret = 0;
    for(int i = 1; i < N; i++)
    {
        if(i == arr[i])
        {
            swap(arr[i], arr[i+1]);
            ret += 1;
        }
    }
    if(N == arr[N])
        ret += 1;
    
    cout << ret << endl;
    return 0;
}


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

#define PB push_back
#define MP make_pair
#define fi first
#define se second

typedef long long LL;

const double EPS=1e-9;
const double PI=acos(-1.0);
const int MAXN=100005;
const LL MOD=1000000007;
const int dx[8]={-1, 0, 1, -1, 1, -1, 0, 1}, dy[8]={-1, -1, -1, 0, 0, 1, 1, 1};

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

set<int> stat;

int main(){
	base();
	int n, d, ans=0;
	cin>>n;

	while(n--){
		cin>>d;
		if(stat.count(d)){
			ans--;
			stat.erase(d);
		}
		else{
			stat.insert(d);
			ans++;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

// greatest common divisor
long long gcd(long long a, long long b) {
  long long r = 1;
  while (r != 0) {
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

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

  ll n, m; cin >> n >> m;
  string s, t; cin >> s >> t;
  ll gd = gcd(n, m);
  ll lcm = n*m/gd;

  rep(i, n) {
    if (i%(lcm/m)==0) {
      ll k = i/(lcm/m);
      k = k*(lcm/n);
      //debug(i); debugln(k);
      if (s.at(i) != t.at(k)) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << lcm << endl;
}

Measured memory_bytes: 640
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-13 06:59:58
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  int k; cin >> k;

  int n = s.size();

  for (int i = 0; i < n; ++i) {
    if (s[i] == 'a') continue;
    int need = 26 - (s[i] - 'a');
    debug(need);
    if (need <= k) {
      k -= need;
      s[i] = 'a';
    }
    if (k == 0) {
      break;
    }
  }

  debug(k);

  if (k > 0) {
    char c = s.back();
    s.back() = (char) ((c - 'a' + (k % 26)) % 26 + 'a');
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include <vector>
#include <queue>
#include <algorithm>
#include <time.h> 
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<int>data;
    //code goes here
    int num, firstNegtiveIdx, minValue=10e8, negativeCtr=0;
    long long sum=0;
    cin >> num;
    for(int i=0;i<num;i++){
        int tmp;
        cin >> tmp;

        if(tmp<0){
            negativeCtr++;
            tmp = tmp*(-1);
        }

        if(tmp < minValue){
            minValue = tmp;
        }

        sum += tmp;

        data.push_back(tmp);
    }

    if((negativeCtr%2) == 1){
        sum = sum - 2*minValue;
    }
    cout<<sum;

}


Measured memory_bytes: 892
N = int(input())

num_list_s=[1,100,10000]
num_list_e=[10,1000,100000]

cnt=0
for n in range(N+1):
    for l in range(3):
        if n >= num_list_s[l] and n < num_list_e[l] :
            cnt+=1
print(cnt)

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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

const int NMax = 1050;

int v[4][NMax];
int main() {
	Boost();

	int n;
	cin >> n;

	for(int i = 1; i <= 2; ++i) {
		for(int j = 1; j <= n; ++j) {
			cin >> v[i][j];
		}
	}

	for(int i = 1; i <= 2; ++i) {
		for(int j = 1; j <= n; ++j) {
			v[i][j] += max(v[i - 1][j], v[i][j - 1]);
		}
	}
	
	cout << v[2][n];
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string X) {
    immutable N = X.length.to!int();
    int n=0,q=0;
    foreach(c;X) {
        if(c=='S') ++q;
        else if(q>0) --q;
        else ++n;
    }
    return n+q;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 636
using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int bun[]={1,2,4,8,16,32,64,128,256,512};
int main()
{
	int x;
	while(cin>>x){
		for(int i=0;i<10;i++){
			if((x>>i)&1)printf(bun[i]>x/2?"%d\n":"%d ",bun[i]);
		}
	}
    return 0;
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
    ll x, y;
    cin>>x>>y;
    if(abs(x-y) <= 1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}


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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#define rep(i,m,n) for(int i=m; i<(n); i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
typedef long long ll;
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ok = true;
    if(s[2] != s[3]) ok = false;
    if(s[4] != s[5]) ok = false;
    if(ok) cout << "Yes";
    else cout << "No";
}


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

using namespace std;

struct st
{
  int val;
  int num;
};

bool operator<(const st& left, const st& right) {
        return left.val < right .val;
}

int main()
{
  long long n, k;
  cin >> n >> k;
  
  vector<st> v;
  for(int i=0; i<n; i++){
    st s;
    cin >> s.val >> s.num;
	v.push_back(s);
  }
  sort(v.begin(), v.end());
  
  long long count=0;
  int val = 0;
  for(vector<st>::iterator i=v.begin(); i!=v.end(); i++){
    count += i->num;
    if(count >= k){
      val = i->val;
      break;
    }
  }
      
  
  cout << val << endl;
  
  return 0;
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int MOD = 998244353;
        int[] array = new int[100001];
        
        int max = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (i == 0 && num != 0) {
                System.out.println(0);
                return;
            }
            max = Math.max(max, num);
            array[num]++;
        }
        
        if (n == 1 && array[0] == 1) {
            System.out.println(1);
            return;
        }
        
        if (array[0] != 1) {
            System.out.println(0);
            return;
        }
        
        long answer = 1;
        for (int i = 1; i <= max; i++) {
            if (array[i] == 0) {
                System.out.println(0);
                return;
            }
            
            for (int j = 1; j <= array[i]; j++) {
                answer = (answer * array[i - 1]) % MOD;
            }
        }
        
        
        System.out.println(answer);
    }
}


Measured memory_bytes: 48540
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 
#include <atcoder/fenwicktree>

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
using namespace atcoder;

void solve()
{
    int n, Q;
    scanf("%d%d", &n, &Q);
    fenwick_tree<ll> fw(n);
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        fw.add(i, tmp);
    }

    for (i = 0; i < Q; i++) {
        int t, u, v;
        scanf("%d%d%d", &t, &u, &v);
        if (t == 0) {
            fw.add(u, v);
        }
        else {
            printf("%lld\n", fw.sum(u, v));
        }
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 8220
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int x,a,b; cin>>x>>a>>b;
  x -= a;
  int y = x/b;
  x -= b*y;
  cout << x << endl;
  return 0;
}


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;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << 0 << endl;
    string S; cin >> S;
    if (S=="Vacant") return 0;
    int lb=0,ub=N,pre=0,seat=(S=="Male"?0:1);
    while(1){
        int mid=(lb+ub)>>1;
        cout << mid << endl;
        cin >> S;
        if (S=="Vacant") return 0;
        int now=(S=="Male"?0:1);
        if (pre<mid) ((mid-pre)%2==abs(now-seat)%2?lb:ub)=mid;
        else ((pre-mid)%2==abs(seat-now)%2?ub:lb)=mid;
    }
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d) {
    cout << "Left" << endl;
  }
  // ここにプログラムを追記
  else if (a + b < c + d) {
    cout << "Right" << endl;
  }
  else if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
image = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    image[l - 1][r - 1] += 1
sumimage = [[0] * n for _ in range(n)]
for l in range(n - 1, -1, -1):
    for r in range(l, n):
        if l == r:
            sumimage[l][r] = image[l][r]
        else:
            sumimage[l][r] = image[l][r] + sumimage[l + 1][r] + sumimage[l][r - 1] - sumimage[l + 1][r - 1]
for _ in range(q):
    a, b = map(int, input().split())
    c = sumimage[a - 1][b - 1]
    print(c)

Measured memory_bytes: 58968
using System;
using System.Collections.Generic;
using System.Text;

public class Program
{
  private static void Main()
  {
   	int n = int.Parse(Console.ReadLine());
    byte[] str = Encoding.ASCII.GetBytes(Console.ReadLine());
    
    for(int i = 0; i < str.Length; i++)
    {
      if(str[i] + n > Encoding.ASCII.GetBytes("Z")[0])
      {
      	str[i] = (byte)(str[i] + n - 26);
      }
      else
        str[i] = (byte)(str[i] + n);
    }
    
    Console.WriteLine(Encoding.ASCII.GetString(str));
  }
}


Measured memory_bytes: 11112
#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;

const long long mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> v;
    for(int i=0;i<n;i++){
        int q;
        cin>>q;
        v.pb(q);
    }
    sort(v.begin(),v.end());
    ll ans=0;
    for(ll i=n-1;i>=n-k;i--){
        ans+=v[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            a = a.OrderByDescending(i => i).ToArray();
            long L1 = 0, L2 = 0, temp = a[0];
            for (int i = 0; i < a.Count() - 1; i++)
            {
                if (L2 != 0) break;
                else if (temp == a[i + 1])
                {
                    L2 = L1;
                    L1 = temp;
                    temp = 0;
                }
                else temp = a[i + 1];
            }
            Console.WriteLine(L1 * L2);
        }
    }
}

Measured memory_bytes: 23520
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  string s1,s2,s3;
  cin>>s1;
  cin>>s2;
  cin>>s3;

  cout<<s1[0]<<s2[1]<<s3[2]<<endl;

}


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

struct Interval { int min, max; };
Interval intersection(const Interval a, const Interval b) { return {max(a.min, b.min), min(a.max, b.max)}; }
bool contains(const Interval a, const int x) { return a.min <= x && x <= a.max; }

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < N-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;

        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    int K; cin >> K;
    auto root = -1;
    auto marked = vector<bool>(N);
    auto marks = vector<int>(N);
    for (auto i = 0; i < K; i++)
    {
        int v, p; cin >> v >> p;
        v--;

        root = v;
        marked[v] = true;
        marks[v] = p;
    }

    auto constraints = vector<Interval>(N);
    function<void(int, int)> preprocess = [&](const int v, const int parent)
    {
        const auto infinity = int(1e9);
        if (marked[v]) constraints[v] = {marks[v], marks[v]};
        else constraints[v] = {-infinity, infinity};

        for (const auto w : adjacency_list[v]) if (w != parent)
        {
            preprocess(w, v);
            constraints[v] = intersection(constraints[v], {constraints[w].min-1, constraints[w].max+1});
        }
    };
    preprocess(root, -1);

    function<bool(int, int)> process = [&](const int v, const int parent)
    {
        auto ok = false;
        if (marked[v]) ok = contains(constraints[v], marks[v]);
        else
        {
            for (const auto x : {marks[parent]-1, marks[parent]+1})
            {
                if (contains(constraints[v], x))
                {
                    marks[v] = x;
                    ok = true;
                }
            }
        }

        for (const auto w : adjacency_list[v]) if (w != parent)
            ok &= process(w, v);

        return ok;
    };

    if (process(root, -1))
    {
        cout << "Yes" << "\n";
        for (const auto x : marks) cout << x << "\n";
    }
    else cout << "No" << "\n";
}


Measured memory_bytes: 17024
N,W=map(int,input().split())
I=[0]+[[*map(int,input().split())]for _ in[0]*N]
C=[[0]*-~W for _ in[0]*-~N]
for i in range(1,N+1):
 for w in range(1,W+1):
  C[i][w]=C[i-1][w]
  if I[i][1]>w:continue
  if I[i][0]+C[i-1][w-I[i][1]]>C[i-1][w]:
   C[i][w]=I[i][0]+C[i-1][w-I[i][1]]
print(C[N][W])


Measured memory_bytes: 25516
from math import factorial
n,m=map(int,input().split())
a,b=max(n,m),min(n,m)
Q=10**9+7
if a-b>1:print(0);exit()
elif (a+b)%2==1:print((factorial(a)*factorial(b))%Q)
else:print((factorial(a)*2*factorial(b))%Q)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  vector<pair<int, int>> ab(n);
  for (int i = 0; i < n; i++) {
    int a, b; cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  sort(ab.begin(), ab.end());
  long long tot = 0;
  long long res = 0;
  for (auto &s: ab) {
    long long a = s.first, b = s.second;
    if (m <= tot + b) {
      res += a * (m - tot);
      break;
    } else {
      res += a * b;
      tot += b;
    }
  }
  cout << res << '\n';
  return 0;
  
}

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

int main()
{
	long long H;
	cin >> H;

	long long n = 1;
	long long ans = 0;
	while( H > 1 ) {
		ans += n;
		n *= 2;
		H /= 2;
	}
	ans += n;

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nums=new int[3],rep=new int[2];
    rep[0]=0;
    rep[1]=0;
    for(int i=0;i<3;i++){
      nums[i]=sc.nextInt();
      if(nums[i]==5){
        rep[0]++;
      }else if(nums[i]==7){
        rep[1]++;
      }
    }
    if(rep[0]==2&&rep[1]==1){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
using namespace std;


int a[100001];
int ans=-1;
int main()
{
    int n;  cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];

    int cnt=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i] >= a[i+1]) cnt++;
        else
        {
            ans=max(cnt,ans);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    //for(int i=0;i<v.size();i++) cnt=max(cnt,v[i]);
    cout<<ans;
}


Measured memory_bytes: 640