akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include <string.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int dp[100100];
int ans;
int m[1000];
int a[1000];
int n;
bool flag;
int K;

void solve(){
  memset(dp,-1,sizeof(dp));
  dp[0]=0;
  rep(i,n){
    rep(j,K+1){
      if(dp[j]>=0){
        dp[j]=m[i];
      }else if(j<a[i] || dp[j-a[i]]<=0){
        dp[j]=-1;
      }else{
        dp[j]=dp[j-a[i]]-1;
      }
    }
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  rep(i,N)cin >> s[i];
  sort(s.begin(),s.end());
  int temp=0;
  rep(i,N)K+=s[i];
  int cnt=0;
  while(temp<N){
    m[cnt]=upper_bound(s.begin(),s.end(),s[temp])-lower_bound(s.begin(),s.end(),s[temp]);
    a[cnt]=s[temp];
    temp=upper_bound(s.begin(),s.end(),s[temp])-s.begin();
    cnt++;
  }
  n=cnt;
  solve();
  for(int i=K;i>=0;i--){
    if((dp[i]>=0 && i%10!=0)||i==0){
      cout << i << endl;
      return 0;
    }
  }
return 0;}

Measured memory_bytes: 640
N,M,L = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]
Q = int(input())
st = [list(map(int,input().split())) for _ in range(Q)]

INF = 1<<30
dp = [[INF]*N for _ in range(N)]

for a,b,c in ABC:
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])
        
d = [[INF]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if dp[i][j]<=L:
            d[i][j] = 1
        
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        
for s,t in st:
    if d[s-1][t-1]!=INF:
        print(d[s-1][t-1]-1)
    else:
        print(-1)

Measured memory_bytes: 82904
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int distx,disty;
    distx = abs(sx-tx);
    disty = abs(sy-ty);

    REP(i,distx)cout << "R";
    REP(i,disty)cout << "U";
    REP(i,distx)cout << "L";
    REP(i,disty+1)cout << "D";
    REP(i,distx+1)cout << "R";
    REP(i,disty+1)cout << "U";
    cout << "LU";
    REP(i,distx+1)cout << "L";
    REP(i,disty+1)cout << "D";
    cout << "R"<<endl;

    
    return 0;
}

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

int main() {
	string mem;
	int n;
	int chk = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> mem;
		if (mem == "Y")
			chk = 1;
	}
	if (chk) cout << "Four" << endl;
	else cout << "Three" << endl;
}

Measured memory_bytes: 3592
def main():
    h = int(input())

    if h == 1:
        print(1)
        exit()

    for i in range(40):
        if 2**(i+1) == h:
            n = i+2
            break
        if 2**(i) < h and h < 2**(i+1):
            n = i+1
            break
    ans = sum([2**i for i in range(n)])
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define DIM 1007
#define DIMM 2007
#define INF 10000000000007.0
#define X 2000000007
#define epc 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO 10009
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;
typedef pair<ll,pllll> pllpllll;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll hh,ww,h,w,s;

int main()
{
    //freopen("events.in", "r", stdin);
    //freopen("events.out", "w", stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

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

    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>hh>>ww;
    cin>>h>>w;
    s=(hh*ww)-(h*ww)-(w*(hh-h));
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 384
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		seed, _ := strconv.Atoi(scanner.Text())
		fmt.Printf("Case %d:\n", i+1)
		for j := 0; j < 10; j++ {
			tmp := fmt.Sprintf("%08d", seed*seed)
			seed, _ = strconv.Atoi(tmp[2:6])
			fmt.Println(seed)
		}
	}
}


Measured memory_bytes: 1068
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int n,k,a[N];
int main()
{
	n=read(); k=read();
	for(int i=1; i<=n; i++){
		a[i]=read();
	}
	sort(a+1, a+n+1);
	ll s=0;
	for(int i=1; i<=n-k; i++) s+=a[i];
	cout<<s<<endl;
}

Measured memory_bytes: 1024
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Usize1;
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        abs: [(Usize1, Usize1); m],
    }
    let mut uf = UnionFind::new(n);
    for &(a, b) in &abs {
        uf.union(a, b);
    }
    let mut counts = HashMap::new();
    for i in 0..n {
        let x = uf.find(i);
        *counts.entry(x).or_insert(0) += 1;
    }
    println!("{}", counts.values().max().unwrap());
}


