akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define pll pair<ll,ll>
#define pii pair<int32_t,int32_t>
#define loop(i,n) for(int64_t i=0; i<n; i++)
#define loop1(i,a,b) for(int64_t i=a; i<=b; i++)
#define rloop(i,n) for(int64_t i=n-1; i>=0; i--) 
#define rloop1(i,a,b) for(int64_t i=a; i>=b; i--) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define print(val) cout << #val << ": " << val << "\n";
#define print_c(a) cout<<#a<<": ";for(auto it=begin(a);it!=end(a);it++)cout<<*it<<" ";cout<<"\n";
#define fill(c,v) fill(begin(c),end(c),v);
template <typename T> T flip(T val) {reverse(begin(val),end(val)); return val;}

string findans(ll n, ll l) {
  if(l==1) {
    string s = ""; 
    char a = 'a' + (n-1);
    s+=a;
    return s;
  } 
  ll temp = (n-1)%26; 
  char a = 'a' + temp;
  return findans( (n-1)/26+1, l-1) + a;
}

int main() {
  // fast_io
  ll t=1; 
  while(t--) {
    ll n; cin >> n;
    ll level = 1;
    ll num = 26; ll a = 26;
    ll prev = 0;
    while(num<n) {
      a*=26;
      prev = num;
      num = num + a;
      level++;
    }
    ll ne = n - prev;
    cout << findans(ne,level) << "\n";
  }
}

Measured memory_bytes: 3568
using namespace std;
#include <bits/stdc++.h>
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <deque>
#include <algorithm>
#include <functional>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (int)(m);i < (int)(n);i++)
#define SZ(x) ((int)(x).size())
#define INF 999999999

typedef long long lint;
#define pb puch_back

using namespace std;

