akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] array = new int[n];
		String[] strArray = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			array[i] = Integer.parseInt(strArray[i]);
		}
		insertionSort(array, n);
	}

	public static void insertionSort(int[] A, int N) {
		for (int i = 0; i < N; i++) {
			int temp = A[i];
			int j = i - 1;
			while (j >= 0 && temp < A[j]) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = temp;
			toArray(A);
		}
	}

	public static void toArray(int[] target) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < target.length; i++) {
			sb.append(target[i]);
			if (i < target.length - 1) sb.append(" ");
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 27560
/**
 * @Author : Gaurang_Kothiya
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;
const int MOD2= 998244353;


void Solve()
{
	string s;
	cin>>s;
	int sum=0;
	fe(x,s)
	{
		sum += x-'0';
	}
	if(sum%9 ==0) cout<<"Yes";
	else cout<<"No";
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);	

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3736
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 998244353;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

class Combination {
    int powmod(int a, int p) {
        int ans = 1;
        int mul = a;

        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    int mod;
    vector<int> fact;
    vector<int> revFact;

    Combination(int n, int m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    int get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

int powmod(int a, int p, int mod) {
    int ans = 1;
    int mul = a;

    for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
        if ((p & 1) == 1) ans = (ans * mul) % mod;
    }

    return ans;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    auto comb = new Combination(200005, MOD);

    int N, M, K;
    cin >> N >> M >> K;

    int ret = 0;
    for (int k = 0; k <= K; k++) {
        int tmp = comb->get(N-1, k);
        (tmp *= M) %= MOD;
        (tmp *= powmod(M-1, N-k-1, MOD)) %= MOD;
        (ret += tmp) %= MOD;
    }

    cout <<ret << endl;
    return 0;
}

Measured memory_bytes: 6724
#include <iostream>

int binSearch(int* a, int n, int k)
{
	int res = 0;
	int lb = 0;
	int ub = n-1;
	while (lb <= ub) {
		int mid = (lb + ub) / 2;
		res++;
		if (a[mid] == k) return res;
		else if (a[mid] < k) lb = mid + 1;
		else ub = mid - 1;
	}
	return res;
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n == 0) break;
		int* a = new int[n];
		for (int i=0; i<n; i++) std::cin >> a[i];
		int k; std::cin >> k;
		std::cout << binSearch(a, n, k) << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3084
local s=io.read()
local n=#s
local p=2019

local t={}
for i=1,p do
    t[i]=(i==1 and 1 or 0)
end

local combination=0
local digit=1
local smod=0
for i=n,1,-1 do
    local x=tonumber(s:sub(i,i))
    smod=(smod+x*digit)%p
    combination=combination+t[smod+1]
    t[smod+1]=t[smod+1]+1
    digit=(digit*10)%p
end
print(combination)

Measured memory_bytes: 2724
#include <iostream>

using namespace std;

int max(int a,int b){
	if(a>=b)return b;
	else return a;
}

int main(){
	int n,m;

	while(cin>>n>>m){
		if(n==0 && m==0)break;

		int *h,*w;

		int *hNum,*wNum;

		h=new int[n];
		w=new int[m];

		int maxHLength=0;
		int maxWLength=0;
		for(int i=0;i<n;i++){
			cin>>h[i];
			maxHLength+=h[i];
		}
		for(int i=0;i<m;i++){
			cin>>w[i];
			maxWLength+=w[i];
		}

		hNum = new int[maxHLength+1];
		wNum = new int[maxWLength+1];

		for(int i=0;i<=maxHLength;i++){
			hNum[i]=0;
		}	

		for(int i=0;i<=maxWLength;i++){
			wNum[i]=0;
		}

		int maxLength=0;

		for(int i=0;i<n;i++){
			int length=0;
			for(int j=i;j<n;j++){
				length+=h[j];
				hNum[length]++;
			}
		}
		for(int i=0;i<m;i++){
			int length=0;
			for(int j=i;j<m;j++){
				length+=w[j];
				wNum[length]++;
			}
		}

		int sum=0;

		maxLength=max(maxHLength,maxWLength);

		for(int i=0;i<=maxLength;i++){
			sum+=hNum[i]*wNum[i];
		}

		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 30192
n, t = map(int, input().split())
a = [int(i) for i in input().split()]
min_a = a[0]
max_a = a[0]
diff = 0
num = 0
for aa in a:
    if min_a > aa:
        min_a = aa
        max_a = aa
    elif min_a < aa:
        if aa - min_a > diff:
            diff = aa - min_a
            num = 1
        elif aa - min_a == diff:
            num += 1
print(num)

Measured memory_bytes: 14252
#include <stdio.h>
int main(){
    long long int num[5] = {};
    long long int ans = 0;
    long long int N, i;
    char name[11];
    scanf("%lld", &N);
    for(i = 0; i < N; ++i){
        scanf("%s", name);
        switch (name[0]) {
            case 'M':
                num[0]++;
                break;
            case 'A':
                num[1]++;
                break;
            case 'R':
                num[2]++;
                break;
            case 'C':
                num[3]++;
                break;
            case 'H':
                num[4]++;
                break;
            default:
                break;
        }
    }
    int x, y, z;
    for(x = 0; x < 5; x++){
        for(y = x + 1; y < 5; y++){
            for(z = y + 1; z < 5; z++){
                ans+=num[x]*num[y]*num[z];
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	vs s(3);

	rep(i, 3) cin>>s[i];

	cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int N;
    cin>>N;
    vector<int> ds(N);
    rep(i, N) cin>>ds[i];

    ll s = 0;
    rep(i, N - 1) {
        for (int j = i + 1; j < N; j++) {
            s += ds[i] * ds[j];
        }
    }
    cout<<s<<endl;
}

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

int main()
{
    int n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)cout<<"hon"<<endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;

    return 0;
}


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

bool f(pair<int,int> x,pair<int,int> y){
	if(x.first<y.first)return true;
	if(x.first>y.first)return false;
	if(x.second>y.second)return false;
	return true;
}

int main(){
while(1){
	int m,n;
	pair<int,int> p;
	vector<pair<int,int>> mm,nn;
	scanf("%d",&m);
	if(m==0)break;
	for(int i=0;i<m;i++){
		scanf("%d%d",&p.first,&p.second);
		mm.push_back(p);
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&p.first,&p.second);
		nn.push_back(p);
	}
	sort(mm.begin(),mm.end(),f);
	sort(nn.begin(),nn.end(),f);
	for(int i=0;i<n-m+1;i++){
		int hx=nn[i].first-mm[0].first,hy=nn[i].second-mm[0].second,j=1;
		bool c=false;
		p.first=mm[j].first+hx; p.second=mm[j].second+hy;
		for(int k=i+1;k<n;k++){
			//if(f(p,nn[k]))break;
			if(p==nn[k]){j++; p.first=mm[j].first+hx; p.second=mm[j].second+hy;}
			if(j==m){c=true; break;}
		}
		if(c){printf("%d %d\n",hx,hy); break;}
	}
}
}

Measured memory_bytes: 1192
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split(' ');
        var a = int.Parse(s[0]);
        var b = int.Parse(s[1]);
        var c = int.Parse(s[2]);

        var ans = true;

        s = Console.ReadLine().Split(' ');
        var d = a - int.Parse(s[0]);
        var e = b - int.Parse(s[1]);
        var f = c - int.Parse(s[2]);
        ans &= d == e;
        ans &= e == f;

        s = Console.ReadLine().Split(' ');
        d = a - int.Parse(s[0]);
        e = b - int.Parse(s[1]);
        f = c - int.Parse(s[2]);
        ans &= d == e;
        ans &= e == f;

        Console.WriteLine(ans ? "Yes" : "No");
    }
}


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

namespace AtCoder.ABC10
{
    class Program
    {
        static void Main(string[] args)
        {
            var b081 = new B081();
            b081.Answer();
        }
    }
    public class B081
    {
        public void Answer()
        {
            string _ = Console.ReadLine();
			int[] numbers = Console.ReadLine()
              .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
              .Select(s => int.Parse(s))
              .ToArray();

            int ans = Answer(numbers);
            Console.WriteLine(ans);
        }
      
        public int Answer(int[] numbers)
        {
            return numbers.Select(n => Divide2WhileEven(n)).Min();
        }

        private int Divide2WhileEven(int x)
        {
            int ans = 0;
            while (true)
            {
              	if (x % 2 != 0)
                {
                    return ans;
                }
                x = x / 2;
                ans++;
            }
        }
    }
}

Measured memory_bytes: 11348
using System;
using System.Linq;
class Program
{
  static void Main(string[] args)
  {
            Console.ReadLine();
            string[] numsStr = Console.ReadLine().Split(' ');
            int[] nums = numsStr.Select(x => int.Parse(x)).ToArray();
            var count = 0;
            var hasOdd = false;
            while (true)
            {
                for (var i = 0; i < nums.Count(); i++)
                {
                    if (nums[i] % 2 == 1)
                    {
                        hasOdd = true;
                        break;
                    }
                    nums[i] = nums[i] / 2;
                }
                if (hasOdd) break;
                count++;
            }
            Console.WriteLine(count);
  }
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int mod=1000000007;
void Wafrelka(int const(&a)[3][3],int const(&b)[3][3],int(&c)[3][3]){
	REP(i,3)REP(j,3){
		c[i][j]=0;
		REP(k,3)c[i][j]+=a[i][k]*b[k][j];
		c[i][j]%=mod;
	}
}
int s[30][3][3],t[3][3];

signed main(){
	{
		int tmp[3][3]={
			{2,1,1},
			{2,1,0},
			{1,1,1}
			};
		swap(s[0],tmp);
		FOR(i,1,30)
			Wafrelka(s[i-1],s[i-1],s[i]);
	}
	{
		int tmp[3][3]={
			{1,0,0},
			{2,1,0},
			{1,1,1}
			};
		swap(t,tmp);
	}
	int n=read(),m=read(),last=0;
	assert(n<=1000000000);
	assert(m<=100000);
	int buf[3][3]={{1,0,0},{0,1,0},{0,0,1}};
	REP(_,m){
		int x=read();
		assert(last<x);
		int g=x-last-1;
		REP(i,30)if((g>>i)&1){
			int tmp[3][3];
			Wafrelka(s[i],buf,tmp);
			swap(buf,tmp);
		}
		int tmp[3][3];
		Wafrelka(t,buf,tmp);
		swap(buf,tmp);
		last=x;
	}
	assert(last<n);
	int g=n-last-1;
	REP(i,30)if((g>>i)&1){
		int tmp[3][3];
		Wafrelka(s[i],buf,tmp);
		swap(buf,tmp);
	}
	int ans=0;
	REP(i,3)ans+=buf[i][0];
	ans%=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < 10; ++i)
		{
			int a = stdIn.nextInt();
			list.add(a);
		}
		Collections.sort(list, new MyComparator());
		for(int i = 0; i < 3; ++i)
		{
			System.out.println(list.get(i));
		}
	}
}

class MyComparator implements java.util.Comparator<Integer>
{
	public int compare(Integer object1, Integer object2)
	{
        return((object1).compareTo(object2) * -1);	//降順
    }
}

Measured memory_bytes: 17176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n+1), b(n+1);
    for(int i = 2; i <= n; i++){
        cin >> a[i];
        b[a[i]]++;
    }
    for(int i = 1; i <= n; i++) cout << b[i] << endl;
    return 0;
}

Measured memory_bytes: 6372
#include<stdio.h>

int div(int N);

int main(void){
	int N;
	int num=0;
	int i;
	scanf("%d",&N);
	for(i=105;i<=N;i+=2){
		if(div(i)==8)num++;
	}
	printf("%d\n",num);
	return 0;
}

int div(int N){
	int divisor=1;
	int i;
	for(i=1;i<N/2;i++){
		if(N%i==0)divisor++;
	}
	return divisor;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Segment_Min {
private:
  int n;
  vector<int> node;
public:
  Segment_Min(vector<int> v) {
    int sz = v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1, INF);
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
  }
  void update(int x, int val) {
    x += (n - 1);
    node[x] = val;
    while(x > 0) {
      x = (x - 1) / 2;
      node[x] = min(node[2*x+1], node[2*x+2]);
    }
  }
  int getmin(int a, int b, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return node[k];
    int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
    int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, x;
  cin >> N >> x;
  vector<int> a(2*N);
  REP(i, N) cin >> a[i];
  REP(i, N) a[N+i] = a[i];
  Segment_Min seg(a);
  lint ans = 1e18;
  REP(k, N+1) {
    lint tmp = (lint)k*(lint)x;
    REP(i, N) tmp += (lint)seg.getmin(N+i-k, N+i+1);
    if(tmp < ans) ans = tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    ll sum=accumulate(all(v),0LL);
    ll p=n*(n+1)/2;
    if(sum%p!=0)cout << "NO" <<endl,exit(0);
    ll lap=sum/p;
    vector<ll> end(n);
    v.pb(v[0]);
    rep(i,n){
        ll dif=v[i+1]-v[i];
        if((lap-dif)%n!=0)cout << "NO" <<endl,exit(0);
        end[i]+=(lap-dif)/n;
        if(end[i]<0)cout << "NO" <<endl,exit(0);
    }
    if(accumulate(all(end),0LL)==lap){
        ll now=0;
        rep(i,n)now+=end[i]*(n-i);
        bool ok=true;
        rep(i,n){
            //cout << now <<endl;
            if(now!=v[i])ok=false;
            now+=lap;
            now-=end[i]*n;
        }
        if(ok)cout << "YES" <<endl;
        else cout <<"NO" <<endl;
    }
    else cout << "NO" <<endl;
}

Measured memory_bytes: 5616
#include <stdio.h>

int main(){
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  
  int max = 0;
  
  for(;;){
    if(k==0) break;
    if(a==0) break;
    max++;
    a--;
    k--;
  }
  
  for(;;){
    if(k==0) break;
    if(b==0) break;
    b--;
    k--;
  }
  
  for(;;){
    if(k==0) break;
    if(c==0) break;
     max--;
     c--;
     k--;
  }
  
  printf("%d",max);
  
}

Measured memory_bytes: 1712
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    int ans = 0;

    int prev_r = 0;
    
    for (int i = 0; i != n; ++i) {
        int a = input<int>();

        int lg = log(a) / log(2) + 1e-9;
//        while ((2 << lg) <= a)
//            ++lg;

        if ((1 << lg) == a) {
            ans += lg;
            ans -= min(prev_r, lg);
            prev_r = lg;
        } else {
            ans += lg + 1;

            if (prev_r <= lg)
                ans -= prev_r, prev_r = lg + 1;
            else
                ans -= lg + 1, prev_r = lg;
            
        }
    }

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


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

#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n, x;
vector<int> vec;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> x;
  int atual = 0;
  int ans = 1;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    atual += a;
    if(atual <= x) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[1000001], b[100000], n; cin >> n;
	long long cnt = 0;
	for (int i = 0; i < n + 1; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) {
		if (b[i] > a[i]) {
			a[i + 1] -= (b[i] - a[i]);
			cnt += b[i];
			if (a[i + 1] < 0) {
				cnt += a[i + 1]; a[i + 1] = 0;
			}
		}
		else {
			cnt += b[i];
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2944
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x:(x[1], x[0]), reverse=True)
a.sort()
cur = 0
for i in range(m):
    for j in range(bc[i][0]):
        if cur == n or a[cur] >= bc[i][1]:
            print(sum(a))
            quit()
        a[cur] = bc[i][1]
        cur += 1
print(sum(a))

Measured memory_bytes: 39236
#include <bits/stdc++.h>
#include <string>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;

int main() {
  int H, A;
  cin >> H >> A;

  int ans = 0;

  while(A * ans < H) {
    ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = INT()

ans = x//11 * 2
x %= 11

if 0 < x <= 6:
	ans += 1
elif 7 <= x:
	ans += 2
print(ans)

Measured memory_bytes: 13680
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 3050;
vector<int> E[N];

vector<pair<int, int>> pr;

int val[N], nval[N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int v;
        scanf("%d", &v);
        pr.emplace_back(v, i);
    }
    for (int i =0 ; i < n - 1; i ++) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    sort(pr.begin(), pr.end());
    for (int l = 0, r = 0; l < n; l = r) {
        while (r < n && pr[r].first == pr[l].first)
            r++;
        for (int i = l; i < r; i++) {
            int x = pr[i].second;
            for (int y : E[x]) {
                if (val[y] == -1)
                    nval[x] = 1;
            }
            if (nval[x] != 1)
                nval[x] = -1;
        }
        for (int i = l; i < r; i++) {
            int x = pr[i].second;
            val[x] = nval[x];
        }
    }
    for (int i = 0; i < n; i++) {
        if (val[i] == 1)
            printf("%d ", i + 1);
    }
    printf("\n");
}


Measured memory_bytes: 512
//#pragma GCC optimize(\"Ofast,no-stack-protector\")
//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\")
//#pragma GCC target(\"avx,tune=native\")
// Neil

#include<bits/stdc++.h>

using namespace std;

typedef complex<double> base;
typedef long double ld;
typedef long long ll;

#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define pll pair< ll , ll >
#define vi vector<int>
#define vvi vector< vi >
const ll MAXN=(int)(2e5+5);
const ll MOD=(ll)(1e9+7);
int t;
ll fact[MAXN];
ll pw(ll a, ll b){
    ll x = 1, y = a;
    while(b>0){
        if(b%2 == 1)
            x = ((x%MOD)*(y%MOD))%MOD;
        y = ((y%MOD)*(y%MOD))%MOD;
        b = b>>1; 
    }
    return x%MOD;
}

ll inv(ll x){
    return pw(x, MOD-2ll);
}

ll path(ll a, ll b){
    ll ans = fact[a+b];
    ans = (ans * inv(fact[a]))%MOD;
    ans = (ans * inv(fact[b]))%MOD;
    return ans;
}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    t = 1;
    while(t--){
        int h, w, a, b;
        fact[0] = 1ll;
        for(int i=1;i<MAXN;i++)
            fact[i] = (i*fact[i-1])%MOD;
        cin>>h>>w>>a>>b;
        ll ans = 0ll;
        for(int i = h-a, j = b+1; i>0 and j<=w;i--,j++){
            ans += (path(i-1, j-1) * path(h-i, w-j))%MOD;
        }
        ans = (ans + MOD)%MOD;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  vector<vector<int>> dist(N, vector<int>(N));
  rep(i, N) rep(j, N) { dist[i][j] = abs(j - i); }

  dist[X][Y] = dist[Y][X] = 1;
  rep(i, N) rep(j, N) {
    dist[i][j] = min(min(dist[i][j], dist[i][X] + 1 + dist[Y][j]),
                     dist[i][Y] + 1 + dist[Y][j]);
  }

  vector<int> result(N, 0);
  rep(i, N) for (int j = i + 1; j < N; j++) { result[dist[i][j]]++; }

  rep(i, N - 1) { cout << result[i + 1] << endl; }
  return 0;
}

Measured memory_bytes: 16000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str1[] = br.readLine().split("");
		String str2[] = br.readLine().split("");

		Arrays.sort(str1, Comparator.naturalOrder());
		Arrays.sort(str2, Comparator.reverseOrder());

		int count = 0;

		for (int i = 0; i < Math.min(str1.length, str2.length); i++) {
			if (str1[i].compareTo(str2[i]) > 0) {
				System.out.println("No");
				return;
			} else if (str1[i].compareTo(str2[i]) < 0) {
				System.out.println("Yes");
				return;
			} else {
				count++;
			}
		}

		if (str1.length < str2.length) {
			if (count == str1.length || count == str2.length) {
				System.out.println("Yes");
			}
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 21332
//Kaori Miyazono, did I reach you ?
//"I can't die because... I'm the one who will protect you." -Asuna Yuuki
 
#include <bits/stdc++.h>
using namespace std;

const int N = 1100;

int nums[2][N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < 2; i++) for(int j = 1; j <= n; j++) cin >> nums[i][j];
	for(int i = 0; i < 2; i++) for(int j = 1; j <= n; j++) {
		nums[i][j] += nums[i][j - 1];
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ans = max(ans, nums[0][i] + nums[1][n] - nums[1][i - 1]);
	}
	cout << ans;
   	return 0;
}	

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

#define maxn 111
int b[maxn];
int n,m;

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char c;
			cin>>c;
			b[c-'a']++;
		}
	}
	int v1=0,v2=0,v3=0,s1=0,s2=0,s3=0;
	for(int i=0;i<26;i++)
	{
		if (b[i]%4==0) v1++;
		else if (b[i]%2==0) v2++;
		else v3++;
		s1+=4*(b[i]/4);
	}
	bool f=0;
	if (n%2==0 && m%2==0)
	{
		if (v2==0 && v3==0) f=1;
	}
	else if (n%2==1 && m%2==1)
	{
		if (v3==1 && s1>=(n-1)*(m-1)) f=1;
	}
	else
	{
		int s;
		s=4*(n/2)*(m/2);
		if (s1>=s && v3==0) f=1;
	}
	if (n*m==1) f=1;
	if (f)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

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

ans = 0
for i in range(2**N):
    light_cnt = 0
    for condition_idx in range(M):


        switch_num = 0
        for j in range(N):
            if i >> j & 1 and j+1 in conditions[condition_idx][1:]: # つながっているスイッチの押してあるものを数える
                switch_num += 1
        if switch_num%2 == p[condition_idx]:
            light_cnt += 1
    if light_cnt == M:
        ans += 1
print(ans)

Measured memory_bytes: 3064
// ref: https://drken1215.hatenablog.com/entry/2018/09/02/020500

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    int L; cin >> L;
    
    int N=0, pow2n=1; while(pow2n<=L){ pow2n*=2; ++N; } // max(N) taht satisfies 2^n <=L.
    int M = (N-1)*2 + __builtin_popcount(L)-1;
    cout << N << ' ' << M << endl;
    
    // filling [0, 2^n]
    for(int i=0; i<N-1; ++i){
        cout << (i+1) << ' ' << (i+2) << ' ' <<   0    << endl;
        cout << (i+1) << ' ' << (i+2) << ' ' << (1<<i) << endl;
    }
    
    // filling (2^n, L]
    int sum = 1<<(N-1);
    int cur = 1<<(N-2);
    for(int i=N-2; i>=0; --i){
        if(L & cur){
            cout << i+1 << ' ' << N << ' ' << sum << endl;
            sum += cur;
        }
        cur>>=1;
    }
    
    return 0;
}


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

int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

const int N = 2000;

std::bitset<N * N / 2 + N> B;

int main()
{
	int n = read();
	int s = 0;
	B[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		int x = read();
		s += x;
		B |= B << x; 
	}
	for (int i = s / 2 + (s & 1);; i++)
		if (B[i])
		{
			printf("%d\n",i);
			return 0;
		}
}

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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  
  bool a = false;
  for (int i = 1; i < B; i++) {
    if (A*i%B == C) {
      a = true;
      break;
    }
  }
  if (a) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

using namespace  std;

#define ll long long

#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;


int main(){
     
  ll n,a[1000001],b[1000001];
  cin>>n;
  for (int i = 1; i<=n; ++i)
  {
      cin>>a[i];
      b[a[i]]=i;
    
  }
  sort(a,a+n);

 for (int i = 1; i<=n; ++i){
 	cout<<b[i]<<" ";
 }
  

 //cerr<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    return 0;
} 

Measured memory_bytes: 6912
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	ll n;
	cin>>n;
	cout<<((n+999)/1000)*1000 - n<<endl;
	
	
	
}


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
# 整数の入力
k, s = map(int, input().split())

# 条件を満たす組み合わせのカウント
count = 0
for x in range(0, k+1):
    for y in range(0, k+1):
        z = s - x - y
        if 0 <= z <= k:
            count += 1

print(count)

Measured memory_bytes: 2940
# https://atcoder.jp/contests/agc011/tasks/agc011_a

n, c, k = map(int, input().split())

schedule = []
for _ in range(n):
    t = int(input())
    schedule.append(t)
schedule.sort()

ans = 0
start = schedule[0]
p = 0
for i in range(n):
    s = schedule[i]
    if s <= start + k:
        p += 1
        if p == c:
            ans += 1
            p = 0
            if i + 1 == n:
                break
            start = schedule[i + 1]
    else:
        ans += 1
        start = schedule[i]
        p = 1
if p:
    ans += 1
print(ans)


Measured memory_bytes: 50392
#include<stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	int n,m;
	while(scanf("%d%d",&n,&m),n){
		int ans=0;
		for(int i=0;i<n;i++){
			int t;
			scanf("%d",&t);
			ans+=min(t,m/n);
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	string s;
	int ans = 0;
	cin >> s;
	int cnt = 0;
	rep(i, s.size() - 1) {
		if (s[i] == 'A') cnt++;
		else if(s[i]=='B'&&s[i+1]=='C'){
			ans += cnt;
			i++;
		}
		else cnt = 0;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  vector<int> f1;
  vector<int> f2;
  vector<int> ans;
  for(int i=0; ;i++){
    int t = i * i * i;
    if(t > 151200) break;
    f1.push_back(t);
  }
  for(int i=0; ;i++){
    int t = (int)(((ll)i * (i + 1) * (i + 2))/6);
    if(t > 151200) break;
    f2.push_back(t);
  }

  FOR(i1,f1){
    FOR(i2,f2){
      int t = *i1 + *i2;
      if(t > 151200) break;
      ans.push_back(t);
    }
  }

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

  int n;
  while(n = getInt()){
    vector<int>::iterator t = lower_bound(ans.begin(),ans.end(),n);
    if(*t != n) --t;
    print(*t);
  }

  return 0;
}

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

int main() {
    string str;

    while(cin >> str, str != "-") {
	int len = str.size(), is = 0, nh;
	cin >> nh;
	for(int i=0; i<nh; ++i) {
	    int h;
	    cin >> h;
	    is += h;
	}
	is %= len;
	cout << str.substr(is) << str.substr(0, is) << endl;
    }
    return 0;
}

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

int main() {
  int a, b, x;
  double h;
  cin >> a >> b >> x;
  h = (double)x / (a * a);
  if(h * 2 >= b)
    cout << setprecision(10) << atan2((b - h) * 2, a) / M_PI * 180 << endl;
  else
    cout << setprecision(10) << atan2(b, h * a * 2 / b) / M_PI * 180 << endl;
}

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




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<ll,ll>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	ll ans =0;
	while (1) {
		int cnt = 0;
		rep(i, n) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
				ans++;
				cnt++;
			}
		}
		if (cnt == 0)break;
		
	}
	cout << ans << endl;
	return 0;
}













Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <set>
#include <iterator>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int n, m, tmp;
	std::vector<int> a, b;
	std::vector<int> result;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> tmp;
#else
		std::cin >> tmp;
#endif
		a.push_back(tmp);
	}

#if INPUT_FROM_FILE
	ifs >> m;
#else
	std::cin >> m;
#endif
	
	
	for(int i = 0; i < m; i++){
#if INPUT_FROM_FILE
		ifs >> tmp;
#else
		std::cin >> tmp;
#endif
		b.push_back(tmp);
	}

	std::set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(result, result.end()));

	for(int i = 0; i < result.size(); i++){
		std::cout << result[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 6536
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
ans=-10**18
for i in range(1,2**10):
  op=[0]*10
  res=0
  for j in range(10):
    if i>>j&1:
      op[j]=1
  for j in range(n):
    cnt=0
    for k in range(10):
      if op[k]&f[j][k]:
        cnt+=1
    res+=p[j][cnt]
  ans=max(ans,res)
print(ans)


Measured memory_bytes: 3064
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())


def main():
    N, M = mi()
    X = list(mi())
    X.sort()
    if N >= M:
        print(0)
        return
    dif = [(X[i+1]-X[i], i) for i in range(M-1)]
    dif.sort(reverse=True)
    koma = [-1]+[dif[i][1] for i in range(N-1)]+[M-1]
    print(sum(X[koma[i+1]]-X[koma[i]+1] for i in range(N)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 84328
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
    int a, b;
    char op;
    
    
    while(1){
        cin >> a >> op >> b;
    if(op == '+'){
        cout << a+b << endl;
    }else if(op == '-'){
        cout << a-b << endl;
    }else if(op == '*'){
        cout << a*b << endl;
    }else if(op == '/'){
        cout << a/b << endl;
    }else if( op == '?'){
        break;
        }
    }
    return 0;
}


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

int main(void){
  int n;
  vector<string> w(100);

  cin >> n;

  for(int i = 0; i < n; i ++)
    cin >> w.at(i);

  char temp;
  vector<string> a(100);
  int j = 0;

  for(int i = 0; i < n; i ++){
    if(i == 0){
      temp = w.at(i).back();
      a.at(j) = w.at(i);
      j ++;
    }
    else{
      for(int k = 0; k < j; k ++){
        if(a.at(k) == w.at(i)){
          cout << "No" << endl;
          return 0;
        }
      }
      if(w.at(i).front() != temp){
        cout << "No" << endl;
        return 0;
      }
      temp = w.at(i).back();
      a.at(j) = w.at(i);
      j ++;
    }
  }

  cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main() {
    ll N;
    cin >> N;
    vector<ll> num(N);
    vector<ll> answers(1000000, 0);

    REP(i, N) {
        cin >> num[i];
        answers[num[i]]++;
        if (num[i] - 1 >= 0) answers[num[i] - 1]++;
        answers[num[i] + 1]++;
    }

    cout << *max_element(answers.begin(), answers.end()) << endl;

    return 0;
}

Measured memory_bytes: 11872