Measured memory_bytes: 10644
#include <bits/stdc++.h>
  #pragma GCC target ("avx2")
  #pragma GCC optimization ("O3")
  #pragma GCC optimization ("unroll-loops")
  using ll = long long;
  using ld = long double;
  #define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
  #define br cout<< "\n";
  #define endl "\n"
  #define vi vector<int>
  #define vii vector<ll>
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define pii pair<int,int>
  #define pcl pair<char,ll>
  #define pb push_back
  #define eb emplace_back
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  #define all(v) begin(v),end(v)
  #define minv(a) *min_element(all(a))
  #define maxv(a) *max_element(all(a))
  #define outputv(a) for(auto i:a) cout<<i<<" ";br;
  #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  #define outputvp(a) for(auto j:a) {cout<<j.first<<" " << j.second << ",",br;}
  #define T ll t;cin>>t;while(t--)
  using namespace std;

  const ll mod = 1000000007;
  const ll inf = 1000000000000000000;
  const ll rk = 256;
  const ld PI = 3.141592653589793;
  

  int dr[]={1,-1,0,0};
  int dc[]={0,0,1,-1};

  // ll isPrime[1000001];

  // void primeDivisors(map<ll,ll> &mapi, ll n){
  //   while(n > 1){
  //     if(isPrime[n] == -1){
  //       mapi[n]+=1;
  //       break;
  //     }
  //     else{
  //       mapi[isPrime[n]]+=1;
  //       n/=isPrime[n]; 
  //     }
  //   }
  // }


// void seive(){
//   ll maxn = 10000001;
//   isPrime[0] = 0; isPrime[1] = 0;
//   rep(i,2,maxn) isPrime[i] = -1;
//   for(int i=2; i*i < maxn; i++){
//     if(isPrime[i] == -1){
//       for(int j=i*i; j < maxn; j+=i){
//         if(isPrime[j] == -1){
//           isPrime[j] = i;
//         }
//       } 
//     }
//   }

// }

 ll power( ll base, ll power, ll mod){
    ll res = 1;
    while( power ){
      if(power%2) res= (res*base)%mod, power--;
      else base= (base * base)%mod, power/=2;
    }

    return res;
  }

    void inout(){
      // seive();
      #ifndef ONLINE_JUDGE
          // for getting input from input.txt
          freopen("/home/logan/contest/ongoing/input.txt", "r", stdin);
          // for writing output to output.txt
          freopen("/home/logan/contest/ongoing/output.txt", "w", stdout);
      #endif
  }

  long long int modi(long long int a, long long int b) {
    long long int ret = a % b;
    if (ret < 0)
        ret += b;
    return ret;
}

  

  int main(){
     FastIO
     // seive();
    inout();

    ll n; cin >> n;
    vii a(n); rep(i,0,n) cin >> a[i];
    sort(all(a), greater<ll>());
    ll ans = a[0];

    ll i = 1;
    ll cnt = 1;
    while(cnt+2 < n){
      ans+=2*a[i];
      cnt+=2;
      i+=1;
    }
    if(cnt != n-1) ans+=a[i];

    cout << ans << endl;
    
    






  return 0;
  }



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

int main() {
  int A, B;
  cin >> A >> B;
  if(A == B) {
    cout << "Draw" << endl;
  } else if(A == 1 || (A > B && B != 1)) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)
    elif op=="?":
        break



Measured memory_bytes: 5592
S = list(map(int,input()))
# print(S)

# 0始まり
# 01010101...
count_0 = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s!= 0:
            count_0 += 1
    else:
        if s!= 1:
            count_0 += 1
# print(count_0)

# 1始まり
# 10101010...
count_1 = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s!= 1:
            count_1 += 1
    else:
        if s!= 0:
            count_1 += 1
# print(count_1)
print(min(count_0, count_1))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

