akhauriyash/Code-Regression huggingface dataset:
#ifndef ___Geometry_Library
#define ___Geometry_Library

// ------ Includes ------ //
#include <cmath>
#include <vector>
#include <complex>
#include <utility>
#include <algorithm>

// ------ Defines ------ //
typedef long double GType;
typedef std::complex<GType> Point;
typedef std::pair<Point, Point> Segment;

// ------ Constants ------ //
const GType EPS = 1.0e-10L;

// ------ Functions Level 1 ------ //
GType dot(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).real();
}
GType cross(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).imag();
}
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point v1 = p2 - p1, v2 = p3 - p1;
	if (cross(v1, v2) > EPS) return +1;
	if (cross(v1, v2) < -EPS) return -1;
	if (dot(v1, v2) < -EPS) return +2;
	if (std::norm(v1) < std::norm(v2)) return -2;
	return 0;
}

// ------ Functions Level 3 ------ //
int contain(std::vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); ++i) {
		Point a = v[i] - p, b = v[(i + 1 != v.size() ? i + 1 : 0)] - p;
		if (a.imag() > b.imag()) swap(a, b);
		if (a.imag() <= EPS && EPS < b.imag() && cross(a, b) < -EPS) in = !in;
		if (cross(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}

#endif

#include <iostream>
using namespace std;
int n, q, x, y; vector<Point> v;
int main() {
	cin >> n; v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		v[i] = Point(x, y);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		Point p(x, y);
		cout << contain(v, p) << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int a,b;
    cin>>a>>b;
    if(a+b==15){
        cout<<"+"<<endl;
    }else if(a*b==15){
        cout<<"*"<<endl;
    }else{
        cout<<"x"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    hs = list(map(int, input().split()))
    dp = [10000000000 for _ in range(n)]

    dp[0] = 0
    dp[1] = abs(hs[1] - hs[0])
    for i in range(2, n):
        jump1 = dp[i-1] + abs(hs[i] - hs[i-1])
        jump2 = dp[i-2] + abs(hs[i] - hs[i-2])
        dp[i] = min(jump1, jump2)

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

Measured memory_bytes: 52840
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int h,w;
    cin>>h>>w;
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int ans[h][w]={};
    //うねうね構築すればいいと思います。
    int idx=0;
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                ans[i][j]=idx+1;
                a[idx]--;if(a[idx]==0) idx++;
            }
        }
        else{
            for(int j=w-1;j>=0;j--){
                ans[i][j]=idx+1;
                a[idx]--;if(a[idx]==0) idx++;
            }
        }
    }

    rep(i,h){
        rep(j,w){
            if(j!=w-1) cout<<ans[i][j]<<' ';
            else cout<<ans[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	static int ans;
	public static void bottom(int n[]){
		int c[]=new int[n.length-1];
		int i;
		
		for(i=0;i+1<n.length;i++){
			c[i]=n[i]+n[i+1];
			if(c[i]>9){
				c[i]=c[i]%10;
			}
		}
		if(c.length==1){
			ans=c[0];
			return;
		}
		else bottom(c);
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n[]=new int[10];
		int i;
		String str;
		char ch[]=new char[10];
		while(sc.hasNext()){
			str=sc.next();
			ch=str.toCharArray();
			for(i=0;i<10;i++){
				n[i]=ch[i]-'0';
			}
			bottom(n);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <stdio.h>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    int n;
    bool card[4][13];
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 13; j++)
        {
            card[i][j] = true;
        }
    }

    cin>>n;

    for (int i = 0; i < n; i++)
    {
        int rank, Suit;
        char suit;
        cin >> suit >> rank;
        switch (suit)
        {
        case 'S':
            Suit = 0;
            break;
        case 'H':
            Suit = 1;
            break;
        case 'C':
            Suit = 2;
            break;
        case 'D':
            Suit = 3;
            break;
        default:
            break;
        }

        card[Suit][rank-1] = false;

    }

    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 13; j++)
        {
            if (card[i][j] == true)
            {
                switch (i)
                {
                    case 0:
                        cout<<"S "<<j+1<<endl;
                        break;
                    case 1:
                        cout<<"H "<<j+1<<endl;
                        break;
                    case 2:
                        cout<<"C "<<j+1<<endl;
                        break;
                    case 3:
                        cout<<"D "<<j+1<<endl;
                        break;
                    default:
                        break;
                }
            }
            
        }
        
    }

    return 0;
}


Measured memory_bytes: 3108
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())
    A = list(map(int,input().split()))
    ans = [0] * N

    for i in range(N-1):
        ans[A[i]-1] += 1

    for i in ans:
        print(i)

