akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i,n) cin >> v[i];
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	rep(i,n){
		if(v.size() == 2) break;
		double newone = (v[(int)v.size() - 1] + v[(int)v.size() - 2])/2;
		v.pop_back();
		v.pop_back();
		v.push_back(newone);
	}
    cout << fixed << setprecision(15) << (v[0] + v[1])/2 << endl;
}


Measured memory_bytes: 3756
#include<stdio.h>

int main(void)
{
    int n, i;
    
    scanf("%d", &n);
    
    int a[n];
    
    for(i=0; i<n; i++){
        scanf("%d ", &a[i]);
    }
    
    for(i=n-1; i>=0; i--){
        printf("%d", a[i]);
        if(i!=0)    putchar(' ');
    }
    
    putchar('\n');
    
    return 0;
}


Measured memory_bytes: 2040
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;

string l, r;

ll dp[65][2][2][2][2][2];

string to_bin(ll val) {
    string s = "";
    while(val) {
        s += '0' + (val & 1);
        val >>= 1;
    }
    reverse(all(s));
    return s;
}

void upd(ll &x, ll y) {
    x = (x + y) % mod;
}

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int k, x;
    cin >> k >> x;
    fr(i, -1000000, 1000000) {
        if(abs(i - x) < k)
            cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100010;
int mxdep,ans=0;
namespace T{
	const int E=N;
	int to[E],bro[E],head[N],e=0;
	int fa[N];
	inline void init(){
		memset(head,-1,sizeof(head));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	int dfs(int x){
		int dep=0;
		for(int i=head[x];~i;i=bro[i]){
			apmax(dep,dfs(to[i])+1);
		}
		if(x!=1&&dep==mxdep-1&&fa[x]!=1){
			return ans++,-1;
		}
		return dep;
	}
}
int main(){
	int n=ni;
	mxdep=ni;
	ans+=ni!=1;
	T::init();
	for(int i=2;i<=n;T::ae(T::fa[i]=ni,i),i++);
	T::dfs(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
    int a,b,c,ans;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c)ans=1;
    else if(a==b)ans=2;
    else if(a==c)ans=2;
    else if(b==c)ans=2;
    else ans=3;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 1e5 + 5;

ll n, m, k;
ll d[N];

void Solve(){
    cin >> n;
    vector<pii> a(n);
    for(int i = 0, len; i < n; i++){
        cin >> a[i].st >> len;
        a[i].nd = a[i].st + len;
        a[i].st -= len;
    }
    sort(all(a), [](pii x, pii y){
         return x.nd < y.nd;
         });
    int res = 0;
    int mx = -2e9;
    for(int i = 0; i < n; i++){
        if(a[i].st >= mx){
            res++;
            mx = a[i].nd;
        }
    }
    cout << res;

}

int main(){
    Speed;
    int query = 1;
//    cin >> query;
    while(query--) Solve();
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 100000

int Partition(int *,int);

int main() {
  int i,n,A[MAX],m;

  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d",&A[i]);
  }
  n--;
  m = Partition(A,n);

  for(i = 0; i < m ; i ++) {
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[m]);

  for(i = m + 1; i < n; i++) {
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n]);

  return 0;
}

int Partition(int *A, int n) {
  int x,i,j,a;
  x = A[n];
  i = 0;
  for(j = 0; j < n; j++) {
    if(A[j] <= x) {
      a = A[i];
      A[i] = A[j];
      A[j] = a;
      i++;
    }
  }
  A[n] = A[i];
  A[i] = x;
  return i;
}



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

int main() {
  int n;cin>>n;
  int ans=1;
  for(int i=2;i<n+1;i++){
    int power=i*i;
    while(power<=n){
      ans=max(ans,power);
      power*=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [x, y] <- readString
  putStrLn $ f x y

f x y
  | x == y = "="
  | x > y = ">"
  | otherwise = "<"


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t) && t != '-') t = getchar();
	if (t == '-')
	{
		_read(x);
		x *= -1;
		return ;
	}
	while (isdigit(t))
		x = x * 10 + t - '0', t = getchar();
} 
const int MAXN = 2005, MAXM = 2000 * 2000 + 1e5 + 5, mo = 1e9 + 7;
int n, k, f[MAXN][MAXN], fac[MAXM], invfac[MAXM];
inline int C(int n, int m)
{
	return 1ll * fac[n] * invfac[m] % mo * invfac[n - m] % mo;
}
int main()
{
	_read(n), _read(k);
	invfac[0] = fac[0] = fac[1] = invfac[1] = 1;
	if(k == 1)return puts("1"), 0;
	for(int i = 2; i <= MAXM - 5; ++i)fac[i] = 1ll * fac[i - 1] * i % mo, invfac[i] = 1ll * (mo - mo / i) * invfac[mo % i] % mo;
	for(int i = 2; i <= MAXM - 5; ++i)invfac[i] = 1ll * invfac[i] * invfac[i - 1] % mo;
	f[1][0] = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j <= i; ++j)
		{
			if(i ^ j)(f[i][j + 1] += f[i][j] %= mo);
			if(i ^ n)(f[i + 1][j] += 1ll * f[i][j] * C((k - 2) + (i * (k - 1) + j), k - 2) % mo) %= mo;
		}
	cout << 1ll * f[n][n]*fac[n] % mo;
	return 0;
}

Measured memory_bytes: 48000
#include <stdio.h>
#include <math.h>

int main(void){
	int n, i;
	int a, min, max;
	long sum;

	scanf("%d %d", &n, &a);
	sum = min = max = a;

	for(i = 1; i < n; i++){
		scanf("%d", &a);
		min = fmin(min, a);
		max = fmax(max, a);
		sum += a;
	}
	printf("%d %d %ld\n", min, max, sum);

	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << "\n";
}

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

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	
	ll a = abs(x) / d;
	ll ans = 0;
	
	if (a >= k) {
		ans = abs(x) - k * d;
	}
	else {
		if ((k - a) % 2 == 0) {
			ans = abs(x) - a * d;
		}
		else {
			ans = abs(x) - (a + 1) * d;
		}
	}
	
	cout << abs(ans) << endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<ll,ll> p[200005];
ll n,d,a,ans=0;
int main(){
    cin>>n>>d>>a;
    for(int i=1;i<=n;i++){
        cin>>p[i].first>>p[i].second;
        p[i].second=(p[i].second+a-1)/a;
    }
    sort(p+1,p+1+n);
    ll pos=1,mx=p[pos].second;ans+=mx;
    for(int i=2;i<=n;i++){
        while(p[i].first-p[pos].first>2*d){
            mx-=p[pos].second;
            pos++;
        }
        if(p[i].second<=mx) p[i].second=0;
        else p[i].second-=mx,mx+=p[i].second;
        ans+=p[i].second;
    }
    cout<<ans<<endl;
}                     

Measured memory_bytes: 3328
/**Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n>>m;
    if(n==m)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define F  first
#define S  second

/*
bool compare (pair<ll,ll> x,pair<ll,ll> y)
    {   
        if(x.F==y.F)return x.S<y.S;
        return x.F<y.F;
    }
*/
/*
ll lcm(ll a,ll b)
    {
        return (a*b)/__gcd(a,b) ;
    }
*/
int main()
{
    /*  if you are getting wrong on test case 2 then think of another proper logic 
        if you are getting wrong on test case 4 then think of edge cases 
        like n=0,n=n-1&& k=0&& k=k-1;
    */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t>0)
    {
        t--;
        ll n,k,a,b,c,x,y,z;
        ll max=LONG_MIN;
        ll min=LONG_MAX;
        ll flag=0,sum=0;
        ll cnt=0,ans=0,gcd=1;
        cin>>a>>b>>c;
        ll i=0,j=0,l=0;
        for(ll i=a;i<=b;i++)
            {
            	if(i%c==0)cnt++;
            }
        cout<<cnt<<"\n";
    }
}