ll mod = 1e9+7;
const ld error = 1e-5;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod)
{
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 50+10;
///===========================================  template  =======================================================

ll two[100];

int main(){
    FASTIO;

    two[0] = 1;
    for(int i = 1; i<100; i++) two[i] = two[i-1] * 2 % mod;

    int n;
    cin>>n;
    vector<ll> input(n);
    for(int i = 0; i<n; i++){
        cin>>input[i];
    }

    ll ans = 0;

    for(int k = 0; k<60; k++){
        ll one = 0, zero = 0;
        for(int i = 0; i<n; i++){
            if(bt(k)&input[i]) one++;
            else zero++;
        }

        ans += two[k]*(one*zero % mod);
        ans %= mod;
    }
    cout<<ans<<"\n";
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll mod=2019;
int main(){
    ll L,R,tmp;
    cin >> L >> R;
    ll ans=INF;

    for(ll i=L;i<=R;i++){
        for(ll j=i+1;j<=R;j++){
            tmp = ((i%mod)*(j%mod))%mod;
            if(tmp==0){
                ans=0;
                goto LABEL;
            }
            ans = min(ans,tmp);
        }
    }
    LABEL:
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#define INF (int)(1e9 + 7)
#define maxn 3010
#define maxm 1010
using namespace std;
int n, m;//n代表竖线
int mup[maxn][maxn];
int mdown[maxn][maxn];
int mleft[maxn][maxn];
int mright[maxn][maxn];
int vis[maxn][maxn];
long long ans=0;
pair<int, int> temp;
int tempx, tempy;
int newx, newy;
pair<int, int> dir[4] = { {0,-1},{0,1},{-1,0},{1,0} };
bool flag = 0;

int a[maxm], b[maxm], c[maxm];
int d[maxm], e[maxm], f[maxm];

vector<int> xs;//存横分割
int xsize,ysize;
vector<int> ys;
queue<pair<int, int> > qu;
int main() {
	scanf("%d%d", &n, &m);
	xs.push_back(-INF);
	xs.push_back(INF);
	ys.push_back(-INF);
	ys.push_back(INF);
	xs.push_back(0);
	ys.push_back(0);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		xs.push_back(a[i]);
		xs.push_back(b[i]);
		ys.push_back(c[i]);
	}
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &d[i], &e[i], &f[i]);
		xs.push_back(d[i]);
		ys.push_back(e[i]);
		ys.push_back(f[i]);
	}
	
	//离散化的传统艺能
	//1.排序
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	//2.去重
	xs.resize(unique(xs.begin(), xs.end()) - xs.begin());
	ys.resize(unique(ys.begin(), ys.end()) - ys.begin());
	//块分完了
	//xs[0] xs[1] ... 所有横分割（升序）
	//ys[0] ys[1] ... 所有竖分割（升序）
	//存储我们的四个方位数组
	//lower_bound(begin(),end(),k) —— 返回一个区域内，大于等于k的下标
	//等于的功能
	//所有竖线
	for (int i = 0; i < n; i++) {
		int xx = lower_bound(ys.begin(), ys.end(), c[i]) - ys.begin(); //返回横坐标
		int yy1 = lower_bound(xs.begin(), xs.end(), a[i]) - xs.begin(); //返回纵坐标起点
		int yy2 = lower_bound(xs.begin(), xs.end(), b[i]) - xs.begin(); //返回纵坐标终点
		for (int j = yy1; j < yy2; j++) {
			//代表的是，线段所覆盖的所有块
			mup[j][xx] = 1;
			mdown[j][xx-1] = 1;
		}
	}
	for (int i = 0; i < m; i++) {
		int yy = lower_bound(xs.begin(), xs.end(), d[i]) - xs.begin(); 
		int xx1 = lower_bound(ys.begin(), ys.end(), e[i]) - ys.begin(); 
		int xx2 = lower_bound(ys.begin(), ys.end(), f[i]) - ys.begin(); 
		for (int j = xx1; j < xx2; j++) {
			//代表的是，线段所覆盖的所有块
			mleft[yy][j] = 1;
			mright[yy-1][j] = 1;
		}
	}
	int x = lower_bound(xs.begin(), xs.end(), 0) - xs.begin();
	int y = lower_bound(ys.begin(), ys.end(), 0) - ys.begin();
	qu.push(pair<int, int>{x, y});
	xsize = xs.size();
	ysize = ys.size();
	while (!qu.empty()) {
		temp = qu.front();
		qu.pop();
		tempx = temp.first;
		tempy = temp.second;

		if (vis[tempx][tempy])continue;
		ans += (long long)(xs[tempx + 1] - xs[tempx]) * (long long)(ys[tempy + 1] - ys[tempy]);
		vis[tempx][tempy] = 1;
		if (tempx <= 0 || tempy <= 0) 
		{
			flag = 1; break;
	}
		if (tempx >= xsize - 1 || tempy >= ysize - 1) {
			flag = 1; break;
		}
		for (int i = 0; i < 4; i++) {
			if (i == 0 && mup[tempx][tempy]) continue;
			if (i == 1 && mdown[tempx][tempy]) continue;
			if (i == 2 && mleft[tempx][tempy]) continue;
			if (i == 3 && mright[tempx][tempy]) continue;
			newx = tempx + dir[i].first;
			newy = tempy + dir[i].second;
			qu.push(pair<int, int>(newx,newy));
		}
	}
	if (flag)printf("INF");
	else printf("%lld",ans);

}

Measured memory_bytes: 113500
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

// x!%MODを計算
ll mod_kaijou(ll x){
    ll res = 1;
    REP2(i,1,x+1){
        res*=i;
        res%=MOD;
    }
    return res;
}

// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}


int main(){
    ll N,M;
    cin>>N>>M;
    vector<pair<ll,ll>> so=prime_factorize(M);

    init_nCk(1000000);

    ll tmp=1;
    REP(i,so.size()){
        tmp*=nCk(N-1+so[i].second,N-1);
        tmp%=MOD;
    }
    cout<<tmp<<endl;

}

Measured memory_bytes: 26756
import java.util.Scanner;

public class Main {
	final double s = 3.305785;

	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.printf("%.6f", 1.0 * a * b / s);
	}

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

}