if __name__ == "__main__":
    main()

Measured memory_bytes: 30968
#include"bits/stdc++.h"
using namespace std;
struct a{
	int time;
	int id;
};
a k[10000000];
bool cmp(a x,a y){
	if(x.time<y.time)return true;
	return false;
}
int main(){
	int num;
	cin>>num;
	for(int i=0;i<num;i++){
		int temp;
		cin>>temp;
		k[i].time=temp;
		k[i].id=i+1;
	}
	sort(k,k+num,cmp);
	cout<<k[0].id;
	for(int i=1;i<num;i++){
		cout<<" "<<k[i].id;
	}
	cout<<endl;
}

Measured memory_bytes: 1536
#include <array>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>

int blocks[300];
int8_t strike_range[300][300];
int score_in_range[300][300];

const int8_t STRIKE_RANGE_UNDEF = 0;
const int8_t STRIKE_RANGE_NO = 1;
const int8_t STRIKE_RANGE_YES = 2;

bool can_strike(int x, int y) {
	return std::abs(blocks[x] - blocks[y]) <= 1;
}

int8_t search_range(int start, int end) {
	if (start >= end) return STRIKE_RANGE_UNDEF;
	if ((end - start + 1) % 2 != 0) return STRIKE_RANGE_NO;

	int8_t* p = &strike_range[start][end];
	if (*p != STRIKE_RANGE_UNDEF) return *p;

	if (start + 1 == end)
		return *p = can_strike(start, end) ? STRIKE_RANGE_YES : STRIKE_RANGE_NO;

	for (int i = start + 1; i < end - 1; i++) {
		if (search_range(start, i) == STRIKE_RANGE_YES
			&& search_range(i + 1, end) == STRIKE_RANGE_YES)
		{
			return *p = STRIKE_RANGE_YES;
		}
	}

	auto result = search_range(start + 1, end - 1);
	return *p = result == STRIKE_RANGE_YES && can_strike(start, end)
		? STRIKE_RANGE_YES : STRIKE_RANGE_NO;
}

int main()
{
	while (true) {
		int n;
		std::cin >> n;

		if (n == 0) return 0;

		for (int i = 0; i < n; i++) {
			int w;
			std::cin >> w;
			blocks[i] = w;
		}

		std::memset(strike_range, 0, sizeof(strike_range));

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				score_in_range[i][j] = search_range(i, j) == STRIKE_RANGE_YES ? j - i + 1 : 0;
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				score_in_range[0][i] = std::max(
					score_in_range[0][i],
					score_in_range[0][j] + score_in_range[j + 1][i]
				);
			}
		}

		std::cout << score_in_range[0][n - 1] << std::endl;
	}
}

Measured memory_bytes: 3552
import math
N = int(input())

if N == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ib = factorization(N)

ans = 0
for i in ib:
    count = 0
    tousa = 0
    while int(tousa) <= i[1]:
        count += 1
        tousa = (count*(count+1))/2
    ans += (count-1)
print(ans)

Measured memory_bytes: 9500
package main

import (
  "fmt"
)

func main() {
  initialStones := readProblem()
  minOperationCount := getMinOperationCount(initialStones)
  fmt.Println(minOperationCount)
}

func getMinOperationCount(initialStones []Color) int {
  whiteOnLeft := 0
  redOnRight := 0
  for _, stone := range initialStones {
    if stone == RED {
      redOnRight++
    }
  }
  
  minOperationCount := len(initialStones) // effectivery infinity
  separator := 0
  for separator <= len(initialStones) {
    operationCount := max(whiteOnLeft, redOnRight)
    if minOperationCount > operationCount {
      minOperationCount = operationCount
    }

    if separator < len(initialStones) {
      if initialStones[separator] == RED {
        redOnRight--
      } else {
        whiteOnLeft++
      }
    } else {
      // we already have minimum value
      // so we don't have anything to do here.
    }
    separator++
  }
  return minOperationCount
}

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

