akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

const ll INF = 1LL<<60;
typedef pair<ll,ll> P;

int n; ll cnt = 1;
P dat[3000000];

void init(){
    int nn = 1;
    while(nn < n) nn *= 2;
    n = nn;
    for (int i=0; i < 2*n-1; i++){
        dat[i] = P(INF,-INF);
    }
}

void update(int a, int b, ll x, int l, int r, int k){
    if (r<=a||b<=l) return;
    if (a<=l&&r<=b) {dat[k]=P(x,cnt);return;}
    update(a,b,x,l,(l+r)/2,2*k+1);
    update(a,b,x,(l+r)/2,r,2*k+2);
}

ll get(int i){
    i = i + n - 1;
    ll last = dat[i].second, val = dat[i].first;
    while(i>0){
        i = (i-1) / 2;
        if(dat[i].second > last) {
            last = dat[i].second;
            val = dat[i].first;
        }
    }
    return val;
}

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<ll> v1;
    vector<pair<ll,pair<ll,ll>>> v2;
    REP(i,N) {
        ll s,t,x; cin >> s >> t >> x;
        v1.push_back(s-x);
        v1.push_back(t-x);
        v2.push_back(make_pair(x,make_pair(s-x,t-x)));
    }
  sort(all(v2),greater<pair<ll,pair<ll,ll>>>());
    vector<ll> hito;
    REP(i,Q){
        ll d; cin >> d;
        v1.push_back(d);
        hito.push_back(d);
    }
    sort(all(v1));
    v1.erase(unique(all(v1)),v1.end());
    n = (int)v1.size();
    init();
    REP(i,N){
        int a = lower_bound(all(v1),v2[i].second.first) - v1.begin();
        int b = lower_bound(all(v1),v2[i].second.second) - v1.begin();
        update(a,b,v2[i].first,0,n,0);
      cnt ++ ;
    }
    REP(i,Q){
        ll ans = get((int)(lower_bound(all(v1),hito[i])-v1.begin()));
        cout << (ans==INF?-1:ans) << endl;
    }
    return 0;
}

Measured memory_bytes: 51320
#include <iostream>
#include <vector>
#include <algorithm>
#include<cmath>
#include <cstring>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

const ll MOD = 1000000007LL;

int main() {

  string S;
  cin >> S;

  ll remainder[13];
  for (ll i = 0; i < 13; i++) {
    remainder[i] = 0;
  }
  remainder[0] = 1;

  ll next_remainder[13];
  for (ll i = 0; i < (ll)S.length(); i++) {
    for (ll i = 0; i < 13; i++) {
      next_remainder[i] = 0;
    }

    if (S[i] == '?') {
      for (ll j = 0; j < 10; j++) {
        for (ll k = 0; k < 13; k++) {
          next_remainder[((k * 10) % 13 + j) % 13] += remainder[k];
          next_remainder[((k * 10) % 13 + j) % 13] %= MOD;
        }
      }
    } else {
      for (ll k = 0; k < 13; k++) {
        next_remainder[((k * 10) % 13 + (S[i] - '0')) % 13] += remainder[k];
        next_remainder[((k * 10) % 13 + (S[i] - '0')) % 13] %= MOD;
      }
    }

    // for (ll i = 0; i < 13; i++) {
    //   cout << next_remainder[i] << ' ';
    // }
    // cout << endl;

    for (ll i = 0; i < 13; i++) {
      remainder[i] = next_remainder[i];
    }
  }
  cout << remainder[5] << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] t = new int[N];
        int[] d = new int[N];
        for (int i = 0; i < N; ++i) {
            t[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        System.out.println(solve(t, d, K));

        sc.close();
    }

    static long solve(int[] t, int[] d, int K) {
        int[] sortedIndices = IntStream.range(0, t.length).boxed().sorted((i1, i2) -> -Integer.compare(d[i1], d[i2]))
                .mapToInt(x -> x).toArray();

        Set<Integer> kinds = new HashSet<>();
        long dSum = 0;
        Stack<Integer> extraDs = new Stack<>();

        for (int i = 0; i < K; ++i) {
            int index = sortedIndices[i];

            dSum += d[index];

            if (kinds.contains(t[index])) {
                extraDs.push(d[index]);
            } else {
                kinds.add(t[index]);
            }
        }

        long result = dSum + (long) kinds.size() * kinds.size();

        for (int i = K; i < sortedIndices.length; ++i) {
            int index = sortedIndices[i];

            if (!extraDs.empty() && !kinds.contains(t[index])) {
                dSum += d[index] - extraDs.pop();
                kinds.add(t[index]);

                result = Math.max(result, dSum + (long) kinds.size() * kinds.size());
            }
        }

        return result;
    }
}