Measured memory_bytes: 3544
#include<stdio.h>
int main(void)
{
	int a1,a2,a3,a4,b1,b2,b3,b4;
	scanf("%d %d %d %d %d %d %d %d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4);
	if(a1+a2+a3+a4>=b1+b2+b3+b4){
		printf("%d\n",a1+a2+a3+a4);
	}
	else{
		printf("%d\n",b1+b2+b3+b4);
	}
	return 0;
}


Measured memory_bytes: 2064
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int A,B;cin>>A>>B;
    for(int i=B*10;i<=B*10+9;i++){
        if(i*8/100==A&&i/10==B){
            cout << i << endl;
            exit(0);
        }        
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
def d_xor_sum(N):
    from functools import lru_cache

    @lru_cache()
    def f(k):
        # a+b<=k,a xor b <= k を満たす正整数(a,b)の組の個数(ただしa>=b)
        # N=0のとき(u,v)の組は(0,0)の1通り
        # N=1のとき(0,0),(1,1)の2通り
        return (1, 2)[k] if k <= 1 else f(k // 2) + f((k - 1) // 2) + f((k - 2) // 2)

    ans = f(N) % (10**9 + 7)
    return ans

N = int(input())
print(d_xor_sum(N))

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
	int d,t,s; cin>>d>>t>>s;
  
  	float ans=(float)d/s;  
    //   cout<<ans;
  	if(ans<=t) 
      	cout<<"Yes";
 	else 
      	cout<<"No";
  
 return 0; 
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, q;
    cin >> a >> b >> q;

    vl s(a+2);
    s[0] = -INF;
    exrep(i, 1, a) {
        cin >> s[i];
    }
    s[a+1] = INF;

    vl t(b+2);
    t[0] = -INF;
    exrep(i, 1, b) {
        cin >> t[i];
    }
    t[b+1] = INF;

    vl ans(q, INF);
    rep(i, q) {
        ll x;
        cin >> x;
        ll pos_sR = upper_bound(all(s), x) - s.begin();
        ll pos_tR = upper_bound(all(t), x) - t.begin();
        ll sR = abs(s[pos_sR] - x);
        ll tR = abs(t[pos_tR] - x);
        pos_sR--;  pos_tR--;
        ll sL = abs(s[pos_sR] - x);
        ll tL = abs(t[pos_tR] - x);
        chmin(ans[i], max(sL, tL));
        chmin(ans[i], max(sR, tR));
        chmin(ans[i], 2*sL + tR);
        chmin(ans[i], 2*tL + sR);
        chmin(ans[i], 2*sR + tL);
        chmin(ans[i], 2*tR + sL);
    }

    rep(i, q) {
        out(ans[i]);
    }

    re0;
}

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

int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	
	if(a==0)
		cout<<1<<endl;
	else
		if(b==0)
			cout<<2<<endl;
		else
			if(c==0)
				cout<<3<<endl;
			else
				if(d==0)
					cout<<4<<endl;
				else
					cout<<5<<endl;
	return 0;
}

Measured memory_bytes: 3596
# coding: utf-8


import math

def distance(p, q):
    return math.sqrt(p*p + q*q)

n, d = list(map(int, input().split(" ")))
ans = 0
for _ in range(n):
    x, y = list(map(int, input().split(" ")))
    if distance(x, y) <= d:
        ans += 1

print(ans)


Measured memory_bytes: 9180
arys = []

loop {
    input = gets.split
    
    break if input == ["0", "0"]
    arys << input
}

arys.each do |_ary|
    _ary[0].to_i.times do
        _ary[1].to_i.times do
            print("#")
        end
        print("\n")
    end
    print("\n")
end



Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000000
using Graph=vector<vector<int>>;

int main(){
  int N,K;
  cin>>N>>K;
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  vector<ll> plus_sum(N+1,0);
  vector<ll> minus_sum(N+1,0);
  for(int i=0;i<N;i++){
    if(a.at(i)>0){
      plus_sum.at(i+1)+=a.at(i);
    }else{
      minus_sum.at(i+1)+=a.at(i);
    }
    minus_sum.at(i+1)+=minus_sum.at(i);
    plus_sum.at(i+1)+=plus_sum.at(i);
  }

  ll ans=0;
  for(int i=0;i<N-K+1;i++){
    ans=max<ll>(ans,plus_sum.at(N)+minus_sum.at(i+K)-minus_sum.at(i));
    ans=max<ll>(ans,plus_sum.at(i)+plus_sum.at(N)-plus_sum.at(i+K));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    string s = to_string(i);
    string t = s;
    reverse(t.begin(), t.end());
    ans += s == t;
  } 
  cout << ans << endl;

  return 0;
}

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

int main(){
  int a;
  int x=0;
  cin >> a;
  int b[4];
  int y=1;
  for(int i=0; i<4; i++){
    y*=10;
    b[i]=a%y/(y/10);
  }
  
  for(int i=0; i<3; i++){
    if(b[i]==b[i+1]){
      x+=1;
    }
  }
  if(x==0){
    cout << "Good";
  }
  else{
    cout << "Bad";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Yes() std::cout << "Yes" << std::endl
#define No() std::cout << "No" << std::endl
#define Say(s) std::cout << s << std::endl
const ll MOD = 1000000007;
const ll INF = 1061109567;

int main()
{
    ll a, b, c, d;
    std::cin >> a >> b >> c >> d;
    ll max;
    max = c * a;
    max = std::max(max, a * d);
    max = std::max(max, b * d);
    max = std::max(max, b * c);
    Say(max);
    return 0;
}

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

int main() {
  int x,a,ans;
  cin >> x >> a;
  if (x<a) ans = 0;
  else ans = 10;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	int n, k, h[100000], count = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (h[i] >= k) {
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
def bubble_sort(a, n):
    flag = True
    counter = 0
    while flag:
        flag = False
        for j in range(n - 1, 0, -1):
            if a[j] < a[j - 1]:
                counter += 1
                tmp = a[j]
                a[j] = a[j - 1]
                a[j - 1] = tmp
                flag = True
    return counter


def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1])


n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])

counter = bubble_sort(a, n)
print_list_split_whitespace(a)
print(counter)


Measured memory_bytes: 5608
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    int i,j;
    for(i=1; i<=9; i++) {
        for(j=1; j<=9; j++) {
            if(i*j==n) {
                printf("Yes\n"); return 0;
            }
        }
    }
    printf("No\n");


    return 0;
}


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

