akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int[][] F = new int[N][10];
        int[][] P = new int[N][11];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 10; j++) {
                F[i][j] = ni();
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 11; j++) {
                P[i][j] = ni();
            }
        }
        long ans = -Long.MIN_VALUE;
        for (int i = 1; i < (1<<10); i++) {
            int[] coopen = new int[N];
            for (int j = 0; j <10 ; j++) {
                if(((i>>j)&1)==1){
                    for (int k = 0; k < N; k++) {
                        if(F[k][j]==1) coopen[k]++;
                    }
                }
            }
            long res = 0;
            for (int j = 0; j < N; j++) {
                res += P[j][coopen[j]];
            }
            ans = Math.max(ans, res);
        }
 
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 34948
//Author: nimishkhurana
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(i=a;i<b;i++)
#define rrep(i,b,a) for(i=b;i>=a;i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int,int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int> 
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define INF 1000000000000000
template <typename T>
ostream& operator << (ostream& stream, const pair<T,T> &p) {
    return stream<<"("<<p.first<<","<<p.second<<") ";
}

int n, w;
const int mxn = 100, mxw = 1e5+1;
int weight[mxn];
ll price[mxn], dp[mxn][mxw];

ll solve(int i, int w){
    if(i==n){
        return 0LL;
    } 

    if(~dp[i][w]) return dp[i][w];

    dp[i][w] = solve(i+1, w);
    if(weight[i] <= w)
        dp[i][w] = max(dp[i][w], price[i] + solve(i+1, w - weight[i]));
    return dp[i][w];
}