Measured memory_bytes: 62308
#include <bits/stdc++.h>
#define mid (l+r)/2
#define ri node+node+1
#define le node+node
#define ll long long
using namespace std;
const int inf=2e5+9;
ll h[inf],val[inf],n,tree[inf<<2],cnt,ans,dp[inf];
map<ll,ll> mp;

void update(ll node,ll l,ll r,ll idx,ll val){

    if(l==r)
        return void(tree[node]=max(tree[node],val));

    if(idx<=mid)
        update(le,l,mid,idx,val);

    else update(ri,mid+1,r,idx,val);
    tree[node]=max(tree[le],tree[ri]);
}

ll query(ll node,ll l,ll r,ll x,ll y){

    if(l>r || r<x || l>y)
        return 0;
    if(l>=x && r<=y)
        return tree[node];

    return max(query(le,l,mid,x,y),query(ri,mid+1,r,x,y));
}

int main(){

    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>h[i],mp[h[i]];

    for(ll i=1;i<=n;i++)
        cin>>val[i];

    for(auto &o:mp)
        o.second=++cnt;

    for(ll i=1;i<=n;i++){

        dp[i]=query(1,1,cnt,1,mp[h[i]]-1)+val[i];
        update(1,1,cnt,mp[h[i]],dp[i]);
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 23680
#include<iostream>
#include<iomanip>
using namespace std;
int main(void){
    double a{},b{},c{},d{},e{},f{},x{},y{};
    while(cin>>a>>b>>c>>d>>e>>f){
        x=(c*e-b*f)/(a*e-b*d);
        y=(a*f-c*d)/(a*e-b*d);
        if(x==-0.0)x=0.0;
        if(y==-0.0)y=0.0;
        cout<<fixed<<setprecision(3)<<x<<' '<<y<<endl;
    }
    return 0;
}

Measured memory_bytes: 3272
#include<stdio.h>

int main(){
  int i,j,n,k;
  int temp,A[100],minj,count=0;
  
  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  
  for(i = 0 ; i < n-1 ; i++){
    minj = i;
    for(j = i+1 ; j < n ; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(minj != i){
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      count++;
    }
  }
  
  for(j = 0 ; j < n ; j++){
    if(j != n-1){
      printf("%d ",A[j]);
    }
    else if(j == n-1){
      printf("%d\n",A[j]);
    }
  }
  printf("%d\n",count);

  return 0;
}



  



Measured memory_bytes: 2068
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}
const int MOD = 1000000007;
void add(ll &a , ll b){
  a += b;
  if(a >= MOD){
    a -= MOD;
  }
}
string S;
ll dp[210000][5];
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> S;
  dp[0][0] = 1;
  for(int i = 0 ; i < S.size(); i++){
    for(int j = 0 ; j < 5 ; j++){
      if(S[i] != '?'){
        add(dp[i+1][j] , dp[i][j]);
      }
      else{
        add(dp[i+1][j], dp[i][j] * 3 % MOD);
      }
    }
    if(S[i] == 'A' || S[i] == '?'){
      add(dp[i+1][1],dp[i][0]);
    }
    if(S[i] == 'B' || S[i] == '?'){
      add(dp[i+1][2],dp[i][1]);
    }
    if(S[i] == 'C' || S[i] == '?'){
      add(dp[i+1][3],dp[i][2]);
    }
  }

  cout << dp[S.size()][3] << endl;
  return 0;
}


Measured memory_bytes: 4544
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s;
    int i,j,k[26] = {0},a = 0;
    while(scanf("%c",&s) != EOF){
        for(j = 0;j < 26;j++){
            if(s == 'a' + j || s == 'A' + j){
                k[j]++;
            }
        }
    }
    for(i = 0;i < 26;i++){
        printf("%c : %d\n",'a' + i,k[i]);
    }


    return 0;
}

