akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int, x)

function main()
	n,x = map(parseInt, split(readline()))
	m = n
	total = 0
	while x > 0
		k=0
		while 2^(k+2)-3+(m-k) <= x
			k += 1
		end
		k-=1
		total += 2^(k+1)-1
		x -= 2^(k+2)-3+(m-k)
		if x >= 1
			x -= 1
			total += 1
		end
		m = k
	end
	print(total)
end

main()

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

using namespace std;

int main(){
    int N;
    vector<int> H(100);
    int Ans = 1;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> H[i];
    }
    for(int i = 1;i < N;i++){
        int count = 0;
        for(int j = 0;j < i;j++){
            if(H[i] >= H[j]){
                count++;
            }
        }
        if(count == i){
            Ans++;
        }
    }
    cout << Ans << endl;
}

Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		string s;
		cin>>s;
		ll int cnt=0;
		for(auto i:s) if(i=='x') cnt++;
		if(cnt<=7) cout<<"YES";
		else cout<<"NO";	
	}
	return 0;
}

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

 
int main() {
    long long N;
    cin >> N;
    vector<long long> member(N,0);
    for (int i = 1; i<N; i++) {
        long long tmp = 0;
        cin >> tmp;
        member[tmp-1]++;
    }
    for (int i = 0; i<N; i++) {
        cout << member[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4844
#include <iostream> // cout, endl, cin
#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 <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  string s;
  cin >> s;
  int N=s.size();
  int gcount=0,pcount=0;
  int ans=0;
  for(int i=0;i<N;i++){
    if(s[i]=='g'){
      if(pcount<gcount){
        ans++;
        pcount++;
      }
      else{
        gcount++;
      }
    }
    else{
      if(pcount<gcount){
        pcount++;
      }
      else{
        gcount++;
        ans--;
      }
    }
  }
  cout <<  ans << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,b;
  cin >> n;
  vector<string> blue(n);
  vector<int> s(n,1);
  for (int i = 0; i < n; i++) {
    cin >> blue.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++){
      if(blue.at(i) == blue.at(j)){
        if (s.at(i) == -1) continue;
        s.at(i)++;
        s.at(j) = -1;
        
      }
    }
  }
  cin >> m;
  vector<string> red(m);
  for (int i = 0; i < m; i++) {
    cin >> red.at(i);
  }
  
  //for (int i = 0; i < n; i++) {
 //   cout << s.at(i) << endl;
 // }
  

  for (int i = 0; i < n; i++) {
    if (s.at(i) == -1) continue;
    a = s.at(i);
    for (int j = 0; j < m; j++){ 
      if (blue.at(i) == red.at(j)){
        a--;
      }
    }
    if(i == 0) b = a;
    else if (b < a) b = a;
  }
   if(b < 0)  b = 0;
  
  cout << b << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,k,q;cin>>n>>k>>q;
    vector<int> s(n,0);
    rep(i,q){int tmp;cin>>tmp;s[tmp-1]++;}
    rep(i,n){
        if(k-q+s[i]>0)co("Yes");
        else co("No");
    }
}

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

using namespace std;

typedef long long llint;

const int MAXN = 1000;

int arr[MAXN];
llint dp[MAXN];
int nxt[MAXN];

int main()
{
//	srand(123);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, i, j;
	
	cin>>n;
	
	for (i = 0; i < n; ++i)
	{
//		arr[i] = rand() - RAND_MAX / 2;
		cin>>arr[i];
		
		dp[i] = 0;
		nxt[i] = -1;
		for (j = i - 2; j >= 0; j -= 2) if (dp[j] > dp[i])
		{
			dp[i] = dp[j];
			nxt[i] = j;
		}
		dp[i] += arr[i];
	}
	
	i = max_element(dp, dp + n) - dp;
	cout<<dp[i]<<'\n';
	
	vector<int> sol;
	while (i != n - 1)
	{
		if (i < n - 3)
		{
			sol.push_back(n - 2);
			n -= 2;
		}
		else
		{
			sol.push_back(n - 1);
			--n;
		}
	}
	while (nxt[i] != -1)
	{
		for (int k = i - nxt[i]; k > 2; k -= 2)
		{
			sol.push_back(nxt[i] + 2);
		}
		sol.push_back(nxt[i] + 1);
		i = nxt[i];
	}
	while (i)
	{
		if (i > 2)
		{
			sol.push_back(1);
			i -= 2;
		}
		else
		{
			sol.push_back(0);
			--i;
		}
	}
	
	cout<<sol.size()<<'\n';
	for (int x: sol)
		cout<<1 + x<<'\n';
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())

    print('Yes' if n == m else 'No')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3316
n=int(input())
n_1=n//100
n_2=n%100

if  1<=n_1<=12 and not(1<=n_2<=12):
            print('MMYY')
elif 1<=n_1<=12 and 1<=n_2<=12:
            print('AMBIGUOUS')
elif 1<=n_2<=12 and not(1<=n_1<=12):
            print('YYMM')
else:
            print('NA')


Measured memory_bytes: 2940
from collections import defaultdict
N, M = map(int, input().split())
tmp = [list(set(list(map(int, input().split()))[1:])) for _ in range(N)]

d = defaultdict(int)
for i in range(N):
    for j in range(len(tmp[i])):
        d[tmp[i][j]] += 1
print(list(d.values()).count(N))

Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <algorithm>
#define max_k 2000
#define max_n 2000
#define max_s max_n+max_k
#define mod 998244353
using namespace std;
long long ans[max_n+1],frac[max_s+1],ifrc[max_s+1];
long long quickpow(long long x,long long k){
	long long ret=1;
	for(; k; k>>=1,x=x*x%mod)
		(k&1)&&(ret=ret*x%mod);
	return ret;
}
#define comb(m,n) frac[m]*ifrc[n]%mod*ifrc[m-(n)]%mod
int main(){
	int k,n,maxs;
	scanf("%d%d",&k,&n);
	frac[0]=ifrc[0]=1,maxs=k+n,memset(ans,0,sizeof(ans));
	for(int i=0; ++i<=maxs; frac[i]=frac[i-1]*i%mod);
	ifrc[maxs]=quickpow(frac[maxs],mod-2);
	for(int i=maxs; --i; ifrc[i]=ifrc[i+1]*(i+1)%mod);
	for(int i=1,t,half=n>>1; ++i<=k+1; printf("%lld\n",ans[i]%=mod))
		for(int j=-1,d=mod-1,l=min(t=i>>1,half); ++j<=l; ans[i]+=comb(t,j)*(d=mod-d)%mod*(comb(maxs-2*j-1,k-1))%mod);
	for(int i=k+1; --i>1; printf("%lld\n",ans[i]));
	return 0;
}

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

const int dx[4] = { 0, 1, 0, -1 };
const int dy[4] = { -1, 0, 1, 0 };
int H, W;
vector<string> S;

int main(void) {
	cin >> H >> W;

	S.resize(H + 2);
	S[0] = S[H + 1] = string(W + 2, '.');
	for (int j = 1; j <= H; ++j) {
		string str;
		cin >> str;
		S[j] = "." + str + ".";
	}

	bool ans = true;
	for (int j = 1; j <= H; ++j) {
		for (int i = 1; i <= W; ++i) {
			if (S[j][i] != '#') continue;
			char c[4];
			for (int k = 0; k < 4; ++k)
				c[k] = S[j + dy[k]][i + dx[k]];
			if ((c[0] != '#') && (c[1] != '#') && (c[2] != '#') && (c[3] != '#')) {
				ans = false;
				break;
			}
		}
		if (!ans)
			break;
	}

	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const data = {
    pond : [],
    stack : []
};

const results = line[0].split('').reduce((acc, x, i) => {
    if (x === '\\') {
        acc.stack.push(i);
    } else if (x === '/' && acc.stack.length > 0) {
        const k = acc.stack.pop();
        const hd = acc.pond.filter(xs => xs[0] >= k);
        const tl = acc.pond.filter(xs => xs[0] < k);

        const sum = [k, hd.map(xs => xs[1]).reduce((acc, x) => acc + x, 0) + (i - k)]
        tl.push(sum);
        acc.pond = tl;
    }

    return acc;
}, data);

const sum = results.pond.reduce((acc, x) => acc + x[1], 0);
const length = results.pond.length;

console.log(sum);
console.log(`${length}${length > 0 ? ' ' + results.pond.map(x => x[1].toString()).join(' ') : ''}`);



Measured memory_bytes: 25408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[102][2][5];
int k, sz;
vector<int> v;
ll fun(int pos, int small, int cnt)
{
    if(pos==sz) return cnt==k;
    if(cnt>k) return 0;
    ll& ret = dp[pos][small][cnt];
    if(ret!=-1) return ret;
    ret = 0;
    int lim;
    if(small) lim = 9;
    else lim = v[pos];
    for(int i=0; i<=lim; i++){
        ret+=fun(pos+1, small||(i<lim), cnt+(i>0));
    }
    return ret;
}
int main()
{
    memset(dp, -1, sizeof dp);
    string str;
    cin>>str;
    cin>>k;
    sz = str.size();
    v.resize(sz);
    for(int i=sz-1; i>=0; i--)
        v[i] = str[i]-'0';
    cout<<fun(0,0,0)<<endl;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M = 1000001;
  int i,j,ct;
  int w=0,x;

  vector<int> c(M,0);
  cin >> N;
  for(i=0;i<N;i++){
    cin >> x;
    c[x] = 1;
    w = gcd(w,x);
  }

  if (w>1){
    cout << "not coprime" << endl;
    return 0;
  }
  
  for(i=2;i<M;i++){
    ct = 0;
    for(j=i;j<M;j+=i)
      if (c[j])
        ct++;
    if (ct>1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "pairwise coprime" << endl;
  return 0;
}

Measured memory_bytes: 7076
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    bool ans = true;

    ans &= (c[0][0] - c[0][1]) == (c[1][0] - c[1][1]); 
    ans &= (c[1][0] - c[1][1]) == (c[2][0] - c[2][1]); 
    ans &= (c[2][0] - c[2][1]) == (c[1][0] - c[1][1]); 

    ans &= (c[0][0] - c[0][2]) == (c[1][0] - c[1][2]); 
    ans &= (c[1][0] - c[1][2]) == (c[2][0] - c[2][2]); 
    ans &= (c[2][0] - c[2][2]) == (c[0][0] - c[0][2]); 

    ans &= (c[0][1] - c[0][2]) == (c[1][1] - c[1][2]); 
    ans &= (c[1][1] - c[1][2]) == (c[2][1] - c[2][2]); 
    ans &= (c[2][1] - c[2][2]) == (c[0][1] - c[0][2]); 

    if(ans){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  override def main(args: Array[String]): Unit = {
    import scala.io.{StdIn => in}

    Iterator.continually(in.readInt).takeWhile(_ != 0)
      .map(n => for (i <- 1 to n) yield in.readLine())
      .map(candidates => new Solver(candidates.toArray, in.readLine()))
      .map(_.solve())
      .foreach(println)

  }
}

class Solver(candidates_ : Array[String], val target: String) {
  val answers = target.substring(0, target.size - 1).split(" ").distinct.sortWith((x, y) => x.distinct.length > y.distinct.length)
  val candidates = candidates_.sortWith((x, y) => x.distinct.length > y.distinct.length)

  def solve(): String = {

    val answersSize: Int = answers.size;

    def getMatch(pointer: Int, map: Map[Char, Char], ans: Map[Char, Char], found: Int): (Map[Char, Char], Int) = {
      if (found > 1) (Map[Char, Char](), 2)
      else
        pointer match {
          case `answersSize` => (map, found + 1)
          case _ =>
            if(answers(pointer).forall(map.isDefinedAt(_)))
              if(candidates contains answers(pointer).map(map(_).toUpper)) getMatch(pointer + 1, map, ans, found)
              else (ans,found)
            else (0 until candidates.size)
              .filter(!candidates(_).forall(map.isDefinedAt(_)))
              .filter(candidates(_).length == answers(pointer).length)
              .map(getNewMap(pointer, map, _))
              .collect({ case Some(x: Map[Char, Char]) => x })
              .foldLeft(ans, found)((f, next) => getMatch(pointer + 1, next, f._1, f._2))
        }
    }

    def getNewMap(pointer: Int, map: Map[Char, Char], index: Int): Option[Map[Char, Char]] = {
      val nextAnswer = answers(pointer)
      val nextCandidate = candidates(index)

      val newMap = nextAnswer.zip(nextCandidate).foldLeft((true, map)) { (z, ansCand) =>
        if (!z._1) {
          (false, z._2)
        } else {
          ansCand match {
            case (answer: Char, candidate: Char) if z._2.isDefinedAt(answer) && z._2.isDefinedAt(candidate) => (z._2(answer).toUpper == candidate, z._2)
            case (answer: Char, candidate: Char) if (!z._2.isDefinedAt(answer)) && (!z._2.isDefinedAt(candidate)) => (true, z._2 + (candidate -> answer.toLower, answer -> candidate.toLower))
            case _ => (false, z._2)
          }
        }
      }

      if (newMap._1) Some(newMap._2) else None
    }
    val res = getMatch(0, Map[Char, Char](), Map[Char, Char](), 0)
    if (res._2 == 1) target.map(c => res._1.getOrElse(c, c)).toUpperCase() else "-."
  }
}

Measured memory_bytes: 104768
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

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

	int N;
	ll X;

	cin >> N >> X;

	ll ok = 0;
	ll ng = 1;
	ll pt = 1;
	for(int i = 1; i <= N; i++){
		ng = ng * 2 + 3;
		pt = pt * 2 + 1;
	}

	ll ans = 0;
	while(ng - ok > 0){

		ll mid = (ng + ok) / 2 + 1;
		pt = (pt-1)/2 + 1;

		if(mid <= X) {
			ok = mid;
			ans += pt;
			ng--;
		} else {
			ng = mid -1; // 真ん中のパティ
			ok++;
		}

	}
	cout << ans << endl;

	Never To return 0;
}


Measured memory_bytes: 384
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    for p in 0..n {
        if graph[p].len() == 1 {
            let v = graph[p][0];
            match dfs(v, p, &graph, &a) {
                Some(up) if up == a[p] => {
                    println!("YES");
                }
                _ => {
                    println!("NO");
                }
            }
            return;
        }
    }
}

fn dfs(v: usize, p: usize, graph: &Vec<Vec<usize>>, a: &Vec<u64>) -> Option<u64> {
    if graph[v].len() == 1 {
        return Some(a[v]);
    }
    let mut children = 0;
    let mut max = 0;
    for &next in graph[v].iter() {
        if next == p {
            continue;
        }
        match dfs(next, v, graph, a) {
            Some(up) => {
                children += up;
                max = cmp::max(max, up);
            }
            None => {
                return None;
            }
        }
    }

    if 2 * a[v] < children || children < a[v] {
        return None;
    }

    let up = 2 * a[v] - children;
    let pairs = children - a[v];

    if children - max < pairs {
        return None;
    } else {
        Some(up)
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

void solve() {
  double a, b, x;
  cin >> a >> b >> x;
  double rad, ans;
  double s = x/a;
  if (a*b / 2 >= s) {
    double l = 2 * s / b;
    rad = atan2(b, l);
  } else {
    double m = (a * b - s) * 2 / a;
    rad = atan2(m, a);
  }
  ans = rad / ( 2 * acos(-1)) * 360;
  printf("%.10f", ans);
}

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

Measured memory_bytes: 256
"use strict"
async function main(){
    const line = await input();
    const [a, b] = line.split(' ').map((n) => parseInt(n));
    let ans = (b-a)*(b-a-1)/2-a;
    console.log(ans);
}

function input(){
    const readline = require('readline')
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    return new Promise((resolve, reject) => {
        rl.on('line', (line) => {
            resolve(line);
            rl.close();
        })
    })
}

main()

Measured memory_bytes: 30912
/* ex4_1
    sak_Citrus*/

#include <stdio.h>

int main(void){
    //標準入力
    int appleNum,d,ans;
    scanf("%d %d",&appleNum,&d);

    //一人2d+1本の木を監視可能
    if(appleNum % (2*d + 1) == 0){
        //全員が最大幅を監視
        ans = appleNum / (2*d+1);
    }else{
        //最後の一人だけ少ない監視範囲
        ans = appleNum / (2*d+1) + 1;
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int a[100],b[100],c[100],d[100];
long long ans=0;
int l[20];
int n,m,q;
void dfs(int x,int y)//x当前第几位,这一位是几 
{   l[x] = y;
    if(x == n)
    {   long long sum = 0;
    	for(int i = 1;i <= q;i++)
	      if(l[b[i]]-l[a[i]] == c[i]) sum+=d[i];
		ans = max(ans,sum); 
	   return;
	}
	else{ 
	for(int i  = y ;i <= m;i++)
	{   
		dfs(x+1,i);
	}
}
} 
int main(){
	cin>>n>>m>>q;
	for(int i = 1;i <= q;i++)
	 {
	 	cin>>a[i]>>b[i]>>c[i]>>d[i];
	 }
	   dfs(1,1);
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

n,k = map(int,input().split())
D = deque()
V = list(map(int,input().split()))
for i in range(n):
    D.append(V[i])
ans = 0
if 2*n <= k:
    for j in range(n):
        if V[j]>0:
            ans += V[j]
    print(ans)
    exit()
else:
    for i in range(k+1):
        for j in range(k+1):
                if i + j> k:
                    continue
                else:
                    cur = 0
                    V1 =[]
                    if i+j >=n:
                        cur = sum(V)
                        for v in V:
                            if v < 0:
                                V1.append(v)
                    else:
                        cur += sum(V[:i])
                        cur += sum(V[n-j:])
                        for s in range(i):
                            if V[s]<0:
                                V1.append(V[s])
                        for t in range(j):
                            if V[n-1-t]<0:
                                V1.append(V[n-1-t])
                    V1.sort(reverse=True)
                    for u in range(k-i-j):
                        if len(V1)>0:
                            cur -= V1.pop()
                        else:
                            break
                    ans = max(cur,ans)
print(ans)


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

int main(){
    unsigned int num_nodes;
    std::cin >> num_nodes;
    std::vector<unsigned int> num_each_dist(num_nodes);
    for (unsigned int i = 0; i < num_nodes; i++){
        unsigned int dist;
        std::cin >> dist;
        if (dist == 0 && i != 0){
            std::cout << 0 << std::endl;
            return 0;
        }
        num_each_dist.at(dist) += 1;
    }
    if (num_each_dist.at(0) != 1){
        std::cout << 0 << std::endl;
        return 0;
    }
    unsigned long long result = 1;
    for (unsigned int i = 1; i < num_each_dist.size(); i++){
        unsigned long long prev = num_each_dist.at(i - 1);
        unsigned long long tmp = 1;
        for (unsigned int j = 0; j < num_each_dist.at(i); j++){
            tmp = (tmp * prev) % 998244353;
        }
        result = (result * tmp) % 998244353;
    }
    std::cout << result << std::endl;
}

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

int main(){
    int n, i, a, index, max1 = 0, max2 = 0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a;
        if(a >= max1){
            index = i;
            max2 = max1;
            max1 = a;
        }else if(a >= max2){
            max2 = a;
        }
    }
    for(i=0; i<n; i++){
        if(i != index){
            printf("%d\n", max1);
        }else{
            printf("%d\n", max2);
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
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 = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/
template<typename T>
vector<pair<T,long long>> RunLengthEncoder(vector<T> &v){
    vector<pair<T,long long>> RLE;
    long long cnt = 1;
    for(int i = 0; i < (int)v.size(); ++i){
        if(i == (int)v.size()-1){
            RLE.push_back(make_pair(v[i], cnt));
            continue;
        }
        if(v[i] == v[i+1])cnt++;
        else{
            RLE.push_back(make_pair(v[i],cnt));
            cnt = 1;
        }
    }
    return RLE;
}

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N,M,V,P;
    cin>>N>>M>>V>>P;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A), greater<ll>());
    print(A);
    //xは0-indexed
    auto check = [&](ll x){
        //0 ~ P-1はOK
        if(x < P){
            cerr<<"上位P"<<endl;
            return true;
        }
        if(A[x] + M < A[P-1]){
            cerr<<"試す価値なし"<<endl;
            return false;
        }
        ll sum = 0;
        rep(i,N){
            if(i < P-1 || x <= i)sum+= M;
            else{
                sum += A[x] + M - A[i];
            }
        }
        cerr<<x << " "<<M * V<< " " << sum<<endl;
        return M * V <= sum;
    };
    ll ok = -1;
    ll ng = N;
    while(ng - ok > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
            cerr<<mid<<" "<<"OK"<<endl;
        }
        else{
            ng = mid;
            cerr<<mid<<" "<<"NG"<<endl;
        }
    }
    cout<<ok + 1<<endl;
}

Measured memory_bytes: 1024
from collections import deque

n, q = [int(_) for _ in input().split()]
processes = deque([tuple(input().split()) for i in range(n)])

time = 0
while processes:
    process = processes.popleft()

    if int(process[1]) <= q:
        time += int(process[1])
        print(process[0], time)

    else:
        time += q
        processes.append((process[0], int(process[1]) - q))



Measured memory_bytes: 12644
/******Author : c0d3rpr0********/
#include <bits/stdc++.h>
using namespace std;

const auto start_time = std::chrono::high_resolution_clock::now();

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long double ld;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
typedef vector<ll>::iterator vit;

const ll INF = 1LL<<18;
const ll MOD = 1e9 + 7;
const ll EPS = 1e-6;

#define      each(it,s)        for(vit it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<ll>())
#define      fill(a)           memset(a, 0, sizeof (a))
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i < (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define 	 pq(x)			   priority_queue<x,std::vector<x>,compare>
#define 	 rpq(x)			   priority_queue<x,std::vector<x>,compare>
#define      F                 first
#define      S                 second
#define      mp                make_pair
#define      pb                push_back
#define      vin(a,n)          vll a;rep(i,n){ll in;cin>>in;a.pb(in);}
#define      arrin(arr,n)      rep(i,n){cin>>arr[i];}
#define      fastio            ios_base::sync_with_stdio(false);cin.tie(NULL);
#define      ignore            cin.ignore(256,'\n');

ll gcd(ll x,ll y)              {if(x==0) return y;return gcd(y%x,x);}
ll powM(ll x,ll y,ll m)        {ll ans=1,r=1;x%=m;while(r>0&&r<=y){if(r&y){ans*=x;ans%=m;}r<<=1;x*=x;x%=m;}return ans;}
ll modI(ll a, ll m)            {ll m0=m,y=0,x=1;if(m==1) return 0;while(a>1){ll q=a/m;ll t=m;m=a%m;a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
ll max(ll a,ll b,ll c)         {return max(max(a,b),c);}
ll power(ll x,ll y)            {ll z=1;while(y>0){if(y%2)z=(z*x);x =(x*x) ;y/=2;}return z;}
void solve()
{
    ll k,a,b;
    cin>>k>>a>>b;
    if(a%k==0 || b%k==0 ||(b/k-a/k>0)) cout<<"OK\n";
    else cout<<"NG\n";
}
int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("/home/naman/Desktop/CP/input.txt","r",stdin);
    freopen("/home/naman/Desktop/CP/output.txt","w",stdout);
    #endif
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time - start_time;
    #ifndef ONLINE_JUDGE
    cerr << "Time Taken : " << diff.count() << "s\n";
    #endif
}

Measured memory_bytes: 3640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    t = 'CODEFESTIVAL2016'
    s = S()
    r = 0
    for i in range(16):
        if t[i] != s[i]:
            r += 1
    return r


print(main())



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

const long long MAXN = 3010;

long long dp[MAXN][MAXN][2];
long long arr[MAXN];
long long f(long long x,long long y,long long turn){
    if(dp[x][y][turn]){
        return dp[x][y][turn];
    }
    if(x>y){
        return 0;
    }
   // cout<<x<<" "<<y<<" "<<turn<<endl;
    if(turn%2 == 1){
        return dp[x][y][turn] = max(arr[x]+f(x+1,y,1-turn),arr[y]+f(x,y-1,1-turn));
    }else{
        return dp[x][y][turn] = min(f(x+1,y,1-turn)-arr[x],f(x,y-1,1-turn)-arr[y]);
    }
}
int main() {
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>arr[i];
    }
    cout<<f(1,n,1)<<endl;
}


Measured memory_bytes: 141696
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll x;
    cin>>x;
    ll dx = x - (x/100)*100;
    ll mx = x/100;
    if(dx<=mx*5) cout<<"1"<<endl;
    else cout<<"0"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	string s;
	cin >> s;
	ll count = 0;
	for (ll i = 0; i <s.size()/2; i++) {
		if (s[i] != s[s.size() - 1 - i]) {
			count++;
			//cout << i << endl;
		}

	}
	cout << count << endl;

}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template< typename OperatorMonoid >
struct DuelSegmentTree {
  using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;

  int sz, height;
  vector< OperatorMonoid > lazy;
  const H h;
  const OperatorMonoid OM0;


  DuelSegmentTree(int n, const H h, const OperatorMonoid OM0)
      : h(h), OM0(OM0) {
    sz = 1;
    height = 0;
    while(sz < n) sz <<= 1, height++;
    lazy.assign(2 * sz, OM0);
  }

  inline void propagate(int k) {
    if(lazy[k] != OM0) {
      lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[k] = OM0;
    }
  }

  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }

  void update(int a, int b, const OperatorMonoid &x) {
    thrust(a += sz);
    thrust(b += sz - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) lazy[l] = h(lazy[l], x), ++l;
      if(r & 1) --r, lazy[r] = h(lazy[r], x);
    }
  }

  OperatorMonoid operator[](int k) {
    thrust(k += sz);
    return lazy[k];
  }
};

signed main(){
	int n, q;
	cin >> n >> q;

	DuelSegmentTree<int> tate(n+1, [](int a, int b){ return min(a, b); }, INT_MAX);
	DuelSegmentTree<int> yoko(n+1, [](int a, int b){ return min(a, b); }, INT_MAX);

	tate.update(0, n, n-2);
	yoko.update(0, n, n-2);

	int ans = (n-2)*(n-2);
	for(int i = 0;i < q;i++){
		int t, p;
		cin >> t >> p;
		p-=2;
		if(t == 1){
			int now = tate[p];
			ans -= now;
			yoko.update(0, now, p);
		}else{
			int now = yoko[p];
			ans -= now;
			tate.update(0, now, p);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11432
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
    }

    let ans = n * (n - 1) / 2;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+5;
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int ans=0;
    for(int i=2;i*i<=n;i++)
    {
    	int cnt=0;
    	while(n%i==0)
    	{
    		n/=i;
    		cnt++;
    	}
    	for(int j=1;;j++)
    	{
    		cnt-=j;
    		if(cnt==0)
    		{
    			ans+=j;
    			break;
    		}
    		else if(cnt<0)
    		{
    			ans+=j-1;
    			break;
    		}

    	}
    }
    if(n>1)
    	ans+=1;
    cout<<ans<<endl;
     
}

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

int main() {
	int a, b; cin >> a >> b;

	if (a == 1) a += 13;
	if (b == 1) b += 13;

	if (a > b) cout << "Alice" << endl;
	else if (a == b) cout << "Draw" << endl;
	else cout << "Bob" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 998244353;
struct mint{
    // 自動的にmodを取ってくれるクラスです。
    ll x;
    mint(ll x = 0):x(x%mod){}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint b = pow(t/2);
        b *= b;
        if(t%2 == 1) b *= *this;
        return b;
    }

    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint a){
        (*this) *= a.inv();
        return *this;
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }
};

int main(){
    int n,k;
    cin >> n >> k;
    vector<mint> dp(n+1);
    vector<mint> dpsum(n+1);
    vector<int> l(k),r(k);
    rep(i,k) cin >> l.at(i) >> r.at(i);
    dp.at(1) = mint(1);
    dpsum.at(1) = mint(1);
    for(int i = 2;i <= n;i++){
        rep(j,k){
            int li = i - r.at(j);
            int ri = i - l.at(j);
            if(ri < 0) continue;
            li = max(li,1);
            dp.at(i) += dpsum.at(ri) - dpsum.at(li-1);
        }
        dpsum.at(i) = dpsum.at(i-1) + dp.at(i);
    }
    cout << dp.at(n).x << endl;
}

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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

int dp[1001][10002];
//int profit1,profit2;
int n;
int cost[10003];
int weight[10003];
//int profit1,profit2,profit3;
int knapsack(int i,int w)
{
    if(i==(n+1))
        return MAX;
    if(w <= 0)return 0 ;

  if(dp[i][w]!=-1)return dp[i][w];
   int profit1= cost[i]+knapsack(i,w-weight[i]);
    profit1= min(profit1,knapsack(i+1,w));
   profit1 = min(profit1,cost[i]+knapsack(i+1,w-weight[i]));

    dp[i][w]=profit1;
    return dp[i][w];
}
int main ()
{
    mem(dp,-1);
        int cap;
        cin >> cap>> n;
        for(int i=1;i<=n;i++)
        {
            cin >> weight[i] >>  cost[i];
        }
        cout << knapsack(1,cap)<<endl;
    return 0;
}




Measured memory_bytes: 40192
H,W = [int(v) for v in input().split()]
area = [input() for _ in range(H)]

dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
dp[1][1] = 1

for h,row in enumerate(area,1):
    for w,cell in enumerate(row,1):
        if cell != '#':
            dp[h][w] += int((dp[h-1][w] + dp[h][w-1]) % (1e9 + 7))

print(dp[-1][-1])


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<ll>>;


int main() {
	int N;
	cin >> N;
	vector<ll> A(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	map<ll, int> ma;
	ll ans = 0;

	for (int i = 1; i <= N; i++) {
		ans += ma[i - A[i]];
		ma[A[i] + i]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 27464
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<ll, ll>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    vector<P> cnt(60);
    rep(i, n){
        rep(j, 60){
            if ((a[i] >> j) & (ll)1) cnt[j].first++;
            else cnt[j].second++; 
        }
    }
    ll ans = 0;
    ll bit = 1;
    rep(i, 60){
        ll num;
        num = (ll)cnt[i].first * cnt[i].second;
        num %= mod;
        ans += num * bit;
        ans %= mod;
        bit *= 2;
        bit %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5960
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;
int main() {
	long long int x = 0, y = 0;
	long long int min;
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N;i++) {
		cin >> a[i];
		y += a[i];
	}
	x += a[0];
	y -= a[0];
	min = abs(x-y);
	for (int i = 1; i < N - 1;i++) {
		x += a[i];
		y -= a[i];
		if (abs(x-y) < min) {
			min = abs(x - y);
		}
	}
	cout << min << endl;
	return 0;
}



Measured memory_bytes: 1024
N = int(input())
people = list(map(int, input().split()))

point1 = round(sum(people)/len(people) + 0.5)
point2 = point1 - 1
point3 = point1 + 1
cost1 = 0
cost2 = 0
cost3 = 0

for person in people:
    cost1 += (person - point1)**2
for person in people:
    cost2 += (person - point2)**2
for person in people:
    cost3 += (person - point3)**2
tmp = [cost1, cost2, cost3]
print(min(tmp))

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

signed main(){

  string s; cin >> s;
  int ans = 0;
  int l = 0,r = s.size()-1;
  while(r - l > 0){
    if(s[l] != s[r] && !(s[l] == 'x' || s[r] == 'x')){
      cout << -1 << endl;
      return 0;
    }
    if(s[l] == s[r]){
      l++,r--;
      continue;
    }
    if(s[l] == 'x') l++;
    if(s[r] == 'x') r--;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


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

/** defines and macros */
#define ll long long
#define ull unsigned long long
#define loop(n) for(int i = 0; i < n; i++)
#define loop1(n) for(int i = 1; i <= n; i++)
#define all(v) ((v).begin()), ((v).end())
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvpii vector<vii>
#define PB push_back

#define fw(fileName) freopen(fileName, "w", stdout)
#define fr(fileName) freopen(fileName, "r", stdin)
#define fc(stream) fclose(stream);

#define faster_IO_stream ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

/*To compile and run

	g++ -o main main.cpp && ./main

*/

/*
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣤⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣤⣀⡀⠄⠄⠄⠄⠄⣰⣷⡀⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⣀⣀⣀⠄⠄⠄⠄⠄⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠄⠄⢠⣿⣿⣷⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠤⠒⠛⠛⠛⠛⠻⠷⣦⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣿⣿⣿⠟⠁⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢀⣤⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⡤⠐⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⢀⣶⣿⣿⠿⢛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⢠⣿⠟⠉⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠘⠁⠄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠻⣿⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⣾⣿⡿⣽⡿⢹⣿⣿⣟⣿⢻⠇⢀⢹⣿⢿⣿⣿⣿⣿⣿⣦⣙⢿⣿⢷⣈⠻⢿⣟⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢿⡿⠁⡿⠁⢸⣿⣿⢹⡇⢸⠄⠈⠄⠻⣏⠻⣿⡿⣿⣿⣿⣌⠛⢿⡌⠙⢧⣀⠙⢳⡹⢻⣿⣿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠘⡇⠄⡇⢠⣼⣿⣿⠈⡇⠘⠤⠤⠤⠤⢜⣢⣘⡻⢮⡛⢿⣿⣷⣬⡤⠤⠤⠤⠥⠤⠥⢬⣿⣧⡄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠘⢿⡏⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿⡿⠋⠉⠛⠉⠄⠄⠄⠄⠄⠄⠄⢹⡿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡟⠁⠈⢳⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠱⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⡜⠁⠄⠄⠈⢇⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠑⠦⢄⣀⣀⣀⣀⣀⠴⠊⠄⠄⠄⠄⠄⠄⠑⠤⢀⣀⣀⣀⡀⠠⠔⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣶⣦⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣤⣶⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣶⣄⣀⣀⣀⣀⣤⣾⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⣿⣿⣿⣿⠟⠁⠄⠄⠄⠄⠙⢿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⠟⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠉⠛⠿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
 */

//const int MAXN = 100;
//int graph[MAXN][MAXN];
//int visited[MAXN];


int dfs(const vvi &graph, vi &visited, int vertix)
{
	int c = 1;
	visited[vertix] = 1;
	for(int child: graph[vertix]) if(!visited[child]) c += dfs(graph, visited, child);
	return c;
}

int main() {
	faster_IO_stream

	int n, m;
	cin >> n >> m;

	vvi graph(n + 1); vi visited(n + 1);

	int v1, v2;
	loop(m) {
		cin >> v1 >> v2;
		graph[v1].PB(v2);
		graph[v2].PB(v1);
	}

	int res = -1;
	loop1(n)
		if(!visited[i]) res = max(res, dfs(graph, visited, i));
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 24324
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    array = [i for i in range(1, n+1)]
    count = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if array[i] + array[j] + array[k] == x:
                    count += 1
                elif array[i] + array[j] + array[k] > x:
                    break
    print(count)


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

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

  long long ans = 0;
  for (int i = floor(sqrt(n)); i >= 1; i--)
    if (n % i == 0) {
      ans = i + n / i - 2;
      break;
    }
  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);


  for(i = 1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i = 0;i<=VMAX;i++){
    C[i] = 0;
  }
  for(j = 1;j <= n;j++){
    C[A[j]]++;
  }
  for(i = 1;i<=VMAX;i++){
    C[i] = C[i] +C[i-1];
  }

  for(j = n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i = 1;i <=n;i++){
    printf("%d",B[i]);
    if(i != n){
      printf(" ");
    }
  }
  printf("\n");


  return 0;
}



Measured memory_bytes: 9596
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel
int mincost(int n, int *arr, int *dp)
{
	if (n == 0)
		return INT_MAX;
	if (n == 1)
		return 0;
	if (dp[n] != -1)
		return dp[n];

	int ans = min(mincost(n - 1, arr, dp) + abs(arr[n] - arr[n - 1]), mincost(n - 2, arr, dp) + abs(arr[n] - arr[n - 2]));
	dp[n] = ans;
	return ans;
}

void solve()
{
	int n;
	cin >> n;
	int arr[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	int dp[n + 1];
	memset(dp, -1, sizeof(dp));
	int ans = mincost(n, arr, dp);
	cout << ans << endl;
}

signed main()
{
	fasterthanlight;
	int T; T = 1;
	//cin>>T;
	while (T--)
	{
		solve();
	}

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b);

  cout << max(a - b * 2, 0) << endl;

  return 0;
}

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

using namespace std;

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

    char diff = 'A'-'a';

    char s1=a[0]+diff;
    char s2=b[0]+diff;
    char s3=c[0]+diff;

    cout<<s1<<s2<<s3<<endl;

}

Measured memory_bytes: 256