Measured memory_bytes: 17372
n=int(input())
abc=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n+1)]
for i in range(n):
  for a in range(3):
    for b in range(3):
      if a!=b:
        dp[i+1][a]=max(dp[i][b]+abc[i][a],dp[i+1][a])
print(max(dp[n]))

Measured memory_bytes: 47320
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K; cin >> N >> K;
	VI L(N);
	REP(i, N)cin >> L[i];
	int ans = 0;
	rSORT(L);
	REP(i, K)ans += L[i];
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct RollingHash
{
  vector< unsigned > hashed, power;
  RollingHash(const string& s, unsigned _base = 1000000007)
  {
    _base = _base;
    int sz = s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
 
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = power[i] * _base;
    }
    for(int i = 0; i < sz; i++) {
      hashed[i + 1] = (hashed[i] + s[i]) * _base;
    }
  }
  unsigned get(int l, int r) // [l, r)
  {
    return((hashed[r] - hashed[l] * power[r - l]));
  }
};

int main()
{
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  RollingHash hash1(S), hash2(S, 1e9+9);
  vector< tuple< unsigned, unsigned > > poyo;
  int l = 0, r = 1;
  while(M--) {
    string q;
    cin >> q;
    if(q == "R++") ++r;
    else if(q == "R--") --r;
    else if(q == "L++") ++l;
    else --l;
    poyo.emplace_back(hash1.get(l, r), hash2.get(l, r));
  }
  sort(poyo.begin(), poyo.end());
  poyo.erase(unique(poyo.begin(), poyo.end()), poyo.end());
  printf("%d\n", poyo.size());
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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 gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll H, W, K; cin >> H >> W >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<string> c(H);
  vector<pair<ll,ll>> blk;
  rep(i, H) {
    cin >> c[i];
    rep(j, W) {
      if(c[i][j] == '#') blk.push_back(make_pair(i, j));
    }
  }

  for(auto itr:blk) cerr << "(" << itr.first << "," << itr.second << ") ";
  cerr << endl;
  
  ll ans = 0;

  for(int i = 0; i < 1<<H; i++) {
    for(int j = 0; j < 1<<W; j++) {
      ll lcnt = 0;
      for(auto itr:blk) {
	if((i&(1<<itr.first))!=0 || (j&(1<<itr.second))!=0) {
	  lcnt ++;
	}
      }
      cerr << "[" << i << "," << j << "] " << blk.size() - lcnt << endl;
      if(blk.size() - lcnt == K) ans++;
    }
  }

  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const int N = 1010;

int main() {
    string s;
    cin >> s;
    cout << s[0] << to_string(s.length() - 2) << s[s.length()-1];
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

void input_array(int a[], int n){
    for(int i=0; i<n; i++){
        std::cin >> a[i];
    }
}

void print_array(int a[], int n){
    for(int i=0; i<n; i++){
        std::cout << a[i];
        if(i<n-1){
            std::cout << " ";
        }
    }
    std::cout << '\n';
}

void sort(int a[], int n){
    print_array(a,n);
    for(int i=1; i<n; i++){
        int key = a[i];
        int j = i-1;
        while(j>=0 && a[j]>key){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;
        print_array(a,n);
    }
}

int main(){

    int N;
    std::cin >> N;
    int A[N];
    input_array(A,N);
    sort(A,N);

    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>

//A=65

int main(void){
	int i,c[3],tmp,x,y;
	char s,t,ans,in[4];
	
	c[0]=1;
	c[1]=0;
	c[2]=0;
	
	while(scanf(/*"%c,%c",&s,&t*/"%s",in)!=EOF){
		/*
		x=(int)s-65;
		y=(int)t-65;
		*/
		
		
		x=(int)in[0]-65;
		y=(int)in[2]-65;
		
		tmp=c[x];
		c[x]=c[y];
		c[y]=tmp;
	}
	
	
	for(i=0;i<3;i++)if(c[i]==1)break;
	
	ans=65+i;
	
	printf("%c\n",ans);
	
	return 0;
}
		
		

Measured memory_bytes: 540
X, Y, Z = map(int, input().split())
ans = 1
X -= (Y + 2 * Z)
if X < 0:
    print(0)
elif X == 0:
    print(1)
else:
    while X >= 0:
        X -= (Y + Z)
        if X >= 0:
            ans += 1
        else:
            break
    print(ans)

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();
        int e = 0;
        int w = 0;
        for(int i = 1; i < n; i++){
        	if(c[i] == 'E'){
            	e++;
            }
        }
        int min = e;
        for(int i = 1; i < n; i++){
            if(c[i] == 'E'){
            	e--;
            }
            if(c[i - 1] == 'W'){
            	w++;
            }
            min = Math.min(min, (e + w));
        }
        System.out.println(min);
	}
}

Measured memory_bytes: 42776
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    auto win = [] {
        u64 n; std::cin >> n;
        vec<u64> a(n);
        for (u64& x: a) std::cin >> x;
        if (n==1) return false;
        std::sort(ALL(a));

        auto sum = [&](){ return std::accumulate(ALL(a), u64{0}); };
        if (n%2==0) return sum()%2==1;
        for (bool rev=false; ; rev^=1) {
            if (sum()%2==0) return !rev;
            if (1u < std::count_if(ALL(a), [](u64 x){ return x%2; })) return rev;
            auto it = std::find_if(ALL(a), [](u64 x){ return x%2; });
            assert(it!=a.end());
            if (*it==u64{1}) return rev;
            --*it;
            u64 g = std::accumulate(ALL(a), u64{0}, [](u64 x, u64 y){ return std::__gcd(x, y); });
            for (u64& x: a) x /= g;
        }
    }();

    std::cout << (win ? "First" : "Second") << '\n';
}
/*
 * N が 1 のときは例外として、N が 2 以上の場合を考えましょう。
 * まず、一度も偶数で割らない場合の勝敗は、sum - N が奇数ならば First, 偶数ならば Second です。
 *
 * N が偶数のときです。
 * sum が奇数な状態で回ってきたときには、奇数なものが 2 個以上ある状態に遷移するのを毎回すると、必ず勝てます。
 * 逆に sum が偶数な状態で回ってきたときには、all-1 の場合は即負けですし、
 * そうでなくともどんな手をとっても次のターンで相手が勝ちルートに入ってしまいます。
 *
 * N が奇数のときです。
 * sum が偶数な状態で回ってきたとき、GCD = 1 より、奇数が 2 個以上あります。
 * N が 1 でないですから、毎回奇数が 3 個以上にして返せば、必勝てます。
 * sum が奇数であり、奇数が 3 個以上あるときには勝てません。
 *
 * 残るは奇数がちょうど 1 個の場合です。
 * この奇数が 1 だった場合はだめです。
 * この奇数が 3 以上だった場合は、もしこれを取らなければ負けます。
 * 取ったあとでもう一度勝敗を判定しましょう。
 */


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int compar(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int main(){
  int i,n,m,x[100001],y[100001],sum=0;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&x[i]);
  }

   qsort(x,m,sizeof(int),compar);


  for(i=0;i<m-1;i++){
    y[i]=x[i+1]-x[i];
  }

  qsort(y,m-1,sizeof(int),compar);


  if(n>=m){
    printf("0");
  }else{
    for(i=0;i<m-n;i++){
      sum+=y[i];
    }
    printf("%d",sum);
  }
}

