akhauriyash/Code-Regression huggingface dataset:
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e9, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
	use_fast;
	int n;
	cin >> n;
	for(int i = 1; i <= 2 * n - 1; i++) 
		cin >> a[i];
	vector <int> v = {a[n - 1], a[n], a[n + 1]};
	sort(v.begin(), v.end());
	int ans = v[1];
	if(n <= 2)
		return cout << ans << endl, 0;
	if(v[1] == a[n]) 
		return cout << ans << endl, 0;
	else if(v[2] == a[n]) {
		int l = v[1], r = v[2];
		for(int i = 2; i < n; i++) {
			if(l >= r)
				break;
			if(i % 2 == 1) {
				ans = max(ans, max(min(r, a[n - i]), min(r, a[n + i])));
				l = max(l, max(a[n - i], a[n + i]));
			}
			else 
				r = min(r, min(a[n - i], a[n + i]));
		}
		if(l < r && n % 2 == 1)
			ans = max(ans, r);
	}
	else {
		ans = v[0];
		int l = v[0], r = v[1];
		for(int i = 2; i < n; i++) {
			if(l >= r)
				break;
			if(i % 2 == 0) {
				ans = max(ans, max(min(r, a[n - i]), min(r, a[n + i])));
				l = max(l, max(a[n - i], a[n + i]));
			}
			else 
				r = min(r, min(a[n - i], a[n + i]));
		}
		if(l < r && n % 2 == 0)
			ans = max(ans, r);
	}
	cout << ans << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 4408
#include <stdio.h>

int main() {
        int n, m;
        scanf("%d %d", &n, &m);
        int nroad[n];
        int i;
        for(i=0;i<n;i++) {
                nroad[i] = 0;
        }
        for(i=0;i<m;i++) {
                int ta, tb;
                scanf("%d %d", &ta, &tb);
                nroad[ta - 1]++;
                nroad[tb - 1]++;
        }
        for(i=0;i<n;i++) {
                printf("%d\n", nroad[i]);
        }

        return 0;
}


Measured memory_bytes: 128
from collections import Counter

s = input()

flg = False
lst = []

for i in range(len(s)-2):
    if(s[i] == s[i+1]):
        flg = True
        lst.append(i+1)
        lst.append(i+2)
        break
    elif(s[i] == s[i+2]):
        flg = True
        lst.append(i+1)
        lst.append(i+3)
        break

if not(lst):     
    if(s[len(s)-1] == s[len(s)-2]):
        lst.append(len(s)-1)
        lst.append(len(s))
        flg = True

if(flg):
    print(*lst)
else:
    print(-1, -1)

Measured memory_bytes: 9412
#include <iostream>
#include <string>

using namespace std;

void swapDice(int* dice, int* ret) {
	for (int i = 0; i < 6; i++) {
		dice[i] = ret[i];
	}
}

void insertDice(int* dice, int up, int south, int east, int west, int north, int down) {
	dice[0] = up;
	dice[1] = south;
	dice[2] = east;
	dice[3] = west;
	dice[4] = north;
	dice[5] = down;
}

int main(void) {
	int n = 0;
	while (cin >> n && n != 0) {
		int dice[] = {1, 2, 3, 4, 5, 6};
		int count = 1;
		for (int i = 0; i < n; i++) {
			string command;
			cin >> command;
			int ret[6];
			if (command.find("North") != string::npos) {
				insertDice(ret, dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]);
			} else if (command.find("East") != string::npos) {
				insertDice(ret, dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]);
			} else if (command.find("West") != string::npos) {
				insertDice(ret, dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]);
			} else if (command.find("South") != string::npos) {
				insertDice(ret, dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]);
			} else if (command.find("Right") != string::npos) {
				insertDice(ret, dice[0], dice[2], dice[4], dice[1], dice[3], dice[5]);
			} else if (command.find("Left") != string::npos) {
				insertDice(ret, dice[0], dice[3], dice[1], dice[4], dice[2], dice[5]);
			}
			swapDice(dice, ret);
			count += dice[0];
		}
		cout << count << endl;
	}
}

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

