akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, "%d", $n);
$tmp = trim(fgets(STDIN));
$input = explode(' ', $tmp);
// バブルソート
$buble = $input;
$select = $input;
$flag = false;
$select_flag = false;
for ($i = 0; $i < $n; $i++) {
    for ($h = $n - 1; $h >= $i + 1; $h--) {
        if ((int)$buble[$h - 1][1] > (int)$buble[$h][1]) {
            $tmp_buble = $buble[$h];
            $buble[$h] = $buble[$h - 1];
            $buble[$h - 1] = $tmp_buble;
        }
    }
    $min = $i;
    for ($h = $i; $h < $n; $h++) {
        if ((int)$select[$min][1] === (int)$select[$h][1] && $h !== $i) {
            $flag = true;
        }
        if ((int)$select[$min][1] > (int)$select[$h][1]) {
            $min = $h;
        }

    }
    if ($min !== $i) {
        $tmp_select = $select[$i];
        $select[$i] = $select[$min];
        $select[$min] = $tmp_select;
        if ($flag) {
            $select_flag = true;
        }
    }
    $flag = false;
}


for ($i = 0; $i < $n; $i++) {
    if ($i === $n - 1) {
        echo "$buble[$i]\n";
    } else {
        echo $buble[$i] . ' ';
    }
}
echo "Stable\n";

for ($i = 0; $i < $n; $i++) {
    if ($i === $n - 1) {
        echo "$select[$i]\n";
    } else {
        echo $select[$i] . ' ';
    }
}
if ($select_flag) {
    echo "Not stable\n";
} else {
    echo "Stable\n";
}


Measured memory_bytes: 9284
q = int(input())
def prime(n):
    if any(n%i==0 or ((n+1)/2)%i==0 for i in range(2,int(n**(1/2))+1)):
        return False
    else:
        return True
cum = [0]*(10**5)
cum[3]=1
for i in range(4,10**5):
    cum[i]=cum[i-1]
    if prime(i):
        cum[i]+=1
for i in range(q):
    l,r = map(int,input().split())
    print(cum[r]-cum[l-1])

Measured memory_bytes: 4340
n = int(input())
a_lst = list(map(int,input().split()))

d = {}

for i in range(n):
    d[a_lst[i]] = i+1

d_sort = sorted(d.items(), key=lambda x : x[0])

ans_lst = []
for item in d_sort:
    ans_lst.append(str(item[1]))

print(" ".join(ans_lst))

Measured memory_bytes: 32092
#include<iostream>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	int n, m, c;
	cin >> n >> m >> c;
	int b[m], i;
	for(i=0; i<m; i++){
		cin >> b[i];
	}
	int sum=0, count = 0;
	for(i=0; i<n; i++){
		for(int j=0; j<m; j++){
			int x;
			cin >> x;
			sum += x*b[j];
		}
		if(sum+c>0) count++;
		sum = 0;
	}
	cout << count << endl;
	return 0;
}


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

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

void solve(void){

  ll a, v; cin >> a >> v;
  ll b, w; cin >> b >> w;
  ll t; cin >> t;

  if (v <= w) {
    cout << "NO" << endl;
    return;
  }

  if (abs(b-a) <= (v-w) * t) {
    cout << "YES" << endl;
  } else cout << "NO" << endl;
}

int main(void) {
  solve();
  return 0;
}

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