typedef long long ll;

int Out[233333];
int n, x;

int main(){
	cin >> n;
	for(int i = 1; i < n; i++) cin >> x, Out[x]++;
	for(int i = 1; i <= n; i++) cout << Out[i] << endl;
	return 0;
}

Measured memory_bytes: 4372
#include<stdio.h>
#include<stdlib.h>
int N,Q,S[100005],T,C,i;
 
int c(int *a,int *b)
{
    return *a-*b;
}
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",S+i);
    scanf("%d",&Q);
    for(i=0;i<Q;i++)
    {
        scanf("%d",&T);
        if(bsearch(&T,S,N,sizeof(int),c)!=NULL)
            C++;
    }
    printf("%d\n",C);
    return 0;
}


Measured memory_bytes: 2236
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            String str = sc.next();
            if (str.equals("Y")) {
                System.out.println("Four");
                sc.close();
                return;
            }
        }

        System.out.println("Three");
        sc.close();
    }

}


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

const long long INF = 1LL << 30;
#define v_max 1000
#define w_max 1000000000

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> w(N), v(N);
  for(int n=0; n<N; n++){
    cin >> w[n] >> v[n];
  }
  
  vector<vector<long long int>> dp(N+1, vector<long long int>(N*v_max+1));
  
  for(int n=0; n<=N; n++){
  	for(int m=0; m<=N*v_max; m++){
      dp[n][m] = INF;
    }
  }  
  dp[0][0] = 0;

  for(int n=0; n<N; n++){
  	for(int m=0; m<=N*v_max; m++){
      dp[n+1][m] = min(dp[n+1][m], dp[n][m]);
      if(m - v[n] >= 0) dp[n+1][m] = min(dp[n+1][m], dp[n][m-v[n]] + w[n]);
    }
  }

  for(int m=N*v_max; m>=0; m--){
  	if(dp[N][m] <= M){
		cout << m << endl;
      	break;
    }
  }
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 


ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1000625;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;



