akhauriyash/Code-Regression huggingface dataset:
N=int(input())
a=[]
b=[]
c=[]

for _ in range(N):
    A,B,C=map(int,input().split())
    a.append(A)
    b.append(B)
    c.append(C)

dp=[[a[0],b[0],c[0]]]

for i in range(1,N):
    DA=a[i]+max(dp[i-1][1:])
    DB=b[i]+max(dp[i-1][0::2])
    DC=c[i]+max(dp[i-1][0:2])
    dp.append([DA,DB,DC])
print(max(dp[-1]))

Measured memory_bytes: 34644
import java.util.*;

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

    long k = sc.nextLong();
    int n = sc.nextInt();
    long[] a = new long[n];

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

    Arrays.sort(a);
    long d = k + a[0] - a[n - 1];
    
    for(int i = 1; i < n; i++){
      if(d < a[i] - a[i - 1]){
        d = a[i] - a[i - 1];
      }
    }

    System.out.println(k - d);
  }
}


Measured memory_bytes: 87888
a,b,c,d=[int(s) for s in list(str(input()))]
x=(a+b+c+d-7)/2
op=["+","+","+"]
for i in range(3):
    if [b,c,d][i]==x:
        op[i]="-"
        break
    elif [b,c,d][i]==b+c+d-x:
        op=["-","-","+","-","-"][2-i:5-i]
        break
print(str(a)+op[0]+str(b)+op[1]+str(c)+op[2]+str(d)+"=7")

Measured memory_bytes: 3188
package main

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