int main(void)
{
	int A, B, C;

	cin >> A >> B >> C;

	if (A == B) {
		cout << C << endl;
	}
	else if (B == C)
	{
		cout << A << endl;
	}
	else if (C == A)
	{
		cout << B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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;
using namespace std;

ll dp[2][1<<12];

int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    vector<int> a(m), x(m);
    int i,j;
    for(i=0; i<m; i++) {
        int num;
        scanf("%d%d", &a[i], &num);
        for(j=0; j<num; j++) {
            int tmp;
            scanf("%d", &tmp); tmp--;
            x[i]+=(1<<tmp);
        }
    }

    for(i=0; i<2; i++) {
        for(j=0; j<(1<<n); j++) {
            dp[i][j]=LINF;
        }
    }
    int prev=0, curr=1;
    dp[prev][0]=0;
    for(i=0; i<m; i++) {
        for(j=0; j<(1<<n); j++) {
            if(dp[prev][j]!=LINF) {
                dp[curr][j]=MIN(dp[curr][j],dp[prev][j]);

                int j2=(j | x[i]);
                dp[curr][j2]=MIN(dp[curr][j2],dp[prev][j]+a[i]);
            }
        }
        swap(prev,curr);
    }
    if(dp[prev][(1<<n)-1]==LINF) {
        printf("-1\n");
    }
    else {
        printf("%lld\n", dp[prev][(1<<n)-1]);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    int ans = 0;
    for(int i = 0; i < N; ++i)
    {
        int xi;
        cin >> xi;
        ans += 2 * min(xi, K - xi);
    }

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



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<vector<int>> v(n,vector<int>(n-1));
  rep(i,n)rep(j,n-1)cin >> v[i][j],v[i][j]--;
  set<P> st;
  vector<P> nxt;
  rep(i,n){
    if(i < v[i][0])nxt.push_back(make_pair(v[i][0],i));
    else nxt.push_back(make_pair(i,v[i][0]));
  }
  vector<int> l(n,1);
  int roop = n*(n-1)/2;
  ll res = 0;
  while(roop){
    if(nxt.empty())break;
    vector<P> k;
    for(auto au : nxt){
      if(st.count(au)){
        roop--;
        if(l[au.first] < n-1)k.push_back(make_pair(max(au.first,v[au.first][l[au.first]]),min(au.first,v[au.first][l[au.first]])));
        if(l[au.second] < n-1)k.push_back(make_pair(max(au.second,v[au.second][l[au.second]]),min(au.second,v[au.second][l[au.second]])));
        l[au.first]++;
        l[au.second]++;
      }else{
        st.insert(au);
      }
    }
    nxt = k;
    res++;
  }
  cout << (!roop ? res : -1) << endl;







  


  return 0;
}

Measured memory_bytes: 27776
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()
  val k = sc.nextInt()

  println(abc167b(a, b, c, k))
}

private fun abc167b(a: Int, b: Int, c: Int, k: Int): Int {
  val ka = k - a
  if (ka <= 0) return k
  val kab = ka - b
  if (kab <= 0) return a

  return a - kab
}


Measured memory_bytes: 36384
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = min(A[0], B[0])
if B[0] > A[0]:
  re = B[0] - A[0]
else:
  re = 0
for i in range(1, N):
  ans += min(A[i], re)
  A[i] = max(0, A[i] - re)
  ans += min(A[i], B[i])
  if B[i] > A[i]:
    re = B[i] - A[i]
  else:
    re = 0
ans += (min(A[-1], re))
print(ans)

Measured memory_bytes: 18752
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    for line in readlines():
        a = float(line)
        s = 0
        for i in range(10):
            s += a
            if i % 2:
                a /= 3
            else:
                a *= 2
        write("%.16f\n" % s)
solve()



Measured memory_bytes: 5584
n = gets.chomp.to_i

x = []
y = []
h = []
n.times do
  xx, yy, hh = gets.chomp.split.map(&:to_i)
  x.push xx
  y.push yy
  h.push hh
end

def height(center_x, center_y, h, x, y, n)
  # center_h = h[0] + (x[0] - center_x).abs + (y[0] - center_y).abs
  debug = false

  center_h = 0
  n.times do |i|
    if h[i] > 0
      center_h = h[i] + (x[i] - center_x).abs + (y[i] - center_y).abs
      p ['==', center_x, center_y, center_h] if debug
      break
    end
  end

  return false unless center_h >= 1

  n.times do |i|
    should_center_h = h[i] + (x[i] - center_x).abs + (y[i] - center_y).abs
    if h[i] > 0
      if center_h != should_center_h
        p ['a ', center_x, center_y, center_h, x[i], y[i], should_center_h] if debug
        return false
      end
    else # h[i] == 0
      if center_h > should_center_h
        p ['b ', center_x, center_y, center_h, x[i], y[i], should_center_h] if debug
        return false
      end
    end
  end
  return center_h
end

101.times do |i|
  101.times do |j|
    if hei = height(i, j, h, x, y, n)
      puts "#{i} #{j} #{hei}"
      exit
    end
  end
end


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

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)

int main(int argc, char const *argv[])
{
    int n = 0;
    cin >> n;

    vector<int> a(n + 1, 0);
    int maxa = INT_MIN;
    for (int i = 1; i < n + 1; i++) {
        cin >> a[i];
        if (a[i] > maxa) {
            maxa = a[i];
        }
    }

    vector<int> c(maxa, 0);
    for (int v = 0; v <= maxa; v++) {
        c[v] = 0;
    }

    for (int i = 1; i <= n; i++) {
        c[a[i]]++;
    }

    // 積分なので一歩前から進む
    for (int v = 1; v <= maxa; v++) {
        c[v] = c[v] + c[v - 1];
    }

    vector<int> b(n + 1, 0);
    for (int i = n; i >= 1; i--) {
        b[c[a[i]]] = a[i];
        c[a[i]]--;
    }

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

    return 0;
}



Measured memory_bytes: 18292
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  ll n; cin >> n;
  vector<ll> cnt(3, -1);

  ll ans = 1;
  rep(i, n) {
    ll a; cin >> a;

    ll rem = 0;
    rep(j, 3) {
      if(cnt[j] == a - 1) ++rem;
    }
    ans *= rem;
    ans %= MOD;

    rep(j, 3) {
      if(cnt[j] == a - 1) {
        ++cnt[j];
        break;
      }
    }
  }

  cout << ans << endl;
}