void solve(int tc = 0) {
	cin >> x >> y >> z;
	
	cout << ((x + y - 1) / y) * z << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("cowland");
	#endif
	
	// usaco("cowland");
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.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 (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s;
	cin >> s;
	if(s[0] == s[1] && s[0] == s[2])
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[20]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'},b[20];
	int t=0;
	scanf("%s",b);
	for(int i=0;i<=15;i++)
		if(a[i]!=b[i])t++;
	cout<<t<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;


public class Main {
	
	int n;
	
	int solve(int y, int m, int d) {
		int[] lastday = new int[]{20, 19, 20, 19, 20, 19, 20, 19, 20, 19};
		
		int days = 0;
		while (true) {
			int leap = (y % 3 == 0 && m % 2 == 0) ? 1 : 0;
			if (d == lastday[m - 1] + leap + 1) {
				d = 1;
				m++;
				if (m == 11) {
					m = 1;
					y++;
				}
			}
			
			if (y == 1000 && m == 1 && d == 1) {
				break;
			}
			
			d++;
			days++;
		}
		return days;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		String output = "";
		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			output += solve(sc.nextInt(), sc.nextInt(), sc.nextInt()) + "\n";
		}
		sc.close();
		System.out.print(output);
	}

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

}

Measured memory_bytes: 20228
def z_algolithm(S, x):
    length = len(S) - x
    A = [0]*length
    B = [0]
    i = 1; j = 0
    while i < length:
        while i+j < length and S[x+j] == S[x+i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        B.append(min(j, i))
        k = 1
        while k < length - i  and k + A[k] < j :
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    ans = max(B)
    return ans

N = int(input())
S = input()
ans = max([z_algolithm(S, x) for x in range(N)])
print(ans)

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int n;
    cin >> n;
    cout << n * n * n;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)x.size())