func readProblem() []Color {
  var stoneCount int
  fmt.Scan(&stoneCount)
  var stoneMarks string
  fmt.Scan(&stoneMarks)
  stones := make([]Color, stoneCount)
  idx := 0
  for idx < stoneCount {
    stones[idx] = ReadColor(stoneMarks[idx])
    idx++
  }
  return stones
}

type Color int
const (
  RED Color = iota
  WHITE
)
func ReadColor(colorStr byte) Color {
  if colorStr == 'R' {
    return RED
  }
  return WHITE
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

int main(){
  int n,W; cin>>n>>W;
  ll weight[n];
  ll value[n];
  for(int i=0;i<n;i++){
    cin>>weight[i]>>value[i];
  }

  ll dp[n+1][W+1];

  for(int w=0;w<=W;w++){
    dp[0][w]=0;
  }

  for(int i=0;i<n;i++){
    for(int w=0;w<=W;w++){
      if(w-weight[i]<0) dp[i+1][w]=dp[i][w];
      else dp[i+1][w]=max(dp[i][w],dp[i][w-weight[i]]+value[i]);
    }
  }

  cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define rep(X,A,B) for(int X=A;X<=B;X++)
#define tep(X,A,B) for(int X=A;X>=B;X--)
#define LL long long
#define DB double
const int N=200010;
using namespace std;

char s[N];
int n;
int cnt=0,u[N],v[N];

void ADD(int x,int y){
	cnt++;u[cnt]=x;v[cnt]=y;
}

int CHK(){
	if(s[1]=='0'||s[n]=='1')return 0;
	rep(i,1,n-1){
		if(s[i]!=s[n-i])return 0;
	}
	return 1;
}

void SOLVE(){
	int pos=1,tot=1;
	rep(sz,1,n-1){
		if(s[sz]=='1'){
			tot++;
			ADD(pos,tot);
			pos=tot;
		}
		else{
			tot++;
			ADD(pos,tot);
		}
	}
	rep(i,1,cnt)printf("%d %d\n",u[i],v[i]);
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(CHK()==0){
		printf("-1\n");
		return 0;
	}
	SOLVE();
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

using graph = vector<vector<ll>>;

int main(){
    ll n,d;
    cin >> n >> d;
    ll ans = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x * x + y * y <= d * d){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    while(cin >> S){
        int I=0,J=0;
        for(int i=0; i<S.size()-2; i++){
            if(S.substr(i,3) == "IOI") I++;
            if(S.substr(i,3) == "JOI") J++;
        }
        cout << J << enld;
        cout << I << enld;
    }
    return 0;
}


Measured memory_bytes: 3108
d={}
for i in range(int(input())):
	verdict=input() 
	if verdict in d:
		d[verdict]+=1
	else:
		d[verdict]=1
print('AC x '+str(d.get('AC',0)))
print('WA x '+str(d.get('WA',0)))
print('TLE x '+str(d.get('TLE',0)))
print('RE x '+str(d.get('RE',0)))

Measured memory_bytes: 9212
#include <stdio.h>

int main() {
    
    int a[200000], n, i, max, min;
    
    scanf("%d", &n);
    
    for (i = 0; i <  n; ++i) {
        scanf("%d", &a[i]);
    }
    
    max = -2000000000;
    min = a[0];
    
    for (i = 1; i < n; ++i) {
        if (max < a[i] - min) max = a[i] - min;
        if (min > a[i]) min = a[i];
    }
    
    printf("%d\n", max);
    
    
    return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

bool fun(pair<string,pair<ll,ll> > a, pair<string,pair<ll,ll> > b)
{
	if(a.ff == b.ff)
	{
		return a.ss.ff > b.ss.ff;
	}

	return a.ff < b.ff;

}

int main()
{
	vector< pair<string,pair<ll,ll> > > v;

	ll n;
	cin>>n;

	for(ll i = 0 ; i < n ; i++)
	{
		pair<string,pair<ll,ll> > p;
		cin>>p.ff;
		cin>>p.ss.ff;
		p.ss.ss = i;

		v.push_back(p);
	}

	sort(v.begin(),v.end(),fun);

	for(ll i = 0 ; i < n ; i++)
	{
		cout<<v[i].ss.ss+1<<endl;
	}

}	

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int p[10];
    int max=0;
    int ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&p[i]);
        if(max<p[i]) max=p[i];
        ans+=p[i];
    }
    printf("%d\n",ans-max/2);
}

Measured memory_bytes: 128
import sys
import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

N, M, X = map(int, input().split())
algorithm = [0] * M

prices = []
rikai = []
for _ in range(N):
    C, *A = list(map(int, input().split()))
    prices.append(C)
    rikai.append(A)

idx = range(N)

prices_min = 10 ** 12
flag = False

for i, _ in enumerate(idx, 1):
    for candidate in itertools.combinations(idx, r=i):

        total = 0
        for c in candidate:
            c_arr = np.array(rikai[c])
            total += c_arr

        if np.all(total >= X):
            flag = True
            price = 0
            for c in candidate:
                price += prices[c]

            prices_min = min(price, prices_min)


print(prices_min if flag else '-1')


Measured memory_bytes: 27324
#include<bits/stdc++.h>
using namespace std;;
int main(){
  string S;
  cin >> S;
  if(S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2]||S[0]==S[2]&&S[1]==S[3]&&S[1]!=S[2]||S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1])cout << "Yes"<<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int hoge[5],k,i,j,sum,x;
	
	x = 0;
	
	for(i = 0; i < 5; i++){
		scanf("%d",&hoge[i]);
	}
	
	scanf("%d",&k);
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 4; j++){
			sum = hoge[j+1] - hoge[i];
			if(k < sum){
				x++;
			}
		}
	}
	
	if(x > 0){
		printf(":(\n");
	}
	
	else if(x == 0){
		printf("Yay!\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
l = input().split()
W = int(l[0])
H = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])