Measured memory_bytes: 1768
def main():
    k, n = map(int, input().split())
    A = [int(x) for x in input().split()]
    # AnからA0までを取り除いたものを初期値にする
    minv = A[n-1] - A[0]
    #️ A0からA1の距離...An-1からAnの距離をkから引いた値を比較してちいさいものが答え
    for i in range(n-1):
        minv = min(minv, k - (A[i+1] - A[i]))
    print(minv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31688
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct ar {
	string name;
	long long int asize;
	map<long long int, long long int>mp;
};
struct order{
	bool assign;
	string name;
	long long int num;
	long long int num2;
};
int a;
long long int getnum(const string st) {
	long long int num = 0;
	while (a!=st.size()&&isdigit(st[a])) {
		num = num * 10 + st[a] - '0';
		a++;
	}
	return num;
}
string getname(const string st) {
	string name;
	while (isalpha(st[a])) {
		name.push_back(st[a]);
		a++;
	}
	return name;
}
order check(const string st,vector<ar>&ars,bool ineq) {
	string name = "";
	int num = -1;
	bool eq = false;
	while (1) {
		if (a == st.size()) {
			if (!ineq) {
				return order{ false,name,num,0 };
			}
			else {
				if (name == "")return order{ false,"",num,0 };
				auto it = find_if(ars.begin(), ars.end(), [=](const ar&aar) {return aar.name == name; });
				if (it == ars.end())throw(false);
				else {
					auto jt = (*it).mp.find(num);
					if (jt == (*it).mp.end())throw(false);
					else {
						return order{ false,"",jt->second,0 };
					}
				}
			}
		}
		if (st[a] == '[') {
			if (name!="") {
				a++;
				num=check(st,ars,ineq).num;
			}
			else {
				throw(false);
			}
		}
		else if (st[a] == ']') {
			a++;
			if (name == "")return order{ false,"",num,0 };
			auto it = find_if(ars.begin(), ars.end(), [=](const ar&aar) {return aar.name == name; });
			if (it == ars.end())throw(false);
			else {
				auto jt = (*it).mp.find(num);
				if (jt == (*it).mp.end())throw(false);
				else {
					return order{ false,"",jt->second,0 };
				}
			}
		}
		else if (isdigit(st[a])) {
			num = getnum(st);
		}
		else if (isalpha(st[a])) {
			name = getname(st);
		}
		else if (st[a] == '=') {
			a++;
			eq = true;
			auto it = find_if(ars.begin(), ars.end(), [=](const ar&aar) {return aar.name == name; });
			if (it == ars.end())throw(false);
			else {
				if (num>=it->asize)throw(false);
				else {
					int anum = check(st, ars, true).num;
					return order{ true,name,num,anum };
				}
			}
		}
	}
}
int main() {
	vector<string>sts;
	while (1) {
		string st; cin >> st;
		if (st != ".")sts.push_back(st);
		else {
			if (sts.empty())break;
			else {

				vector<ar>ars;
				bool ok = true;
				for (int i = 0; i < sts.size(); ++i) {
					a = 0;
					try {

						order o=check(sts[i], ars,false);
						if (o.assign) {
							auto it = find_if(ars.begin(), ars.end(), [=](const ar&aar) {return aar.name == o.name; });
							it->mp[o.num] = o.num2;
						}
						else {
							ars.push_back(ar{ o.name,o.num,map<long long int,long long int>() });
						}
					}
					catch (...) 
					{
						ok = false;
						cout << i + 1 << endl;
						break;
					}
				}
				sts.clear();
				if (ok)cout << 0 << endl;

			}
		}
	}
	return 0;
}

Measured memory_bytes: 3340
#include<iostream>
using namespace std;
int main(){
	int a[1001],n,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=n-1;i>=0;i--){
		cout<<a[i];
		if(i!=0){
			cout<<" ";
		}
	}cout<<endl;
	return 0;
}