int main(){
    ll N;
    cin>>N;
    vector<pair<int,int>>R(N);
    vector<pair<int,int>>B(N);
    vector<int>uselist(N,0);
    rep(i,N){
        cin>>R[i].second>>R[i].first;
    }
    rep(i,N){
        cin>>B[i].first>>B[i].second;
    }
    sort(R.begin(),R.end());
    reverse(R.begin(),R.end());
    sort(B.begin(),B.end());
    int cnt=0;
    rep(i,N){
        rep(j,N){
            if(R[j].first<B[i].second&&R[j].second<B[i].first&&uselist[j]==0){
                uselist[j]=1;
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<endl;
}
    

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

int n, d, ans;
double dist;

int main() {
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep (i, n) {
    rep (j, d) {
      cin >> x[i][j];
    }
  }
  ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      dist = 0;
      rep (k, d) {
        dist += pow((double)(x[i][k]-x[j][k]), 2);
      }
      rep (i, 401) {
        if (dist == i*i) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

T1, T2 = mapint()
A1, A2 = mapint()
B1, B2 = mapint()

if not (A1-B1)*(A2-B2)<0:
    print(0)
else:
    if A1<B1:
        A1, B1 = B1, A1
        A2, B2 = B2, A2
    if A1*T1+A2*T2==B1*T1+B2*T2:
        print('infinity')
        exit(0)
    rest = (A1-B1)*T1
    come = (B2-A2)*T2
    if come<rest:
        print(0)
    else:
        ans = come//(come-rest)
        last = 1 if come%(come-rest)==0 else 0
        print(ans*2-1-last)

Measured memory_bytes: 62008
program atcoder
implicit none
integer(16) :: n,m,i,ans,num,t
integer(16), allocatable :: a(:),b(:),turn(:)

read(*,*) n,m
allocate(a(n),b(n),turn(n))

do i = 1,n
	read(*,*) a(i), b(i)
end do

if(n == 1)then
	write(*,'(i0)') m*a(n)
    stop
end if

call hs2(n,a,turn)

ans = 0
num = 0
do i = 1, n
	t = b(turn(i))
	num = num + t
    ans = ans + a(i)*t
	if(num >= m)then
    	ans = ans - (num-m)*a(i)
        write(*,'(i0)') ans
        stop
    end if
end do

contains
subroutine hs2(n,array,turn)
  implicit none
  integer(16),intent(in)::n
  integer(16),intent(out)::turn(1:n)
  integer(16),intent(inout)::array(1:n)
  
  integer(16)::i,k,j,l,m
  integer(16)::t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  do i=1,N
     turn(i)=i
  enddo

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(l)
        m=turn(l)
     else
        t=array(k)
        m=turn(k)
        array(k)=array(1)
        turn(k)=turn(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           turn(1)=m
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           turn(i)=turn(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     turn(i)=m
  enddo

  return
end subroutine hs2

end program atcoder

Measured memory_bytes: 4864
package main

import (
	"bufio"
	"fmt"
    "os"
    "sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	V_LIST := make([]float64, N)
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		fmt.Scan(&V_LIST[i])
	}

    var sorted_v_list = V_LIST
    sort.Float64Slice(sorted_v_list).Sort()
    ans := V_LIST[0]
	for i := 1; i < N; i++ {
        ans = (ans + V_LIST[i]) / 2
    }
	fmt.Println(ans)
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;

int		main(void)
{
	int		a;
	cin >> a;
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			if (i * j == a)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    ll a;
    double b;
    cin >> a >> b;
    ll c = round(b * ll(100));
    cout << (a*c)/ll(100) << endl;
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n;
string s[MAXX];

int main()
{
    _FastIO;

    cin >> n;
    string ans = "Yes";
    char c;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        if(i){
            if(c != s[i][0]){
                ans = "No";
            }
           for(int j = i - 1; j >= 0; j--){
                if(s[i] == s[j])
                    ans = "No";
           }
        }
        string h = s[i];
        int p = h.size();
        c = h[p - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
char ss[256];
char s[101];
char p[101];
char *x;
char *endx;
int i;
main(){
	scanf("%s%s",&s,&p);
	strcpy(ss,s);
	strcat(ss,s);
	
	x=ss;
	
	x=strstr(x,p);
	
	if(x){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 540
#include<stdio.h>
int main(void)
{
	int d,n;
	int t[201];
	int a[201],b[201],c[201];
	int c1;
	int i,j,k;
	int kei=0,max=-1;
	int dp[201][201];
	
	scanf("%d %d",&d,&n);
	for(i=0;i<d;i++){
		for(j=0;j<n;j++){
			dp[i][j]=0;
		}
	}
	for(i=0;i<d;i++){
		scanf("%d",&t[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	for(i=0;i<d-1;i++){
		for(j=0;j<n;j++){
			if(t[i]>=a[j] && t[i]<=b[j]){
				for(k=0;k<n;k++){
					if(t[i+1]>=a[k] && t[i+1]<=b[k]){
						c1=c[j]-c[k];
						if(c1<0){
							c1=c1*-1;
						}
						if(c1+dp[i][j]>dp[i+1][k]){
							dp[i+1][k]=dp[i][j]+c1;
						}
					}
				}
			}
		}
	}
	for(i=0;i<n;i++){
		if(dp[d-1][i]>max){
			max=dp[d-1][i];
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 1188
n=int(input())
x=[0,3,5,7]
p=[]
flag=True
flag2=True
for c1 in x:
  for c2 in x:
    for c3 in x:
      for c4 in x:
        for c5 in x:
          for c6 in x:
            for c7 in x:
              for c8 in x:
                for c9 in x:
                  line=[c1,c2,c3,c4,c5,c6,c7,c8,c9]
                  sum_=0
                  if line.count(7)>0 and line.count(3)>0 and line.count(5)>0:
                    for i in range(9):
                      if flag==False and line[i] in [3,5,7]:
                        flag2=False
                        break
                      if line[i]==0:
                        flag=False
                      sum_+=line[i]*10**i
                    if flag2==False:
                      flag=True
                      flag2=True
                      continue
                    p.append(sum_)
                    flag=True
p.sort()
for i in range(len(p)):
  if p[i]>n:
    print(i)
    exit()
print(i+1)

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

string &replaceAll(string &s, const string &from, const string &to) {
  int pos = 0;
  size_t find_pos;
  while ((find_pos = s.find(from, pos)) != string::npos) {
    s.replace(find_pos, from.size(), to);
    pos = find_pos + to.size();
  }
  return s;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    cout << replaceAll(s, "Hoshino", "Hoshina") << endl;
  }

  return 0;
}


Measured memory_bytes: 3140
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;

signed main() {
	int p, q, r;
	cin >> p >> q >> r;
	cout << p + q + r - max({ p,q,r }) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i+=2)
using namespace std;
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i]=='L'){
            cout << "No" << endl;
            cnt++;
            break;
        }
        if (s[i + 1] == 'R'){
            cout << "No" << endl;
            cnt++;
            break;
        }
    }
    if(cnt==0)
        cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char** argv) {
    int64_t n, w, ans{0};
    cin >> n >> w;

    std::vector<int64_t> dp(1e5+10, 1e12);
    dp[0] = 0;

    for (int64_t i = 1; i < n+1; ++i) {
        int64_t wi, vi;
        cin >> wi >> vi;
        for (int64_t j = dp.size(); j > 0; --j) {
            if (j-vi  >= 0) {
                dp[j] = min(dp[j], dp[j-vi] + wi);
            }
        }
    }
    for (int64_t j = 1; j < dp.size(); ++j) {
        if (dp[j] > w) continue;
        ans = j;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
/*
ID: varunra2
LANG: C++
TASK: codechef
*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

#define EPS 1e-9
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()

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

const double pi = acos(-1.0);
typedef long int int32;
typedef long long int int64;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef unsigned long int uint32;
typedef unsigned long long int uint64;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define watch(x) cerr << (#x) << " is " << (x) << endl
#define printvii(v)                                    \
  cerr << (#v) << "=";                                 \
  for_each(v.begin(), v.end(), [](PII i) -> void {     \
    cerr << "(" << i.first << "," << i.second << "),"; \
  });                                                  \
  cerr << endl;
#define printvi(v)                                                       \
  cerr << (#v) << "=";                                                   \
  for_each(v.begin(), v.end(), [](int i) -> void { cerr << i << ","; }); \
  cerr << endl;

int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  //freopen("codechef.in", "r", stdin);    
  //freopen("codechef.out", "w", stdout); 
#endif
  cin.sync_with_stdio(0); cin.tie(0);

  string s;
  cin >> s;

  if(s == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if(s == "Rainy") {
    cout << "Sunny" << endl;
  }
  else {
    cout << "Rainy" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
    ll a,b,v,w,t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    if(v==w)
    {
        cout<<"NO";
    }
    else
    {
        ll k=abs(b-a);
        if(k<=(v-w)*t)
        {
            cout<<"YES";
        }
        else
        {
            cout<<"NO";
        }
       
    }
    
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Policy_based_Data_Structure 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/

#define ll long long int
#define ld long double
#define bigint int64_t
#define fst first
#define scd second
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;read(t);while(t--)
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define INF (ll)(1e15)
#define vvll vector<vector<ll>>
#define R_0 return 0
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'


#define forn(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define for1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define forr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define forab(i,a,b,c) for(ll (i) = a ; (i) <= (b) ; (i)+=(c))

using namespace std;
ll dp[1000+5][1000+5],n,m;char a[1000+5][1000+5];
ll f(ll i,ll j){
if(i==n-1&&j==m-1){
    return 1;
}
if(dp[i][j]!=-1)return dp[i][j];
ll x=0,y=0;
if(j+1<m&&a[i][j+1]=='.')
    x=f(i,j+1);
if(i+1<n&&a[i+1][j]=='.')
y=f(i+1,j);
return dp[i][j]=(x+y)%mod;
}
int main(){
cin>>n>>m;
forab(i,0,n-1,1){
forab(j,0,m-1,1){
cin>>a[i][j];
}
}
forab(i,0,n-1,1)
forab(j,0,m-1,1)dp[i][j]=-1;
cout<<f(0,0);
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll n;cin>>n;
    vll d(n); REP(i,n) cin>>d[i];
    VSORT(d);
    ll min = d[n/2-1];
    ll max = d[n/2];
    cout << max-min <<endl;
    return 0;
}

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

int main(){
  long long n;
  cin >> n;
  long long a = pow(10, 15) +1;
  long long b;
  for (int i = 0; i < 5; i ++){
    cin >> b;
    a = min(a, b);
  }
  long long ans;
  long long amari = n % a;
  if (amari == 0){
    ans = n / a + 4;
  }
  else{
    ans = n/a + 4 +1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int i = 0;

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int ma,mi;
		long sum=0;
		int a[] = new int[n];

		for(i=0; i<n; i++) {
			int num = sc.nextInt();
			a[i] = num;
		}

		ma = mi = a[0];

		for(i=1; i<n; i++) {
			if(ma < a[i]) {
				ma = a[i];
			}
		}

		for(i=1; i<n; i++) {
			if(mi > a[i]) {
				mi = a[i];
			}
		}

		for(i=0; i<n; i++) {
			sum += a[i];
		}

		System.out.println(String.format("%d %d %d",mi,ma,sum));
	}

}



Measured memory_bytes: 42488
N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7


def comb(n, r):
    if n - r < r:
        r = n - r

    res = 1
    for i in range(n - r + 1, n + 1):
        res = res * i % MOD
    for i in range(1, r + 1):
        res = res * pow(i, MOD - 2, MOD) % MOD
    return res


res = pow(2, N, MOD)

res -= comb(N, A) + comb(N, B)
res %= MOD
print(res - 1)


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

int mi = 10000000, ma = 0, n;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    mi = min(x, mi);
    ma = max(x, ma);
  }
  cout << ma - mi << endl;
  return 0;
}

Measured memory_bytes: 256
while True :
    
    n=int(input())
    if n==0 :
        break
    
    i=0
    b=0
    ma=0
    mi=1000
    while i<n :
        c=int(input())
        if ma<c :
            ma=c
        if mi>c :
            mi=c
        b=b+c
        i=i+1
    print(int((b-ma-mi)/(n-2)))


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

using namespace std;




int main(){
    
    int N;
    cin >> N;
    int W[N];
    int S1 = 0;
    int S2 = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> W[i];
        S1 += W[i];
    }
    
    int S12 = S1 - S2;
    
    for (int i = N-1; i >= 0; i--) {
        
        S2 += W[i];
        S1 -= W[i];
        
        int S12n = max(S1, S2) - min(S1, S2);
        if (S12n < S12) {
            S12 = S12n;
        }
        
        
    }
    
    
    cout << S12 << endl;
    
}


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

int main() {
  int N, K;
  cin >> N;
  cin >> K;
  int n = 1, k = K;
  
  for (int i = 0; i < N; i++) {
    if (2 * n <= k + n) {
      n = 2 * n;
    }
    else if (2 * n > k + n) {
      n = k + n;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  int ans = 0;
  
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i))
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main
{

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

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		Map<Integer, Integer> map = new HashMap<>();

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());

			map.put(a, map.getOrDefault(a, 0) + 1);
		}

		int ans = 0;

		if (k < map.size()) {
			ans = map.values().stream()
							  .sorted()
							  .limit(map.size() - k)
							  .mapToInt(x -> x)
							  .sum();
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 65496
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll H,W,K;
    cin >> H >> W >> K;
    char c[H][W];
    ll sum = 0;
    ll sum_h[H];
    rep(i,H) sum_h[i] = 0;
    rep(i,H){
        rep(j,W){
            cin >> c[i][j];
            if(c[i][j]=='#'){
                sum++;
                sum_h[i]++;
            }
        }
    }
    ll out = 0;
    for (int bit_h = 0; bit_h < (1<<H); ++bit_h){
        ll tmp = sum;
        for (int i = 0; i < H; ++i) {
            if (bit_h & (1<<i)) {
                tmp -= sum_h[i];
            }
        }
        if(tmp>=K){
            for (int bit_w = 0; bit_w < (1<<W); ++bit_w){
                ll res = tmp;
                for (int i = 0; i < W; ++i) {
                    if (bit_w & (1<<i)) {
                        rep(j,H){
                            if(!(bit_h & (1<<j)) && c[j][i]=='#') res --;
                        }
                    }
                }
                if(res==K) out++;
            }
        }
    }
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 3528
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100010
const int MAX_N = 1<<17;
typedef long long ll;
 
class RMQ{
public:
    ll n,dat[2*MAX_N-1];
   
    void init(int n_){
	n = 1;
	while(n < n_){ n *= 2; }
	for(int i = 0 ; i < 2*n-1 ; i++){
	    dat[i] = 0LL;
	}
    }
 
    void update(ll k,ll a){
	k += n - 1;
	dat[k] = a;
	while(k > 0){
	    k = (k - 1) / 2;
	    dat[k] = max(dat[k*2+1],dat[k*2+2]);
	}
    }
 
    ll query(ll a,ll b,ll k,ll l,ll r){
	if(r <= a || b <= l) return 0LL;
	if(a <= l && r <= b){
	    return dat[k];
	}else{
	    ll vl = query(a,b,k*2+1,l,(l+r)/2);
	    ll vr = query(a,b,k*2+2,(l+r)/2,r);
	    return max(vl,vr);
	}
    }
};
 
int main(){
    ll N,x[MAX],sum = 0LL;
    cin >> N;
    for(int i = 0 ; i < N ; i++){
	cin >> x[i];
	sum += x[i];
    }
    RMQ rmq;
    rmq.init(N);
    for(int i = 0 ; i < N ; i++){
	ll c = rmq.query(1,x[i]+1,0,0,rmq.n);
	rmq.update(x[i],c+x[i]);
    }
    cout << sum-rmq.query(1,N+1,0,0,rmq.n) << endl;
    return 0;
}

Measured memory_bytes: 5932
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>

using namespace std;

char str[234];
char ch[234];

bool is_even(char s[],int n){
    int length = n;
    int len = length / 2;
    for(int i=0;i<len;i++){
        if(s[i] != s[len+i]){
            return false;
        }
    }
    return true;
}

void get_s(int n){
    for(int i=0;i<=n;i++){
        ch[i] = str[i];
    }
}

int main() {
    scanf("%s",str);
    int len = strlen(str);
    for(int i=len-1;i>=1;i--){
        if(i%2==0){
            get_s(i-1);
            if(is_even(ch,i)) {
                printf("%d\n",i);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();

    os.println(search(s));

  }
//  private static long search(String s) {
//
//    int n = s.length();
//
//    long sum = 0;
//    int j = 0;
//    while (0 <= j &&j < n){
//
//      if (s.charAt(j) != 'A') {
//        j = s.indexOf("A", j + 1);
//        continue;
//      }
//
//      // for each, find A
//      // found A
//
//      int aCount = 0;
//      int i = j;
//      while (i < n && (s.charAt(i) == 'A' || i < n - 1 && (s.charAt(i) == 'B' && s.charAt(i + 1) == 'C'))) {
//        if (s.charAt(i) == 'A') {
//          aCount++;
//          i++;
//        } else {
//          sum += aCount;
//          i += 2;
//        }
//      }
//      j = i;
//    }
//    return sum;
//  }

  private static long search(String s) {

    int n = s.length();
    char[] c = s.toCharArray();

    long sum = 0;
    int j = 0;
    while (0 <= j && j < n) {

      // for each, find A
      // found A
      if (c[j] != 'A') {
        j = s.indexOf("A", j + 1);
        continue;
      }

      int aCount = 0;
      int i = j;
      while (i < n) {
        if (c[i] == 'A') {
          aCount++;
          i++;
        } else if (i + 1 < n && c[i] == 'B' && c[i + 1] == 'C') {
          i += 2;
          sum += aCount;
        } else {
          break;
        }
      }
      j = i;
    }
    return sum;
  }
}

Measured memory_bytes: 26552
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        if(a>=3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
        sc.close();
    }
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int k;
  int x;
  cin>>k>>x;
  int min=x-(k-1);
  while(min<=x+(k-1)){
    cout<<min<<" ";
    min++;
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,b=0;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  sort(a, a+N);
  for(int i=0;i<N-1;i++) {
    b += a[i];
  }
  if(a[N-1]<b) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  

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

int main() {

  int N;
  cin >> N;

  vector<int> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  sort(S.begin(), S.end());
  
  int sum = 0;

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

  if (sum % 10 == 0) {
    for (int i = 0; i < N; i++) {
      if (S[i] % 10 != 0) {
        sum = sum - S[i];
        break;
      }
    }
    if (sum % 10 == 0) {
      sum = 0;
    }
  }

  cout << sum << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

//Educational DP Contest / DP まとめコンテスト
//B	Frog 2
public class Main {

	static void chMin(int[] dp, int i, int v) {
		if (dp[i] > v) {
			dp[i] = v;
		}
	}

	static void chMax(int[] dp, int i, int v) {
		if (dp[i] < v) {
			dp[i] = v;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());

		final int DP_SIZE = 100000 + K + 10;

		int[] hArr = new int[DP_SIZE];
		for (int i = 0; i < N; i++) {
			hArr[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int[] dp = new int[DP_SIZE];
		for (int i = 0; i < DP_SIZE; i++) {
			dp[i] = Integer.MAX_VALUE;
		}

		dp[0] = 0;

		for (int i = 0; i < N; i++) {
			for (int j = 1; j <= K; j++) {
				chMin(dp, i + j, dp[i] + Math.abs(hArr[i] - hArr[i + j]));
			}
		}

		System.out.println(dp[N - 1]);
	}

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N, A, B;
  cin >> N >> A >> B;

  if( B > (N-A)+1 || A * B < N){
    cout << -1 << endl;
  }else{
    
    vector<ll> T;
    ll S = N - A;
    ll cur = N;
    for(int i = 0; i < A ; i++){
      ll num = min(B-1, S) + 1;
      S -= num - 1;
      for(int j = 0; j < num; j++){
        T.push_back(cur-num+1+j);
      }
      cur -= num;
    }
    reverse(T.begin(), T.end());
    for(int i = 0; i < N; i++){
      cout << T[i] << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 6000
#include <iostream>

using namespace std;

int rec(int n, int s, int over) 
{
    if (s < 0 || n < 0)
        return 0;
    if (!n && !s)
        return 1;
    
    int count = 0;
    for (int i = over + 1; i < 10; i++) 
        count += rec(n - 1, s - i, i);

    return count;
}

int main()
{
    int n, s;

    while (true) {
        cin >> n >> s;
        if (!n && !s)
            break;

        cout << rec(n, s, -1) << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#define MAX 100
using namespace std;

int bubbleCount(int* array, int n);

int main(){
	int n;
	while(scanf("%d", &n)){
		if(n == 0) break;
		int array[MAX];
		fill(array, array + MAX, 0);
		for(int i = 0; i < n; i++) scanf("%d", &array[i]);
		
		printf("%d\n", bubbleCount(array, n));
	}
	return 0;
}

int bubbleCount(int* array, int n){
	bool flag = true;
    int temp, count = 0;
    while(flag){
        flag = false;
        for(int i = n - 1; i > 0; i--)
        	if(array[i] < array[i - 1]){
            	temp = array[i];
            	array[i] = array[i - 1];
            	array[i - 1] = temp;
            	flag = true;
            	count++;
        	}
    	}
    return count;
}

Measured memory_bytes: 1028
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var N = NextInt();
		var ans = 0;

		for (var i = 1; i <= N; i += 2) {
			if (Judge(i)) {
				ans++;
			}
		}
		WriteLine(ans);
	}

	static bool Judge(int n) {
		var dic = new HashSet<int>();
		for (var i = 1; i <= n; i++) {
			if (n % i == 0) {
				dic.Add(i);
				dic.Add(n / i);
			}
		}
		if (dic.Count == 8) {
			return true;
		}
		return false;
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int h,w,k;
	int ans=0;
	cin>>h>>w>>k;
	char a[h][w];
	repi(i,h) repi(j,w) cin>>a[i][j];
	for(int i=0;i<(1<<h);++i){
		for(int j=0;j<(1<<w);++j){
		int p=0;
			repi(x,h){
				if((1<<x)&i) continue;
				repi(y,w){
					if((1<<y)&j) continue;
					if(a[x][y]=='#') p++;
				}
			}
		if(p==k) ans++;
		}
	}
	
	//repi(i,h) repi(j,w) cout<<a[i][j];
	db(ans);
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n; cin >> n;
    int min_a = INF, min_cnt = 0, zero = 0;
    ll ans = 0;
    rep(i, n) {
        int a; cin >> a;
        ans += abs(a);
        min_a = min(min_a, abs(a));
        if (a < 0) min_cnt++;
        if (a == 0) zero++;
    }

    if (min_cnt % 2 == 0 || zero > 0)
        cout << ans << endl;
    else
        cout << ans - (2*min_a) << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

int main() {
    int n,k;

    // n個使った時の最小値 - 最大値 + 1個作れるっぽい。
    // 3 2のときは
    // 0 1 = 1, 2 3 = 5 なので 4 + 1
    // 0 1 2 = 3, 1 2 3 = 6 なので 4
    // 0 1 2 3 = 6, 0 1 2 3 = 6 なので 1個
    cin >> n >> k;

    // n個使っていいときの最小 / 最大値.
    ll min[n + 2];
    ll max[n + 2];

    rep(i, n+2) {
        if (i == 0) {
            min[0] = 0;
            max[0] = 0;
            continue;
        }
        min[i] = min[i-1] + i - 1;     // 0, 1, 2, 3...
        max[i] = max[i-1] + n - i + 1; // n, n-1, n-2, n-3...
    }

    ll total;
    for(int i = k; i <= n + 1; i++ ) {
        total = total + (max[i] - min[i] + 1);
    }

    total = total % 1000000007 ;
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 6672
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(ReadLine());
        long res = N;
        for (long i = 0; i <= N; i++)
        {
            long tmp = 0;
            long t = i;
            while (t > 0) {
                tmp += t % 6;
                t /= 6;
            }
            t = N - i;
            while (t > 0)
            {
                tmp += t % 9;
                t /= 9;
            }
            if (res > tmp)
            {
                res = tmp;
            }
        }
        WriteLine(res);
    }
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> k(M),p(M);
  vector<vector<int>> s(M);
  for(int i=0;i<M;i++){
    cin>>k.at(i);
    s.at(i).resize(k.at(i));
    for(int j=0;j<k.at(i);j++){
      cin>>s.at(i).at(j);
      s.at(i).at(j)--;
    }
  }
  for(int i=0;i<M;i++){
    cin>>p.at(i);
  }

  int ans=0;
  for(int i=0;i<(1<<N);i++){
    vector<int> on(N);
    int n=i;
    for(int j=0;j<N;j++){
      on.at(j)=n%2;
      n>>=1;
    }
    bool flag=true;
    for(int j=0;j<M;j++){
      int count=0;
      for(int l=0;l<k.at(j);l++){
        count+=on.at(s.at(j).at(l));
      }
      if(count%2!=p.at(j)){
        flag=false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
    string str; cin >> str;
    int n = str.size();
    int s[n];
    char op[n];
    for(int i=0;i<n;i++) s[i] = str[i]-'0';

    int ans;
    for(int bit=0;bit<(1<<n-1);bit++){
        ans = s[0];
        for(int i=0;i<n-1;i++){
            if(bit & (1<<i)){
                ans += s[i+1];
                op[i] = '+';
            }
            else{
                ans -= s[i+1];
                op[i] = '-';
            }
        }
        if(ans == 7) break;
    }
    cout<<s[0]<<op[0]<<s[1]<<op[1]<<s[2]<<op[2]<<s[3]<<'='<<ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define p printf
#define s scanf
#define REP(i, a, b) for(int i = 1; i<=n; i++)
int main()
{
	/*ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	*/
	int a, b, c; cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << "\n";
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zhangyong
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            int sum = 0;
            for (int i = n - 1; i >= (n - k); i--) {
                sum += arr[i];
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21588
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


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

	cin >> N >> M >> K;
	if (N > M&&N > K) {
		cout << "A\n";
	}
	else if (M > K) {
		cout << "B\n";
	}
	else {
		cout << "C\n";
	}
	return 0;
}



Measured memory_bytes: 3184
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int i = 0;
        while(true){
            i++;
            int n = Integer.parseInt(br.readLine());
            if(n == 0){
                break;
            }
            System.out.println("Case "+ i +": "+ n);
        }
    }
}

Measured memory_bytes: 31860
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int s[n]={0};
    cin>>a[0];
    s[0]=a[0];
    for (int i = 1; i < n; ++i) {
        cin>>a[i];
        s[i]=s[i-1]+a[i];
    }

    int mina=1e9;

    for (int i = 0; i < n-1; ++i) {
            mina=min(mina,abs(s[n-1]-2*s[i]));
    }

    cout<<mina;

}

Measured memory_bytes: 256
if __name__ == '__main__':
    MOD = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    res = 0
    two_factor = 1

    for d in range(60):
        even, odd = 0, 0
        for i in range(n):
            if a[i] & (1 << d):
                odd += 1
            else:
                even += 1
        add = (odd * even) % MOD * two_factor % MOD
        res = (res + add) % MOD
        two_factor = two_factor * 2 % MOD

    print(res)


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

int main() {
  
  int x;
  cin >> x;
  
  if(x < 1200){
    cout << "ABC" << endl;
  }
  
  else if(x >= 1200){
    cout << "ARC" << endl;
  }
  
  
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/09/07.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vl a(n);
    vi pos(n);
    rep(i,n){
        cin >> a[i];
        pos[a[i]-1]=i;
    }
    ll ans=0;
    set<int> st;
    st.insert(pos[n-1]);
    per(i,n-1){
        ll l1,l2,r1,r2;
        auto itr=st.lower_bound(pos[i]);
        if(itr==st.end()){
            r1=n-pos[i];
            r2=0;
        }else{
            r1=*itr-pos[i];
            int k=*itr;
            itr++;
            if(itr==st.end()){
                r2=n-k;
            }else{
                r2=*itr-k;
            }
        }
        itr=st.lower_bound(pos[i]);
        if(itr==st.begin()){
            l1=pos[i]+1;
            l2=0;
        }else{
            itr--;
            l1=-*itr+pos[i];
            if(itr==st.begin()){
                l2=*itr+1;
            }else{
                l2=*itr;
                itr--;
                l2-=*itr;
            }
        }
        st.insert(pos[i]);
//        cout <<i+1 SP l2 SP l1 SP r1 SP r2 << endl;
        ans+=(i+1)*(r1*l2+l1*r2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6144
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int MAX = 30;
	double EPS = 1e-5;
	int n, m;
	int s, g;
	int map[][];
	int lim[][];
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			m = sc.nextInt();
			if( (n|m) == 0 ) break;
			s = sc.nextInt()-1;
			g = sc.nextInt()-1;
			map = new int[n][n];
			lim = new int[n][n];
			for(int i=0;i<m;i++) {
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				int d = sc.nextInt();
				int l = sc.nextInt();
				map[a][b] = map[b][a] = d;
				lim[a][b] = lim[b][a] = l;
			}
			System.out.println(dijkstra());
		}
	}
	int dv[] = {-1,0,1};
	String dijkstra() {
		double t[][][] = new double[n][n+1][MAX+1];
		for(double[][] a:t ) for(double[] b:  a) fill(b, INF);
		t[s][n][0] = 0;
		PriorityQueue<Pair> que = new PriorityQueue<Pair>(1, new MyComp());
		Pair now = new Pair(s, -1, 1, 0, 0);
		que.add(now);
		for(;!que.isEmpty();) {
			now = que.remove();
//			debug(que);
//			debug(now.p, now.past_p, now.v, now.t);
			if( now.p == g && now.past_v == 1 ) return String.valueOf(now.t);
			if( 0 == now.v ) continue;
			for(int i=0;i<n;i++) {
				if( map[now.p][i] == 0 || now.p == i || now.past_p == i) continue;
				if( now.v > lim[now.p][i] ) continue;
				double time = now.t + (double)map[now.p][i] / now.v;
//				debug(now.p, i, map[now.p][i]*1.0/now.v);
				if(time < t[i][now.p][now.v]) {
					for(int j=0;j<3;j++) {
						if( now.v + dv[j] >= 0 ) {					
							que.add(new Pair(i, now.p, now.v+dv[j], now.v, time));
//							debug(i, now.p, now.v+dv[j], time);
						}
					}
					t[i][now.p][now.v] = time;
				}
			}
		}
		return "unreachable";
	}
	
	class Pair {
		int p, v, past_p, past_v;
		double t;
		Pair(int p, int past_p, int v, int past_v, double t) {
			this.p = p;
			this.v = v;
			this.t = t;
			this.past_p = past_p;
			this.past_v = past_v;
		}
	}
	
	class MyComp implements Comparator<Pair> {

		@Override
		public int compare(Pair o1, Pair o2) {
			// TODO 自動生成されたメソッド・スタブ
			if(o1.t > o2.t ) return 1;
			else if(o1.t < o2.t) return -1;
			return o1.v - o2.v;
		}
		
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 16000
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var ans =0;
  for(var i =0;i<6;i++){
    if(N>=Math.pow(10,i)){
      if(i%2==1){
        ans+=Math.pow(10,i)-1;
      }else{
        ans-=Math.pow(10,i)-1;
      }
    }else{
      if(i%2==1){
        ans+=N;
        break;
      }else{
        break;
      }
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372