using namespace std;

typedef long long lli;
typedef pair<int,int> pii;

int cnt[26],n;
char str[51];

int main() {
	for(int i=0;i<26;i++) cnt[i] = 100;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%s",str);
		
		int m=strlen(str),c[26]={0,};
		for(int j=0;j<m;j++) c[str[j]-'a']++;
		for(int j=0;j<26;j++) cnt[j] = min(cnt[j],c[j]);
	}
	for(int j=0;j<26;j++) while(cnt[j]--) printf("%c",j+'a');
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using iii = pair<int, ii>;

using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvvi = vector<vi>;

const int LIMSQRT = 22370;

//Criba de Eratostenes
vector<bool> marcaje(LIMSQRT, true); //Colocar n = sqrt(limite del problema)
vector<int> primes;
void sieve() { //Ejecutar al principio del programa
	marcaje[0] = marcaje[1] = 0;
	for (int i = 2; i < marcaje.size(); i++)
		if (marcaje[i]) {
			for (int j = i*i; j < marcaje.size(); j += i) marcaje[j] = 0;
			primes.push_back(i);
		}
}

//devuelve el vector de factores primos de N //devuelve el nmero de factores primosde N
vector<int> primeFactors(int N) {
	vector<int> factors;
	int PF_idx = 0, PF = primes[PF_idx];
	while (PF_idx < primes.size() && PF*PF <= N) {
		while (N % PF == 0) {
			N /= PF;
			factors.push_back(PF);
		}
		PF = primes[++PF_idx];
	}
	if (N != 1) factors.push_back(N);
	return factors; // ans;
}