int main(void) {
	int count;
	bool flag = 0;
	string w;
	cin >> w;

	for (int i = 0;i<w.size(); ++i) {
		count = 0;
		for (int j = 0;j<w.size(); ++j) {
			if (w[i] == w[j]) ++count;
		}
		if (count % 2 == 1) flag = 1;
	}

	if (flag == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n, d, x; cin >> n >> d >> x;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    int res = 0;
    for(int i=0; i<n; i++){
        int day = 1;
        while(day<=d){
            res++;
            day+=a.at(i);
        }
        dump(res);
    }
    
    cout << res + x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	double gx = w / 2;
	double gy = h / 2;
	int ch = 0;
	if (x == gx && y == gy) {
		ch = 1;
	}
	double s = w * h/2;
	printf("%.10f", s); cout << endl; printf("%d", ch);
	return 0;
}

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

int main() {
	int n,a,s,d,f,b[15][10];
	cin>>n;
	for(int i=0;i<15;i++){
		for(int j=0;j<10;j++){
			b[i][j]=0;
		}
	}
	for(int i=0;i<n;i++){
		cin>>a>>s>>d>>f;
		if(a==1){
			b[s-1][d-1]+=f;
		}
		else if(a==2){
			b[s+3][d-1]+=f;
		}
		else if(a==3){
			b[s+7][d-1]+=f;
		}
		else{
			b[s+11][d-1]+=f;
		}
	}
	for(int i=0;i<15;i++){
		for(int j=0;j<10;j++){
			if(i==3||i==7||i==11){
				cout<<"####################"<<endl;
				i++;
				j=-1;
			}
			else if(j==9){
				cout<<" "<<b[i][j]<<endl;
			}
			else{
				cout<<" "<<b[i][j];
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1160
import Control.Applicative

type Dice = [Int]

roll :: Dice -> Char -> Dice
roll [a, b, c, d, e, f] direction =
  case direction of 
    'N' -> [b, f, c, d, a, e]
    'S' -> [e, a, c, d, f, b]
    'W' -> [c, b, f, a, e, d]
    'E' -> [d, b, a, f, e, c]

top :: Dice -> Int
top (x:xs) = x 

main :: IO ()
main = do
  dice <- map read . words <$> getLine :: IO [Int]
  commands <- getLine :: IO String
  print $ top $ foldl roll dice commands 

Measured memory_bytes: 3556
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int num3 = sc.nextInt();
        
        int n = 0;
        
        for(int i = num1;i <= num2;i++){
        	if(i % num3 == 0){
            	n++;
            }
        }
        System.out.println(n);
	}
}

Measured memory_bytes: 35764
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
	string s;
	cin >> s;
	ll a = INF, z = -INF;
	REP(i, s.size()) {
		if(s[i] == 'A') a = min(a, i);
		if(s[i] == 'Z') z = max(z, i);
	}
	cout << z-a+1 << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

int n;
const ll MOD = 1e9+7;
char s[3010];
ll D[3010][3010];

int main() {
    int i, j;

    scanf("%d",&n);
    scanf("%s",&s);
    D[0][0] = 1;
    for (i=1;i<=n;i++) {
        if (s[i-1]=='<')
            for (j=1;j<=i;j++) D[i][j] = (D[i][j-1]+D[i-1][j-1])%MOD;
        else
            for (j=i-1;j>=0;j--) D[i][j] = (D[i][j+1]+D[i-1][j])%MOD;
    }
    printf("%lld\n",D[n][0]);

    return 0;
}


Measured memory_bytes: 69120
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

vector<pair<int, int>> inp;


bool check(int added, int m)
{
	vector<int> all_rs;
	multiset<int> rs;
	for (auto x : inp)
	{
		rs.insert(x.second);
		while (((int)rs.size() - added) > x.first )
		{
			int vvv = *rs.begin();
			all_rs.push_back(vvv);
			rs.erase(rs.find(vvv));
		}
	}
	sort(all_rs.begin(), all_rs.end());

	if ((m + added) < (rs.size() + all_rs.size()))
	{
		return false;
	}

	int cnt = 0;
	for (int i = all_rs.size()-1;i>=0;i--)
	{
		int val = all_rs[i];
#if 0
		if (rs.find(val) != rs.end())
		{
			rs.erase(rs.find(val));
			continue;
		}
#endif
		if (val > m)
			return false;
		cnt++;
		if ((m - val + 1) < cnt)
			return false;
	}
	return true;
}


int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	int n, m;
//	cin >> n >> m;
	scanf("%d %d ", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int a, b;
//		cin >> a >> b;
		scanf("%d %d ", &a, &b);
		inp.push_back({ a,b });
	}
	sort(inp.begin(), inp.end());



	int left = 0, right = (n  + 1);
	while (left < right)
	{
		int mm = (left + right) / 2;
		if (check(mm, m))
		{
			right = mm;
		}
		else
		{
			left = mm + 1;
		}
	}

	printf("%d", left);
//	cout << left;
	return 0;
}


Measured memory_bytes: 11264
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	A, B, N := sc.i(), sc.i(), sc.i()
	x := min(B-1, N)
	f := A * x / B
	fmt.Println(f)

}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    string S;
    std::cin >> S;
    int n = S.size();

    int ans = INF;
    bool f = true;
    rep2(i, 1, n) {
        if (S[i] != S[i - 1]) {
            ans = min(ans, max(i, n - i));
            f = false;
        }
    }
    if (f)
        cout << n << endl;
    else
        cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 3e5 + 15;
const ll MOD = 1e15 + 7;
const double EPS = 1e-9;
const int BLOCK = 500;
const double PI = acos(-1);
//auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
auto seed = 194113341;
mt19937 rnd(seed);

bool is_equal(double a, double b) {
    return abs(a - b) <= EPS;
}


#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) % m + (x < 0 ? m: 0))


inline void IO() {
#if buyolitsez
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

inline void solve() {
    cout << setprecision(13) << fixed;
    double x;
    cin >> x;
    x = 2.0 * M_PI * x;
    cout << x;
}

signed main() {
    IO();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;

vector<int> to[200001];
int ctr[200001] = {};
bool visited[200001] = {};

void bfs(int n, int acc)
{
    if (visited[n]) {
        return;
    }

    ctr[n] += acc;
    visited[n] = true;
    for (int u : to[n]) {
        bfs(u, ctr[n]);
    }
}

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

    bfs(1, 0);
    cout << ctr[1];
    for (int i = 2; i < N+1; i++) {
        cout << " " << ctr[i];
    }
    cout << endl;
}

Measured memory_bytes: 20608
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int D, Q, x[131072], ls, rs, es; vector<int> seg[262144];
int query(int a, int b, int x1, int x2, int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return lower_bound(seg[k].begin(), seg[k].end(), x2) - lower_bound(seg[k].begin(), seg[k].end(), x1);
	int lc = query(a, b, x1, x2, 2 * k, l, (l + r) / 2);
	int rc = query(a, b, x1, x2, 2 * k + 1, (l + r) / 2, r);
	return lc + rc;
}
int main() {
	scanf("%d", &D);
	for (int i = 0; i < D; i++) {
		scanf("%d", &x[i]);
		int t = i + 131072;
		while (t > 0) {
			seg[t].push_back(x[i]);
			t >>= 1;
		}
	}
	for (int i = 1; i < 262144; i++) {
		if (seg[i].size() > 1) {
			sort(seg[i].begin(), seg[i].end());
		}
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d%d", &ls, &rs, &es);
		int a = min(x[ls - 1], x[rs - 1]);
		int b = max(x[ls - 1], x[rs - 1]);
		printf("%d\n", rs - ls + 1 - query(ls - 1, rs, a - es, b + es + 1, 1, 0, 131072));
	}
	return 0;
}

Measured memory_bytes: 21228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* this can get the minimum(maximum) value of lines(f_i(x)=ax+b)
when query add and get is monotony(x1<=x2<=x3... or x1>=x2>=x3>=...
and a1<=a2<=a3... or a1>=a2>=a3...), you can use (isMonoticX=true) (O(N+Q))
when add query is monotony, you use (isMonoticX=false) (O((N+Q)logN) */
using P = pair<ll,ll>;
struct CHTrick{
	deque<P> lines;
	bool isMonoticX = false;
	CHTrick(bool flag=false){
		isMonoticX = flag;
	}
	// check whether line l2 is useless
	// maybe overflow
	bool check(P l1, P l2, P l3){
		return (long double)(l3.second-l2.second)*(l2.first-l1.first) >= (long double)(l2.second-l1.second)*(l3.first-l2.first);
	}
	// add line(y=ax+b)
	void add(ll a, ll b){
		if(lines.size()>0 && lines.back().first==a){
			// if you find minimum val, replace max to min
			b = min(b, lines.back().second);
			lines.pop_back();
		}
		P line(a,b);
		while(lines.size()>=2 && check(*(lines.end()-2),lines.back(),line)){
			lines.pop_back();
		}
		lines.push_back(line);
	}
	// return the value of f_i(x)
	ll f(int i, ll x){
		return lines[i].first*x + lines[i].second;
	}
	ll f(P line, ll x){
		return line.first*x + line.second;
	}
	// minimum -> (lv>=rv), maximum ->(lv<=rv)
	bool comp(ll lv, ll rv){
		return lv >= rv;
	}
	// return the minimum(maximum) values among lines
	ll get(ll x){
		if(isMonoticX){
			while(lines.size()>=2 && comp(f(0,x),f(1,x))){
				lines.pop_front();
			}
			return f(0,x);
		}else{
			int low = -1, high = lines.size()-1;
			while(high-low>1){
				int mid=(high+low)/2;
				if(comp(f(mid,x),f(mid+1,x))) low = mid;
				else high = mid;
			}
			return f(high,x);
		}
	}
};

const ll INF = LLONG_MAX/3;

int main(){
    int n;
    ll c;
    cin >>n >>c;
    vector<ll> h(n);
    rep(i,n) cin >>h[i];

    CHTrick cht(true);

    vector<ll> dp(n,INF);
    dp[0] = 0;
    cht.add(-2*h[0], h[0]*h[0]+dp[0]);
    for(int i=1; i<n; ++i){
        dp[i] = cht.get(h[i]) + h[i]*h[i] + c;
        cht.add(-2*h[i], h[i]*h[i]+dp[i]);
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 5632
n, m = map(int, input().split())
l_r = list(list(int(i) for i in input().split()) for i in range(m))

x = []
y = []

for i in range(m):
    x.append(l_r[i][0])
    y.append(l_r[i][1])

x1 = max(x)
y1 = min(y)

if x1 <= y1:
    print(y1 - x1 + 1)
else:
    print('0')


Measured memory_bytes: 29064
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a,ans;
vector<ll> v;
int main(void){
    cin>>n>>m;
    if(n<=m){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<(n-m);i++){
        ans+=v[i];
    }
    cout<<ans<<endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> ans(n);
    for (int i = 0; i < n - 1; i++) {
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 4044
<?php
//error_reporting(0);
//$s = trim(fgets(STDIN));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$a[] = array_map('intval',explode(" ",trim(fgets(STDIN))));
list($N,$P) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$S = trim(fgets(STDIN));

https://atcoder.jp/contests/abc158/submissions/10605418
$S = strrev($S);
$slen = strlen($S);
$ans=0;
$pow10=1;
$sum = 0;
$cnt=array();

if ($P != 2 && $P != 5) {
  $cnt[0]=1;
  for($i=0;$i<$slen;$i++) {
    $sum = ($sum + $S[$i]*$pow10) % $P;
    $ans += $cnt[$sum];
    if (isset($cnt[$sum])) {
      $cnt[$sum]++;
    }
    else {
      $cnt[$sum]=1;
    }
    $pow10 = $pow10 * 10 % $P;
  }
}
else {
  $z = 0;
  for($i=0;$i<$slen;$i++) {
    if ($S[$i] % $P == 0) $z++;
    $ans += $z;
  }
}
printf("%d\n",$ans);


Measured memory_bytes: 4856
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
using lli = long long int;
typedef pair<ll, ll> pii;
const ll MM = 1000000000;
const ll mod = MM + 7;
int main(){
    int n; cin >> n;
    int p[11];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p, p + n);
    int ans = 0;
    for(int i = 0; i < n-1; i++){
        ans += p[i];
    }
    ans += (p[n-1]/2);
    cout << ans << endl;
}

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

#define ll long long int
 
int main() {
    double n, pi = 3.1415926535897932;
    cin >> n;
    double ans = 2 * (double)(pi) * (double)(n);
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 3788
require 'set'

def main
  n = gets.chomp.to_i
  n_arr = gets.chomp.split(/\s/).collect { |x| x.to_i}
  q = gets.chomp.to_i
  q_arr = gets.chomp.split(/\s/).collect { |x| x.to_i}

  s1, s2 = Set.new, Set.new
  n_arr.each { |elem| s1 << elem}
  q_arr.each { |elem| s2 << elem}

  puts (s1 & s2).size
end

main

Measured memory_bytes: 6500
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int n,m;
int cost[1005]={0},g[1005]={0};
int dp[1005][10005],mm=0;
int fun(int in,int res){
	if(in==m){
		if(res==mm)return 0;
		else return hell;
	}
	if(dp[in][res]!=-1)return dp[in][res];
	dp[in][res]=min(fun(in+1,(res|g[in]))+cost[in],fun(in+1,res));
	return dp[in][res];
}
int main(){
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	int p[12];
	p[0]=1;
	for(int i=1;i<12;i++)p[i]=p[i-1]*2;
	mm=pow(2,n)-1;
	for(int i=0;i<m;i++){
		cin>>cost[i];
		int l;cin>>l;
		for(int j=0;j<l;j++){
			int x;cin>>x;
			g[i]+=p[x-1];
		}
	}
	int res=0;
	int x=fun(0,res);
	if(x>=hell)cout<<"-1"<<endl;
	else cout<<x<<endl;
}

Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
void chkmax(int &x,int y){
	x=x>y?x:y;
}
int a[maxn][maxn];
int dp[maxn][maxn];
int main(){
//	freopen("A.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]+=a[i][j];
			chkmax(dp[i+1][j],dp[i][j]);
			chkmax(dp[i][j+1],dp[i][j]);
		}
	}
	printf("%d\n",dp[2][n]);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ABC170D();

int main()
{
	ABC170D();
	fflush(stdout);
	return 0;
}


static void ABC170D()
{
	int N;
	getint(N);

	std::multiset<int> ai;
	for (int i = 0; i < N; i++) {
		int a;
		getint(a);
		ai.insert(a);
	}

	int ans = 0;
	while (ai.size()) {
		//	現時点での最小値はかならず条件を満たす
		int minVal = *(ai.begin());
		ai.erase(ai.begin());
		if (ai.find(minVal) == ai.end()) {
			//	ただし，同じ数が他になければ
			ans++;
		}

		//	現時点での最小値の倍数を消していく
		LLONG mul = minVal;
		while ((ai.size()) && (mul <= *(ai.rbegin()))) {
			auto it = ai.find(mul);
			if (it != ai.end()) {
				//	同じ値は全消し
				ai.erase(mul);
			}
			mul += minVal;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 13068
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int x[3];

    cin >> x[0] >> x[1] >> x[2];
    sort(x, x + 3);
    cout << (x[0] + x[1]) << endl;

    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"
import "math"

func main() {
	var n int
	fmt.Scan(&n)

	inputs := make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&inputs[i])
	}

	min := math.MaxInt32
	for i := -100; i <= 100; i++ {
		sum := 0

		for _, a := range inputs {
			sum += (a - i) * (a - i)
		}

		if sum < min {
			min = sum
		}
	}

	fmt.Println(min)
}

Measured memory_bytes: 512
import math
def main():
	s = raw_input()
	l = s.split()
	x = int(l[0])
	k = int(l[1])
	d = int(l[2])
	value = x - k * d
	ans = x + k * d
	be = 0
	en = k
	while (be <= en):
	    mid = (be + en) // 2
	    diff = 2 * mid * d
	    if ((value + diff) >= 0):
	        ans = value + diff
	        en = mid - 1
	    else:
	        be = mid + 1

	ans2 = value
	be = 0
	en = k
	while (be <= en):
		mid = (be + en) / 2
		diff = 2 * mid * d
		if ((value + diff) < 0):
		    ans2 = value + diff
		    be = mid + 1
		else:
		    en = mid - 1
	print(int(min(abs(ans), abs(ans2))))	



if __name__ == '__main__':
	main()



Measured memory_bytes: 85436
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
#define int long long
using namespace std;
int x[100000],y[100000],z[100000],vx[2],vy[2];
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,a) cin>>x[i];
	f(i,b) cin>>y[i];
	f(i,c){
		cin>>z[i];
		int ans=LLONG_MAX/3;
		f(j,2){
			vx[j]=x[max((int)(0),min((int)(lower_bound(x,x+a,z[i])-x-j),a-1))];
			f(k,2){
				vy[k]=y[max((int)(0),min((int)(lower_bound(y,y+b,z[i])-y-k),b-1))];
				ans=min(ans,min(abs(z[i]-vx[j]),abs(z[i]-vy[k]))+abs(vx[j]-vy[k]));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	private void calc(){
		Scanner scanner = new Scanner(System.in);
		int x =scanner.nextInt();
		int y =scanner.nextInt();
		int z =scanner.nextInt();
		if(x<y && y<z){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

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

	}
}

Measured memory_bytes: 17320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ( (A+B) == (C+D)){
   cout << "Balanced" << endl; 
  }
  else if ((A+B) > (C+D)) {
   cout << "Left" << endl; 
  }
  else if ((A+B) < (C+D)) {
   cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <map>
#include <algorithm>
//#include <functional>
//#include <cmath>

constexpr uint32_t MOD = 1000000007;

int main(){
    int32_t N, M;
    std::cin >> N >> M;
    
    // naiive: All process - process using broken staris
    // dp approach: dp[i] = path until n-th step.
    // dp[i] = dp[i-2]*2 + dp[i-1] if step i is not broken
    // dp[i] = dp[i-2] if step i is broken.
    // use map to store broken step
    
    int32_t prev = N;
    int32_t cur = 0;
    std::map<int32_t, bool> broken_stairs;
    for(int32_t i = 0; i < M; i++){
        std::cin >> cur;
        if(cur == prev + 1){
            std::cout << 0;
            return 0;
        }
        broken_stairs.insert(std::make_pair(cur, true));
        prev = cur;
    }

    int64_t dp[N+1];
    dp[0] = 1; 
    if(broken_stairs.find(1) != broken_stairs.end()){
        dp[1] = 0;
    }
    else{
        dp[1] = 1;
    }
    for(int32_t s = 1; s < N; s++){
        if(broken_stairs.find(s+1) != broken_stairs.end()){
            assert(s < N - 1);
            dp[s+1] = 0;
            dp[s+2] = dp[s];
            s++;
        }
        else{
            dp[s+1] = (dp[s] + dp[s-1]) % MOD;
            //std::cout << "else path s,dp[s],dp[s-1],dp[s+1]," << s << "," << dp[s] << "," << dp[s-1] << "," << dp[s+1] << std::endl;
        }
        //debug
        //std::cout << "s:dp[s] = " << s << ":" << dp[s] << std::endl;

    }
    std::cout << dp[N];


    return 0;
}


Measured memory_bytes: 3328
N = int(input())
A = list(map(int, input().split()))

MAX = 10 ** 6

A.sort()
s = set()
ans = N
for i in range(N):
    a = A[i]
    if a in s:
        ans -= 1
        continue
    if i < N - 1 and A[i + 1] == a:
        ans -= 1
    n = MAX // a
    for i in range(1, n + 1):
        s.add(a * i)
print(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int>X(N);
  for(int i=0; i<N; i++){
    cin >> X.at(i);
  }
  
  int ans = 0;
  
  for(int i=0; i<N; i++){
    if(X.at(i)*2<K){
      ans += 2*X.at(i);
    }
    
    else{
      ans += 2*(K-X.at(i));
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long
#define MOD 1000000007

ll dp[100000][4];

int main(){
  string S;
  cin >> S;
  int N = (int)S.size();
  dp[0][0] = 1;
  for(int i=1; i<=N; i++) {
    if(S[i-1] == '?') {
      dp[i][0] = 3 * dp[i-1][0];
      dp[i][1] = 3 * dp[i-1][1];
      dp[i][2] = 3 * dp[i-1][2];
      dp[i][3] = 3 * dp[i-1][3];
    } else {
      dp[i][0] = dp[i-1][0];
      dp[i][1] = dp[i-1][1];
      dp[i][2] = dp[i-1][2];
      dp[i][3] = dp[i-1][3];
    }
    if(S[i-1] == 'A')
      dp[i][1] += dp[i-1][0];
    else if(S[i-1] == 'B')
      dp[i][2] += dp[i-1][1];
    else if(S[i-1] == 'C')
      dp[i][3] += dp[i-1][2];
    else { // S[i-1] == '?'
      dp[i][1] += dp[i-1][0];
      dp[i][2] += dp[i-1][1];
      dp[i][3] += dp[i-1][2];
    }

    dp[i][0] %= MOD;
    dp[i][1] %= MOD;
    dp[i][2] %= MOD;
    dp[i][3] %= MOD;
  }
  // for(int i=0; i<N+1; i++) {
  //   for(int j=0; j<4; j++) {
  //     cout << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  cout << dp[N][3] << endl;
  return 0;
}


Measured memory_bytes: 3584
n = int(input())
s = input()

cha = {}

for i in range(n):
    if s[i] in cha:
        cha[s[i]] += 1
    else:
        cha[s[i]] = 1

cnt = []

for k in cha:
    cnt.append(cha[k])

ans = 1

for c in cnt:
    ans *= (c+1)
    ans %=10**9+7

print(ans-1)


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

namespace ABC083_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var X = XY[0];
            var Y = XY[1];
            var c = 0;

            for (long i = X; i <= Y; i*=2)
                c++;
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define mp make_pair
#define pb push_back
#define LL long long
#define PII pair<long long, long long>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
const int inf = 0x7fffffff; //beware overflow
const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
inline LL getint(){
   LL _x=0,_tmp=1; char _tc=getchar();
   while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
   if( _tc == '-' ) _tc=getchar() , _tmp = -1;
   while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
   return _x*_tmp;
}
#define maxn 1005
int xs, ys, xt, yt;
int n;
struct C{
    double x, y, r;
    void read() {
        scanf("%lf %lf %lf", &x, &y, &r);
    }
}c[maxn];
double d[maxn][maxn];
double dis(double x1, double y1, double x2, double y2) {
    return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}
double dd[maxn];
void dij() {
    fill(dd, dd+n+1, 1e30);
    typedef pair<double , int> pii;
    priority_queue< pii, vector<pii>, greater<pii> > pq;
    dd[0] = 0;
    pq.push( mp(0, 0) );

    while( !pq.empty() ) {
        auto tp = pq.top(); pq.pop();
        int u = tp.se;
        double dis = tp.fi;
        if( dis > dd[u] ) continue;

        for(int i=0;i<=n;i++) if( i!=u ) {
            if( dis + d[u][i] < dd[i] )
                dd[i] = dis + d[u][i], pq.push( mp(dd[i], i) );
        }
    }
}
int main() {
    scanf("%d %d %d %d", &xs, &ys, &xt, &yt);
    n = getint();
    c[0].x = xs, c[0].y = ys, c[0].r = 0;
    for(int i = 1; i <= n; i++) c[i].read();
    n++;
    c[n].x = xt, c[n].y = yt, c[n].r = 0;

    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            d[i][j] = max(0.0, dis(c[i].x ,c[i].y, c[j].x, c[j].y) - c[i].r - c[j].r ),
            debug("d[%d][%d] = %f\n", i, j, d[i][j]);;
    dij();
    printf("%.10f\n", dd[n]);

}



Measured memory_bytes: 12400
D, G = map(int, input().split())
PC = []
for i in range(D):
    pi, ci = map(int, input().split())
    PC.append([pi, ci])
# dp[i][j]:得られる得点  (i番目の問題まで見る といた問題数j)
dp = [[0 for _ in range(2000)]for i in range(11)]
# print(dp)
for i in range(D):
    for j in range(1001):
        # k問解く(中途半端に解く)
        for k in range(PC[i][0]):
            #print(i, j, k)
            dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j]+k*(i+1)*100)
        # コンプボーナスもらえるまで解く
        dp[i + 1][j + PC[i][0]] = max(dp[i + 1][j + PC[i][0]],
                                      dp[i][j] + PC[i][0] * (i + 1) * 100 + PC[i][1])

# print(dp)
for j in range(1001):
    if dp[D][j] >= G:
        print(j)
        break

Measured memory_bytes: 3508
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    set<int> s;
    s.it(-1);
    IN n;
    rep(i,2,n/2){
	int c = 2;
	while(1){
	    int t = modpow(i,c);
	    c++;
	    if(t <= n )s.it(-t);
	    else break;
	}
    }

    P(-(*s.begin()));
    
    return  0;
    
}



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

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        
        int l=0;
        int r=a[N-1];
        int mid;
        int J=0;
        while(r-l>1){
            J=0;
            mid=(r+l)/2;
            for(int i=0; i<N; i++){
             
               J+=(int)Math.ceil((double)a[i]/mid)-1;
         
            }
            if(J>K){
                l=mid;
            }else{
                r=mid;
            }
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 61376
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    string s; cin >> s;
    ll ans = 0;
    vector<int> r(2 * n, 0), g(2 * n, 0), b(2 * n, 0);
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'R') r[i]++;
        if(s[i] == 'G') g[i]++;
        if(s[i] == 'B') b[i]++;
    }

    vector<int> sum_r(n + 1, 0), sum_g(n + 1, 0), sum_b(n + 1, 0);
    for(int i = 0; i < n; i++) sum_r[i + 1] += sum_r[i] + r[i];
    for(int i = 0; i < n; i++) sum_g[i + 1] += sum_g[i] + g[i];
    for(int i = 0; i < n; i++) sum_b[i + 1] += sum_b[i] + b[i];

    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            if(s[i] == s[j]) continue;
            if(s[i] == 'R' && s[j] == 'G')
            {
                int cnt = sum_b[n] - sum_b[j];
                if (b[j + j - i])
                    cnt--;
                ans += cnt;
            }
            if (s[i] == 'R' && s[j] == 'B')
            {
                int cnt = sum_g[n] - sum_g[j];
                if (g[2 * j - i])
                    cnt--;
                ans += cnt;
            }
            if (s[i] == 'G' && s[j] == 'B')
            {
                int cnt = sum_r[n] - sum_r[j];
                if (r[2 * j - i])
                    cnt--;
                ans += cnt;
            }
            if (s[i] == 'G' && s[j] == 'R')
            {
                int cnt = sum_b[n] - sum_b[j];
                if (b[2 * j - i])
                    cnt--;
                ans += cnt;
            }
            if (s[i] == 'B' && s[j] == 'R')
            {
                int cnt = sum_g[n] - sum_g[j];
                if (g[2 * j - i])
                    cnt--;
                ans += cnt;
            }
            if (s[i] == 'B' && s[j] == 'G')
            {
                int cnt = sum_r[n] - sum_r[j];
                if (r[2 * j - i])
                    cnt--;
                ans += cnt;
            }
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

typedef pair<int ,int> P;

int main(){
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> l(N);
    vector<P> t(N);

    for(int i = 0; i < N; ++i){
        cin >> x[i] >> l[i];
        t[i].first = x[i] + l[i];
        t[i].second = x[i] - l[i];
    }

    sort(t.begin(), t.end());

    int ans = 0;
    int nt = -1e9;

    for(int i = 0; i < N; ++i){
        if(t[i].second >= nt){
            ans++;
            nt = t[i].first;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4832
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n,i,j,c,k;
    int x[4][14];  //二次元配列
    char m, d;
    
    //配列を初期化
    for(i=0; i<4; i++){
        for(j=0; j<14; j++){
            x[i][j]=0;
        }
    }
    
    scanf("%d",&c);
    for(i=0; i<c; i++){
        scanf("%d",&k);  //?
        scanf("%c %d",&m,&n);
        if(m == 'S'){
            x[0][n] = 1;
        }
        if(m == 'H'){
            x[1][n] = 1;
        }
        if(m == 'C'){
            x[2][n] = 1;
        }
        if(m == 'D'){
            x[3][n] = 1;
        }
    }
    
    for(j=1; j<14; j++){
        if(x[0][j] != 1){
            printf("S %d\n",j);
        }
    }
    for(j=1; j<14; j++){
        if(x[1][j] != 1){
            printf("H %d\n",j);
        }
    }
    for(j=1; j<14; j++){
        if(x[2][j] != 1){
            printf("C %d\n",j);
        }
    }
    for(j=1; j<14; j++){
        if(x[3][j] != 1){
            printf("D %d\n",j);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>

void solve() {
    std::string s;
    std::cin >> s;

    std::cout << (std::count(s.begin(), s.end(), '7') ? "Yes" : "No")
              << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3644
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n + 1)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    // 1. 下から必要な分裂数を決定(ある深さより下にある葉の数)
    // 2. 上から条件を満たしながら分裂させる
    let mut s = vec![0; n + 2];
    for i in (0..n + 1).rev() {
        s[i] = s[i + 1] + a[i];
    }

    let mut ans = 0;
    let mut now = 1;
    for i in 0..n + 1 {
        if a[i] > now {
            println!("-1");
            return;
        }
        ans += now;
        // 生やせる最大の枝
        let eda_max = (now - a[i]) << 1;
        // これ以上生やすと下がおかしくなる
        let eda_min = s[i] - a[i];
        now = std::cmp::min(eda_max, eda_min);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4464