Measured memory_bytes: 1396
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int n,m;
vector<int> v[100010];
int d[100010];
bool bol[100010];
vector<int> tb;

void px(){
	queue<int> q;
	for(int i=1;i<=n;i++)
		if(d[i]==0){
			q.push(i);
			d[i]=-1;
		}
	while(!q.empty()){
		int x=q.front();
		q.pop();
		tb.pb(x);
		for(int i=0;i<v[x].size();i++){
			d[v[x][i]]--;
			if(d[v[x][i]]==0){
				q.push(v[x][i]);
				d[v[x][i]]=-1;
			}
		}
	}
}

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	scanf("%d%d",&n,&m);
//	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;
//		cin>>a>>b;
		scanf("%d%d",&a,&b);
		v[a].pb(b);
		d[b]++;
	}
	
	px();
//	int ok=0;
	/*while(ok<n){
		for(int i=1;i<=n;i++)
			if(d[i]==0&&(!bol[i])){
				bol[i]=true;
//				cout<<i<<endl;
				tb.pb(i);
				ok++;
				for(int j=0;j<v[i].size();j++)
					d[v[i][j]]--;
			}
//		cout<<ok<<' '<<(ok<n)<<endl;
	}*/
//	for(int i=0;i<tb.size();i++)
//		cout<<tb[i]<<' ';
	int dp[n+10];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<tb.size();i++){
		int now=tb[i];
		for(int j=0;j<v[now].size();j++)
			dp[v[now][j]]=max(dp[v[now][j]],dp[now]+1);
	}
	int maxn=0;
	for(int i=1;i<=n;i++)
		maxn=max(maxn,dp[i]);
	cout<<maxn;
	return 0;
}
/*
4 5
1 2
1 3
3 2
2 4
3 4
*/

Measured memory_bytes: 7032
#include <stdio.h>
int main(void){
    // Your code here!
    int n, i, ans = 0;
    int a[101];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", a + i);
        if (i % 2 == 0 && a[i] % 2 == 1)
            ans++;
    }
    printf("%d", ans);
}


Measured memory_bytes: 1728
while (al_line = gets.chomp) != "-" do
  h = gets.to_i

  (0..(h-1)).each {|i|
    back_str = ''
    n = gets.to_i
    front_str = al_line[0,n]
    # puts "al_lineの削除する文字を出力"
    al_line.slice!(0,n)
    al_line = al_line + front_str     
    # puts al_line
  }
  puts al_line