Measured memory_bytes: 3096
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
k = int(read())
for ss in s:
    ss = int(ss)
    if ss > 1:
        print(ss)
        break
    else:
        if k > 1:
            k -= 1
        else:
            print(ss)
            break


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


def solve(N: int):
    if N % 10 in (0, 1, 6, 8):
        print("pon")
    elif N % 10 == 3:
        print("bon")
    else:
        print("hon")

    return


# Generated by 1.1.7.1 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
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;

const int N = 20;
int x[N], y[N];

double dist[10010][N][N];

vector<int> G[N][N];
double D[N][N];
int ok[N][N][N];

const double PI = 4 * atan(1);
const double EPS = 1e-9;

int main(){
	int n;
	double r, theta;
	cin >> n >> r >> theta;
	theta = theta / 180 * PI;
	rep(i, n) cin >> x[i] >> y[i];

	rep(i, n) rep(j, n){
		D[i][j] = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
	}

	rep(i, n) rep(j, n) rep(k, n){
		if (i == j || j == k) continue;
		double x1 = x[j] - x[i], y1 = y[j] - y[i];
		double x2 = x[k] - x[j], y2 = y[k] - y[j];

		double ct = (x1*x2 + y1*y2) / (D[i][j]*D[j][k]);
		double t = acos(ct);

		if (abs(t) < theta + EPS) G[i][j].push_back(k), ok[i][j][k] = 1;
	}

	MEMSET(dist, 0x7f);

	priority_queue<tuple<double, int, int, int>> pq;

	rep(i, n) rep(j, n){
		if (i) continue;
		if (i == j) continue;
		if (D[i][j] > r - EPS) continue;
		pq.emplace(-D[i][j], 1, i, j);
		dist[1][i][j] = D[i][j];
	}

	int ans = 0;
	while (!pq.empty()){
		auto t = pq.top();
		pq.pop();
		double d;
		int c, prv, cur;
		tie(d, c, prv, cur) = t;
		d = -d;

		if (dist[c][prv][cur] + EPS < d) continue;

		ans = max(ans, c);

		for (auto v : G[prv][cur]){
			double nd = d + D[cur][v];
			if (r < nd + EPS) continue;
			if (dist[c + 1][cur][v] < nd + EPS) continue;
			dist[c + 1][cur][v] = nd;
			pq.emplace(-nd, c + 1, cur, v);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 32840
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int count = 0;
    if(s[0] == '1')
        count++;
    if(s[1] == '1')
        count++;
    if(s[2] == '1')
        count++;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

int main() {
  int n;
  cin >> n;
  int data[105][15];
  ll profit[105][15];
  REP(i, n) {
    REP(j, 10) { cin >> data[i][j]; }
  }
  REP(i, n) {
    REP(j, 11) { cin >> profit[i][j]; }
  }
  ll ans = -LLONG_MAX;
  for (int bit = 0; bit < (1 << 11); ++bit) {
    int cnt[105] = {};
    for (int i = 0; i < 11; ++i) {
      if (bit & (1 << i)) {
        // 列挙にi番目の要素が含まれる場合の処理
        REP(k, n) {
          if (data[k][i] == 1) cnt[k]++;
        }
      }
    }
    bool flag = true;
    REP(k, n) {
      if (cnt[k] != 0) flag = false;
    }
    if (flag) continue;

    ll tmp = 0;
    REP(t, n) { tmp += profit[t][cnt[t]]; }
    chmax(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val array = IntArray(n){sc.nextInt()}
    var min = array.first()
    var max = array[1] - array[0]
    (1 until n).forEach {
        max = maxOf(max, array[it] - min)
        min = minOf(min, array[it])
    }
    println(max)
}


Measured memory_bytes: 103012
#include<stdio.h>
int main(){
int W,H,x,y,r;
-100<=x,y&&x,y<=100;
0<W,H,r&&W,H,r<=100;
scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

if(2*r<=W&&2*r<=H&&x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
   printf("Yes\n");
}
else{
   printf("No\n");
}



  return 0;
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
using namespace std;

#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

string s;
int n;

int main(){
    cin >> s;
    n = s.size();
    int res = INT_MAX;
    int temp = 0;
    REP(i,n){
        int c = (s[i]-'0')%2;
        if(c==i%2){
            temp++;
        }
    }
    chmin(res,temp);
    temp = 0;
    REP(i,n){
        int c = (s[i]-'0')%2;
        if(c!=i%2){
            temp++;
        }
    }
    chmin(res,temp);
    
    put(res);
    return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	string s;
	while(cin>>A>>B) {
		cout<<(A-1)*(B-1)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,s;
    cin>>a>>b;
    int n1=a.size(),n2=b.size();
    int c[n1+1][n2+1]={},i,j;
    for(i=1;i<=n1;i++)
    {
        for(j=1;j<=n2;j++)
        {
            if(a[i-1]==b[j-1])
            {
                c[i][j]=1+c[i-1][j-1];
                //s+=a[i-1];
            }
            else
                c[i][j]=max(c[i-1][j],c[i][j-1]);
        }
    }
    int n=c[n1][n2];
    string ans;
    i=n1;
    j=n2;
    while(n>0)
    {
        if(c[i-1][j]==c[i][j])
            i-=1;
        else if(c[i][j-1]==c[i][j])
            j-=1;
        else
        {
            i-=1;
            j-=1;
            ans+=a[i];
            n--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V,int NV> class SegTree_1 {
public:
	vector<V> val;
	static V const def=0;
	// static V const def=1LL<<60; min
	V comp(V l,V r){ return max(l,r);};
	
	SegTree_1(){val=vector<V>(NV*2,def);};
	V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return def;
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=comp(v,val[entry]); //上書きかチェック
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};
SegTree_1<int,1<<20> st;

int N,K;
int A[303030];
pair<int,int> P[303030];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	int ma=0;
	FOR(i,N) {
		cin>>x;
		y=st.getval(max(0,x-K),x+K+1)+1;
		ma=max(ma,y);
		st.update(x,y);
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 11260
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
     
    
    map<string, int> m;

    int t;
    cin>>t;
    while(t--){

        string s;
        cin>>s;

        m[s]++;

    }
    int count = 0;

    for(auto i :  m){
        if(i.second >0){
            count++;
        }
    }


    cout<<count<<endl;
}

Measured memory_bytes: 19276
x = int(input())

while(True):
  if x < 2:
    x += 1
  elif x == 2:
    print(x)
    break
  else :
    isPrime = True
    for p in range(2,x):
      if x % p == 0:
        x += 1
        isPrime = False
        break
    if isPrime:
      print(x)
      break
    

Measured memory_bytes: 9116
import java.util.*;
import java.io.*;
public class Main {

    public static void main (String[] args) throws java.lang.Exception
{
    BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
    String[] s1 = inp.readLine().split(" ");
    int A = Integer.parseInt(s1[0]);
    int B = Integer.parseInt(s1[1]);
    if(A<=9 && A>=0 && B<=9 && B>=0){
        System.out.println(A*B);
    }else{
        System.out.println(-1);
    }

    
}
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define all(c) begin(c),end(c)
const ll INF = 1e10;

int main() {
	cin.sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	sort(all(a),greater<int>());
	int cnt = N, sum = 0;
	rep(i, N) {
		if (sum + a[i] < K)sum += a[i];
		else cnt = N - 1 - i;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
def BubbleSort(A,N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for i in range(N-1,0,-1):
            if A[i] < A[i-1]:
                tmp = A[i]
                A[i] = A[i- 1]
                A[i-1] = tmp
                flag = 1
                count = count +1
    print(' '.join(map(str,A)))
    print(count)
            
N = int(input())
A = input()
A = list(map(int,A.split()))
BubbleSort(A,N)


Measured memory_bytes: 5600
#include <stdio.h>
main(){
    int a,b,c;
    int d,e,f;
/*  d=a-b;
    if(d<0)d*=-1;
    e=c-b;
    if(e<0)e*=-1;
    f=c-a;
    if(f<0)f*=-1;
*/
    scanf("%d %d %d",&d,&e,&f);
    int tmp;
    if(d>e){
	tmp=d;
	d=e;
	e=tmp;
    }
    if(e>f){
	tmp=e;
	e=f;
	f=tmp;
    }
    if(d>e){
	tmp=d;
	d=e;
	e=tmp;
    }
//  printf("%d %d %d\n",d,e,f);
    printf("%d\n",f-d);
    return 0;

}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(){
  double x1,x2,y1,y2,a;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  a=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
  printf("%lf\n",sqrt(a));
  return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <map>

int main(){
  int n;
  std::map<int,long long> m;
  std::vector<int> v;
  //mlÛ¶vÛ¶
  long long a,b,c;
  //aÔbP¿cÊ
  bool f;
  while(std::cin>>n && n){
     m.clear();
     v.clear();
     f=true;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000){
	f=false;
	std::cout<<v[i]<<std::endl;}
    }
    if(f)std::cout<<"NA"<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] input = br.readLine().split(" ");
		double x1 = Double.parseDouble(input[0]);
		double y1 = Double.parseDouble(input[1]);
		double x2 = Double.parseDouble(input[2]);
		double y2 = Double.parseDouble(input[3]);

		double a = Math.pow(Math.abs(x1-x2), 2);
		double b = Math.pow(Math.abs(y1-y2), 2);

		System.out.println(String.format("%.6f",Math.sqrt(a+b)));
	}
}

Measured memory_bytes: 24684
n = int(input())
work = sorted([list(map(int, input().split()))
               for i in range(n)], key=lambda x: x[1])

t = 0
flag = True
for w in work:
    t += w[0]
    if t > w[1]:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 55264
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
using namespace std;

struct Data{
    int dep,lastmove[2],s[3][15],top[15];
    Data(){
        for(int i=0;i<3;i++){
            top[i] = -1;
        }
    }
};
bool memo[14348908] = {};

int int_pow(int n,int m){
    int ans = 1;
    while(m--){
        ans *= n;
    }
    return ans;
}

int main(){
    int hoge,n;
    while(cin>>hoge>>n,n || hoge){
        for(int i=0;i<14348908;i++) memo[i] = false;
        Data q_c,q_d,first;
        int m,input,nt,cup,cntempty,state,nowdep;
		bool flag;
        int situ[2] = {-1,1};
        queue<Data> q;
        for(int i=0;i<3;i++){
            cin>>m;
            for(int j=0;j<m;j++){
                cin>>input;
                first.s[i][first.top[i]+1] = input;
                first.top[i]++;
            }
        }
        first.dep = 0;first.lastmove[0] = -1;first.lastmove[1] = -1;
        q.push(first);
        flag = false;
        while(!q.empty()){
            q_c = q.front();
            q.pop();
            //printf("%d\n",q_c.dep);
            if(q_c.dep%1000 == 0){
                //printf("%d\n",q_c.dep);
            }
            //for(int i=0;i<3;i++) printf("%d ",!q_c.s[i].empty());
            //puts("");
            if(q_c.dep == n) break;
            cntempty = 0;
            for(int i=0;i<3;i++){
                if(q_c.top[i] != -1){
                    if(i == 1){
                        cntempty = 0;
                        break;
                    }
                    cntempty++;
                }
            }
            if(cntempty == 1){
                printf("%d\n",q_c.dep);
                flag = true;
                break;
            }
            state = 0;
            for(int i=0;i<3;i++){
                for(int j=0;j<=q_c.top[i];j++){
                    cup = q_c.s[i][j];
                    state += i*int_pow(3,cup-1);
                }
            }
            if(memo[state]) continue;
            memo[state] = true;
            //printf("%d\n",state);
            for(int i=0;i<3;i++){
                for(int j=0;j<2;j++){
                    nt = i+situ[j];
                    if(nt<0 || 3<=nt) continue;
                    q_d = q_c;
                    if((q_c.lastmove[1]==i && q_c.lastmove[0]==nt)
                       || q_d.top[i]==-1) continue;
                    cup = q_d.s[i][q_d.top[i]];
                    q_d.top[i]--;
                    if(q_d.top[nt]!=-1 && cup < q_d.s[nt][q_d.top[nt]]) continue;
                    q_d.s[nt][q_d.top[nt]+1] = cup;
                    q_d.top[nt]++;
                    q_d.dep++;
                    q_d.lastmove[0] = i;q_d.lastmove[1] = nt;
                    q.push(q_d);
                }
            }
        }
        if(!flag) printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 15208
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n,m;cin>>n>>m;
  if(n*2 >= m){
    print(m/2);
    return 0;
  }

  ll ans = n; m -= n*2;
  ans += m/4;
  print(ans);
  return 0;
}

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

int main(void){
    // Your code here!
    long long A,B,K;cin>>A>>B>>K;
    if(K>=A+B){
        cout<<0<<" "<<0<<endl;
        return 0;
    }
    else if(A>=K){
        cout<<A-K<<" "<<B<<endl;
        return 0;
    }
    else{
        cout<<0<<" "<<B-K+A<<endl;
        return 0;
    }
}


Measured memory_bytes: 3592
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int64 l, r;

    cin >> l >> r;

    int64 l2019 = (l / 2019) * 2019;
    l -= l2019;
    r -= l2019;

    if (r - l >= 2019) {
        cout << "0\n";
        return 0;
    }

    r -= ((r - l) / 2019) * 2019;

    int tmin = INF;

    for (int i = l; i < r; i++) {
        for (int j = i + 1; j <= r; j++) {
            int mod = (i * j) % 2019;
            if (mod < tmin) tmin = mod;
        }
    }

    cout << tmin << '\n';



    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict

K=int(input())

if K%2==0:
    print(-1)
    exit()

memo=defaultdict(int)
tmp=0
ans=0
while True:    
    tmp=(tmp*10+7)%K
    ans+=1
    if tmp==0:
        print(ans)
        break
    elif memo[tmp]==1:
        print(-1)
        break
    else:
        memo[tmp]+=1

Measured memory_bytes: 93092
import os
import sys
from io import BytesIO, IOBase
# from collections import defaultdict as dd
# from collections import deque as dq
# import itertools as it
# from math import sqrt, log, log2
# from fractions import Fraction

def main():
    t = 1
    for _ in range(t):
        n = int(input())
        count = 8
        for i in range(400, 2000, 200):
            if i <= n <= i + 200 - 1:
                print(count)
                break
            count -= 1
        #x, y = map(int, input().split())
        #nums = list(map(int, input().split()))
        




































# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 62740
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
    int n;
    cin >> n;
    while(n){
        if(n%10==9){
            cout << "Yes" << endl;
            return 0;
        }
        n/=10;
    }
    cout << "No" << endl;
}


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

a=int(input())
b=int(input())
min_number=min(a,b)
profit=b-a


for i in range(N-2):
	c=int(input())
	if profit<c-min_number:
		profit=c-min_number	
	if min_number>c:
		min_number=c


print(profit)

Measured memory_bytes: 7720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while (true) {
        int n; cin >> n;
        if (!n) break;

        int ans = INF;
        for (int z = 0; z*z*z <= n; z++) {
            for (int y = 0; y*y <= n; y++) {
                int x = n - (z*z*z+y*y);
                if (x>=0) {
                    // cout << x << " " << y << " " << z << endl;
                    ans = min(ans, x+y+z);
                }
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3096
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b = input().split()

    a = int(a)
    b = b.replace('.','')
    b = int(b)
    r = (a * b) // 100
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
def strr():
 a=raw_input()
 return a
def sstrr():
 a=raw_input().split()
 return a
def intt():
 a=int(raw_input())
 return a
def iintt():
 a=[int(s) for s in raw_input().split()]
 return a
def nestt(t):
 a=[raw_input().split() for s in range(t)] 
 return a

nk=iintt()
n=nk[0]
k=nk[1]
a=0
s=1
while n>=s:
 s*=k
 a+=1
if a==0:
 a=1
print a

Measured memory_bytes: 2568
INFTY = 10**5
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]
dist = [[INFTY for _ in range(10)] for _ in range(10)]
for i in range(10):
    dist[i][i] = 0
for i in range(10):
    for j in range(10):
        dist[i][j] = C[i][j]
for k in range(10):
    for i in range(10):
        for j in range(10):
            dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])
cnt = 0
for i in range(H):
    for j in range(W):
        a = A[i][j]
        if a!=-1:
            cnt += dist[a][1]
print(cnt)

Measured memory_bytes: 40284
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807LL;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0);}

func fact(ll a){return a?fact(a-1)*a:1;}

signed main(){
    ll N,K,P;
    cin>>N>>K;
    P=N/K;
    P=P*P*P;
    if(!(K&1)){
        ll Q=N/(K/2)-N/K;
        Q=Q*Q*Q;
        P+=Q;
    }
    cout<<P<<endl;

}
//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;

    ll K; cin >> K;
    ll A[N], B[M]; F0R(i, N) cin >> A[i];
    F0R(i, M) cin >> B[i];

    ll as = 0; F0R(i, N) as += A[i];
    ll bs = 0;
    int bp = 0;
    int ans = 0;
    F0Rd(i, N+1) {
        if (i < N) as -= A[i];
        if (as <= K) {
            while (bp < M && as + bs + B[bp] <= K) {
                 bs += B[bp]; bp++;
            }
            ckmax(ans, i + bp);
        }
//        cout << as << " " << bs << " " << bp << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 




Measured memory_bytes: 6744
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     bool ok=false;
     cin>>n;
     while(n!=0)
     {
      i=n%10;
      n/=10;
      if(i==7) ok=true;
     }
     if(ok) cout<<"Yes";
     else cout<<"No";
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
stack<int>q;
stack<int>p;
int s[15];
bool flag;
void dfs(int x)
{
   if(x==10)
   {
      flag=true;
      return ;
   }
   if(s[x]>q.top())
   {
      q.push(s[x]);
      dfs(x+1);
      q.pop();
   }
   if(s[x]>p.top())
   {
      p.push(s[x]);
      dfs(x+1);
      p.pop();
   }
   return ;
}
int main()
{
   int t;
   scanf("%d",&t);
   q.push(0);
   p.push(0);
   while(t--)
   {
      flag=false;
      for(int i=0;i<10;i++)
         scanf("%d",&s[i]);
      dfs(0);
      if(flag)
         cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
   }
   return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>

int n, N[20];

int solve(int i, int m) {
   if(m==0)
      return 1;
   if(i>=n)
      return 0;
  int res=solve(i+1, m) || solve(i+1, m-N[i]);
  return res;
}

int main() {

 int q, m[200], i, j, k;

  scanf("%d",&n);
  for(i=0; i<n; i++)
     scanf("%d",&N[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
     scanf("%d",&m[i]);
     if(solve(0,m[i])==1)
        printf("yes\n");
     else
        printf("no\n");

   }
   return 0;
}

Measured memory_bytes: 580
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			
			final long MOD = 1000000007;
			
			long without_one = 1;
			long without_both = 1;
			long all = 1;
			
			for(int i = 0; i < N; i++) {
				all *= 10;
				all %= MOD;
				without_one *= 9;
				without_one %= MOD;
				without_both *= 8;
				without_both %= MOD;
			}
			
			//System.out.println(all + " " + without_one + " " + without_both);
			
			final long without_0_9 = (without_one * 2 + MOD - without_both) % MOD;
			final long with09 = (MOD + all - without_0_9) % MOD;
			
			System.out.println(with09);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32884