bool res() {
	int n, k;
	cin >> n >> k;
	if (!cin) return false;

	vi v(n);
	int stot = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		stot += v[i];
	}

	//Hallamos los factores primos de stot
	vi fact = primeFactors(stot);

	//Calculamos los divisores de stot con un knapsack

	unordered_set<int> div, divsig;
	div.insert(1);
	for (int i = 0; i < fact.size(); ++i) {
		for (auto it = div.begin(); it != div.end(); ++it) {
			divsig.insert(*it);
			divsig.insert(*it * fact[i]);
		}
		div = divsig;
	}

	vi candidatos;
	for (auto it = div.begin(); it != div.end(); ++it) {
		candidatos.push_back(*it);
	}

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

	for (int i = candidatos.size() - 1; i >= 0; --i) {
		//Calculamos la distancia al múltiplo más cercano

		vi maymult, menmult;

		for (int j = 0; j < n; ++j) {
			menmult.push_back(v[j] % candidatos[i]);
			maymult.push_back(candidatos[i] - (v[j] % candidatos[i]));
		}

		sort(menmult.begin(), menmult.end());
		sort(maymult.begin(), maymult.end());

		int numres = 0;
		int opreal = 0;

		int idx1 = 0, idx2 = 0;
		while (true) {
			if (menmult[idx1] < maymult[idx2]) {
				maymult[idx2] -= menmult[idx1];
				opreal += menmult[idx1];
				++idx1;
				++numres;
			}
			else if (menmult[idx1] > maymult[idx2]) {
				menmult[idx1] -= maymult[idx2];
				opreal += maymult[idx2];
				++idx2;
				++numres;
			}
			else {
				opreal += maymult[idx2];
				++idx1; ++idx2;
				++++numres;
			}

			if (numres <= n && opreal > k) {
				break;
			}
			else if (numres == n && opreal <= k) {
				cout << candidatos[i] << '\n';
				return true;
			}
		}
	}

	return true;
}

int main() {
	sieve();
	while (res()) {}
	return 0;
}

Measured memory_bytes: 384
# PROBLEM C
n = int(input())
As = [int(s) for s in input().split()]
As = [0] + As + [0]
full_cost = sum(abs(a - As[idx - 1]) for idx, a in enumerate(As) if idx - 1 >= 0)
for idx in range(1, len(As) - 1):
    a = As[idx]
    if any([
            As[idx - 1] <= a <= As[idx + 1],
            As[idx - 1] >= a >= As[idx + 1]]):
        ci = full_cost
    elif any([
            a > As[idx + 1] >= As[idx - 1],
            a < As[idx + 1] <= As[idx - 1]]):
        ci = full_cost - 2 * abs(a - As[idx + 1])
    elif any([
            a < As[idx - 1] <= As[idx + 1],
            As[idx + 1] <= As[idx - 1] < a]):
        ci = full_cost - 2 * abs(a - As[idx - 1])
    else:
        assert(False)
    print(ci)

Measured memory_bytes: 14048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
int N;
vi x,y;
double dist(double x1,double x2,double y1,double y2){
    return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}
bool isOK(double index) {
    for (int i = 0; i < N; i++){
        for (int j = i+1; j < N; j++){
            int dx=x[i]-x[j];
            int dy=y[i]-y[j];
            double d=sqrt(dx*dx+dy*dy);
            if(2*index<d)continue;
            double d2=sqrt(pow(index,2)-pow(d/2.0,2));
            double midx=(x[i]+x[j])/2.0;
            double midy=(y[i]+y[j])/2.0;
            double p1x,p1y,p2x,p2y;
            if(dy==0){
                p1x=midx; p1y=midy+d2;
                p2x=midx; p2y=midy-d2;
            }else{
                double theta=atan(-(double)dx/dy);
                p1x=midx+d2*cos(theta);
                p1y=midy+d2*sin(theta);
                p2x=midx-d2*cos(theta);
                p2y=midy-d2*sin(theta);
            }
            bool ok1=true,ok2=true;
            for (int k = 0; k < N; k++){
                if(k==i || k==j)continue;
                if(dist(p1x,x[k],p1y,y[k])>index)ok1=false;
                if(dist(p2x,x[k],p2y,y[k])>index)ok2=false;
            }
            if(ok1 || ok2)return true;
        }
    }
    return false;
}