if(x>=r and x+r<=W and y>=r and y+r<=H):
   print("Yes")
elif(x<r or x+r>W or y<r or y+r>H):
   print("No")


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<sstream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a-c) <= d) cout << "Yes" << endl;
	else if (abs(a-b) <= d && abs(b-c) <= d)  cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[101000];
long long C[101000], INF = 1e15, S[101000], res;
int main(){
    int i;
    scanf("%d",&n);
    for(i=0;i<=n;i++){
        scanf("%d",&w[i]);
    }
    C[0]=1-w[0];
    for(i=1;i<=n;i++){
        C[i]=min(C[i-1]*2-w[i],INF);
    }
    for(i=0;i<=n;i++){
        if(C[i]<0){
            puts("-1");
            return 0;
        }
    }
    S[n]=w[n];
    for(i=n-1;i>=0;i--){
        S[i] = min(C[i],S[i+1])+w[i];
    }
    for(i=0;i<=n;i++){
        res+=S[i];
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 3668
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b,c;
    cin >> a >> b >> c;
    if(a + b < c ) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


int main(){
  int R; cin >> R;
  if(R < 1200) cout << "ABC" << endl;
  else if(R < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
 
  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

ll f(ll x, ll y, ll z) {
    return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main(){
    ll n;
    cin >> n;
    int m = 0;
    while (m*m<=n) {
        m++;
    }
    vector<int> ans(n+1);
    for (ll i=1;i<=m;i++) {
        for (ll j=1;j<=m;j++) {
            for (ll k=1;k<=m;k++) {
                ll x = f(i, j, k);
                if (x<=n) ans[x]++;
            }
        }
    }
    
    rep(i, n+1) {
        if (i==0) continue;
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	int x,y,ans=0;
	for (int i=1;i<=n;i++)
	{
		cin>>x>>y;
		if (x>=a && y>=b)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

/*struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}*/
struct UnionFind
{
	void init(long n)
	{
		par = new long[](n); foreach (i; 0..n) par[i] = i;
		dist = new long[](n);
	}
	long root(long i)
	{
		if (par[i] == i) return i;
		else
		{
			auto d = distance(par[i]);
			par[i] = root(par[i]);
			dist[i] += d;
			return par[i];
		}
	}
	bool same(long i, long j) { return root(i) == root(j); }
	long distance(long i)
	{
		long d;
		long pos = i;
		while (par[pos] != pos)
		{
			d += dist[pos];
			pos = par[pos];
		}
		return d;
	}
	bool unite(long i, long j, long d)
	{
		auto root_i = root(i);
		auto root_j = root(j);
		auto d_i = distance(i);
		auto d_j = distance(j);
		if (root_i == root_j)
		{
			return d_i - d_j == d;
		}
		else
		{
			par[root_i] = j;
			dist[root_i] = d - d_i;
			return true;
		}
	}
	long[] par;
	long[] dist;
}

void main()
{
	auto N = RD!long;
	auto M = RD!long;
	UnionFind uf;
	uf.init(N);
	foreach (i; 0..M)
	{
		auto L = RD!long - 1;
		auto R = RD!long - 1;
		auto D = RD!long;
		auto r = uf.unite(R, L, D);
		if (!r)
		{
			writeln("No");
			return;
		}
	}

	writeln("Yes");
	stdout.flush();
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 100000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;

string w;
vector<int> alpha(26,0);

int main() {
	cin >> w;
	rep(i, w.size()) {
		char c;
		c = w.at(i);
		int tmp;
		tmp = c - 'a';
		alpha.at(tmp)++;
	}
	rep(i, 26) {
		if (alpha.at(i)%2 !=0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

void Main()
{
	int N;
	cin>>N;
	vecll(A,N);
	vin(A);

	ll money=1000;
	int mi=0;
	for(int i=1; i<N; i++){
		if(A[i]>A[mi]){//でかければ取引
			money = (ll)money - A[mi]*(money/A[mi]) + A[i]*(money/A[mi]);
			mi=i;
		}
		else if(A[i]<A[mi])mi=i;
	}

	cout<<money<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;

int main() {
	long N, D, A;
	cin>>N>>D>>A;
	vector<pair<long, long> >monsters;
	long X, H;
	for(int i=0;i<N;++i){
		cin>>X>>H;
		if(H % A == 0) H /= A;
		else H = H / A + 1;
		monsters.push_back(make_pair(X, H));
	}
	sort(monsters.begin(), monsters.end());
	// しゃくとりみたいにして、どこまで爆風が届くか調べる
	int scope[N];
	int j = 0;
	for(int i=0;i<N;++i){
		while((monsters[j].first - monsters[i].first <= 2*D) & (j<N)){
			j++;
		}
		j--;
		scope[i] = j - i;
	}
	/**
	for(int i=0;i<N;++i){
		cout<<scope[i]<<endl;
	}
	**/
	// 累積和とって、必要な爆弾の数を調べる
	int bomb[N];
	for(int i=0;i<N;++i){
		bomb[i] = 0;
	}
	long ruiseki = 0;
	long ans = 0;
	for(int i=0;i<N;++i){
		ruiseki += bomb[i];
		if(ruiseki < monsters[i].second){
			bomb[i] += monsters[i].second - ruiseki;
			bomb[i+scope[i]+1] -= monsters[i].second - ruiseki;
			ans += monsters[i].second - ruiseki;
			ruiseki += monsters[i].second - ruiseki;
		}
	}
	/**
	for(int i=0;i<N;++i){
		cout<<bomb[i]<<endl;
	}
	**/
	cout<<ans<<endl;
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
#define ll long long
#define N 100123
#define endl '\n'

using namespace std;

ll pow_five(ll x) {
    return x * x * x * x * x;
}

map<ll, ll> is_five;

ll x;

int main() {
    ios_base::sync_with_stdio(0);
    
    cin >> x;

    for(ll i=0; i <= 1000; ++i) {
        is_five[pow_five(i)] = i;
    }

    for(ll i=0; i <= 1000; ++i) {
        if(is_five.find(x - pow_five(i)) != is_five.end()) {
            cout << is_five[x - pow_five(i)] << ' ' << (-i) << endl;
            return 0;
        }
    }

    for(ll i= 0; i <= 10000; ++i) {
        if(is_five.find(x + pow_five(i)) != is_five.end()) {
            cout << is_five[x + pow_five(i)] << ' ' << i << endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;
int n, a[101], b[101], c[101], d[101];
pair < int, int > m[201][201];
vector < pair < int, int > > g[201][201];
int used[201][201];
bool dfs(int x, int y, int time){
    if(used[x][y] == time){
        return 0;
    }
    used[x][y] = time;
    for(int i = 0; i < g[x][y].size(); i++){
        int tox = g[x][y][i].first;
        int toy = g[x][y][i].second;
        if(m[tox][toy].first == -1 || dfs(m[tox][toy].first, m[tox][toy].second, time)){
            m[tox][toy].first = x;
            m[tox][toy].second = y;
            return 1;
        }
    }
    return 0;
}
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> c[i] >> d[i];
        m[c[i]][d[i]].first = -1;
        m[c[i]][d[i]].second = -1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
          if(a[i] < c[j] && b[i] < d[j]){
            g[a[i]][b[i]].push_back({c[j], d[j]});
          }
        }
    }
    for(int i = 1; i <= n; i++){
        dfs(a[i], b[i], i);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(m[c[i]][d[i]].first != -1){
            ans++;
        }
    }
    cout << ans;
}


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

int main() {
  int a, B, C, D;
  cin>>a>>B>>C>>D;
  if(a+B>C+D){
    cout<<"Left"<<endl;}
  if(a+B==C+D){
    cout<<"Balanced"<<endl;}
  if(a+B<C+D){
    cout<<"Right"<<endl;}
}


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

#define PB emplace_back

using namespace std;

const int N = 5e5+100;

long long int fen[N];

void upd(int x, long long int val) {
    for(; x < N - 10; x += (x & (-x))) fen[x] += val;
}

long long int que(int x) {
    long long int ret = 0;
    for(; x >= 1; x -= (x & (-x))) ret+=fen[x];
    return ret;
}

long long int query(int l, int r) {
    return que(r) - que(l-1);
}

int main () {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0 ; i < n ; i++ ) {
        long long int val;
        cin >> val;
        upd(i + 1, val);
    }
    while(m--) {
        int t, l, r;
        cin >> t>> l >> r;
        if(t == 0) {
            upd(l + 1, r);
        }
        else {
            cout << query(l+1 , r) << '\n';
        }
    }
}


Measured memory_bytes: 8248
n = int(input())
arr = [int(x) for x in input().split(' ')]

pre = []

for x in arr:
    if len(pre) == 0:
        pre.append(x)
    else:
        pre.append(pre[len(pre)-1] + x)
        
ans = 0
mod=int(1e9+7)
for i in range(n):
    s = (pre[n - 1] - pre[i]) * arr[i]
    ans = ((ans % mod) + s % mod) % mod
    
print(ans)
    

Measured memory_bytes: 31544
n = int(input())
a,b = [],[]
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if n % 2 == 1:
    print(b[n//2]-a[n//2]+1)
else:
    M = (b[n//2]+b[n//2-1])/2
    m = (a[n//2]+a[n//2-1])/2
    print(int((M-m)*2+1))

Measured memory_bytes: 25524
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

// 整数スキャン（複数）
/*
int x;
scanf("%d",&x);
int y;
scanf("%d",&y);
int z;
scanf("%d",&y);

// n個の整数のスキャン
/*
ll a[n] = {};
rep(i,n){
    scanf("%lld",&a[i]);
}
*/

// 文字列スキャン
/*
string s;
cin >> s;
*/


int main() {
    int n;
    scanf("%d",&n);
    int nn;
    scanf("%d",&nn);

    nn = n*nn;

    if(nn%2==1)yn;




    int ans = 0;

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


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        h: [usize; n],
        ab: [(usize, usize); m],
    }
    let mut ans = vec![true; n];

    for i in 0..m {
        if h[ab[i].0 - 1] <= h[ab[i].1 - 1] {
            ans[ab[i].0 - 1] = false;
        }
        if h[ab[i].1 - 1] <= h[ab[i].0 - 1] {
            ans[ab[i].1 - 1] = false;
        }
    }

    println!("{}", ans.iter().filter(|&&x| x).count());
}


Measured memory_bytes: 6684
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  int a[100000] = {};
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    a[l-1] += 1;
    a[r] -= 1;
  }
  for (int i = 0; i < 100000-1; i++)  a[i+1] += a[i];
  int res = 0;
  for (int i = 0; i < 100000; i++) if (a[i]) res++;
  dump(res);
  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a; ll b, n; cin >> a >> b >> n;
  function<ll(ll)> f = [&](ll x) {
    return x * a / b - x / b * a;
  };
  cout << max({f((n + 1) / b), f(n), n >= b - 1 ? f(b - 1) : 0}) << '\n';
  return 0;
}


Measured memory_bytes: 3652
arr = gets.chomp.split("")
a = arr[0]==="A"
c = arr.slice(2..arr.size-2).count("C") == 1
isLower = arr.select{|e| e =~ /[a-z]/}.size == arr.size - 2
puts (a && c && isLower) ? "AC" : "WA"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 1; i <= (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int gcd2(int &a, int &b){
  int x;
  if(a%b == 0)
    return b;
  else{
    x = a%b;
    return (gcd2(b,x));
  }
}

int gcd1(int &a, int &b, int &c){
    int g1 = gcd2(a,b);
    return (gcd2(g1,c));
}


int main(){
//type
  int k;
  cin >> k;
//solve
  ll total = 0;
  rep(p,k)
    rep(q,k)
      rep(r,k){
        total += gcd1(p,q,r);
      }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 3636
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

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

    bool ok = true;



    int mpp[n + 1] = {0};

    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;

        if(x > n){
            ok = false;
        }

        if(mpp[x] != 0 && mpp[x] != y){
            ok = false;
        }

        if(x == 1 && y == 0) ok = false;

        else mpp[x] = y;
    }

    if(n == 1 && mpp[1] == 0){
        cout << 0;
        return 0;
    }

    if(m == 0 && n == 1){
        cout << 0;
        return 0;
    }

    if(m == 0 && n > 1){
        if(n == 2) cout << "10";
        else cout << "100";
        return 0;
    }

    if(!ok){
        cout << -1;
        return 0;
    }

    if(mpp[1] == 0){
        mpp[1] = 1;
    }

    for(int i = 1; i <= n; i++) cout << mpp[i];
}


Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 200003;

int n , L , a[MAXN] , q , mx , ans , l , r;
int dp[MAXN][19];//dp[i][j]表示从第i个点跳2^j次，最多能跳到的点的下标

void solve() {
    a[n + 1] = 0x7f7f7f7f;
    for(int i = 1 ; i <= n ; ++i) {//二分找到第i个点跳一次最远能到达的点的下标
        dp[i][0] = lower_bound(a + 1 , a + n + 2 , a[i] + L +1) - a - 1;
    }
    for(mx = 1 ; (1 << mx) <= n ; ++mx) {//更新dp[i][j]
        for(int i = 1 ; i <= n ; ++i) {
            dp[i][mx] = dp[dp[i][mx-1]][mx-1];
        }
    }
    --mx;
    scanf("%d" , &q);
    while(q-- >0) {
        scanf("%d%d" , &l , &r);
        if(l > r) {
            swap(l , r);
        }
        ans = 0;
        for(int i = mx ; i >=0 ;--i) {//从权重最大的开始枚举
            if(dp[l][i] < r) {
                ans += 1 << i;
                l = dp[l][i];
            }
        }
        while(l < r) {
            ++ans;
            l = dp[l][0];
        }
        printf("%d\n",ans);
    }
}

int main() {
    while(1 == scanf("%d", &n)) {
        for(int i = 1 ; i <= n ; ++i) {
            scanf("%d" , a+i);
        }
        scanf("%d" , &L);
        solve();
    }
    return 0;
}


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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

ll h,count=0;
   

ll ans(ll h)
{
  if(h==1)
  {
    return 1;
  }

  if(h%2==0)
      {
        h/=2; 
      }else
      {
        h=(h-1)/2;  
      }

      return 2*ans(h)+1;
}
int main() {
   ll i,j,k;
     cin >> h;




  cout << ans(h) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	if A < C {
		A, C = C, A
	}
	if A < B {
		A, B = B, A
	}
	fmt.Println(A*10 + B + C)
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n; cin >> n;
    int x[n]; list(i,n) cin >> x[i];
    int ans = INF;
    rep(i,1,101){
        int cost = 0;
        list(j,n) cost += (x[j]-i)*(x[j]-i);
        ans = min(ans,cost);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}

ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
	ll n;
	cin >> n;
	ll a[n+1];
	forn(i,n+1){
		cin >> a[i];
	}
	ll b[n];
	forn(i,n){
		cin >> b[i];
	}
	ll rem = 0;
	ll ans = 0;
	forn(i,n+1){
		ans += min(rem,a[i]);
		a[i]=max((ll)0,a[i]-rem);
		if(i==n) break;
		ans += min(b[i],a[i]);
		rem=max((ll)0,b[i]-a[i]);
	}
	cout << ans << ln;
}

int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

void YES() {cout << "YES" << endl; exit(0);}
void NO() {cout << "NO" << endl; exit(0);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}


int main() {
  int h, w;
  cin >> h >> w;
  int a, b;
  cin >> a >> b;
  h -= a;
  w -= b;
  cout << h * w << endl;
}
    


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	int n,a,b,c,d[10000],i,j,k;
	cin>>n>>a>>b>>c;
	for(i=0;i!=n;i++)
		cin>>d[i];
	for(i=0;i!=n;i++){
		for(j=i;j!=n;j++){
			if(d[i]<d[j]){
				k=d[i];
				d[i]=d[j];
				d[j]=k;
			}
		}
	}
	k=c/a;
	for(i=0;i!=n;i++){
		c+=d[i];
		a+=b;
		if(k<=c/a)
			k=c/a;
		else
			break;
	}
	cout<<k<<endl;
}

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

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

	int bunshi = n/2+1;
	if(n%2 == 0) cout << 0.5 << endl;
	else cout << (double)bunshi/n << endl;
}


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

#define MAX_K 100001
static const long M = 1000000007;

long N, K, G[MAX_K], ans = 0;

long power(long n, long m){
    long res = 1;
    if (m > 0){
        res = power(n, m / 2);
        if (m % 2 == 0) res = (res * res) % M;
        else res = (((res * res) % M) * n) % M;
    }
    return res;
}

void solve(){
    for(long i = K; i > 0; i--){
        G[i] = power(K / i, N);
        long a = 2;
        while(i * a <= K){
            G[i] -= G[i * a];
            a++;
        }
    }
    for(int i = 1; i <= K; i++){
        ans = (ans + i * G[i]) % M;
    }
    cout << ans << endl;
    return;
}

int main(){
    cin >> N >> K;
    solve();
    return 0;
}

Measured memory_bytes: 4392
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
vector<pair<int,int> > v[2];
int main(void){
  int res;
  int n,f;
  while(cin >> n && n){
    f = res = 0;
    v[0].clear();
    for(int i = 0; i < n; i++){
      int a,b,c,d;
      scanf("%d:%d:%d",&a,&b,&c);
      d = a*3600 + b*60 + c;
      scanf("%d:%d:%d",&a,&b,&c);
      c = a*3600 + b*60 + c;
      v[0].push_back(make_pair(d,c));
    }

    sort(v[0].begin(),v[0].end());

    while((int)v[f].size()){
      res++;
      int b = v[f][0].second;
      v[(f+1)%2].clear();
      for(int i = 1; i < (int)v[f].size(); i++){
	if(v[f][i].first < b){
	  v[(f+1)%2].push_back(v[f][i]);
	}else{
	  b = v[f][i].second;
	}
      }
      f = (f+1)%2;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1444
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  char c;
  int ans=0;
  rep(i,3){
    cin>>c;
    if(c=='1') ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	const int MAXN = 1000000;

	VI dpAll( MAXN, INT_MAX ), dpOdd( MAXN, INT_MAX );
	dpAll[0] = dpOdd[0] = 0;
	REP( i, 0, MAXN )
	{
		REP( j, 1, 1000001 )
		{
			const int s = j * ( j + 1 ) * ( j + 2 ) / 6;
			if ( MAXN <= i + s )
			{
				break;
			}

			dpAll[ i + s ] = min( dpAll[ i + s ], dpAll[i] + 1 );
			if ( s % 2 )
			{
				dpOdd[ i + s ] = min( dpOdd[ i + s ], dpOdd[i] + 1 );
			}
		}
	}

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		cout << dpAll[n] << ' ' << dpOdd[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 8848