end



Measured memory_bytes: 8896
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main()
{
  int d;
  cin>>d;
  switch(d){
    case 25:
    cout<<"Christmas"<<endl;
    break;
    case 24:
    cout<<"Christmas Eve"<<endl;
    break;
    case 23:
    cout<<"Christmas Eve Eve"<<endl;
    break;
    case 22:
    cout<<"Christmas Eve Eve Eve"<<endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>

/*
 *変数
 */
int ans=0,a[3];

/*
 *解 
 */
void solve(){
    std::sort(a,a+3);
    ans+=std::abs(a[1]-a[0]);
    ans+=std::abs(a[2]-a[1]);
    printf("%d",ans);
}

/*
 *入力 
 */
int main(){
       std::cin.tie(0);
       std::ios::sync_with_stdio(false);
       std::cin>>a[0]>>a[1]>>a[2];
       solve();
       return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int s,s1,s2;
	s=a+b;
	s1=a-b;
	s2=a*b;
	cout<<max(max(s,s1),s2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,a=0;cin >>n;
  if(n%2!=0){
    cout << "No" << endl;
  }else{
   char mo[n];
   for(int i=0;i<n;i++){
     cin >>mo[i];
   }
    for(int i=0;i<n/2;i++){
      if(mo[i]==mo[n/2+i]){
        a++;
      }
    }
    if(n/2==a){
      cout << "Yes"<< endl;
    }else{
      cout << "No"<<endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        if (a%2==0){System.out.println("0.5");}
        else{double ans = (a+1.0)/(2.0*a);
             System.out.println(ans);}
	}
}


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

vector<long long> DP(100,-1) ;

long long lucas (int a) {
  if(DP[a] != -1 ) return DP[a] ;
  DP[a] = lucas(a-1) + lucas(a-2) ;
  return DP[a] ;
}

int main () {
  DP[0] = 2 ;
  DP[1] = 1 ;
  int a  ;
  cin >> a ;
  cout << lucas(a) << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
#define N 3072

int d[N][N],i,j,it,n,m;
string s,t;
char ans[N];
int main()
{
    cin >> s >> t;
    n = s.size() + 1;
    m = t.size() + 1;
    for (i = 1; i < n; ++i)
    for (j = 1; j < m; ++j){
        d[i][j] = max (d[i - 1][j], d[i][j - 1]);
        if (s[i - 1] == t[j - 1])
            d[i][j] = max (d[i][j], d[i - 1][j - 1] + 1);
    }
    i = n - 1; j = m - 1;
    it = d[n - 1][m - 1] - 1;
    while (d[i][j] > 0){
        if (s[i - 1] == t[j - 1]){
            --i;
            --j;
            ans[it] = s[i];
            --it;
        }
        else{
            if (d[i][j - 1] > d[i - 1][j])
                --j;
            else
                --i;
        }
    }
    cout << ans;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int size = s.size() - 1;

    if(s.at(size) == 's'){
        cout << s << "es" << endl;
    }
    else {
        cout << s << 's' << endl;
    }
}

Measured memory_bytes: 3600
while True:
    middle, final, reexam = map(int, input().split())
    if (middle, final, reexam) == (-1,-1,-1):
        break
    elif middle == -1:
        print('F')
    elif final == -1:
        print('F')
    elif middle + final >= 80:
        print('A')
    elif middle + final >= 65:
        print('B')
    elif middle + final >= 50:
        print('C')
    elif middle + final >= 30:
        if reexam >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

	int target = 0;
    for(int i = 0; i<5; i++)
    {
    	int temp;
    	cin >> temp;
    	if(temp == 0)target = i+1;
	}
	cout<<target;
	
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;

typedef long long ll;
ll n, mx = -4e18;
ll a[300005];
ll sum[300005];
ll sum2;
priority_queue<ll, vector<ll>, greater<ll> > pq1;
priority_queue<ll> pq2;

int main()
{
    scanf("%lld", &n);
    for(ll i = 1; i <= 3 * n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 1; i <= 2 * n; i++)
    {
        pq1.push(a[i]);
        if(i <= n) sum[n] += a[i];
        else sum[i] = sum[i - 1] - pq1.top() + a[i], pq1.pop();
    }
    for(ll i = 2 * n + 1; i <= 3 * n; i++) pq2.push(a[i]), sum2 += a[i];
    for(ll i = 2 * n; i >= n; i--)
    {
        mx = max(mx, sum[i] - sum2);
        pq2.push(a[i]);
        sum2 += -pq2.top() + a[i], pq2.pop();
    }
    printf("%lld", mx);
    return 0;
}


Measured memory_bytes: 6004
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


T, X = ds_in()
print(T / X)


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VI h(n);
    vector<bool> is_good(n, true);
    REP(i, n) cin >> h[i];
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (h[a] == h[b]) {
            is_good[a] = false;
            is_good[b] = false;
        } else if (h[a] < h[b]) {
            is_good[a] = false;
        } else {
            is_good[b] = false;
        }
    }

    int ans = 0;
    REP(i, n) if (is_good[i]) ans++;
    cout << ans << ln;

    return 0;
}


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

count=0
dic=dict()

for i in range(N):
    s="".join(sorted(input()))
#    print(s)

    if s in dic:
        count+=dic[s]
#        print(dic[s])
        dic[s]+=1
    else:
        dic[s]=1
#        print(dic)

print(count)


Measured memory_bytes: 65496
s = input()
nbits = 2**(len(s)-1)
ans = 0
for bit in range(nbits):
  tmp = []
  for i in range(len(s)-1):
    if bit & (1 << i):
      tmp.append(i)
  curr = 0
  for x in tmp:
    ans += int(s[curr:x+1])
    curr = x + 1
  ans += int(s[curr:])
 
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;
int main(void){

    int n;
    while(cin>>n){
        int a=1;
        for(int i=0;i<n;i++){
            a+=i+1;



        }
    cout<<a<<endl;




    }






    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >>K;
    int ans = 0;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        
        cin >> a[i];
        
    }
    SORT(a);
    for (int i = 0; i < K; ++i) {
        ans += a[i];
     
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(){
    
    int    a = 0, b = 0, d = 0, r = 0;
    double f = 0;                                               // float → 精度が足りないので double に修正
    
    // データの入力
    scanf("%d %d", &a , &b );
    
    if( a < 1 || a > 1000000000 || b < 1 || b > 1000000000 ){
        return 0;
    }
    
    // データの処理
    d = a / b;
    r = a % b;
    f = (double)a / (double)b ;                                // (double)( a / b ) → 計算前に変換が必要

    // データの出力
    printf("%d %d %f\n", d , r , f );
    
    return 0;
}


Measured memory_bytes: 2124
local N = io.read("n")
local T, A = io.read("n", "n")
local nearest = 1000
local ans = -1
for i=1,N do
    local h = io.read("n")
    local t = T - h * 0.006
    local diff = math.abs(t - A)
    if diff < nearest then
        ans = i
        nearest = diff
    end
end
print(ans)

Measured memory_bytes: 760
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll n;cin>>n;
  vector<ll>p(n);
  vector<ll>r(100003,0);
  
  for(int i=0;i<n;i++){
    cin>>p.at(i);
    p.at(i)++;
  }
  for(int i=0;i<n;i++){
    r.at(p.at(i)+1)++;
    r.at(p.at(i))++;
    r.at(p.at(i)-1)++;
  }
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  cout<<r.at(0);
}
  
    
  

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,c,d;cin>>a>>b>>c>>d;

  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(c-b)<=d)){out("Yes");}
  else out("No");


  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << char(a[0] - 32) << char(b[0] - 32) << char(c[0] - 32) << endl;
}