// 0 1 2 0 1 0 1 2
// r r r g g b b gb


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
#define q 50000
int binarySearch(int *,int,int);


int main(){
  int a[N],x,y,i,j,count=0,r;

  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&a[i]);
  }
   scanf("%d",&y);
  for(i=0;i<y;i++){
    scanf("%d",&r);
    j=binarySearch(a,x,r);
    if(j==1) count++;
  }

  printf("%d\n",count);
  
  return 0;
}


int binarySearch(int *a,int x,int key){
  int left = 0,right = x,mid;
  while(left<right){
    mid = (left + right)/2;
    if(a[mid]==key) return 1;
    else if(key<a[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
  
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
intvec v;

void input() {
	cin>>N;
}

void solve() {
	for(int i=0; i<N; i++) {
		int A; cin>>A;
		int ok=v.size(), ng=-1;
		while(abs(ok-ng)>1) {
			int mid=(ok+ng)/2;
			if(v[mid]<A) ok=mid;
			else ng=mid;
		}
		if(ok==v.size()) v.pushb(A);
		else v[ok]=A;
	}
	cout<<v.size()<<endl;
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3872
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<int> vec(13); // [0,13)
    vec[0]++;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        vec[d]++;
    }
    int ans = -1;
    bool fg = false;
    for (int i = 0; i < 13; i++) {
        if (vec[i] > 2 || vec[0] > 1) {
            fg = true;
        }
    }

    if (fg) {
        ans = 0;
        cout << ans << endl;
    }
    else {
        vector<int> const_arr;
        for (int i = 0; i < 13; i++) {
            if (vec[i] == 2) {
                const_arr.push_back(i);
                const_arr.push_back(24 - i);
            }
        }
        vector<int> dynamic_arr;
        for (int i = 0; i < 13; i++) {
            if (vec[i] == 1) {
                dynamic_arr.push_back(i);
            }
        }
        int M = dynamic_arr.size();
        vector<int> tmp;
        for (int p = 0; p < (1 << M); p++) {
            bitset<40> bs = p;
            tmp = dynamic_arr;
            for (int i = 0; i < M; i++) {
                if (bs[i] == true) {
                    tmp[i] = 24 - tmp[i];
                    tmp[i] %= 24;
                }
            }
            tmp.insert(tmp.end(), const_arr.begin(), const_arr.end());
            sort(ALL(tmp));
            int diff = 1000;
            for (int pos = 1; pos < tmp.size(); pos++) {
                diff = min(diff, tmp[pos] - tmp[pos - 1]);
            }
            int findif = min(abs(tmp.back() - tmp.front()), 24 - abs(tmp.back() - tmp.front()));
            diff = min(diff, findif);

            ans = max(ans, diff);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3644
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
i = A.index(1)
if K==N:
    print(1)
else:
    print( min(i//(K-1) + (N-i-1)//(K-1) + (i%(K-1)!=0) + ((N-i-1)%(K-1)!=0), ((N-1)//(K-1) + ((N-1)%(K-1)!=0) ) ) )


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



int main(){
    ll N;
    cin >> N;
    vector<string> siritori(N,"");
    vector<string> siritori_check;
    for(int i = 0; i < N; i++) cin >> siritori[i];

    siritori_check = siritori;
    sort(siritori_check.begin(),siritori_check.end());
    auto result = unique(siritori_check.begin() , siritori_check.end());
    siritori_check.erase(result, siritori_check.end());


    if(siritori_check.size() != N){
        cout << "No" <<endl;
        return 0;
    }

    for(int i = 0; i < N - 1; i++){
        if(siritori[i][siritori[i].size() - 1] != siritori[i + 1][0]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;



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

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

double sum = 0.0;
rep(i,0,N) sum += 1.0 / A[i];

cout << 1.0 / sum << "\n";

return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = 1e18;

struct ST {
  ll a, b;
};
bool operator==(const ST& x, const ST& y){
  return (x.a == y.a && x.b == y.b);
}

int N, M;
vector<pair<ll,ll>> G[100005];
vector<ST> states[100005];


int main(){
  cin >> N >> M;
  rep(i,M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,c);
  }

  queue<pair<int,ST>> que;
  que.push(make_pair(0,(ST){1,0}));
  while(!que.empty()){
    pair<int,ST> p = que.front(); que.pop();

    bool flg = false;
    rep(i,states[p.first].size()){
      if(states[p.first][i] == p.second) flg = true;
    }
    if(flg) continue;
    states[p.first].push_back(p.second);

    if(states[p.first].size() > 2){
      cout << 0 << endl;
      return 0;
    }

    rep(i,G[p.first].size()){
      pair<ll,ll> j = G[p.first][i];
      que.push(make_pair(j.first,(ST){-p.second.a,j.second-(p.second.b)}));
    }
  }

  ll lb = 0, ub = INF;
  rep(i,N){
    if(states[i].size() == 1){
      if(states[i][0].a > 0){
        //x+b>0
        lb = max(lb, -states[i][0].b);
      }else{
        //-x+b>0
        ub = min(ub, states[i][0].b);
      }
    }else{
      if(states[i][0].a > 0 && states[i][1].a < 0){
        lb = max(lb, -states[i][0].b);
        ub = min(ub, states[i][1].b);

        //x+a == -x+b <=> x = (b-a)/2 > 0
        if(llabs(states[i][1].b - states[i][0].b)%2 == 0){
          ll x = (states[i][1].b - states[i][0].b) / 2;
          lb = max(lb, x-1);
          ub = min(ub, x+1);
        }
      }
      else if(states[i][0].a < 0 && states[i][1].a > 0){
        ub = min(ub, states[i][0].b);
        lb = max(lb, -states[i][1].b);

        //-x+a == x+b <=> x = (a-b)/2 > 0
        if(llabs(states[i][0].b - states[i][1].b)%2 == 0){
          ll x = (states[i][0].b - states[i][1].b) / 2;
          lb = max(lb, x-1);
          ub = min(ub, x+1);
        }
      }
      else{
        cout << 0 << endl;
        return 0;
      }
    }
  }

  lb++;
  if(ub-lb <= 0) cout << 0 << endl;
  else cout << ub - lb << endl;

  return 0;
}



Measured memory_bytes: 18192
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
int n;
string a, b, c;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b >> c;
	int ans = 0;
	fw (i, 0, n) {
		int lol = inf;
		fw (j, 0, 26) {
			int cnt = 3;
			if (a[i] - 'a' == j) cnt--;
			if (b[i] - 'a' == j) cnt--;
			if (c[i] - 'a' == j) cnt--;
			lol = min(lol, cnt);
		}
		ans += lol;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
string S[410];
bool used[410][410];

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

void solve() {
	cin >> N >> M;
	rep(i, 0, N) cin >> S[i];
	queue<pi> que;
	ll res = 0;
	rep(i, 0, N) {
		rep(j, 0, M) {
			if(used[i][j]) continue;
			int b = 0;
			int w = 0;
			que.push(pi(i, j));
			used[i][j] = true;
			while(!que.empty()) {
				pi p = que.front(); que.pop();
				if(S[p.fst][p.sec] == '.') w++;
				else b++;
				rep(k, 0, 4) {
					int nx = dx[k] + p.fst, ny = dy[k] + p.sec;
					if(0 <= nx && nx < N && 0 <= ny && ny < M) {
						if(!used[nx][ny] && S[p.fst][p.sec] != S[nx][ny]) {
							used[nx][ny] = true;
							que.push(pi(nx, ny));
						}
					}
				}

			}
			res += 1ll * w * b;
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    // As[自分]=好きな対象
    vector<int> As(N+1,-1);
    REP(i,N) {
        int like_ind;
        cin >> like_ind;
        As[i+1] = like_ind;
    }
    int cnt = 0;
    REP(i,N) {
        // 自分よりあとが好きならcheck
        if (As[i+1] < i+1) continue;
        // 両思い
        if (As[As[i+1]] == i+1) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
    while(true) {
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) return 0;
        if(a < b) cout << a << " " << b << endl;
        else cout << b << " " << a << endl;
    }
}




Measured memory_bytes: 3044
#include <stdio.h>
int main(void)
{
  int a,b,k;
  scanf("%d %d %d",&a,&b,&k);
  if ((b-a+1)<=2*k) //全ての数
  {
    int count=b-a+1;
    int buffer=a;
    while(count>0)
    {
      printf("%d\n",buffer);
      count--;
      buffer++;
    }
  }
  else
  {
    int count=0;
    int buffer=a;
    while(count<k)
    {
      printf("%d\n",buffer);
      count++;
      buffer++;
    }
    count=0;
    buffer=b-k+1;
    while(count<k)
    {
      printf("%d\n",buffer);
      count++;
      buffer++;
    }
  }
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_159
{
    class A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            Console.WriteLine(nCm(N, 2) + nCm(M, 2) );
            Console.ReadKey();
        }

        private static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }
    }
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005;
int n, m, p[MX], res;

int parent (int a) {
	return a == p[a] ? a : p[a] = parent(p[a]);
}

void join (int a, int b) {
	p[parent(a)] = parent(b);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	iota(p, p + MX, 0);

	cin >> n >> m;
	while (m--) {
		int a, b;
		cin >> a >> b;
		join(a, b);
	}

	for (int i = 1; i <= n; i++) {
		res += parent(i) == i;
	}

	cout << res - 1 << endl;

	return 0;
}


Measured memory_bytes: 4044
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var to = new List<int>[n];
			for (int i = 0; i < n; i++) {
				to[i] = new List<int>();
			}

			for (int i = 0; i < n - 1; i++) {
				int a = cin.Int() - 1;
				int b = cin.Int() - 1;
				to[a].Add(b);
				to[b].Add(a);
			}

			var c = cin.ArrayInt(n);
			Array.Sort(c);
			Array.Reverse(c);

			long sum = c.Sum() - c[0];
			long[] d = new long[n];
			d[0] = c[0];
			var q = new Queue<int>();
			q.Enqueue(0);
			int count = 0;
			while (q.Count > 0) {
				int cur = q.Dequeue();
				foreach (int next in to[cur]) {
					if (d[next] == 0) {
						++count;
						d[next] = c[count];
						q.Enqueue(next);
					}
				}
			}

			Console.WriteLine(sum);
			Console.WriteLine(string.Join(" ", d));
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 16480
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll x;

int main() {
	cin >> x;
	cout << !x << endl;
	return 0;
}

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

int main(void){
        int N, K;
        cin >> N >> K;
        double se[N+1];
        double sum = 0;
        rep(i,N) {
                int p;
                cin >> p;
                se[i] = sum;
                sum += (p+1)/2.;
        }
        se[N] = sum;
        double ans = 0;
        for (int i = K; i <= N; i++) {
                ans = max(ans, se[i]-se[i-K]);
        }
        cout << setprecision(10) << ans << endl;

        return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto& x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << '\n'; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

const int INF = 0x3F3F3F3F;
const int MAXN = (int) 1e6;
const int MOD = (int) 1e9+7;

//=========================

void run_test() {
    ll n; read(n);
    int ans = 0;
    for(int a = 1; a < n; a++)
        ans += (n - 1) / a;
    println(ans);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3588
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(ll i = 0 ; i < n ; i++)cerr << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const ll max_n = 1e5 + 9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    ll n;
    cin >> n;
    
    set<ll> s;
    map<ll,  ll> m;
    
    for(ll i = 0 ; i < n ; i++){
    	ll x;
    	cin >> x;
    	m[x]++;
    	s.insert(x);
    }
    
    ll sum = 0;
    for(auto it : s){
    	sum += it * m[it];
    }
    
    ll q;
    cin >> q;
    while(q--){
    	ll b , c;
    	cin >> b >> c;
    	
    	sum -= b * m[b];
    	sum += c * m[b];
    	m[c] += m[b];
    	m[b] = 0;
    	s.erase(b);
    	s.insert(c);
    	
    	cout << sum << endl;
    }
    
    
    return 0;
}

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

set<string>ss;
string a[200048],s;
int tot=0,k;

int main()
{
	cin>>s>>k;
	
	int i,j,n=int(s.size());
	
	for(i=0;i<=n-1;i++)
		
		for(j=1;j<=5;j++)
		{
			if(i+j-1>=n) continue;
			ss.insert(s.substr(i,j));
		}	
	
	for(i=1;i<=k-1;i++) ss.erase(ss.begin());
	
	cout<<(*(ss.begin()))<<endl;
	
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s, ans;
	getline(cin, s);
	rep(i, SZ(s)) {
		if (isupper(s[i]))ans += (char)(s[i] + 32);
		else if (islower(s[i]))ans += (char)(s[i] - 32);
		else ans += s[i];
	}
	cout << ans << endl;
}
/*
a:97
A:65
*/


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

int main() {
    int N;
    cin >>N;
    map<string,int> mp;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx=0;
    for(auto p:mp) mx=max(mx,p.second);
    for(auto p:mp) {
        if(p.second != mx) continue;
        cout << p.first <<endl;
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    auto v2 = v;
    sort(ALL(v2));
    
    REP(i,n) {
        if (v[i] < v2[n/2]) OUT(v2[n/2])
        else OUT(v2[n/2-1])
    }

    return 0;
}

Measured memory_bytes: 3840
import sys
import  math
import fractions
from collections import defaultdict
import copy
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()
h=0
for i in range(K):
    h+=A[i]

for i in range(K,N):
    hbef=h
    h+=A[i]-A[i-K]
    print('Yes' if hbef<h else 'No')
        

    

Measured memory_bytes: 33056
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    sum = B[A[0]-1]
    for i in range(1, len(A)):
        sum += B[A[i]-1]
        if A[i] - A[i-1] == 1:
            sum += C[A[i-1]-1]
    print(sum)
    return

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

  for (int m = 0; m < 1e5; ++m) {
    int a = m * 0.08;
    int b = m * 0.1;
    if (a == A && b == B) {
      cout << m << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
//累乗(power)a^n
long long power(int a,int n){
  long long count=a,sum=1;
  while(n>0){
    if(n%2==1)
      sum*=count;
    count*=count;
    n/=2;
  }
  return sum;
}

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int mod0=n/k;
  long long sum=0;
  sum+=power(mod0,3);
  if(k%2==0){
    int mod2=(n+k/2)/k;
    sum+=power(mod2,3);
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    int ave = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i]; ave += A[i];
    }
    double ave_t = ave / (N * 1.0);
    vector<double> diff(N, 0.0);
    double mini = 10e8;
    for (int i = 0; i < N; ++i) {
        diff[i] = abs(ave_t - A[i]);
        mini = min(mini, diff[i]);
    }
    for (int i = 0; i < N; ++i) {
        if (mini == diff[i]) {
            printf("%d\n", i);
            return 0;
        }
    }
}


Measured memory_bytes: 3720
/*********************
*  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 <LL,LL>
#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;

LL n,m,p,x,y,z,num[2510],canrn[2510];
pii dp[2510],res[2510];
vector <pii> g[2510];
vector <LL> topo;
bool vis[2510],ok=true;

int dfs(int pos)
{
	vis[pos]=true;
	int ret=0;
	rep(i,g[pos].size())
	{
		if(vis[g[pos][i].fi]) continue;
		ret|=dfs(g[pos][i].fi);
	}
	topo.pb(pos);
	return canrn[pos]=ret|(pos==n ? 1:0);
}

int main()
{
	for(int i=2;i<=2503;i++) dp[i].se=1e9;
	cin>>n>>m>>p;
	rep(i,m)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		g[x].pb({y,z});
	}
	dfs(1);
	reverse(topo.begin(),topo.end());
	rep(i,topo.size()) num[topo[i]]=i;
	rep(i,topo.size())
	{
		for(int j=0;j<topo.size();j++)
		{
			rep(k,g[topo[j]].size())
			{
				if(dp[topo[j]].fi+g[topo[j]][k].se-(dp[topo[j]].se+1)*p>
				dp[g[topo[j]][k].fi].fi-dp[g[topo[j]][k].fi].se*p) 
				dp[g[topo[j]][k].fi]={dp[topo[j]].fi+g[topo[j]][k].se,
				dp[topo[j]].se+1};
				//cout<<g[topo[j]][k].fi<<' '<<dp[g[topo[j]][k].fi].fi<<' '<<dp[g[topo[j]][k].fi].se<<endl;
			}
		}
	}
	rep(i,topo.size()) res[topo[i]]=dp[topo[i]];
	rep(i,topo.size())
	{
		for(int j=0;j<topo.size();j++)
		{
			rep(k,g[topo[j]].size())
			{
				if(dp[topo[j]].fi+g[topo[j]][k].se-(dp[topo[j]].se+1)*p>
				dp[g[topo[j]][k].fi].fi-dp[g[topo[j]][k].fi].se*p) 
				dp[g[topo[j]][k].fi]={dp[topo[j]].fi+g[topo[j]][k].se,
				dp[topo[j]].se+1};
			}
		}
	}
	rep(i,topo.size()) if(res[topo[i]]!=dp[topo[i]]&&canrn[topo[i]]) ok=false;
	if(!ok) puts("-1");
	else cout<<max(0LL,dp[n].fi-dp[n].se*p)<<endl;
	return 0;
}

Measured memory_bytes: 768
/**
    __author__ : srv_twry
**/

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}

bool ge(const ll& a, const ll& b) { return a >= b; }
bool le(const ll& a, const ll& b) { return a <= b; }
bool eq(const ll& a, const ll& b) { return a == b; }
bool gt(const ll& a, const ll& b) { return a > b; }
bool lt(const ll& a, const ll& b) { return a < b; }
int sgn(const ll& x) { return le(x, 0) ? eq(x, 0) ? 0 : -1 : 1; }
/*----------------------------------------------------------------------*/

const int N = 101;
int b[N],a[N];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n; cin>>n;
    FOR(i, 0, n) a[i] = INF;
    FOR(i, 0, n-1) {
    	cin>>b[i];
    	a[i] = min(a[i], b[i]);
    	a[i+1] = min(a[i+1], b[i]);
    }
    int res = 0;
    FOR(i, 0, n) res += a[i];
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,a[200001],ans=0;
	cin>>n;
	REP(i,0,n){
	cin>>a[i];
	if(i==0)continue;
	if(a[i]<a[i-1]){
		ans+=(a[i-1]-a[i]);
		a[i]=a[i-1];
	}
	}
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5204
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> w(n);
	bool a = true;

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

	for (int i = 0; i < n-1; i++) {
		if (w[i].back() != w[i+1].front()) {
			a = false;
		}
	}

	
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (w[i] == w[j]) {
				a = false;
			}
		}
	}
	if (a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
		
	return 0;
}

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

ll d[100001];

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n, k; cin >> n >> k;

  rep(i, n) {
    int a, b; cin >> a >> b;
    d[a] += b;
  }

  ll now = 0;
  rep2(i, 1, 100000) {
    now += d[i];

    if (now >= k) {
      cout << i << endl;
      return (0);
    }
  }
  
  return (0);
}

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

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  double invsum = 0.0;

  for (size_t i = 0; i < n; ++i) {
    int temp;
    cin >> temp;
    invsum += 1.0 / (double)temp;
  }

  cout << 1.0 / invsum;

  return 0;
}


Measured memory_bytes: 256