akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll N, S;
ll f(ll b, ll n)
{
    if (n < b)
    {
        return n;
    }
    return f(b, n / b) + n % b;
}
ll solve()
{
    ll b = 2;

    while (true)
    {
        if (b * b > N)
        {
            break;
        }

        if (f(b, N) == S)
        {
            return b;
        }
        b++;
    }
    if (N == S)
    {
        return N + 1;
    }
    int sqrt_n = min(N, (ll)sqrt(N) + 3);
    for (ll p = sqrt_n; p >= 1; p--)
    {
        b = 1 + (N - S) / p;
        if (b < 2)
        {
            continue;
        }
        if (f(b, N) == S)
        {
            return b;
        }
    }
    return -1;
}
int main()
{
    cin >> N;
    cin >> S;
    ll res = solve();
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
// AOJ 0120: Patisserie
// 2017.9.28 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

#define EQ(a,b) (fabs(a-b)<= 1e-7)

int r[13];
char buf[202], *p;
double d[13][13];					// ???????????±???????????????????°´????????¢
double dp[13][4100];				// ?°´????????¢, ??´?????????????????±??????????±\??´?????????

int main()
{
	int w, n, i, j, k, t, s;
	int lim;
	double x;

	for (i = 3; i <= 10; i++) for (j = i; j <= 10; j++)
		d[i][j] = d[j][i] = 2.0 * sqrt(i * j);

	while (fgets(p = buf, 200, stdin) != NULL) {
		s = 0, n = -1;
		while (*p) {
			while (isspace(*p)) p++;
			if (isdigit(*p)) {
				if (n < 0) w = atoi(p);
				else       t = atoi(p), r[n] = t, s += t;
				n++;
				while (isdigit(*p)) p++;
			}
		}
		if (2 * s <= w) { puts("OK"); continue; }

		memset(dp, 0, sizeof(dp));
		for (i = 0; i < n; i++)	dp[i][1<<i] = r[i];

		lim = 1 << n;
		for (k = 0; k < lim; k++) {
			for (i = 0; i < n; i++)	{		// ??????????????±??????
				for (j = 0; j < n; j++) {	// ??´????????±??????
					if (dp[j][k] == 0) continue;
					else {
						int ii;
						x = dp[j][k] + d[r[i]][r[j]];
						ii = k | (1 << i);
						if (dp[i][ii] == 0 || x < dp[i][ii]) dp[i][ii] = x;
					}
				}
			}
		}
		for (x = 10000, i = 0; i < n; i++) {
			if (dp[i][lim-1] == 0) continue;
			dp[i][lim-1] += r[i];
			if (dp[i][lim-1] < x) x = dp[i][lim-1];
		}
		puts(EQ(x, w) || x <= w ? "OK" : "NA");
	}
	return 0;
}

Measured memory_bytes: 1992
import math

n = int(input())

x = list(range(n))
y = list(range(n))
m = list(range(n))
l = list(range(n))
for i in range(n):
  x[i],y[i] = map(int,input().split())
  m[i] = x[i] - y[i]
  l[i] = x[i] + y[i]
m.sort()
l.sort()
res = max(m[n-1]-m[0], l[n-1]-l[0])
print(res)

Measured memory_bytes: 41200
#include<stdio.h>
 
int main(){
    int i,j, v[3], k, ans = 0;
    scanf("%d %d %d %d", &v[0], &v[1], &v[2], &k);
    
    for(i = 0; i < k; i++){
        int max = 0;
        for(j = 0; j < 3; j++){
            if(v[j]>v[max]){
                max = j;
            }
        }
        v[max] *= 2;
    }
    int sum = 0;
    for(j = 0; j < 3; j++)
        sum += v[j];
    printf("%d\n", sum);

}

Measured memory_bytes: 128
fn main() {
    let n = read::<usize>();
    let mut d = read_vec::<u32>();
    d.sort();

    let l = d[n / 2 - 1];
    let h = d[n / 2];

    let mut ret = 0;
    let mut i = l + 1;
    while i <= h {
        ret += 1;
        i += 1;
    }

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream> // includes cin to read from stdin and cout to write to stdout
using namespace std; // since cin and cout are both in namespace std, this saves some text
#define REP(i, n) for (int (i)=0; i < (n); ++(i))

int main()
{
    int N;
    string S;
    
    cin >> N;
    cin >> S;
    int west = 0;
    int east = 0;
    REP(i, N) {
        if (S[i] == 'W') ++west;
        else if (S[i] == 'E') ++east;
    }
    
    int t_west = 0;
    int t_east = 0;
    
    int res = east;
    if (S[0] == 'W') { ++t_west;}
    else {++t_east; --res;}

    for (int i = 1; i < N; ++i) {
        int sum = t_west + (east - t_east);
        if (S[i] == 'E') --sum;
        if (sum < res) res = sum;
        
        if (S[i] == 'W') ++t_west;
        else ++t_east;
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 900
#include <cstdio>
#include <algorithm>
typedef long long ll;
const int M = 200010;
int n;
int x[M],y[M],a[M],d[M],ans[M],top = 0;

template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(n);
    for(int i = 1;i <= n; i++) read(x[i]), read(y[i]), a[x[i]] = y[i];
    int m = n + 1;
    for(int i = 1;i <= n; i++){
        m = std::min(m,a[i]);
        if(m == n - i + 1) d[++top] = i;//每一个连接的起始点
    }
    for(int i = 1;i <= top; i++)
        for(int j = d[i];j > d[i - 1]; j--)
            ans[j] = d[i] - d[i - 1];//枚举每一个连接
    for(int i = 1;i <= n; i++) printf("%d\n",ans[x[i]]);
    return 0;
}

Measured memory_bytes: 4800
//#pragma GCC optimize ("-O3","unroll-loops")
#include<bits/stdc++.h>
 
using namespace std;
 
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define move(x) ans.push_back(x),c[x]--,now=x;
 
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

vector<int> calc(int A,int B,int N){
	vector<int>ret;
	if(N==1){
		ret.push_back(A);ret.push_back(B);
		return ret;
	}
	int s=0,t=B^A;
	if(t<(1<<(N-1))){
		vector<int>ret1=calc(s,t,N-1);
		vector<int>ret2=calc(s^(1<<(N-1)),ret1[1]^(1<<(N-1)),N-1);
		ret.push_back(ret1[0]);
		REP(i,ret2.size()){
			ret.push_back(ret2[i]);
		}
		FOR(i,1,ret1.size())ret.push_back(ret1[i]);
		REP(i,ret.size()){
			ret[i]^=A;
		}
	}
	else{
		vector<int>ret1=calc(0,1,N-1);
		vector<int>ret2=calc(1^(1<<(N-1)),t,N-1);
		REP(i,ret1.size())ret.push_back(ret1[i]);
		REP(i,ret2.size())ret.push_back(ret2[i]);
		REP(i,ret.size())ret[i]^=A;
	}

	return ret;
}
void solve() {
	int N,A,B;
	cin>>N>>A>>B;
	if(__builtin_popcount(A)%2==__builtin_popcount(B)%2){
		print("NO");return;
	}
	else{
		print("YES");
		vector<int>ans=calc(A,B,N);
		REP(i,ans.size()){
			pe(ans[i]);
		}cout<<endl;
	}
}

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

	solve();
}

Measured memory_bytes: 2392
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper



a, b = inl()
if a <= b:
    print(a)
else:
    print(a-1)


Measured memory_bytes: 3572
//author: dazhong_feliks

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

int main() {
  int N;
  char S;
  string ans = "Three";
  
  cin >> N;
  
  for (int i = 0; i < N; i++ ) {
    cin >> S;  
    if ( S == 'Y'){
     ans =  "Four";
     break;
    }    
     }  
     
      cout << ans << endl; 
}    
      
    

   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

using namespace std;

long int gcd(long int a, long int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

long int lcm(long int a, long int b)
{
    return a * b / gcd(a, b);
}

long int sinceDiv(long int since, long int div)
{
    if (since % div == 0)
    {
        return since / div - 1;
    }
    else
    {
        return since / div;
    }
}

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

    long int c_div = b/c - sinceDiv(a, c);
    long int d_div = b/d - sinceDiv(a, d);
    long int cd_div = b/lcm(c, d) - sinceDiv(a, lcm(c, d));

    cout << b - a + 1 + cd_div - c_div - d_div << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif


class AGC003B
{
public:
	AGC003B()
	{
		cin >> n_;
		a_collection_.resize(n_);
		loop(i, n_)
			cin >> a_collection_[i];
		ans_ = 0;
	}
	void Run(void)
	{

		loop(i, n_)
		{
			ans_ += a_collection_[i] / 2;
			if (i != n_ - 1 && a_collection_[i+1] > 0)
			{
				a_collection_[i + 1] -= a_collection_[i] % 2;
				ans_+= a_collection_[i] % 2;
			}
		}

		cout << ans_;
	}
private:
	llong n_;
	llong ans_;
	vector<llong> a_collection_;
};

int main(void)
{
	AGC003B agc003b;
	agc003b.Run();

	return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 21 21:50:38 2020

@author: liang
"""

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

tmp = sum(A) + B[N-1]
ans = tmp
for i in reversed(range(1,N)):
    tmp -= A[i]
    tmp += B[i-1]
    if ans < tmp:
        ans = tmp
print(ans)

Measured memory_bytes: 8944
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
string s;
int count=0,len;
bool panda=false;
cin>>s;
len=s.length();
while(!panda){
	len--;
	if(len%2==0){
		panda=true;
		for(int i=0;i<len/2;i++){
			if(s[i]!=s[(len+1)/2+i]){
				panda=false;
				break;
			}
		}
	}
}
cout<<len;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map{ it.toInt() }
    val l = readLine()!!.split(" ").map { it.toDouble() }.sorted().reversed()
    val al = l.sum()
    val popl = l.subList(0, y)
    if (popl.all { it >= al / 4 / y }) println("Yes") else println("No")
}


Measured memory_bytes: 37668
# -*- coding:utf8 -*-

l, r = map(int, input().split())
if (l - r) >= 2019:
    ans = 0
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            m =  (i * j) % 2019
            if m == 0:
                print(m)
                exit()
            elif m < ans:
                ans = m
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=1;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1])a++;
    else a=1;
    if(a>=3){
      cout<<"Yes"<<endl;return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
use std::collections::BTreeSet;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let k: i32 = read();
    let mut d = BTreeSet::new();
    for _ in 0..k {
        let c: String = read();
        d.insert(c.chars().next().unwrap());
    }

    for i in n.. {
        let set: BTreeSet<char> = i.to_string().chars().collect();
        if set.intersection(&d).collect::<Vec<_>>().len() == 0 {
            println!("{}", i);
            return;
        }
    }
}

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


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	while (1) {
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
				cnt++;
			}
		}
		if (cnt == n) {
			ans++;
		} else {
			break;
		}		
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a+b+c)<22) {
			System.out.print("win");
		}else {
			System.out.print("bust");
		}
	}
}


Measured memory_bytes: 21844
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

xyh.sort(key=lambda x:x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        H = abs(x - cx) + abs(y - cy) + h
        f = True

        for i in range(1, n):
            x, y, h = xyh[i]
            h2 = max(0, H - abs(x - cx) - abs(y - cy))
            if h != h2:
                f = False
                break

        if f:
            ans = (cx, cy, H)

print(ans[0], ans[1], ans[2])


Measured memory_bytes: 44016
#include <iostream>
#include <map>
#include <unordered_map>
#include <iterator>
using namespace std;

typedef multimap<int, int> mm;
typedef mm::reverse_iterator ri;
unordered_map<int, bool> memo;

bool solve(ri p, int t, mm &A) {
	
	long key = distance(A.rbegin(), p) + 1 + ((t + 1) << 16);
	auto i = memo.find(key);
	if (i != memo.end())
		return (*i).second;

	bool res;
	int x = (*p).first;
	if (p == A.rend())
		res = false;
	else if (x == t)
		res = true;
	else if ((*p).second < t)
		res = false;
	else if (x <= t)
		res = solve(next(p, 1), t - x, A) ? true : solve(next(p, 1), t, A);
	else
		res = solve(make_reverse_iterator(A.upper_bound(t)), t, A);

	memo[key] = res;
	return res;
}

int main()
{
	int n, q, m, sum = 0;

	cin >> n;
	mm A;
	while (n--) {
		cin >> m;
		A.insert({m, 0});
	}

	for (auto &x:A) {
		sum += x.first;
		x.second = sum;
	}
	
	cin >> q;
	while (q--) {
		cin >> m;
		cout << (solve(A.rbegin(), m, A) ? "yes" : "no") << endl;
	}
}


Measured memory_bytes: 3120
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int total = 0;
        total = (int) (k * Math.pow((k - 1), (n - 1)));
        System.out.println(total);
        bw.flush();
    }
}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

def main():
    N,M = cin.mapInt()
    G = cin.intListList(M)

    L = [0] * (N + 1)
    for i in G:
        L[i[0] - 1] += 1
        L[i[1]] -= 1
    for i in range(1,N + 1):
        L[i] += L[i - 1]
    print(L.count(M))
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 57436
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    ll n, d, x, y;
    cin >> n >> d;
    ll cnt = 0;
    FOR (i, 0, n) {
        cin >> x >> y;
        if (x*x + y*y <= d*d)
            cnt ++;
    }
    cout << cnt << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases


Measured memory_bytes: 3668
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> s(n);
    for(int i = 0; i < n; ++i){
        long long si;
        cin >> si;
        s.at(i) = si;
    }

    long long ans = 0;
    for(int c = 1; c < n - 1; ++c){
        long long tmp = 0;
        for(int k = 1; (k + 1) * c < n - 1; ++k){
            const long long a = n - 1 - k * c;
            if(a % c == 0 && (a / c <= k)){
                continue;
            }
            tmp += s.at(k * c) + s.at(n - 1 - k * c);
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,m; ll k; cin >> n >> m >> k;
    vector<ll> a(n+1),b(m+1);
    a[0]=0;
    rep(i,n){
        cin >> a[i+1];
        a[i+1]+=a[i];
    }
    b[0]=0;
    rep(i,m){
        cin >> b[i+1];
        b[i+1]+=b[i];
    }

    int ans=0;

    rep(i,n+1){
        ll now=a[i];
        if(now>k) continue;
        ll s=k-now;
        int l=0;
        int r=m;
        while(l!=r){
            int c=1+(l+r)/2;
            if(b[c]>s) r=c-1;
            else l=c;
        }
        ans=max(ans,l+i);
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

#define N 10005

int main(){
    int n;
    while(cin >> n){
        bool prime[N], pairPrime[N];

        n++;
        rep(i,n) prime[i] = 1;
        prime[0] = prime[1] = 0;

        int primeSum[N] = {0};
        rep(i,n){
            if(prime[i]){
                for(int j = i + i; j <= n; j+=i) prime[j] = 0;
            }
        }

        range(i,1,n) pairPrime[i] = (prime[i] && prime[n - i]);

        int count = 0;
        rep(i,n){
            count+=static_cast<int>(pairPrime[i]);
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

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

    ll n,z; cin >> n >> z;
    ll w; cin >> w;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    if(n == 1)ans = abs(a[0] - w);
    else{
        ans = max(abs(a[n-1]-w), abs(a[n-2]-a[n-1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string s;
    string t="CODEFESTIVAL2016";
    int Ans=0;
    cin >> s;
    REP(i,s.size()){
        if(s[i]!=t[i]){Ans++;}
    }
    cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

LL GCD(LL a, LL b)
{
  while(a % b)
  {
    LL r = a % b;
    a = b;
    b = r;
  }
  return b;
}

LL LCM(LL a, LL b)
{
  return (a * b) / GCD(a, b);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL a, b;
  cin >> a >> b;
  cout << LCM(a, b) << endl;

  return 0;
}


Measured memory_bytes: 256
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    x,y=L()
    for i in range(x+1):
        if i*2==y and i==x:
            print('Yes')
            exit()
        for j in range(x+1-i):
            if i*2+j*4==y and i+j==x:
                print('Yes')
                exit()
    print('No')
            
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
N = int(input())
s = [input() for _ in range(N)]
 
a = [0] * 5
for i in range(N):
    if s[i][0] == "M":
        a[0] += 1
    elif s[i][0] == "A":
        a[1] += 1
    elif s[i][0] == "R":
        a[2] += 1
    elif s[i][0] == "C":
        a[3] += 1
    elif s[i][0] == "H":
        a[4] += 1
 
c = 0
for k in range(5):
    for l in range(k + 1, 5):
        for m in range(l + 1, 5):
            c += a[k] * a[l] * a[m]
 
print(c)

Measured memory_bytes: 9776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll a, b; cin >> a >> b;
    ll ans = -1;
    for(int i = 0; i < 10000; ++i){
        int t1 = (int)((float)i * 0.08);
        int t2 = (int)((float)i * 0.10);
        if( (t1 == a) && (t2 == b) ){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    if x < y:
        return gcd(y, x)
    return gcd(y, x % y)


N, K = map(int, input().split())
a = list(map(int, input().split()))

g = a[0]
for i in range(1, N):
    g = gcd(a[i], g)

ma = max(a)
ok = (K <= ma and (ma - K) % g == 0)

print('POSSIBLE' if ok else 'IMPOSSIBLE')


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

int main( void ) {
    
    int k, s;
    cin >> k >> s;
    
    int ans = 0;
    for( int i = 0; i <= k; i ++ )
        for( int j = 0; j <= k; j ++ )
            if( s - i - j <= k && s - i - j >= 0 )
                ans ++;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, i, x, k = 1;
    long long ans = 0;
    vector <long long> v;

    cin >> n;

    for(i = 0; i < n * 3; ++i)
    {
        cin >> x;
        v.push_back(x);
    }
    sort(v.rbegin(), v.rend());
    while(n > 0)
    {
        n--;
        ans += v[k];
        k += 2;
    }
    cout << ans;

return 0;
}


Measured memory_bytes: 5360
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 100000000000000ll
#define MOD 998244353
#define LOG 31
#define EPS 0.000000001
#define M 305
#define PI 3.14159265359
using namespace std;

int n, t;
int be[N], sub[N], c[N];
ll ans[N];
vector<int> has[N], v[N];

void evaluate(int node, int color) {

	int cnt = sub[node];
	while(sz(has[color]) and be[has[color].back()] >= be[node]) {
		cnt -= sub[has[color].back()];
		has[color].pop_back();
	}
	ans[color] -= (ll) cnt * (cnt + 1) / 2;

}

void dfs(int node, int dad) {

	be[node] = ++t;
	sub[node] = 1;
	for(int go: v[node]) {
		if(go == dad) continue ;
		dfs(go, node);
		sub[node] += sub[go];
	}
	has[c[node]].pb(node);
	if(!dad) 
		for(int i = 1; i <= n; i++)
			evaluate(node, i);
	else
		evaluate(node, c[dad]);

}

int main() {

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

	cin >> n;
	for(int i = 1; i <= n ; i++) 
		cin >> c[i];
	for(int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1, 0);
	for(int i = 1; i <= n; i++) 
		cout << (ll) n * (n + 1) / 2 + ans[i] << "\n";

}

Measured memory_bytes: 39556
#include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
     
    int main()
    {
    	int i, j, imax, jmax = 0, count = 0;
    	int *buf = calloc(1, 100001 * sizeof(int));
    	
    	scanf("%d", &imax);
    	
    	for (i = 0; i < imax; i++) {
    		int tmp;
    		scanf("%d", &tmp);
    		if (jmax < tmp) {
    			jmax = tmp;
    		}
    		if (tmp == 0) {
    			buf[tmp] = buf[tmp] + 1;
    			buf[tmp + 1] = buf[tmp + 1] + 1;
    		} else {
    			buf[tmp - 1] = buf[tmp - 1] + 1;
    			buf[tmp] = buf[tmp] + 1;
    			buf[tmp + 1] = buf[tmp + 1] + 1;
    		}
    	}
    	
    	for (j = 0; j < 100000; j++) {
    		if (count <= buf[j]) {
    			count = buf[j];
    		}
    	}
    	
    	printf("%d", count);
    	return 0;
    }

Measured memory_bytes: 512
using System;

namespace AtCoder0621
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string[] ps = Console.ReadLine().Split(' ');

            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            int[] p = new int[N];
            for (var i = 0; i < ps.Length; i++) {
                p[i] = int.Parse(ps[i]);
            }

            Array.Sort(p);

            int ans = 0;

            for(var i =0; i<K; i++)
            {
                ans += p[i];
            }

            Console.WriteLine(ans);

        }
    }
}


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

    int n, m,j, l, k,t,H,D;
    scanf("%d%d%d",&n,&m,&k);
    j=m-n;
    l=k-m;
    if(j==l){
        printf("YES\n");
    } else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int x,y,a;
    for(a=0;a<3000;a++){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0){
            break;
        }
        else if(x<y){
            printf("%d %d\n",x,y);
        }
        else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    int negative = 0, zero = 0, minimum = 1 << 30; ll ans = 0;
    REP(i, 0, N) {
        int a; cin >> a;
        if (a == 0) zero++;
        else if (a < 0) negative++;
        minimum = min(minimum, abs(a));
        ans += abs(a);
    }
    if (zero > 0 || negative % 2 == 0) cout << ans << endl;
    else cout << ans - minimum * 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
typedef pair<int, int> PII;
typedef long long ll;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int a, b;

int main() {

	cin >> a >> b;

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

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A.at(i);

	}
	ll an = 0,k=0;
	rep(i, N - 1) {
		if (A.at(i) > A.at(i + 1)) {
			an += A.at(i) - A.at(i + 1);
			A.at(i + 1) = A.at(i);
		}
		
	}
	cout << an << endl;
}


Measured memory_bytes: 4784
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
int main()
{
	int k;
	cin>>k;
	cout<<a[k];
	return 0;
}

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

w = str(input())
W = list(w)
# start = W[0]
Ws = [w]
stop = W[-1]
count = 1

for i in range(N-1):

	w2 = str(input())
	W2 = list(w2)
	if(w2 not in Ws):
		if(W2[0]==stop):
			stop = W2[-1]
			count += 1
			Ws.append(w2)

if(count==N):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
//配列が２か奇数になったら終了
//２で何回割れるか考えるそれの最大値が答え
//syuuryousinai
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

#define ll long long

#define REP(i,n) for(i=0;i<n;i++)

int gcd(int a,int b);

int main(void)
{
  int n;
  scanf("%d",&n);
  int a[10001];
  int i,j;
  int sum = 0;
  int counter;
  int v;
  /*ここが原因で動かない
  REP(i,n)
  {
    counter = 0;
    i=0;
    scanf("%d",&v);
    while((v>>i)&0)
    {
      counter ++;
      i++;
    }
    sum+=counter;
  }
  */
  REP(i,n)
  {
    scanf("%d",&v);
    while(v%2==0)
    {
      v/=2;
      sum++;
    }
  }
  printf("%d",sum);
  return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

ll gcd(ll a, ll b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  int a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;

  return 0;
}


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

int main() {
    long long N;
    cin >> N;
    long long ans = N - 1;
    for(long long i = 1; i * i <= N; i++) {
        if((N / i) * i == N)
            ans = min(i + (N / i) - 2, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
///*Radhe Krishna*/
import javax.management.DynamicMBean;
import javax.print.DocFlavor;
import javax.print.attribute.HashAttributeSet;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.net.CookieHandler;
import java.nio.file.attribute.FileAttribute;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.util.Arrays;
import java.util.concurrent.Callable;



public class Main {
    static int mod = 1000000007;

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
//        Scanner sc=new Scanner(System.in);
                int n=sc.nextInt();
                        double     d=sc.nextDouble();

                int count=0;
                for(int j=0;j<n;j++){
                    int x=sc.nextInt();
                    int y=sc.nextInt();
                    x=Math.abs(x);
                    y=Math.abs(y);
                    double dis=(double)Math.sqrt((double)((long)x*x)+(double)((long)y*y));
                    if(dis<=(double)d){
                        count++;
                    }

                }
                System.out.println(count);

    }
}





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

int main(){
  
  int a,c,d,e,f;
  cin >> a;
  c=0;
  d=0;
  e=0;
  f=0;
  vector<string> b(a);
  for(int i=0;i<a;i++){
    cin >> b.at(i);
  }
 
  for(int i=0;i<a;i++){
    if( b.at(i) == "AC" ){
    c++;  
    }
  }
  
    cout << "AC" << " x " << c << endl;
   
      
  for(int i=0;i<a;i++){
    if( b.at(i) == "WA" ){
    d++;
    }
  }
    
    cout << "WA" << " x " << d << endl;
  
   
  for(int i=0;i<a;i++){
    if( b.at(i) == "TLE" ){
    e++;
    }
  }
  
    cout << "TLE" << " x " << e << endl;
  
  for(int i=0;i<a;i++){
    if( b.at(i) == "RE" ){
    f++;
    }
  }
  
    cout << "RE" << " x " << f << endl;
    
}
    
    
   


Measured memory_bytes: 6420
import math

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

Ai= sorted(A, reverse=True)
Bi= sorted(B, reverse=True)
Ci= sorted(C, reverse=True)

def su(a,b,c):
	return(Ai[a]+Bi[b]+Ci[c])

a=0
b=0
c=0

pq=[[su(a,b,c),a,b,c]]
ck=[a,b,c]

dl=0
for i in range(k):
	dl=pq.index(max(pq))
	res=pq.pop(dl)
	print(res[0])

	a=res[1]
	b=res[2]
	c=res[3]
	if a+1<=x-1 and (not [a+1,b,c] in ck):
		pq.append([su(a+1,b,c),a+1,b,c])
		ck.append([a+1,b,c])
	if b+1<=y-1 and (not [a,b+1,c] in ck):
		pq.append([su(a,b+1,c),a,b+1,c])
		ck.append([a,b+1,c])
	if c+1<=z-1 and (not [a,b,c+1] in ck):
		pq.append([su(a,b,c+1),a,b,c+1])
		ck.append([a,b,c+1])

Measured memory_bytes: 4724
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int prime[1000005], tim[1000005];

int main(){
    for (int i = 2; i <= 1000000; i++) {
        if (prime[i] == 0) {
            for (int j = 1; i * j <= 1000000; j++)
                if (prime[i*j]==0) prime[i*j] = i;
        }
    }
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int a; scanf("%d", &a);
        while(a != 1) {
            int k = prime[a];
            tim[k]++;
            while(a%k==0) a /= k;
        }
    }
    int ans = 0;
    for (int i = 1; i <= 1000000; i++) if (tim[i] > ans) ans = tim[i];
    if (ans <= 1) printf("pairwise coprime");
    else if (ans < n) printf("setwise coprime");
    else printf("not coprime");
    return 0;
}

Measured memory_bytes: 11628
/*input
8
1 2 1 4 2 1 4 1
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    ll n;
    cin>>n;
    ll a[n+1]={0};
    ll b[n];
    rep(i,0,n){cin>>j,b[i]=j,a[j]++;}
    ll ans=0;
    rep(i,1,n+1){
    	ans+=(a[i])*(a[i]-1)/2;
    }
    rep(i,0,n){
    	ll k=a[b[i]];
    	cout<<ans-k*(k-1)/2+(k-1)*(k-2)/2<<endl;
    }
    return 0;
}




Measured memory_bytes: 5760
dp = [true]
n = gets.to_i
(1..n).each do |i|
  next if i < 100
  dp[i] = dp[i-105] || dp[i-104] || dp[i-103] || dp[i-102] || dp[i-101] || dp[i-100]
end
p dp[n] ? 1 : 0


Measured memory_bytes: 15324
# encoding: "utf-8"

from collections import defaultdict

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]


def count_and_del(xs):
    cnt = 0
    fst = xs[0]
    # cnt = xs.count(fst)
    for x in xs:
        if x != fst:
            break
        cnt += 1
    del xs[:cnt]
    return cnt   

def main():
    _ = input()
    xs = Stdin.read_line(converter=int)
    xs.sort()
    ys = defaultdict(int)
    while xs:
        key = xs[0]
        cnt = count_and_del(xs)
        ys[key] += cnt
        ys[key-1] += cnt
        ys[key+1] += cnt

    print(max(ys.values()))


if __name__ == "__main__":
    main()

Measured memory_bytes: 18460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
///The greatest enemy of knowledge is not ignorance, it is illusion of knowledge

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


#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound

#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define PI (acos(-1.0))
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define fast ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree ll l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)

#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define AMR std::ios::sync_with_stdio(false);cin.tie(NULL);
int n;
ll w[109],v[109], W,dp[100009][101];
ll call(int pos, int ojon)
{
    if(pos>n ) return 0;
    ll &ret=dp[ojon][pos];
    if(ret!=-1) return ret;
    if(w[pos]<=ojon)
    ret=call(pos+1, ojon-w[pos])+v[pos];
    ret=max(ret, call(pos+1, ojon) );
    return ret;

}


int main(){
AMR;
memset(dp, -1, sizeof dp);
cin>>n>>W;
for(int i=1; i<=n; i++)cin>>w[i]>>v[i];
ll ans=call(1, W);
cout<<ans<<endl;


}










Measured memory_bytes: 79232