func rangeCheck(x, y int) bool {
	if x >= 0 && x <= 9 && y >= 0 && y <= 9 {
		return true
	} else {
		return false
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	paper := make([][]int, 10)
	for i := range paper {
		paper[i] = make([]int, 10)
		for j := range paper[i] {
			paper[i][j] = 0
		}
	}
	// fmt.Println(paper)
	for scanner.Scan() {
		infos := strings.Split(scanner.Text(), ",")
		x, _ := strconv.Atoi(infos[0])
		y, _ := strconv.Atoi(infos[1])
		s, _ := strconv.Atoi(infos[2])
		// fmt.Println(x, y, s)
		switch s {
		case 1:
			paper[x][y]++
			if rangeCheck(x, y-1) {
				paper[x][y-1]++
			}
			if rangeCheck(x, y+1) {
				paper[x][y+1]++
			}
			if rangeCheck(x-1, y) {
				paper[x-1][y]++
			}
			if rangeCheck(x+1, y) {
				paper[x+1][y]++
			}
			continue
		case 2:
			paper[x][y]++
			if rangeCheck(x-1, y-1) {
				paper[x-1][y-1]++
			}
			if rangeCheck(x, y-1) {
				paper[x][y-1]++
			}
			if rangeCheck(x+1, y-1) {
				paper[x+1][y-1]++
			}
			if rangeCheck(x-1, y) {
				paper[x-1][y]++
			}
			if rangeCheck(x+1, y) {
				paper[x+1][y]++
			}
			if rangeCheck(x-1, y+1) {
				paper[x-1][y+1]++
			}
			if rangeCheck(x, y+1) {
				paper[x][y+1]++
			}
			if rangeCheck(x+1, y+1) {
				paper[x+1][y+1]++
			}
			continue
		case 3:
			paper[x][y]++
			if rangeCheck(x-1,y-1) {
				paper[x-1][y-1]++
			}
			if rangeCheck(x,y-1) {
				paper[x][y-1]++
			}
			if rangeCheck(x+1,y-1) {
				paper[x+1][y-1]++
			}
			if rangeCheck(x-1,y) {
				paper[x-1][y]++
			}
			if rangeCheck(x+1,y) {
				paper[x+1][y]++
			}
			if rangeCheck(x-1,y+1) {
				paper[x-1][y+1]++
			}
			if rangeCheck(x,y+1) {
				paper[x][y+1]++
			}
			if rangeCheck(x+1,y+1) {
				paper[x+1][y+1]++
			}
			if rangeCheck(x,y-2) {
				paper[x][y-2]++
			}
			if rangeCheck(x-2,y) {
				paper[x-2][y]++
			}
			if rangeCheck(x+2,y) {
				paper[x+2][y]++
			}
			if rangeCheck(x,y+2) {
				paper[x][y+2]++
			}
			continue
		}
	}
	count := 0
	max := -1
	for i := range paper {
		for j := range paper[i] {
			if paper[i][j] == 0 {
				count++
			}
			if max >= paper[i][j] {
				max = max
			} else {
				max = paper[i][j]
			}
		}
	}
	fmt.Printf("%d\n%d\n", count, max)
}


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

int main(){
    string n;
    bool f=0;
    cin>>n;
    rep(i,3)
        if(n[i]=='7')
            f=1;
    cout<<(f?"Yes":"No")<<endl;

}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int square(int x) {
	return x * x;
}
int main()
{
	int N;
	int a[110];
	cin >> N;
	for (int i = 0; i < N; i++)	cin >> a[i];
	int ans = mod;
	for (int j = -100; j <= 100; j++) {
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			cnt += square(a[i] - j);
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int abs(int a) {
  if (a >= 0) {
   return a; 
  } else {
   return (-1)*a; 
  }
}

int even(int a) {
  if (a%2 == 0)
  return 0;
  else 
  return 1;
}

int judge(int t, int x, int y){
  int sum = abs(x)+abs(y);
  
  if (t < sum) return 1;
  
  if (even(t-sum) == 0) return 0;
  else return 1;
}

int main(void)
{
  int N;
  scanf("%d", &N);
  int t[N], x[N], y[N];
  for (int i = 0; i < N; i++) {
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
  }
  
  int mark = 0;
  int j = 0;
  while(j < N) {
    if (j == 0) {
      mark = judge(t[j], x[j], y[j]);
      if (mark == 1) break;
    } else {
      mark = judge(t[j]-t[j-1], x[j]-x[j-1], y[j]-y[j-1]);
      if (mark == 1) break;
    }
    j++;
  }
  
  
  if (j == N) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
  
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

int solve(int n, V& as){
    int alice = 0, bob = 0;
    bool turn = true;
    sort(begin(as), end(as), greater<int>());
    for(const auto& a : as){
        if(turn){
            alice += a;
        }else{
            bob += a;
        }
        turn = !turn;
    }
    return alice - bob;
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    V as(n);
    cin >> as;

    cout << solve(n, as) << endl;

    return 0;
}


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

void solver() {
  long long h;
  cin >> h;

  long long ans = 1;
  int cnt = 0;
  while(true) {
    if (h == 1) {
      ans *= 2;
      break;
    }
    h /= 2;
    ans *= 2;
  }

  cout << ans - 1 << "\n";
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define pb push_back
#define SZ(a) ((int)a.size())

 
const int oo = 1e9;
const int Maxn = 1e5;
const int N = 2e5 + 100;
const double PI = (-2.00) * asin(-1);
 
typedef pair<int, pair<int, int> > iii;
typedef pair<int, int> ii;    


int n, m, k, x1, x2, y11, y2;
vector< vector<int> > check, a, check1; 
vector<ii> vi[2];

int solve() {
    int lst = 0, nxt = 1;
    check[x1][y11] = 1;
    vi[lst].pb({x1, y11});
    int cnt = 0;
    while(SZ(vi[lst]) > 0)  {
        cnt += 1;
        vi[nxt].clear();
        for(auto v: vi[lst]) {
            check[v.fi][v.se] = 1;
            if(v == ii(x2, y2)) return cnt - 1;
        }
        for(auto v: vi[lst]) {
            for(int i = v.fi - 1; i >= 1 && v.fi - i <= k; i -= 1) {
                if(a[i][v.se] || check[i][v.se]) break;
                if(check1[i][v.se]) continue;
                check1[i][v.se] = 1;
                vi[nxt].pb({i, v.se});
            }
            for(int i = v.fi + 1; i <= n && i - v.fi <= k; i ++) {
                if(a[i][v.se] || check[i][v.se]) break;
                if(check1[i][v.se]) continue;
                check1[i][v.se] = 1;
                vi[nxt].pb({i, v.se});
            }
            // columns
            for(int i = v.se - 1; i >= 1 && v.se - i <= k; i -= 1) {
                if(a[v.fi][i] || check[v.fi][i] ) break;
                if(check1[v.fi][i]) continue;
                check1[v.fi][i] = 1;
                vi[nxt].pb({v.fi, i});
            }
            for(int i = v.se + 1; i <= m && i - v.se <= k; i += 1) {
                if(a[v.fi][i] || check[v.fi][i]) break;
                if(check1[v.fi][i]) continue;
                check1[v.fi][i] = 1;
                vi[nxt].pb({v.fi, i});
            }
        }
        swap(lst, nxt);
    }
    return -1;
}
signed main()
{
    #ifdef TEST
        freopen("test.inp", "r", stdin);
    #endif // TEST  
    ios_base::sync_with_stdio(false);                                      
    cin.tie(0); cout.tie(0);

    // 0 = up
    // 1 = down
    // 2 = right
    // 3 = left
    cin >> n >> m >> k;
    a.resize(n + 10);
    FOR(i, 1, n) {
        FOR(j, 1, m + 10) a[i].pb(0);
    }
    check.resize(n + 10);
    FOR(i, 1, n) FOR(j, 1, m + 10) check[i].pb(0);

    check1.resize(n + 10);
    FOR(i, 1, n) FOR(j, 1, m + 10) check1[i].pb(0);

    cin >> x1 >> y11 >> x2 >> y2;
    FOR(i, 1, n)    {
        FOR(j,1, m) {
            char x; cin >> x;
            a[i][j] = (x == '@');
        }
    }
    cout << solve();
}


Measured memory_bytes: 17372
#include <stdio.h>

int main()
{
	int a,N;

	scanf("%d",&N);

	a=N%10;
	
	if(a==2 || a==4 || a== 5 || a==7 || a==9)
	{
		printf("hon\n");
	}
	else if(a==3)
	{
		printf("bon\n");
	}
	else
	{
		printf("pon\n");
	}
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	for(int i = 0; i < N; i++)
		cin >> L[i];
	
	int i;
	int d = 0;
	for(i = 0; i < N; i++){
		d = d + L[i];
		if(d > X)
			break;
	}

	cout << i+1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<iosfwd>
#include<sstream>
#include<math.h>
#define N 100
using namespace std;
int main(){
    int a[6];
    int b[4]= {0,0,0,0};
    int cnt=0;
    for(int i=0; i<6; i++){
        int d;
        cin >> d;
        b[d-1]++;
        if(b[d-1]==2) cnt++;
        else if(b[d-1]>2) {cnt=3; break;}
    }
    if(cnt==2) cout << "YES" << endl;
    else cout << "NO" << endl;

}

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

int main(){
  int N,K,X,Y,ans;
  cin >> N >> K >> X >> Y;
  if(K>=N){
    ans= N*X;
  }
  else{
    ans= K*X+(N-K)*Y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    ll n, k;
    cin >> n >> k;
    ll a, b, c;
    a = n%k;
    b = abs(a-k);
    c = abs(b-k);
    cout << min({a, b, c}) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MAX_VERTEXES 100
#define ZERO 0

using namespace std;

//think easy make easy

int n;//num of vertexes(頂点)
int matrix_graph[MAX_VERTEXES+1+1][MAX_VERTEXES+1+1];//1オリジン

int main(){
	scanf("%d",&n);

	int v_num;
	int k;//v_numの出次数

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			matrix_graph[i][j] = ZERO;
		}
	}

	for(int i=0;i<n;i++){
		scanf("%d",&v_num);
		scanf("%d",&k);

		for(int j=0;j<k;j++){
			int v_num2;
			scanf("%d",&v_num2);
			matrix_graph[v_num][v_num2] = 1;
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j<n) printf("%d ",matrix_graph[i][j]);
			else printf("%d\n",matrix_graph[i][j]);
		}
	}

	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define maxN 200000
using namespace std;
long long a[maxN];
int main()
{
    int n;
    scanf("%d", &n);
    long long int s1 = 0, s2 = 0, min = 0X7fffffff;
    for (int i = 0; i < n; i++) {
        scanf("%lld", a + i);
        s1 += a[i];
    }
    if (n != 2)
        for (int i = n - 1; i > 0; i--) {
            s2 += a[i];
            if (abs(s1 - s2 - s2) < min)
                min = abs(s1 - s2 - s2);
        }
    else
        min = abs(a[0] - a[1]);
    printf("%lld\n", min);
    return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (
        T&& t
      ) noexcept
      : T(forward<T>(t))
      {
      }
    template<typename... Args>
    constexpr decltype(auto)
    operator()(
        Args&&... args
      ) const
      {
        return T::operator()(*this, forward<Args>(args)...);
      }
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{forward<T>(t)};
}
template <typename T>
class ford_fulkerson {
  public:
    const T inf = numeric_limits<T>::max();
  private:
    struct edge {
      int to; T cap;
      weak_ptr<edge> rev;
      edge(int to, T cap) : to(to), cap(cap) {}
    };
    const int n, source, sink;
    vector<bool> ckd;
    vector<vector<shared_ptr<edge>>> grh;
    T dfs () {
      return fix ([&](auto dfs, int crr, int f) -> T {
        if (crr == sink) return f;
        ckd[crr] = true;
        for (auto& e : grh[crr]) {
          if (ckd[e->to] || !e->cap) continue;
          T d = dfs(e->to, min(f, e->cap));
          if (d) {
            e->cap -= d;
            e->rev.lock()->cap += d;
            return d;
          }
        }
        return 0;
      })(source, inf);
    }
  public:
    ford_fulkerson (int n, int source, int sink) :
      n(n), source(source), sink(sink), grh(n)
      {}
    void insert(int u, int v, T c) {
      auto e = make_shared<edge>(v, c);
      auto r = make_shared<edge>(u, 0);
      e->rev = r;
      r->rev = e;
      grh[u].push_back(e);
      grh[v].push_back(r);
    }
    T cal() {
      T ret = 0;
      while (true) {
        ckd.assign(n, false);
        T f = dfs();
        if (!f) return ret;
        ret += f;
      }
    }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> str(h, string(w, '$'));
  int si, sj, ti, tj;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> str[i][j];
      if (str[i][j] == 'S') si = i, sj = j;
      if (str[i][j] == 'T') ti = i, tj = j;
    }
  }
  int source = si, sink = ti;
  ford_fulkerson<int> ffk(h + w, source, sink);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c = str[i][j];
      if (c == 'o') {
        ffk.insert(i,     h + j, 1);
        ffk.insert(h + j, i,     1);
      }
      if (c == 'S'|| c == 'T') {
        if (c == 'S') si = i, sj = j;
        else ti = i, tj = j;
        ffk.insert(i,     h + j, ffk.inf);
        ffk.insert(h + j, i,     ffk.inf);
      }
    }
  }
  if (si == ti || sj == tj) {
    cout << -1 << endl;
    return 0;
  }
  auto ret = ffk.cal();
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 2944
n=int(input())
a=list(map(int,input().split()))
s=sum(a)//n
cnt_1=0
cnt_2=0
for i in range(n):
    cnt_1+=(a[i]-s)**2
    cnt_2+=(a[i]-s-1)**2
print(min(cnt_1,cnt_2))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> int Factor_L(T N, T fac[], int fs[]){
  T i;
  int sz=0;
  if(N%2==0){
    fac[sz] = 2;
    fs[sz] = 1;
    N /= 2;
    while(N%2==0){
      N /= 2;
      fs[sz]++;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      fac[sz] = i;
      fs[sz] = 1;
      N /= i;
      while(N%i==0){
        N /= i;
        fs[sz]++;
      }
      sz++;
    }
  }
  if(N > 1){
    fac[sz] = N;
    fs[sz] = 1;
    sz++;
  }
  return sz;
}
template<class T> int Divisor_L(T N, T res[], void *mem = wmem){
  T *fc;
  int *fs, fsz, i, j, k, s, sz=0;
  fc = (T*)wmem;
  fs = (int*)(fc+100);
  fsz =Factor_L(N, fc, fs);
  res[sz++] = 1;
  for(i=0;i<fsz;i++){
    s = sz;
    k = s * fs[i];
    for(j=0;j<k;j++){
      res[sz++] = res[j] * fc[i];
    }
  }
  sort(res, res+sz);
  return sz;
}
char memarr[96000000];
long long S;
long long X1;
long long Y1;
long long X2;
long long Y2;
long long X3;
long long Y3;
long long y[100000];
int ys;
int main(){
  long long i, k;
  wmem = memarr;
  rd(S);
  k = sqrt(S);
  while(k*k<S){
    k++;
  }
  X2 = Y3 = k;
  for(;;){
    i = X2 * Y3 - S;
    if(i <= 1000000000){
      X3 = i;
      Y2 = 1;
      break;
    }
    ys =Divisor_L(i, y);
    for(k=0;k<ys;k++){
      if(y[k] <= 1000000000 && i/y[k] <= 1000000000){
        break;
      }
    }
    if(k < ys){
      X3 = y[k];
      Y2 = i / y[k];
      break;
    }
    if(X2 <= Y3){
      X2++;
    }
    else{
      Y3++;
    }
  }
  wt_L(X1);
  wt_L(' ');
  wt_L(Y1);
  wt_L(' ');
  wt_L(X2);
  wt_L(' ');
  wt_L(Y2);
  wt_L(' ');
  wt_L(X3);
  wt_L(' ');
  wt_L(Y3);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// ll S;
// ll X1, Y1, X2, Y2, X3, Y3;
// 
// ll y[1d5]; int ys;
// 
// {
//   ll i, k;
//   rd(S);
// 
//   k = sqrt(S);
//   while(k*k<S) k++;
//   X2 = Y3 = k;
// 
//   for(;;){
//     i = X2 * Y3 - S;
//     if(i <= 1d9){
//       X3 = i;
//       Y2 = 1;
//       break;
//     }
//     ys = Divisor(i, y);
//     rep(k,ys) if(y[k] <= 1d9 && i/y[k] <= 1d9) break;
//     if(k < ys){
//       X3 = y[k];
//       Y2 = i / y[k];
//       break;
//     }
// 
//     if[X2 <= Y3, X2, Y3]++;
//   }
// 
//   wt(X1,Y1,X2,Y2,X3,Y3);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, A, B;
    cin >> N >> A >> B;
    vl V(N);
    rep(i, N) cin >> V[i];
    sort(all(V), greater<ll>());

    ld sum = accumulate(V.begin(), V.begin() + A, 0ll);
    ld nowa = sum / A;
    ll vi = B;

    repe(i,A,B){
        ld tmpa = (nowa * i + V[i]) / (i + 1);
        // err(i, tmpa, nowa);
        if(nowa>tmpa){
            vi = i;
            break;
        }
    }

    ll ans = 0;
    repe(c,A-1,vi){
        ll v = V[c], vallcnt = count(all(V), V[c]), vcnt = count(V.begin(), V.begin() + c + 1, V[c]);
        ld cnt = 1;
        repe(i,1,vcnt + 1){
            cnt *= vallcnt - i + 1;
            cnt /= i;
        }
        ans += (ll)cnt;
        // err(vallcnt, vcnt, vi, ans, cnt);
    }

    cout << nowa << endl
         << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

vector<ll>P, C;
//始点sから1~k回まで回した時の最大得点を返す
ll func(int s, ll k){
    int index = s;
    ll ret = -LINF, score = 0;
    rep(i, k){
        int nx = P[index];
        score += C[nx];
        chmax(ret, score);
        index = nx;
    }
    return ret;
}

int main(){
    ll n, k; cin >> n >> k;
    P.resize(n), C.resize(n);
    rep(i, n){cin >> P[i]; P[i]--;}
    rep(i, n) cin >> C[i];

    ll res = -LINF;
    rep(i, n){
         int index = i, cnt = 0;ll score = 0;
         while(1){
            int nx = P[index];
            score += C[nx];
            index = nx;
            cnt++;
            if(nx == i)break;//一周した
         }
         int r = cnt;//ループ長
         if(k < r){
            chmax(res, func(i, k));
         }else{
            if(score >= 0){
               if(k%r==0){
                  ll tmp = score * (k/r - 1);
                  chmax(res, tmp + func(i, r));
               }else{
                  ll tmp = score * (k/r);
                  chmax(res, tmp + func(i, k%r));
               }
            }else{
                chmax(res, func(i, r-1));
            }
        }
    }
    cout << res << ln;
}
    


Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[q];
		for(int i = 0; i < q; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		String[] ret = new Main().attack_survival(n, k, a);
		for(String r : ret) {
			System.out.println(r);
		}
	}
	
	public String[] attack_survival(int n, int k, int[] a) {
		int i;
		int[] player = new int[n];
		String[] result = new String[n];
		for(i = 0; i < n; i++) {
			player[i] = k + (-a.length);
		}
		
		for(int p : a) {
			player[p - 1] += 1;
		}
		for(i = 0; i < n; i++) {
			if(player[i] > 0) {
				result[i] = "Yes";
			}else {
				result[i] = "No";
			}
		}
		
		return result;
	}
}


Measured memory_bytes: 57424
#!/usr/bin/env python3

import sys

def main():
    n, m = map(int, input().split())
    a = []
    b = []
    atoi = [[] for i in range(n)]
    btoi = [[] for i in range(n)]
    for i in range(m):
        aa, bb = map(int, sys.stdin.readline().split())
        a.append(aa - 1)
        b.append(bb - 1)
        atoi[aa - 1].append(i)
        btoi[bb - 1].append(i)

    achieved = [False for i in range(m)]
    res = 0
    aptr = -1  # Already achieved
    for x in range(n - 1):
        tobreak = False
        for i in btoi[x + 1]:
            if not achieved[i]:
                tobreak = True
        if tobreak:
            res += 1
            while aptr < x:
                aptr += 1
                for j in atoi[aptr]:
                    achieved[j] = True
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 37320
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define all(v) (v).begin(),(v).end()
using namespace std;

signed main(){
    multiset<int> set;
    int q;
    cin>>q;
    while(q--){
        int y;
        cin>>y;
        if(y==0){
            int x;
            cin>>x;
            set.insert(x);
            cout<<set.size()<<endl;
        }
        else if(y==1){
            int x;
            cin>>x;
            cout<<set.count(x)<<endl;
        }
        else if(y==2){
            int x;
            cin>>x;
            set.erase(x);
        }
        else{
            int l,r;
            cin>>l>>r;
            for(auto it=set.lower_bound(l);it!=set.upper_bound(r);it++){
                cout<<*it<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 12296
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

template<typename T>
struct bit {
  vector<T> data;
  bit(int sz) {
    data.assign(++sz, 0);
  }
  bit(int sz, int v){
    data.assign(++sz, v);
    REP(i, sz) data[i+(i&-i)] += data[i];
  }
  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return ret;
  }
  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int sum = 0;
  vector<int> v(N+1);
  REP(i, N+1){
    v[i] = sum-i*K;
    if(i != N) sum += A[i];
  }

  vector<int> o(N+1);
  iota(ALL(o), 0);

  sort(ALL(o), [&](int const & l, int const & r){
      if(v[l] != v[r]) return v[l] > v[r];
      return l > r;
      });

  bit<int> bit(N+1);

  int ans = 0;
  REP(i, N+1){
    bit.add(o[i], 1);
    ans += bit.sum(N)-bit.sum(o[i]);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 6656
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N, K;
    cin >> N >> K;
    int M = (N - 1)*(N - 2) / 2;
    if (K > M) {
        cout << -1 << endl;
        return;
    }
    vector<pii> ans;
    for (int i = 2; i <= N; ++i)ans.emplace_back(1, i);
    
    [&] {
        int cnt = M;
        for (int i = 2; i < N; ++i)for (int j = i + 1; j <= N; ++j) {
            if (cnt-- == K)return;
            ans.emplace_back(i, j);
        }
    }();

    cout << sz(ans) << endl;
    each(a, ans)cout << a.first << ' ' << a.second << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 384
from collections import deque

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)

dist = [10 ** 9] * (N + 1)
dist[1] = 0
ans = [0] * (N + 1)
q = deque([1])

while q:
    u = q.popleft()
    for v in graph[u]:
        if dist[v] > dist[u] + 1:
            dist[v] = dist[u] + 1
            ans[v] = u
            q.append(v)

print("Yes")
print(*ans[2:], sep="\n")


Measured memory_bytes: 129676
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 100 + 10;
set < string > st ;
string s[maxn] ;
int main()
{
	int n ;
	cin >> n ;
	cin >> s[0] ;
	st.insert ( s[0] ) ;
	char c = s[0][s[0].size()-1] ;
	bool b , p = false ;
	for ( int i =1; i< n ; i++)
	{
		//cout << " I " << i << "  c " << c << endl;
		cin >> s[i] ;
		b = st.insert ( s[i] ).second ;
		//cout << " b " << b << endl;
		if ( s[i][0] !=c || b == false)
		{
			p = true ;
		}
		c= s[i][s[i].size()-1] ;
	}
	if ( !p ) 
	cout << "Yes" << endl;
	else
		cout << "No" << endl;
		

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
    cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
    return 0;
}



Measured memory_bytes: 2140
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  let AB = Number(inputs[0].split(" ")[0]);
  let BC = Number(inputs[0].split(" ")[1]);

  console.log(AB * BC / 2);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

ll gcd (ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

const int mod = 1000000007;

int main() {
    ll a, b, c ,d; cin >> a >> b >> c >> d;

    ll g = gcd(c, d);
    ll cd = (c*d) / g;
    ll cm = (b / c) - (a / c);
    if (a % c == 0) cm++;
    ll dm = (b / d) - (a / d);
    if (a % d == 0) dm++;
    ll cdm = (b / cd) - (a / cd);
    if (a % cd == 0) cdm++; 
    ll ans = b - a + 1 - cm - dm + cdm;
    cerr << cm << dm << cdm << endl;
    cerr << cd << endl;
    cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> id(n,0);
  double fac = 1.0;
  for (int i = 0; i < n; i++) id[i] = i, fac *= (i + 1);
  vector<P> a(n);
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

  double res = 0.0;
  do {
    
    for (int i = 0; i < n-1; i++) {
      res += sqrt((a[id[i]].first - a[id[i + 1]].first) * (a[id[i]].first - a[id[i + 1]].first) + (a[id[i]].second - a[id[i + 1]].second) * (a[id[i]].second - a[id[i + 1]].second)); 
    }

  } while (next_permutation(id.begin(), id.end()));

  printf("%.12f\n", res / fac);

  return 0;
} 

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    val a = (1..m).map { readLine()!!.toInt() }.toTypedArray()

    val stepAnswers = Array(n) { 0L }
    val steps = Array(n) { true }

    // 壊れている段を記録
    for (i in 0 until m) {
        steps[a[i] - 1] = false
    }

    // 最上段が1の場合
    if(n == 1){
        println(1)
        return
    }

    // 最上段が2の場合
    if(n == 2){
        if(!steps[0]) println(1) else println(2)
        return
    }

    stepAnswers[0] = if (!steps[0]) 0L else 1L
    stepAnswers[1] = if (!steps[1]) 0L else 1L + stepAnswers[0]

    for (i in 2 until n) {
        if (!steps[i - 1] && !steps[i - 2]) {
            println(0)
            return
        }
        if (!steps[i]) {
            stepAnswers[i] = 0L
            continue
        }
        stepAnswers[i] = (stepAnswers[i - 1] + stepAnswers[i - 2]) % 1000000007L
    }

    println(stepAnswers[n - 1] % 1000000007L)
}


Measured memory_bytes: 41264
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	string S;
	string S_mae, S_ato;
	char C;
	int T, F;
	int Q;
	bool is_reversed = false;


	cin >> S;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> T;
		if (T == 1) {
			is_reversed = !is_reversed;
		}
		else {
			cin >> F >> C;
			if (F == 1) {
				if (!is_reversed) {
					S_mae.push_back(C);
				}
				else {
					S_ato.push_back(C);
				}
			}
			else {
				if (!is_reversed) {
					S_ato.push_back(C);
				}
				else {
					S_mae.push_back(C);
				}
			}
		}
	}

	reverse(S_mae.begin(), S_mae.end());
	S = S_mae + S + S_ato;
	if (is_reversed)
	{
		reverse(S.begin(), S.end());
	}
	cout << S;

}

Measured memory_bytes: 1348
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	  public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	 
	    int n = sc.nextInt(); //県の数
	    int m = sc.nextInt(); //市の数
	    Map<Integer,int[]> map = new TreeMap<Integer,int[]>();
	 
	    for(int i=0; i<m; i++){
	        int[] array = new int[2];
	        array[0] = i;
	        array[1] = sc.nextInt(); //県番号
	        int b = sc.nextInt(); //誕生年
	        map.put(b,array);
	    }
	    int[] ary = new int[n]; //県の数を格納
	    String[] s = new String[m]; //IDを格納
	 
	    for(int[] num :map.values()){
	      ary[num[1]-1]++;
	      s[num[0]] = String.format("%06d%06d",num[1],ary[num[1]-1]);
	    }
	    
	    for(String a: s) {
	    	System.out.println(a);
	    }
	  }
}

Measured memory_bytes: 160840
// #[proconio::fastout]
fn main() {
    let (x, n): (i64, i64) = (read::<i64>(), read::<i64>());
    let p: Vec<i64> = (0..n).map(|_| read::<i64>()).collect();
    let p: HashSet<i64> = HashSet::from_iter(p);
    let mut resv = std::i64::MAX;
    let mut res = 0;
    for i in 0..102 {
        if !p.contains(&i) && resv > (x - i).abs() {
            resv = (x - i).abs();
            res = i;
        }
    }
    println!("{}", res);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: i64 = 1000000007;

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

// =========


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

int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;

  int ans=0;
  if(N<K){
    ans = N*X;
  }else{
    ans = K*X + (N-K)*Y;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char map[310][310];
char a[310][310];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int y = 0; y < n; y++) 
			scanf(" %1c", &map[i][y]);
	int dap = 0;
	for (int z = 0; z < n; z++) 
	{
		for (int i = 0; i < n; i++)
		{
			for (int y = 0; y < n; y++)
			{
				a[i][y]=map[i][(y + z) % n];
			}
		}
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			for (int y = 0; y < n; y++)
			{
				if (a[i][y] == a[y][i])
					sum++;
			}
		}
		if (sum == n*n)
			dap++;
	}
	printf("%d", dap*n);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(string, S);
    ll ans = 0;
    int s = S.size();
    ll temp;

    for (int d = 0; d < s; d++) {
        temp = 0;

        for (int i = 0; i < s-d; i++) {
            temp += pow(2, d) * pow(2, max(0,i-1)) * pow(10, s-d-i-1);
        }
        ans += temp * (S[d]-'0');
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
// 2013/09/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
	cin >> s1;
	cin >> s2;
	cin >> s3;
	cin >> s4;
	cin >> s5;
	cin >> s6;
	cin >> s7;
	cin >> s8;
	cin >> s9;
	cin >> s10;

	int sum = s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;

	cout << sum << '\n';

	return 0;
}

Measured memory_bytes: 1160
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
print("Yes") if ((x in a) & (y in a)) or ((x in b) & (y in b)) or ((x in c) & (y in c)) else print("No")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			for (int i = 0; i < n; i++) {
				int tmp = in.nextInt();
				if (map.containsKey(tmp)) {
					int current = map.get(tmp);
					map.put(tmp, current + 1);
				} else {
					map.put(tmp, 1);
				}
				int plus = tmp + 1;
				if (map.containsKey(plus)) {
					int current = map.get(plus);
					map.put(plus, current + 1);
				} else {
					map.put(plus, 1);
				}
				int minus = tmp - 1;
				if (map.containsKey(minus)) {
					int current = map.get(minus);
					map.put(minus, current + 1);
				} else {
					map.put(minus, 1);
				}
			}

			out.println(maxUsingStreamAndLambda(map));
		}
	}

	static <K, V extends Comparable<V>> V maxUsingStreamAndLambda(Map<K, V> map) {
		Optional<Entry<K, V>> maxEntry = map.entrySet().stream()
				.max((Entry<K, V> e1, Entry<K, V> e2) -> e1.getValue().compareTo(e2.getValue()));

		return maxEntry.get().getValue();
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 46148
#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdlib.h>
#include<sstream>
#define FastRead                      \
                        ios_base::sync_with_stdio(false); \
                        cin.tie(0);
#define endl "\n"
using namespace std;
int main()

{
    FastRead
    int n,k,i,sum=0,j;
    cin>>n>>k;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0; i<k; i++)
    {
        sum=sum+a[i];
    }
    cout<<sum;
    return 0;

}





Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    int a;
    cin>>a;
    
    int even=0,cnt=0;
    for(int i=0;i<a;i++){
        int x;
        cin>>x;
        if(x%2==0 && (x%3==0 || x%5==0))
           even++;
        if(x%2==0) cnt++;   
    }
    
    if(even==cnt) cout<<"APPROVED"<<"\n";
    else cout<<"DENIED"<<"\n";
    
    
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"

using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  ll a[100100];
  ll b[100100];
  ll asum = 0LL;
  ll bsum = 0LL;
  int ans;
  ll c[100100];
  ll minus = 0;
  int miindex = 0;

  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    asum += a[i];
  }
  for (int i = 0; i < n; i++)
  {
    cin >> b[i];
    bsum += b[i];
  }
  if (asum < bsum)
  {
    ans = -1;
  }
  else
  {
    for (int i = 0; i < n; i++)
    {
      c[i] = a[i] - b[i];
      if (c[i] < 0)
      {
        minus += c[i];
        miindex++;
      }
    }
    sort(c, c + n, greater<ll>());
    int i = -1;
    while (minus < 0)
    {
      i++;
      minus += c[i];
    }
    if (i == -1)
    {
      ans = 0;
    }
    else
    {
      ans = miindex + i + 1;
    }
  }
  cout << ans << "\n";
}

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

     int ans = 0;

      for(int i = 0; i < n; i++){
          ans += B[i];
     }
      for(int i = 0; i < n; i++){
          if((A[i] + 1) == A[i+1]){
               int x = A[i];
               ans += C[x-1]; 
          }
     }

     cout << ans << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e15+7;