Measured memory_bytes: 256
import collections
import copy

s = input()

s_dict = dict(collections.Counter(list(s)))
s_dict = sorted(s_dict.items(), key=lambda x:x[1], reverse= True)
tmp = s_dict[0][0]

resres = float("inf")

for tmp in s:
    res = 0
    tmp_s = copy.copy(s)
    while True:
        if len(set(tmp_s)) == 1:
            break
        _len = len(tmp_s)
        for i in range(_len-1):
            if tmp_s[i+1] == tmp:
                tmp_s = tmp_s[:i] + tmp + tmp_s[i+1:]
        res += 1
        tmp_s = tmp_s[:-1]
    if res < resres:
        resres = res

print(resres)


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 1e18;
    ll v = a * b * llabs((c - c/2) - c/2);
    chmin(ans, v);
    v = a * c * llabs((b - b/2) - b/2);
    chmin(ans, v);
    v = b * c * llabs((a - a/2) - a/2);
    chmin(ans, v);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
x, k, d = map(int, input().split())

if x == 0:
    if k % 2 == 0:
        print(0)
    else:
        print(d)
elif x > 0:
    if x >= k * d:
        print(x - k * d)
    else:
        q, mod = divmod(x, d)
        k -= q
        if k % 2 == 0:
            print(mod)
        else:
            print(abs(mod - d))