double binary_search() {
    double ng = 0;
    double ok = 1000.0; 
    while (abs(ok - ng) > 1e-7) {
        double mid = (ok + ng) / 2.0;
        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}
int main() {
    cin>>N;
    for (int i = 0; i < N; i++){
        int a,b;
        cin>>a>>b;
        x.push_back(a);
        y.push_back(b);
    }
    printf("%.7f\n",binary_search());
}


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

typedef struct {
	int a;
	int b;
} OP;

int main()
{
	int N;
	
	while (scanf("%d", &N), N){
		char str[256];
		scanf("%s", str);
		
		OP op[128];
		for (int i = 0; i < N; i++){
			int a, b;
			scanf("%d %d", &op[i].a, &op[i].b);
		}
		
		for (int i = N - 1; i >= 0; i--){
			str[op[i].a - 1] = ((str[op[i].a - 1] - 'a') + (op[i].b - op[i].a)) % 26 + 'a';
			str[op[i].b - 1] = ((str[op[i].b - 1] - 'a') + (op[i].b - op[i].a)) % 26 + 'a';
			swap(str[op[i].a - 1], str[op[i].b - 1]);
		}
		printf("%s\n", str);
	}
	
	return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int S = 100005;
int W , n;
long long dp[N][S];
array<long long, 2> itens[N];

int32_t main(){
	scanf("%d%d" , &n , &W);
	for(int i = 0 ; i < N ; i ++){
		for(int j = 0 ; j < S ; j ++) dp[i][j] = -(long long) 1e18;
	}
	for(int i = 0 ; i < N; i ++){
		dp[i][0] = 0ll;
	}
	for(int i = 1 ; i <= n; i ++){
		scanf("%lld%lld" , &itens[i][0] , &itens[i][1]);
	}
	for(int i = 1 ; i <=n ; i ++){
		for(long long j = 0 ; j <= W ; j ++){
			dp[i][j] = dp[i-1][j];
			if(j >= itens[i][0]){
				dp[i][j] = max(dp[i][j] , itens[i][1] + dp[i-1][j - itens[i][0]]);
			}
		}

	}
	long long ans = 0;
	for(int i = 1 ; i <= n; i ++){
		for(int j = 0 ; j <= W ; j++){
			ans = max(ans , dp[i][j]);
		}
	}
	printf("%lld\n" , ans);
}

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

int main(){
	long long a, b, k;
	cin >> a >> b >> k;
	if(k <= a){
		a -= k;
		k = 0;
	}else{
		k -= a;
		a = 0;
	}

	if(k <= b){
		b -= k;
		k = 0;
	}else{
		k -= b;
		b = 0;
	}
	cout << a << ' ' << b << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392, X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288, X20 = 1048576;
const int MOD = (int)(1e9+7);

void _(){
    int n,k;
    cin >> n >> k;
    if(k&1){
        cout << (ll)(pow(n/k,3));
    }
    else{
        cout << (ll)((ll)pow(n/k,3)+(ll)pow(((n+(k/2))/k),3));
    }


}

int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}





Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
  int n,x,min=1000000,max=-1000000;
  long total=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x;
    if(x < min){
      min = x;
    }if(x > max){
      max = x;
    }
    total += x;
  }
  cout << min << " " << max << " " << total << endl;
  return 0;
}

Measured memory_bytes: 3096
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    N,=pin()
    A=[int(input())for i in range(N)]
    B=sorted(A)
    first=B[-1]
    second=B[-2]
    for a in A:
        if a==first:print(second);continue
        print(first)
          
#%%submit!    
resolve()

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;

	vector<int> a;
	ll sum = 0;
	ll mi = INF;
	for(int i=0; i<n; i++){
		ll t;
		cin >> t;
		a.pb(t);
		sum += t;
		if(t % 10 != 0){
			mi = min(t, mi);
		}
	}

	if(sum % 10 != 0){
		cout << sum << endl;
	}else if(mi != INF){
		cout << sum - mi << endl;
	}else{
		cout << 0 << endl;
	}
	
	return 0;
}


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