int main(){
    fastIO
    int i, j;
    
    cin>>n>>w;
    
    rep(i, 0, n){
        cin>>weight[i]>>price[i];
        rep(j, 0, w+1)
            dp[i][j] = -1;
    }

    ll ans = solve(0, w);
    cout<<ans;

    return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const ll inf = INT_MAX;

int main(void){
  string s;
  cin >> s;
  vector<bool> check(s.size(), false);
  int ans = s.size();
  int a = 0;
  REP (i, s.size()) {
    if (s[i] == 'S') a++;
    else {
      if (a > 0) {
        a--;
        ans -= 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  cout<<std::setprecision(10)<<(n+1)/2*1.0/n<<endl;
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int, input().split())

theta1 = 30*H+30*(M/60)
theta2 = 360*(M/60)
theta  = abs(theta1-theta2)

print((A**2+B**2-2*A*B*math.cos(math.radians(theta)))**0.5)

Measured memory_bytes: 9532
from collections import defaultdict
n = int(input())
rec = defaultdict(int)
for i in range(n):
    a = input()
    rec[a] += 1
m = int(input())
for i in range(m):
    a = input()
    rec[a] -= 1

q = -100000
for k, v in rec.items():
    if q <= v:
        q = v

print(max(q, 0))

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

int main(){
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int x_temp = X;
  int y_temp = Y;
  X = y_temp, Y = x_temp;
  x_temp = X;
  int z_temp = Z;
  Z = x_temp, X = z_temp;
  cout << X << " " << Y << " "  << Z << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
#define endl '\n'
#define next next_
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space puthchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = f; it <= e; ++it)
#define per(it, f, e) for (rint it = f; it >= e; --it)
const int MAXN = 5e5 + 20;
char s[MAXN], t[MAXN];
int n, fail1[MAXN], fail2[MAXN];
/*inline void getfail(int fail[], char S[]) {
	int j = fail[0] = -1;
	rep (i, 1, n - 1) {
		while(j >= 0 && S[i] != S[j]) j = fail[j];
		fail[i + 1] = ++j;
	}
}*/
inline void getfail(int *fail, char *s) {
    fail[0] = -1;
    int j = 0;
    for (int i = 1; i < n; ++i) { 
        while (j && s[i] != s[j]) j = fail[j];
        if (s[i] == s[j]) fail[i + 1] = ++j;
        else fail[i + 1] = 0;
    }
}
inline bool check_cyc1(int x) {
	return fail1[x] == 0 || x % (x - fail1[x]);
}
inline bool check_cyc2(int x) {
	if (x == 0) return false;
	return fail2[x] == 0 || x % (x - fail2[x]);
}
int main() {
	scanf("%s", s);
	n = strlen(s);
	memcpy(t, s, sizeof(t));
	reverse(t, t + n);
	//for (int i = 0; i < n; ++i) t[i] = s[n - i - 1];
	getfail(fail1, s);
	getfail(fail2, t);
	int res = check_cyc1(n) ? 1 : 2;
	bool flag = true;
	rep (i, 1, n - 1) {
		if (s[i] != s[i - 1]) {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << n << endl;
		cout << 1 << endl;
	} else if (res == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
	} else {
		int ans = 0;
		rep (i, 0, n - 1) {
			ans += (check_cyc1(i + 1) && check_cyc2(n - i - 1));
		}
		cout << 2 << endl;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long ans = 1;
        while (true) {
            if (y >= x * 2) {
                ans++;
                x *= 2;
            } else
                break;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll mod = 1000000007;

int dp[100005];

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

  int n;
  cin >> n;
  vector<int> h(n+1);
  rep(i, n) cin >> h[i+1];

  dp[n] = 0;
  dp[n-1] = abs(h[n] - h[n-1]);
  for (int i = n-2; i > 0; i--) {
    dp[i] = min(dp[i+1] + abs(h[i] - h[i+1]), dp[i+2] + abs(h[i] - h[i+2]));
  }

  cout << dp[1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	ll X, Y;
	cin >> X >> Y;

	ll ans = 0;
	while (X <= Y) {
		X *= 2;
		ans++;
	}
	cout << ans << endl;
	return 0;

}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	double A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
	double M = 0;
	int mt_ans = 0, ms_ans = 0;
	for(int i = 0; i <= 30; i++) {
		for(int j = 0; j <= 30; j++) {
			if(i == 0 && j == 0) continue;
			double mw = 100 * (i * A + j * B);
			if(mw > F) break;
			for(int u = 0; u <= (mw * E / 100); u++) {
				for(int v = 0; v <= (mw * E / 100); v++) {
					double ms = u * C + v * D;
					if(mw + ms > F) break;
					if(ms > mw * E / 100) break;
					double moist = 100 * ms / (mw + ms);
					if(moist >= M) {
						M = moist;
						mt_ans = mw + ms;
						ms_ans = ms;
					}
				}
			}
		}
	}
	cout << mt_ans << " " << ms_ans << endl;
}

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



int main() {
  string one;
  string two;
  string three;
  string first;
  string second;
  string thrd;
  string ans;

  cin >> one >> two >> three;
  first = one.at(0);
  second = two.at(0);
  thrd = three.at(0);
  // ans = one.at(0) + two.at(0) + three.at(0);
  ans = first + second + thrd;
  cout << ans << endl;
}

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

int main(){
    int n, cnt = 0;
    int p[50];
    cin >> n;
    for(int i = 0; i < n; i++){ cin >> p[i];}

    for(int i = 0; i < n; i++){
        int min = i;
        for(int j = i + 1; j < n; j++){
            if(p[j] < p[min]){
                min = j;
            }
        }
        if(min != i){
            swap(p[i],p[min]);
            cnt++;
            //cout << "swap" << endl;
        }
    }

    cout << (cnt < 2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    string O, E;
    cin >> O >> E;
    string pass;
    int i = 0;
    if (O.size() == E.size())
    {
        rep(i, O.size())
        {
            pass.push_back(O[i]);
            pass.push_back(E[i]);
        }
    }
    else
    {
        rep(i, O.size() - 1)
        {
            pass.push_back(O[i]);
            pass.push_back(E[i]);
        }
        pass.push_back(O[O.size() - 1]);
    }
    cout << pass << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

int main(){
	int N;
	cin >> N;
	vector<int>A(N);
	int a;
	rep(N) {
		cin >> A[i];
	}
	int flag = 1;
	for (int i = 0; i < A.size(); i++) {
		if (A[i] %2==0){
			if (A[i] % 3 != 0 && A[i] % 5 != 0)
				flag = 0;
		}
	}
	if (flag == 0)
		cout << "DENIED";
	else
		cout << "APPROVED";

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

bool topologicalSort(const vec<int, 2>& G, vector<int>& order) {
  const int V = G.size();
  vector<int> deg(V, 0);
  for (int v = 0; v < V; v++) {
    for (int u : G[v]) {
      ++deg[u];
    }
  }
  queue<int> pq;
  for (int v = 0; v < V; v++) {
    if (deg[v] == 0) {
      pq.push(v);
    }
  }
  order.clear();
  while (!pq.empty()) {
    int v = pq.front();
    pq.pop();
    order.push_back(v);
    for (int u : G[v]) {
      --deg[u];
      if (deg[u] == 0) {
        pq.push(u);
      }
    }
  }
  return order.size() == V;
}

int main() {
  int N, M;
  while (cin >> N >> M) {
    string S;
    cin >> S;
    vec<int, 2> G(N);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    vec<int, 2> dG(2 * N);
    for (int a = 0; a < N; a++) {
      for (int b : G[a]) {
        if (S[a] == S[b]) {
          dG[2 * a + 0].push_back(2 * b + 1);
        } else {
          dG[2 * a + 1].push_back(2 * b + 0);
        }
      }
    }
    vector<int> order;
    bool res = !topologicalSort(dG, order);
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 30848
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  6 16:28:37 2019

@author: iwata
"""

A,B,K = map(int,input().split())
count = 0

if A >= B:
    for i in reversed(range(B+1)):
        rema1 = A%i
        remb1 = B%i
        if rema1==0 and remb1==0:
            count = count +1
        if K == count:
            print(i)
            break
else:
    for j in reversed(range(A+1)):
        rema = A%j
        remb = B%j
        if rema==0 and remb==0:
            count = count +1
        if K == count:
            print(j)
            break

Measured memory_bytes: 3064
a = int(input())
mini = 10 ** 10
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
for i in divisor(a):
    i = int(i)
    b = a//i
    maxchecker = max(len(str(i)),len(str(b)))
    mini = min(maxchecker,mini)
print(mini)

Measured memory_bytes: 67024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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



Measured memory_bytes: 3604
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	map<string, ll> s;
	map<string, ll>::iterator itr;
	string tmp = "";
	ll N = 0;
	ll M = 0;
	ll ans = 0;

 	cin >> N;
	Rep(i, N) {
		cin >> tmp;
		s[tmp]++;
	}

	cin >> M;
	Rep(i, M) {
		cin >> tmp;
		s[tmp]--;
	}

	for (itr = s.begin(); itr != s.end(); itr++) {
		ans = max( itr->second, ans );
	}
	ans = max( ans, (ll)0 );

	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int N,W;
	cin >> N >> W;
	int V[101][10001]={0};
	for (int i=1; i<=N; i++){
		int v,w;
		cin >> v >> w;
		for (int j=0; j<=10000; j++){
			if (j<w) V[i][j]=V[i-1][j];
			else if (V[i-1][j]<V[i-1][j-w]+v) V[i][j]=V[i-1][j-w]+v;
			else V[i][j]=V[i-1][j];
		}
	}
	cout << V[N][W] << endl;
}

Measured memory_bytes: 7052
N = int(input())
A = list(map(int,input().split()))
ruiseki = [0]*(N+1)
total = 0
now = 10**20
sa = 0
now_2 = 0
for i in range(N):
  total += A[i]
  ruiseki[i+1] = total
for i in range(1,len(ruiseki)-1):
  snuke = ruiseki[i]-ruiseki[0]
  arai = ruiseki[N]-ruiseki[i]
  now_2 = abs(snuke-arai)
  now = min(now,now_2)
print(now)


Measured memory_bytes: 76880
N=input()
a=map(int, raw_input().split())
b=map(int, raw_input().split())

if a==b:
	print "Yes"
	quit()

try_cnt=sum(b)-sum(a)

C={}
C[1]=try_cnt
C[2]=try_cnt

for i,j in zip(a,b):
	if i<j:
		C[2]-=(j+1-i)/2
		C[1]+=(j-i)%2
	if i>j:
		C[1]-=(i-j)


if C[1]>=0 and C[2]>=0:
	print "Yes"
else:
	print "No"


Measured memory_bytes: 3980
n,k=map(int,input().split())
td=[tuple(map(int,input().split())) for _ in range(n)]

td.sort(key=lambda x:x[1])

kind=set()

base=0
rest=[]

for i in range(k):
    t,d=td.pop()

    base+=d

    if t in kind:
        rest.append(d)
    
    kind.add(t)

cntk=len(kind)
ans=base+cntk*cntk

while len(rest)>0:
    bd=rest.pop()
    
    while len(td)>0:
        nt,nd=td.pop()
        if nt not in kind:
            break
    else:
        break

    base+=nd-bd
    cntk+=1
    ans=max(ans,base+cntk*cntk)
    kind.add(nt)

print(ans)

Measured memory_bytes: 102088
#include<bits/stdc++.h>
using namespace std;
int main(){
 long  long a,b,c;
 cin>>a>>b>>c;
 long long k=0;
 if(a%c==0){
   k=b/c-a/c+1;
   }


 else
  k=b/c-a/c;
  cout<<k<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int d[6],n,i,j,blank,ue,mae;
  
  for(i = 0; i < 6; i++){
    
    scanf("%d",&d[i]);
    
  }
  
  scanf("%d",&n);
  
  for(j = 0; j < n; j++){
    
    scanf("%d %d",&ue,&mae);
    
    for(i = 0; d[1] != mae && i < 3; i++){

      //3S
      blank=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=blank;
      
    }
    
    if(d[1] != mae){

      //1E
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
      
      for(i = 0; d[1] != mae; i++){

	//3S
	blank=d[0];
	d[0]=d[4];
	d[4]=d[5];
	d[5]=d[1];
	d[1]=blank;
	
      }
      
    }
    
    for(i = 0; d[0] != ue; i++){

      //3E
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
      
    }
    
    printf("%d\n",d[2]);
    
  }
  
  return 0;

}

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

int V[100010];
int N,K;
vector<int> mem(100010,1e9+1);

int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    mem[0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=K;j++){
            if(i+j<N){
                mem[i+j]=min(mem[i+j],mem[i]+abs(V[i]-V[i+j]));
            }
        }
    }
    cout<<mem[N-1]<<endl;
    return 0;
}

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

int main()
{
    ll N, D;
    cin >> N >> D;
    vector<vector<ll>> X(N, vector<ll>(D));
    rep(i, N)
    {
        rep(j, D)
        {
            cin >> X[i][j];
        }
    }
    ll ans = 0;
    rep(i, N)
    {
        for (int j = i + 1; j < N; j++)
        {
            double sum = 0;
            rep(k, D) sum += pow(X[i][k] - X[j][k], 2);
            if (sum == pow(ll(floor(sqrt(sum))), 2))
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

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

	rep(a, 2) rep(b, 2) {
		//0:羊,　1:狼
		vector<char> ans(s.size(), '-');
		if (a == 0) ans[0] = 'S'; else ans[0] = 'W';
		if (b == 0) ans[1] = 'S'; else ans[1] = 'W';

		for (int i = 2; i < s.size(); ++i) {
			if (ans[i - 2] == 'S') {
				if (ans[i - 1] == 'S') {
					if (s[i - 1] == 'o') {
					  ans[i] = 'S';
					}
					else {
						ans[i] = 'W';
					}
				}
				else {
					if (s[i - 1] == 'o') {
						ans[i] = 'W';
					}
					else {
					  ans[i] = 'S';
					}
				}
			}
			else {
				if (ans[i - 1] == 'S') {
					if (s[i - 1] == 'o') {
						ans[i] = 'W';
					}
					else {
						ans[i] = 'S';
					}
				}
				else {
					if (s[i - 1] == 'o') {
						ans[i] = 'S';
					}
					else {
						ans[i] = 'W';
					}
				}
			}
		}

		bool ok = true;
		int n = s.size() - 1;
		if (ans[n] == 'S'){
			if (s[n] == 'o') {
				if (ans[n - 1] != ans[0]) ok = false;
			}
			else {
				if (ans[n - 1] == ans[0]) ok = false;
			}
		}
		else {
			if (s[n] == 'o') {
				if (ans[n - 1] == ans[0]) ok = false;
			}
			else {
				if (ans[n - 1] != ans[0]) ok = false;
			}
		}

		if (ans[0] == 'S') {
			if (s[0] == 'o') {
				if (ans[n] != ans[1]) ok = false;
			}
			else {
				if (ans[n] == ans[1]) ok = false;
			}
		}
		else {
			if (s[0] == 'o') {
				if (ans[n] == ans[1]) ok = false;
			}
			else {
				if (ans[n] != ans[1]) ok = false;
			}
		}

		if (ok) {
		  rep(i,n+1) cout << ans[i]; 
			cout << endl;
			return 0;
		}
	}

	cout << -1 << endl;
}




Measured memory_bytes: 512
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    ss=readline().rstrip()
    tt=readline().rstrip()

    ls=len(ss)
    lt=len(tt)
    ans=0
    for i in range(0,ls-lt+1):
        n=0
        for j in range(lt):
            if tt[j]==ss[i+j]:
                n+=1
        ans=max(ans,n)
    print(lt-ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16200
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

vector<int> prime_list;
void prime_factorization(int n) {
  while (n % 2 == 0) {
    n /= 2;
    prime_list.push_back(2);
  }
  for (int i = 3; i < (int)(sqrt((double)n)) + 2; i += 2)
    if (n % i == 0)
      while (n % i == 0) {
        n /= i;
        prime_list.push_back(i);
      }
  if (n != 1) prime_list.push_back(n);
}
class DDivGame {
public:
  static void solve(istream &cin, ostream &cout) {
    prime_list = {};
    int N;
    cin >> N;
    prime_factorization(N);
    map<int, int> primes;
    while (prime_list.size()) {
      primes[prime_list[prime_list.size() - 1]]++;
      prime_list.pop_back();
    }
    int ans = 0;
    vector<int> judge(10000);
    rep(i, 1000) {
      judge[i] = (i + 1) * (i + 2) / 2;
    }
    FOR(i, primes) {
      if (i.second != 0) {
        rep(j, 1000) {
          if (i.second >= judge[j] and i.second < judge[j + 1]) {
            ans += j + 1;
            break;
          }
        }
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  DDivGame solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#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 pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  if(n>m)swap(n,m);
  if(m-n > 1){
    cout << 0 << "\n";
    return 0;
  }
  ll f = 1;
  FOR(i, 1, n+1){
    f = f * i % mod;
  }
  ll ans = f;
  f = f * (m>n ? m : 2ll) % mod;
  ans = ans * f % mod;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
use std::cmp::Ord;
use std::cmp::Ordering;
use std::cmp::PartialOrd;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    // (city name, rating, index)
    let mut sp: Vec<(String, i32, usize)> = (0..n).map(|i| (read(), read(), i + 1)).collect();

    sp.sort_by_key(|k| (k.0.clone(), Reverse(k.1)));

    for &(_, _, index) in sp.iter() {
        println!("{}", index);
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[derive(PartialEq, Eq, Debug, Copy, Clone, Default, Hash)]
struct Reverse<T>(T);

impl<T: PartialOrd> PartialOrd for Reverse<T> {
    #[inline]
    fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Reverse<T> {
    #[inline]
    fn cmp(&self, other: &Reverse<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}


Measured memory_bytes: 4352
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;



void mymain(){
    int n;
    cin >> n;
    int ans=LMAX;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            int cnt = i-1;
            cnt += n/i -1;
            ans = min(ans,cnt);
        }
    }
    cout << ans <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}


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

int main(){
  int a, b, sumAB, numOfFirstPlace;
  cin >> a >> b;
  sumAB = a + b;
  numOfFirstPlace = (sumAB * 5) % 10; // "* 5" means "* (1/2) * 10"
  if (numOfFirstPlace >= 5) {
    cout << (sumAB / 2) + 1 << endl;
  }
  else {
    cout << (sumAB / 2) << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		/* 隣接する要素の間に1つの空白を出力 */
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cout<<"Case "<<i<<":"<<endl;
        int s;
        cin>>s;
        stringstream ss;
        ss<<setw(8)<<setfill('0')<<s*s;
        string str;
        ss>>str;
        for(int j=0;j<10;j++){
            ss.clear();
            str=str.substr(2,4);
            ss<<str;
            int a;
            ss>>a;
            ss.clear();
            cout<<a<<endl;
            ss<<setw(8)<<setfill('0')<<a*a;
            ss>>str;
        }

    }
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <queue>

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vpl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define foR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define foRs(i, a, b, s) for (int i = (int)(a); i < (int)(b); i += s)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define foRr(i, a, b) for (int i = (int)(a) - 1; i >= (int)(b); --i)

#define prnt(a) cout << (a)
#define prntl(a) cout << (a) << endl
#define in insert
#define rem remove
#define er erase

#define linf ((ll) 1e9)
#define inf ((int) 1e5)
#define otherinf 555555

#define mod 1000000007

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

	string s;
	getline(cin, s);
	if(s.size() < 2 || s.find('C') == s.npos || s.find('F') == s.npos)
	{
		cout << "No";
		return 0;
	}

	auto c = s.find('C');
	auto f = s.find('F');
	while(f <= c && f != s.npos)
	{
		f = s.find('F', f+1);
	}

	if(c < f && f!=s.npos)
		cout << "Yes";
	else
		cout << "No";


	return 0;
}

Measured memory_bytes: 256
X,K,D = list(map(int, input().split()))

X = abs(X)

if X >= K*D:
    print(X-K*D)
else:
    t,r = divmod(X-D, D)
    if r>0:
        t+=1
    K -= t
    
    if K%2==0:
        print(X - t*D)
    else:
        print(abs(X - (t+1)*D))

Measured memory_bytes: 9188
def main():
    N, M, X, *CA = map(int, open(0).read().split())
    C = [0]*N
    A = [[0]*M for i in range(N)]

    for i in range(N):
        C[i] = CA[(M + 1)*i]
        for j in range(M):
            A[i][j] = CA[(M + 1)*i + j + 1]
    # print(N, M, X, C, A)
    B = [0]*M
    for i in range(N):
        for j in range(M):
            B[j] += A[i][j]
    for i in range(M):
        if B[i] < X:
            print(-1)
            return

    ans = sum(C)
    for i in range(2**N):
        B = [0]*M
        price = 0
        for j in range(N):
            if (i >> j) & 1 == 1:
                price += C[j]
                for k in range(M):
                    B[k] += A[j][k]
        found = True
        for j in range(M):
            if B[j] < X:
                found = False
                break
        if found:
            ans = min(ans, price)
    print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 9260
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main() {
ll Q;
  cin >>Q;
  
  vl l(Q);
  vl r(Q);
  rep(i,Q) {
cin >>l.at(i)>>r.at(i);
  }

   bool data[100010];
  data[0]=false;
  repl(i,1,100010) {
   if(  (IsPrime(i)) &&(IsPrime((i+1)/2) )   ) {
     data[i]=true;
   }
    else {
      data[i]=false;
    }
  }
    
    
    
  
  
  
  
  
  
  ll ps[100010];
  ps[0]=0;
  repl(i,1,100010) {
   if(data[i]) {
     ps[i]=ps[i-1]+1;
   }
    else {
      ps[i]=ps[i-1];
    }
  }
  
  
  
vl vec(Q);
  rep(i,Q) {
vec.at(i)=ps[r.at(i)]-ps[l.at(i)-1];
  }
  rep(i,Q) {
    cout<<vec.at(i)<<endl;
  }
  
}
    
  
  
  
  

Measured memory_bytes: 3840
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n, x;

    Scanner in = new Scanner(System.in);

    while(true){
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    }

  }
}

Measured memory_bytes: 26080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+100;
const int inf=0x3f3f3f3f;
typedef pair<ll,int>P;

ll a[maxn];
int main(){
    int n,k;
    scanf("%d%d",&k,&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    a[n]=k+a[0];
    ll mine=inf;
    for(int i=0;i<n;i++)
        mine=min(mine,k-(a[i+1]-a[i]));
    cout<<mine<<endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long comb(long long x,long long y){
  long long z = 1;
  for(long long i=0;i<y;i++) z = z*(x-i)/(i+1);
  return z;
}
int main(){
  cout << fixed << setprecision(10);
  long long n,a,b,i,ans = 0,al,c = 0;cin >> n >> a >> b;
  long long v[n];
  for(i=0;i<n;i++) cin >> v[i];
  sort(v,v+n,greater<long long>());
  for(i=0;i<a;i++) ans += v[i];
  cout << double(ans)/a << "\n";
  ans = 0;al = count(v,v+n,v[a-1]);
  for(i=0;i<a;i++) c += (v[i]==v[a-1]);
  ans += comb(al,c);
  if(v[0] != v[a-1]){
    cout << ans << "\n";return 0;
  }
  for(i=a;i<b;i++){
    if(v[i]==v[a-1]){
      c++;ans += comb(al,c);
    } else break;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int f[2010][6010];
int n,Mod;
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int main()
{
	scanf("%d %d",&n,&Mod);
	f[0][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=i;j<=3*n;j++)
		{
			if(j>0)add(f[i][j],f[i][j-1]);
			if(i>0){
				if(j>1)
					add(f[i][j],(long long)f[i-1][j-2]*(j-1)%Mod);
				if(j>2)add(f[i][j],(long long)f[i-1][j-3]*(j-2)%Mod*(j-1)%Mod);
			}
		}
	int ans=0;
	for(int i=0;i<=n;i++)
		add(ans,f[i][n*3]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 47360
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
	int N;
	cin >> N;

	int* A = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int* B = new int[N];
	memcpy(B, A, sizeof(int) * N);

	sort(B, B + N);

	for (int i = 0; i < N; i++) {
		if (B[N-1] == A[i])
			cout << B[N-2] << endl;
		else
			cout << B[N-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,l,c,f;
	cin>>n>>k;
	vc a(n+1);
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n-k;i++)
	{
	    if(a[i+k]>a[i])
	        cout<<"Yes\n";
	    else cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 4784
from operator import itemgetter

h, w, m = (int(x) for x in input().split())
H = [0] * h
W = [0] * w
HW = []
for _ in range(m):
    h_, w_ = (int(x) - 1 for x in input().split())
    HW.append((h_, w_))
    H[h_] += 1
    W[w_] += 1
hmax = max(H)
wmax = max(W)
hindex = set()
windex = set()

HW.sort(key=itemgetter(0, 1))
for y in range(h):
    if H[y] == hmax:
        hindex.add(y)
for x in range(w):
    if W[x] == wmax:
        windex.add(x)

count = 0
for h, w in HW:
    if h in hindex and w in windex:
        count += 1

if count == len(hindex)*len(windex):
    ans = hmax + wmax - 1
else:
    ans = hmax + wmax

print(ans)


Measured memory_bytes: 175084
/*
[agc014] D - Black and White Tree
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;
const int MAX_V = MAX_N;

int N;
vector<int> g[MAX_V];
int match[MAX_V];
bool used[MAX_V];

bool dfs(int v) {
    used[v] = true;
    for (int u : g[v]) {
        int w = match[u];
        if (w < 0 || (!used[w] && dfs(w))) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(int V) {
    int cnt = 0;
    memset(match, -1, sizeof(match));
    for (int v = 0; v < V; v++) {
        if (match[v] < 0) {
            memset(used, 0, sizeof(used));
            if (dfs(v)) {
                cnt++;
            }
        }
    }

    return cnt;
}

bool solve() { return (bipartite_matching(N) * 2 < N); }

int main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    cout << (solve() ? "First" : "Second") << endl;

    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;
  cin >> n;
  vp robot(n,P(0,0));
  rep(i,n) {
    int x,l;
    cin >> x >> l;
    robot.at(i) = P(x+l,x-l);
  }
  sort(rng(robot));
  int ans = 1;
  P now = robot.at(0);
  orep(i,n-1) {
    if(now.fi<=robot.at(i).se) {
      ans++;
      now=robot.at(i);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
n = int(input())
h = list(map(int, input().split()))


# 後ろから
for i in range(n-1,0,-1):
  if i == n-1:
    continue
  elif h[i] <= h[i+1]:
    continue
  elif h[i] == h[i+1] + 1:
    h[i] -= 1
  else:
    print('No')
    break
else:
  print('Yes')


  



Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n, k;
    cin >> n >> k;
    int ans = k;
    for (int i = 0; i < n - 1; i++)
    {
        ans *= (k - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256