elif x < 0:
    if abs(x) >= k * d:
        print(abs(x + k * d))
    else:
        q, mod = divmod(abs(x), d)
        k -= q
        if k % 2 == 0:
            print(mod)
        else:
            print(abs(mod - d))


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
ll func(int l,int r,VV &dp,vector<pair<ll,ll>>&data){
	if(dp[l][r]==-1){
		dp[l][r]=INFLL;
		for(int med=l;med<r;med++){
			chmin(dp[l][r],func(l,med,dp,data)+func(med+1,r,dp,data)+data[l].F*data[med].S*data[r].S);
		}
	}
	return dp[l][r];
}
int main(){
	int n;
	
	cin >>n;
	vector<pair<ll,ll>>data(n,mp(1,1));
	rep(i,n){
		cin>>data[i].F>>data[i].S;
	}
	VV dp(n,V(n,-1));
	rep(i,n){
		dp[i][i]=0LL;
	}

	cout<<func(0,n-1,dp,data)<<endl;
}


Measured memory_bytes: 3240
import math
N,K = map(int,input().split(" "))
array = list(map(int,input().split(" ")))
m = array.index(1)
i = m%(K-1) 
left = int((m-i)/(K-1))
right = math.ceil((N-m-(K-i))/(K-1))
print(left+right+1)

Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

struct UF {
	vi t;
	int cs;
	UF(int n){
		t.resize(n, -1);
		cs = n;
	}
	int find(int a){
		return t[a]<0 ? a : t[a] = find(t[a]);
	}
	void uni(int a, int b){
		a = find(a), b = find(b);
		if(a == b) return;
		--cs;
		if(t[a] < t[b]) swap(a,b);
		t[b] += t[a];
		t[a] = b;
	}
};

bool solve(){
	int n, m;
	cin >> n >> m;
	if(m < n+2) return false;
	vi a(m), b(m);
	rep(i,0,m) cin >> a[i] >> b[i];
	trav(x, a) --x;
	trav(x, b) --x;
	vi deg(n);
	trav(x, a) ++deg[x];
	trav(x, b) ++deg[x];
	trav(x, deg) if(x%2) return false;
	trav(x, deg) if(x >= 6) return true;
	if(m > n+2) return true;
	int r = -1;
	rep(i,0,n) if(deg[i] == 4) r = i;
	UF uf(n);
	rep(i,0,m) if(a[i] != r && b[i] != r) uf.uni(a[i], b[i]);
	if(uf.cs >= 3) return true;
	return false;
}

int main(){
	cout << (solve() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");

int main(){
    ll n, l, a, b, c, ans=0;
    cin >> n;
    vector<ll> list;
    rep(i, 0, n){
      cin >> l;
      list.push_back(l);
    }
    sort(list.begin(), list.end());
    //printarray(list, n);

    rep(i, 0, n-2){
      a = list[i];
      rep(j, i+1, n-1){
        b = list[j];
        for(ll k=n-1; k>j; k--){
          c = list[k];
          if(c < a + b){
            ans += k - j;
            break;
          }
        }

      }
    }

    print(ans);
  
  return 0;
}

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

#define ll long long

int main(void){
    int n,x;
    cin >> n >> x;
    vector<int>m(n);
    for(int i=0;i<n;i++){
        cin >> m[i];
    }
    sort(m.begin(),m.end());
    int sum = accumulate(m.begin(),m.end(),0);
    x -= sum;
    int cnt=n;
    cnt = cnt + x/m[0];
    cout << cnt << endl;
    return 0;
}

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

const int N = 2e5 + 15;
int n, dp[N][3], a[N][3];

int main() {
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < 3; ++j) {
            for(int k = 0; k < 3; ++k) {
                if(k != j)
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
            }
        }
    }
    cout << *max_element(dp[n], dp[n] + 3);
    return 0;
}

Measured memory_bytes: 3456
$n=<>;
@A=map{$_<3200?int($_/400):8}(glob<>);
$C{$_}++ for@A;
$o=0;
$o=($C{$_}>0)?$o+1:$o for(0..7);
if($o<1){
    print "1 $C{8}"
}else{
    print "$o ",$o+$C{8}
}

Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
	int q;
	scanf(" %d", &q);
	for(int i=0; i<q; ++i){
		string a, b;
		cin >> a >> b;
		
		int m=a.size(), n=b.size();
		
		string x=" "+a;
		string y=" "+b;
		
		int c[1001][1001]={0};
		for(int i=1; i<=m; ++i) c[i][0]=0;
		for(int i=1; i<=n; ++i) c[0][n]=0;
		
		int ans=0;
		for(int i=1; i<=m; ++i){
			for(int j=1; j<=n; ++j){
				if(x[i]==y[j]) c[i][j]=c[i-1][j-1]+1;
				else c[i][j]=max(c[i][j-1], c[i-1][j]);
				
				ans=max(ans,c[i][j]);		
			}
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 5168
n = int(input())
S = list(map(int, input().split()))
res = 0.0;
S.sort()

for d in range(n-1):
    c = d+1
    a = n-1
    b = n-2
    if d == n-3:
        b = d-1
    elif d == n-2:
        a = d-2
        b = d-1
    res = max(res, 1.0*(S[a]+S[b])/(S[c]-S[d]))

print(res)




Measured memory_bytes: 5636