int main(){
  int ans=0;
  string S,T="CODEFESTIVAL2016";

  cin>>S;
  for(int i=0;i<16;i++)
    if(S[i]!=T[i])
      ans++;

  cout<<ans<<endl;

  return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

ll GCD(ll a,ll b){
    if(a < b)return GCD(b,a);
    ll r = INF;
    while(r){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(){
  ll N;cin >> N;
  vector<ll> A(N);
  int ec = 0,oc = 0;
  for(int i = 0;i < N;i++){
      cin >> A[i];
      if(A[i] % 2 == 0){
          ec++;
      }else{
          oc++;
      }
  }
  //cout << ec << ' ' << oc << endl;
  while(ec+oc >= 2 && !(ec == 1 && oc == 1)){
      if(ec >= 2){
          ec--;
      }
      if(oc >= 2){
          oc -= 2;
          ec++;
      }
  }
  //cout << ec << ' ' << oc << endl;
  if(ec == 1 && oc == 0){
      cout << "YES" << endl;
  }else{
      cout << "NO" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int n; char s[N];
ll R[N],G[N],B[N],ans;
signed main(){
	cin>>n>>(s+1);
	repeat(i,1,n+1){
		R[i]=R[i-1]+(s[i]=='R');
		G[i]=G[i-1]+(s[i]=='G');
		B[i]=B[i-1]+(s[i]=='B');
	}
	repeat(i,1,n+1){
		#define x(R,G,B) if(s[i]==#R[0])ans+=G[i]*(B[n]-B[i])+B[i]*(G[n]-G[i]);
		x(R,G,B);
		x(G,R,B);
		x(B,G,R);
	}
	repeat(i,1,n+1){
		for(int j=1;j+i+i<=n;j++){
			if(s[j]!=s[j+i] && s[j]!=s[j+i+i] && s[j+i]!=s[j+i+i])
				ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3688
# print('input >>')
N = int(input())
As = list(map(int,(input().split())))
As_even = [e for e in As if e % 2 == 0]

for A in As_even:
    if not(A % 3 == 0 or A % 5 == 0):
        print('DENIED')
        exit()
        
# print('-----output-----')
print('APPROVED')

Measured memory_bytes: 2940
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

nn = inputs[0][0]
kk = inputs[0][1]

def calc(b, kk, nn)
  ret = 0
  pre_blkn = (nn - kk)/b
  addx = pre_blkn*(b - kk)
  pd addx
  ret += addx

  addy = [nn - (kk + b*pre_blkn) + 1, b-kk].min
  pd addy
  ret += addy
end

ans = 0
for b in kk+1..nn # b > kk
  tmp = calc(b, kk, nn)
  pd "b=#{b}: #{tmp}"
  tmp -= 1 if kk == 0
  ans += tmp
end

puts ans



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,H,W;
    cin>>N>>H>>W;
    cout<<(N-H+1)*(N-W+1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin >> N;
    int dp[N][3];
    int h[N][3];

    REP(i,N){
        dp[i][0] = -1;
        dp[i][1] = -1;
        dp[i][2] = -1;
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    }

    dp[0][0] = h[0][0];
    dp[0][1] = h[0][1];
    dp[0][2] = h[0][2];

    FOR(i,1,N){
        REP(j,3){
            REP(k,3){
                if( j!=k && dp[i][j] < h[i][j]+dp[i-1][k])
                dp[i][j] = h[i][j]+dp[i-1][k];
            }
        }
    }

    int ans=-1;
    REP(i,3){
        ans = max(ans, dp[N-1][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	ll n,k;
	cin >> n>>k;
	ll ans = 0;
	if (!k) {
		cout << n*n << endl;
	}
	else {
		FOR(b,k+1,n+1){
			//bを固定
			ans += (b-k)*(n/b);
			ll r = n%b - k + 1;
			if (r>0) ans += r;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

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

Measured memory_bytes: 256