ll dp[3005][1005];
ll dm[3005][1005];
ll memo[2][300005];
int main(){
	//ios_base::sync_with_stdio(0);
	ll N;
	ll a[300005];

	cin >> N;
	rep(i,3*N) cin >> a[i];

	ll sum = 0;
	priority_queue<ll> que;
	rep(i,3*N){
		sum += a[i];
		que.push( -a[i] );
		if( que.size() > N ){
			sum += que.top();
			que.pop();
		}
		memo[0][i] = sum;
	}
	while( que.size() ) que.pop();
	sum = 0;
	rrep(i,3*N){
		sum += a[i];
		que.push( a[i] );
		if( que.size() > N ){
			sum -= que.top();
			que.pop();
		}
		memo[1][i] = sum;
	}

	//rep(i,3*N) cout << memo[0][i] << " "; cout << endl;
	//rep(i,3*N) cout << memo[1][i] << " "; cout << endl;

	ll ans = -INF;
	rep(i,N+1){
		chmax( ans, memo[0][i+N-1] - memo[1][i+N] );
	}

/*
	if( N > 1000 ) return 0;

	Fill( dp, 0ll );
	rep(i,3*N) rep(j,N){
		//cout << "dp[" << i << "," << j << "] " << dp[i][j] << "+" << a[i] << endl;
		chmax( dp[i+1][j+1], dp[i][j] + a[i] );
		chmax( dp[i+1][j+1], dp[i][j+1] );
	}
	Fill( dm, INF );
	rep(i,3*N+1) dm[i][0] = 0;
	rrep(i,3*N) rrep(j,N){
		chmin( dm[i][j+1], dm[i+1][j] + a[i] );
		chmin( dm[i][j+1], dm[i+1][j+1] );
	}

	//rep(i,3*N) cout << dp[i][k] << " "; cout << endl;
	//rep(i,3*N) cout << dm[i][N] << " "; cout << endl;

	ll ans = -INF;
	rep(i,N){
		chmax( ans, dp[i+N][N] - dm[i+N][N] );
	}
*/

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int N = in(), T = in();
    int min = INF;
    rep(i, N){
        int c = in(), t = in();
        if (t > T){
            continue;
        }
        if (c < min){
            min = c;
        }
    }
    if (min == INF){
        print("TLE");
    } else{
    print(min);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	int N, V[20] = {}, C[20] = {},ans=0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> V[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> C[i];
		if (V[i]-C[i]>0)
		{
			ans += V[i] - C[i];
		}
	}
	cout << ans;
	return 0;
}

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

int n;
double ans;

int main() {
    cin >> n;
    double x[n], y[n];
    for (int i=0; i<n; i++) cin >> x[i];
    for (int i=0; i<n; i++) cin >> y[i];
    for (int i=0; i<n; i++) {
        ans+=abs(y[i]-x[i]);
    }
    cout << fixed << setprecision(9);
    cout << ans << endl;
    ans = 0;
    for (int i=0; i<n; i++) {
        ans+=(y[i]-x[i])*(y[i]-x[i]);
    }
    ans = sqrt(ans);
    cout << ans << endl;
    ans = 0;
    for (int i=0; i<n; i++) {
        ans+=abs((y[i]-x[i])*(y[i]-x[i])*(y[i]-x[i]));
    }
    ans = cbrt(ans);
    cout << ans << endl;
    ans = 0;
    double z[n];
    for (int i=0; i<n; i++) z[i]=abs(y[i]-x[i]);
    sort(z, z+n);
    cout << z[n-1] << endl;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    double track[n+1][n+1];
    track[0][0]=1;
    for(int i=1;i<n+1;i++)
        track[0][i]=0;
    double nb=1;
    for(int i=1;i<n+1;i++)
    {
        nb=nb*(1-p[i-1]);
        track[i][0]=nb;
    }
    for(int i=1;i<n+1;i++)
            {
            for(int j=1;j<n+1;j++)
            {
            if (j<=i)
            track[i][j]=p[i-1]*track[i-1][j-1]+(1-p[i-1])*track[i-1][j];
            else
            track[i][j]=0;
            }
            }
    double sum=0;
    for(int i=(n/2+1);i<n+1;i++)
    {
        sum+=track[n][i];
    }
    cout<<setprecision(10)<<sum;
    return 0;
}


Measured memory_bytes: 70656