akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >


// int mod=1e9+7;
// inline int mul(int a,int b){return (a*1ll*b)%mod;}
// inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
// inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
// inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
// inline int inv(int a){return power(a,mod-2);}
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 

const int INF = 1e9;	
#define C(x) ((int)(x-'a'))
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	string s;cin>>s;
	int len = s.length();
	vi fis(26, INF);
	vi mil(len+1, INF);
	vi nx(len+1, INF);
	int i,j;
	vi mans(26, 0);
	for(i=len-1;i>=0;i--){
		for(j=0;j<26;j++){
			if(fis[j]>=INF){
				if(mil[i]>2){
					mil[i] = 2;
					nx[i] = INF + j;
				}
			}
			else{
				if(mil[fis[j]]+1 < mil[i]){
					mil[i] = mil[fis[j]] + 1;
					nx[i] = fis[j];
				}
			}
		}
		mans[C(s[i])] = mil[i];
		fis[C(s[i])] = i;
	}
	pii ans = {INF, -1};
	// trace(mil);
	for(i=0;i<26;i++){
		ans = min(ans, {mans[i], i});

	}
	if(ans.F == 0){
		cout<<char('a'+ans.S);
	}
	else{
		int cur = fis[ans.S];
		// trace(cur);
		while(1){
			if(cur<INF){
				cout<<s[cur];
				cur = nx[cur];
			}
			else{
				cout<<char('a'+cur-INF);
				break;
			}
		}
	}
}


Measured memory_bytes: 2196
n=int(input())
S=input()
a=[0]*n
if S[0]=='W':
  a[0]=1
for i in range(1,n):
  if S[i]=='W':
    a[i]+=a[i-1]+1
  else:
    a[i]+=a[i-1]

N=n-1-(a[-1]-a[0])
M=min(n,N)
for k in range(1,n):
  N=a[k-1]+n-(k+1)-(a[-1]-a[k])
  M=min(M,N)

print(M)


Measured memory_bytes: 15264
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int mi = N;
        int ma = 1;
        for(int i = 0;i < M;i++){
            int l = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            if(ma < l){
                ma = l;
            }
            if(mi > r){
                mi = r;
            }
        }
        if(ma > mi){
            System.out.println(0);
        }else{
            System.out.println(mi-ma+1);
        }
    }
}

Measured memory_bytes: 46232
class ZAlgorithm(object):
    def __init__(self, s: str):
        self.lcp = self.__create_z(s)

    def __call__(self, i: int):
        return self.lcp[i]

    def __create_z(self, s: str):
        n = len(s)
        lcp = [n] + [0]*(n-1)
        l, r = 0, 0

        for t in range(1, n):
            if t>r:
                z = 0
                while t+z<n and s[0+z]==s[t+z]:
                    z += 1
                lcp[t] = z
                if z>0:
                    l, r = t, t+z-1
            else:
                p, b = t-l, r-t+1
                if lcp[p]<b:
                    lcp[t] = lcp[p]
                else:
                    i = r+1
                    while i<n and s[i]==s[i-t]:
                        i += 1
                    lcp[t] = i-t
                    l, r = t, i-1
        return lcp

def main():
    n, s = open(0).read().split()
    a = 0
    for i in range(int(n)-1):
        ss = s[i:]
        z_algo = ZAlgorithm(ss)
        for j in range(len(ss)):
            a = max(a, min(z_algo(j), j))
    print(a)

if __name__ == "__main__":
    main()


Measured memory_bytes: 51420
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
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;}
//------------------------------------------------------------------------------

signed main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long X, long long N, std::vector<long long> p)
{

  set<int> vals;
  for (auto pp : p)
    vals.insert(pp);

  for (int i = 0; i < 100; i++)
  {
    int val = X - i;
    if (vals.find(val) == vals.end())
    {
      cout << val << endl;
      return;
    }
    val = X + i;

    if (vals.find(val) == vals.end())
    {
      cout << val << endl;
      return;
    }
  }
}

int main()
{
  cout << setprecision(10);
  long long X;
  scanf("%lld", &X);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &p[i]);
  }
  solve(X, N, std::move(p));
  return 0;
}


Measured memory_bytes: 3688
#include"bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

lint N, M, A, B;
vector<lint> to[100001];
lint dp[100001];
lint prev_i[100001];
const lint MAX = 1e6;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M;
	REP(i, M) {
		cin >> A >> B;
		to[A].push_back(B);
		to[B].push_back(A);
	}
	REP(i, N + 1) {
		dp[i] = MAX;
	}
	dp[1] = 0;
	queue<lint> que;
	que.push(1);
	while (!que.empty()) {
		lint curr = que.front(); que.pop();
		REP(i, SZ(to[curr])) {
			lint next = to[curr][i];
			if (dp[next] > dp[curr] + 1) {
				dp[next] = dp[curr] + 1;
				prev_i[next] = curr;
				que.push(next);
			}
		}
	}
	bool flag = true;
	FOR(i, 2, N + 1) {
		flag &= (dp[i] != MAX);
	}
	if (!flag) {
		cout << "No";
	}
	else {
		cout << "Yes" << endl;
		FOR(i, 2, N + 1) {
			cout << prev_i[i] << endl;
		}
	}
}


Measured memory_bytes: 13844
a_list = []
a_result = []
b_list = []
for i in range(3):
    a_list.append(list(map(int,input().split())))
    a_result.append([0,0,0])
n = int(input())
for i in range(n):
    b_list.append(int(input()))

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a_list[i][j] == b_list[k]:
                a_result[i][j] = 1
                break

judge = 'No'
for i in range(3):
    if a_result[i][0]*a_result[i][1]*a_result[i][2] == 1:
        judge = 'Yes'
for j in range(3):
    if a_result[0][j]*a_result[1][j]*a_result[2][j] == 1:
        judge = 'Yes'
if a_result[0][0]*a_result[1][1]*a_result[2][2] == 1:
    judge = 'Yes'
if a_result[0][2]*a_result[1][1]*a_result[2][0] == 1:
    judge = 'Yes'

print(judge)

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

using namespace std;

typedef long long ll;

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

	int k;
	cin >> k;

	string s;
	cin >> s;

	int n;
	n = s.size();

	string ans;
	rep(i, n){
		ans.push_back((char)((s[i] - 'A' + k) % 26 + 'A')); 
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
	char alphabet[30] = "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ";

	char input[1000];
	char output[1000];

	char noword[1] = "";

	cin >> input;

	for (int a = 0; a < 1000; a++)
	{
		for (int b = 3; b < 29; b++)
		{
			if (input[a] == alphabet[b])
			{
				output[a] = alphabet[b - 3];
				break;
			}
			else if (b == 28)
			{
				output[a] = noword[0];
			}
		}
	}

	cout << output << endl;

	return 0;
}

Measured memory_bytes: 1140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        Arrays.sort(array);
        // System.out.println(Arrays.toString(array));
        
        long[] cumsum = new long[n+1];
        for (int i = 0; i < n; i++) {
            cumsum[i+1] = cumsum[i] + array[i];
        }
        // System.out.println(Arrays.toString(cumsum));
        
        int ok = 1;
        for (int i = n-1; i > 0; i--) {
            if (cumsum[i] * 2 >= array[i]) {
                ok++;
            } else {
                break;
            }
        }
        System.out.println(ok);
    }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};




int main(){

  int n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] += 0x20;  
  cout << s << endl;
  


  return 0;
}


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

int main() {
  
  int64_t N;
  cin >> N;
  int64_t ans=0;
  int flag = 0;
  
  for(int64_t i=1; i*i<=N; i++){
    if(N%i==0){
     ans = (i-1) + (N/i -1);
      //cout << ans << endl;
     flag = 1;
    }
  }
  
  if(flag == 1) cout << ans << endl;
  else cout << N-1 << endl;

}

Measured memory_bytes: 256
//author : Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define ln "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

const ll MOD = 1e9 + 7;
ll arr[205];

int main()
{
	FASTIO;
	ll n, l;
	cin >> n >> l;
	ll sum = 0;
	for (int i = 1; i < n + 1; i++)
		arr[i] = (l + i - 1), sum += arr[i];
	ll ans = 1e18, mn = 1e18;
	for (int i = 1; i < n + 1; i++)
	{
		ll temp = sum - arr[i];
		if (abs(sum - temp) < mn)
		{
			mn = abs(sum - temp);
			ans = temp;
		}
	}
	cout << ans << ln;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(){ 
    int n, m, c; cin >> n >> m >> c;
    vector<int> B(m); rep(i, m)cin >> B[i];
    vector<vector<int>> A(n, vector<int>(m)); rep(i, n)rep(j, m)cin >> A[i][j];

    int res = 0;
    rep(i, n){
        int score = c;
        rep(j, m){
            score += A[i][j] * B[j];
        }
        if(score>0)res++;
    }
    cout << res << ln;
}



Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;

int N,M;
vector<string> A,B;
bool search(int x, int y);
int main(){
	int N;
	cin >> N;
	int mod = 1e9+7;
	long long power = 1;
	for(int i = 1; i<=N; ++i)
		power = (power*i)%mod;
	cout << power << endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int k = 0;
    rep(i,n)
        if (a[i] != i + 1) k++;
    cout << (k <= 2 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3540
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
int n,a[200010];
bool b=false;
int main(){
	deque <int> q;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(b==true) q.push_front(a[i]);
		if(b==false) q.push_back(a[i]);
		b=!b;
	}
	if(n%2==0)
	{
		while(!q.empty())
		{
			printf("%d ",q.front());
			q.pop_front();
		}
	}
	else
	{
		while(!q.empty())
		{
			printf("%d ",q.back());
			q.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 3712
# -*- coding: utf-8 -*-

N = int(input())
A_list = list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

divisors = list(set(make_divisors(A_list[0]) + make_divisors(A_list[1])))
divisors.sort(reverse=True)

counter = 0
for divisor in divisors:
    for A in A_list:
        if A % divisor != 0:
            counter += 1
        if counter > 1:
            break
    if counter <= 1:
        print(divisor)
        break
    else:
        counter = 0

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i-1] <= a[i]) continue;
        ans += a[i-1] - a[i];
        a[i] = a[i-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4012
def x(p0, p1):
    d = abs(p0 - p1)
    if d > 2:
        return []
    elif d == 2:
        return [(p0 + p1) / 2]
    else:
        m = (p0 + p1) / 2
        v = m - p0
        w = complex(v.imag, -v.real)
        l = abs(w)
        h = (1 - l ** 2) ** .5 * w / l
        return [m + h, m - h]

for e in iter(input, '0'):
    n = int(e)
    P = [complex(*map(float, input().split(','))) for _ in [0] * n]
    Q = []
    for i in range(n):
        for j in range(i + 1, n):
            Q += x(P[i], P[j])
    print(max([sum(1.01 >= abs(q - p) for p in P) for q in Q] + [1]))


Measured memory_bytes: 5732
S = input()

n = len(S)

if not(S == S[::-1]):
  print("No")
  exit()
if not(S[0:((n-1)//2)] == S[((n-1)//2)-1::-1]):
  print("No")
  exit()

if not(S[((n+3)//2)-1:] == S[-1:((n+3)//2)-2:-1]):
  print("No")
  exit()
  
  
print("Yes")

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(void){

    int n, m, i, j;

    cin >> n >> m;

    int a[n][m], b[m], c[n];

    for(i = 0;i < n;i++){

        for(j = 0;j < m;j++){

            cin >> a[i][j];

        }
    }//???????????\???

    for(j = 0;j < m;j++){

        cin >> b[j];

    }//?????????????????\???

    for(i = 0;i < n;i++){

        for(j = 0;j < m;j++){

            if(j == 0) c[i] = a[i][0] * b[0];
            else{c[i] = c[i] + a[i][j] * b[j];
            }

        } 
    }

    for(i = 0;i < n ;i++){

        cout << c[i] << endl;

    }

return 0;

}

Measured memory_bytes: 1196
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi x(n), y(n);
	rep(i, n) cin >> x[i], y[i] = x[i];
	sort(all(y));
	int med = y[n / 2];
	rep(i, n){
		if(!(x[i] < med)) cout << y[(n / 2) - 1] << endl;
		else cout << y[n / 2] << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int a=0,b,N,M;
int arr[10010];
int main(){
	cin>>N>>M;
	b=N+M;
	if(M!=0) {
		arr[1]=1;
		for(int i=1; i<=M; i++) {
		arr[i]=1+i*2;
		}
	}
	if(N!=0) {
		for(int i=M+1; i<=N; i++) {
			int c=0;
			arr[i]=c+2;
			c=c+2;
		}
	}
	for(int i=1; i<=b; i++) {
		for(int j=i+1; j<=b; j++) {
			if((arr[i]+arr[j])%2==0) {
				a++;
			}
		}
	}
	cout<<a<<endl;
}


Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*define
*********************************/
int input_ary[ 10000 ];

/*********************************
*function
*********************************/
int main( void )
{
	int x;
	int y;
	int temp;

	while ( 1 ) {
		scanf( "%d %d", &x, &y );
		
		if( ( 0 == x ) && ( 0 == y ) ) {
			break;
		}

		if ( x > y ) {
			temp = x;
			x = y;
			y = temp;
		}
		printf( "%d %d\n", x, y );
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
typedef long long int ll;
int main()
{
    int n;
    double a;
    a=.50;
    cin>>n;
    int m=n/2;
    m++;
    if(n%2==0)
        cout<<a<<endl;
    else
        cout<<(double)m/n<<endl;

    return 0;
}



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

using namespace std;

const int NS = (int)1e5 + 4;
int N, k;
char arr[NS];

int main(){
    scanf("%d %d", &N, &k);
    scanf("%s", arr + 1);
    int cnt = 0, ans = 0;
    for(int i = 2; i <= N; ++i){
        if(arr[i] != arr[i - 1]) ++cnt;
    }
    ++cnt;
    while(k--){
        if(cnt >= 3){
            ans += 2; cnt -= 2;
        }
        else if(cnt == 2){
            ++ans; cnt = 1;
        }
    }
    for(int i = 1; i <= N; ++i){
        if(arr[i] == 'L' && arr[i - 1] == 'L') ++ans;
        if(arr[i] == 'R' && arr[i + 1] == 'R') ++ans;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];

    vector<int> cnt(n);
    rep(i, n) cnt[i] = 0;
    rep(i, m) {
        cnt[a[i] - 1]++;
        cnt[b[i] - 1]++;
    }
    rep(i, n) {
        put(cnt[i]);
    }
    
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 0113c
bool my_compare(pair<int, pair<ll, ll>> a, pair<int, pair<ll, ll>> b){
    if (a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }

    if (a.second.second != b.second.second){
        return a.second.second < b.second.second;
    }else{
        return true;
    }
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, pair<ll, ll>>> py;
    rep(i, m){
        ll p, y;
        cin >> p >> y;
        py.push_back(make_pair(i, make_pair(p, y)));
    }

    sort(py.begin(), py.end(), my_compare);
    vector<pair<int, string>> ans;
    int dd = 1;
    rep(i, m){
        ll p = py[i].second.first, y = py[i].second.second;
        string ss;
        string tmp = to_string(p);
        rep(j, 6-tmp.size()){
            ss += '0';
        }
        ss += tmp;
        tmp = to_string(dd);
        rep(j, 6-tmp.size()){
            ss += '0';
        }
        ss += tmp;
        if (i!=m-1){
            if (py[i+1].second.first ==  p){
                dd++;
            }else{
                dd = 1;
            }
        }
        ans.push_back(make_pair(py[i].first, ss));

    }

    sort(ans.begin(), ans.end());
    rep(i, m) cout << ans[i].second << endl;

    return 0;
}

Measured memory_bytes: 12400
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

A, B, C = MI()
print('Yes' if A < C < B or B < C < A else 'No')

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

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

	    while(sc.hasNext()){
	        int a = sc.nextInt();
	        int b = sc.nextInt();
	        int c = sc.nextInt();
	        int d = a+b;

	        if((a==-1)&&(b==-1)&&(c==-1))
	            break;
            else{
                if(d>=80)
                    System.out.print("A\n");
                else if(d>=65&&d<80)
                    System.out.print("B\n");
                else if((d>=50&&d<65)||c>=50)
                    System.out.print("C\n");
                else if((d<30)||((a==-1||b==-1)))
                    System.out.print("F\n");
                else if((d>=30)&&(d<50))
                    System.out.print("D\n");

            }
        }
    }
}



Measured memory_bytes: 26264
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    boolean flag = false;
    for(int i = 0;i <= x;i++){
      if(2 * i + 4 * (x - i) == y){
        flag = true;
        break;
      }
    }
    if(flag){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35576
#include <bits/stdc++.h>
 
using namespace std;
const long long MOD = 1e9+7;
int main(){
  
  long long N, K, value;
  
  cin>>N>>K;
 /* vector<long long> powTen(111);
  powTen[0]=1;
  for(int i = 0; i < 110; i++){
    
   	powTen[i+1] = powTen[i]*10;
    powTen[i+1] %= MOD;
    
  }*/
  long long differentValues = 0;
  long long minVal, maxVal;
  vector<long long> sums(N+100);
  for(int i = 1; i < N+100; i++){
      sums[i] = sums[i-1] + i;
  }
  for(int i = K-1; i <= N; i++){
    minVal = sums[i];
    if(i==N)
        maxVal = minVal;
    else    
        maxVal = sums[N]-sums[N-i-1]; 
    //cout<<'\n'<<minVal<<' '<<maxVal<<'\n';
  	differentValues = differentValues + maxVal - minVal + 1;
    differentValues %= MOD;
   // cout<<differentValues<<' ';
  }
  cout<<differentValues;
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; ++i) {
    cin >> v[i];
  }

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

  double ans = v[0];
  for(int i = 0; i < N - 1; ++i) {
    ans = (v[i + 1] + ans) / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3708
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  vector<int> sa(n);
  for (int i = 0; i < n; ++i) sa[i] = s[i] % 3;
  vector<int> cnt(3, 0);
  for (int i = 0; i < n; ++i) ++cnt[sa[i]];
  ll ans = 1;
  for (int i = 0; i < 3; ++i) ans *= (ll)cnt[i];

  for (int j = 0; j < n; ++j)
    for (int i = 0; i < j; ++i) {
      int k = (j - i) + j;
      if (k < n) {
        if (s[i] == s[j]) continue;
        if (s[i] == s[k]) continue;
        if (s[j] == s[k]) continue;

        --ans;
      }
    }
  cout << ans << endl;
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			double x1 =  scanner.nextDouble();
			double y1 =  scanner.nextDouble();
			double x2 =  scanner.nextDouble();
			double y2 =  scanner.nextDouble();
			double x3 =  scanner.nextDouble();
			double y3 =  scanner.nextDouble();
			double xp =  scanner.nextDouble();
			double yp =  scanner.nextDouble();

			double v1 =(x2 - x1) *  (yp - y2) - (y2 - y1) *  (xp - x2);
			double v2 =(x3 - x2) *  (yp - y3) - (y3 - y2) *  (xp - x3);
			double v3 =(x1 - x3) *  (yp - y1) - (y1 - y3) *  (xp - x1);
			//System.out.println(v1);
			//System.out.println(v2);
			//System.out.println(v3);

			if ((v1 < 0 && v2 < 0 && v3 < 0) || (v1 > 0 && v2 > 0 && v3 > 0)) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}

		}
		scanner.close();

	}

}



Measured memory_bytes: 30876
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)


Measured memory_bytes: 158756
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

const int MAX_N = 100;
typedef pair<int, int> P;
//pursue the Eulerian trail
int v[MAX_N+1];
vector<P> edge;


int main()
{
        int e1,e2;
        int even,odd;

        fill(v,v+MAX_N+1,0);

        while(cin >> e1 >> e2){
                if(e1==0 && e2==0){
                        while(!edge.empty()){
                                P p = edge.front(); edge.erase(edge.begin());
                                v[p.first]++;
                                v[p.second]++;
                        }
                        for(int i=3;i<MAX_N+1;i++){
                                if(v[i]%2==0){
                                        even++;
                                        v[i] = 0;
                                }else if(v[i]%2!=0){
                                        odd++;
                                        v[i] = 0;
                                }
                        }
                        if(odd==0 && (v[1]%2)!=0 && (v[2]%2)!=0) cout << "OK" << endl;
                        else cout << "NG" << endl;
                        even = 0;
                        odd = 0;
                        v[1] = 0; v[2] = 0;
                        continue;
                }
                edge.push_back(P(e1,e2));
        }

        return 0;
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    Map<Integer, Integer> map = new HashMap<Integer, Integer>();

    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      if (map.containsKey(a)) {
        map.put(a,map.get(a) + 1);
      } else {
        map.put(a,1);
      }
    }

    sc.close();

    int count = 0;

    for (int key : map.keySet()) {
      if (key <= map.get(key)) {
        count += map.get(key) - key;
      } else {
        count += map.get(key);
      }
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 60312
#include <stdio.h>
#include <string.h>

int main(){

	int  i,j;
	int 	x,y,a,b,c;
	int N,M,A[110];
	long long sum=0;
	scanf("%d%d",&N,&M);
	

	for(i=0;i<N;i++){
		scanf("%d",A+i);
		sum +=(long long)A[i];
	}
	if(N==1){
		printf("Yes\n");
		return 0;
	}
	long long gt  = sum/(long long)(4*M);
	double amari = sum - gt * (long long )(4*M);
	if(amari!=0)gt+=1;
	int cnt =0;
	for(i=0;i<N;i++){
		if(A[i]<gt){}
		else{
			cnt++;
		}
	}
	
	if(cnt>=M)printf("Yes\n");
	else	printf("No\n");
 return 0;
 }

Measured memory_bytes: 128
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0]] * N
dp[0] = abc[0]

for i in range(1, N):
    tmp1 = max(dp[i-1][1]+abc[i][0], dp[i-1][2]+abc[i][0])
    tmp2 = max(dp[i-1][0]+abc[i][1], dp[i-1][2]+abc[i][1])
    tmp3 = max(dp[i-1][0]+abc[i][2], dp[i-1][1]+abc[i][2])
    dp[i] = [tmp1, tmp2, tmp3]
print(max(dp[N-1]))



Measured memory_bytes: 100184
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a;
  cin >> a;
  int b[a],c[a],d[a-1],sum=0;
  rep(i,a){
    cin >> b[i];
  }
  rep(i,a){
    cin >> c[i];
  }
  rep(i,a-1){
    cin >> d[i];
  }
  rep(i,a){
    sum += c[i];
    if(b[i]==b[i-1]+1) sum += d[b[i-1]-1];
  }
  cout << sum;
}

Measured memory_bytes: 3548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long[] A;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadLongArray();
            Array.Sort(A);
            long mx = A[N - 1];
            long mn = A[0];

            List<string> ret = new List<string>();

            // 両端を除く
            for (int i = 1; i < N - 1; i++)
            {
                if (A[i] < 0)
                {
                    ret.Add($"{mx} {A[i]}");
                    mx -= A[i];
                }
                else
                {
                    ret.Add($"{mn} {A[i]}");
                    mn -= A[i];
                }
            }

            ret.Add($"{mx} {mn}");
            Console.WriteLine(mx - mn);
            foreach (var line in ret)
            {
                Console.WriteLine(line);
            }
        }
    }
    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 34644
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int width, hight, x, y, r;

    scanf("%d %d %d %d %d", &width, &hight, &x, &y, &r);

    if(x+r>width || y+r>hight ||
    x-r<0 || y-r<0){
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    
    return 0;
}


Measured memory_bytes: 2144
#include <stdio.h>
#include <stdlib.h>

int cmp(const void* a, const void* b) {
  return *(int*)b - *(int*)a;
}

int main() {
  int n, m, ans;
  scanf("%d%d", &n, &m);
  int x[m], d[m-1];
  for (size_t i = 0; i < m; i++) {
    scanf("%d", x+i);
  }
  qsort(x, m, sizeof(int), cmp);
  for (size_t i = 0; i < m-1; i++) {
    d[i] = x[i] - x[i+1];
  }
  qsort(d, m-1, sizeof(int), cmp);
  ans = x[0] - x[m-1];
  if (m <= n) {
    printf("0\n");
    return 0;
  }
  for (size_t i = 0; i < n-1; i++) {
    ans -= d[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W;cin >> n >> W;
	vector<int> w(n),v(n);
	rep(i,n) cin >> w.at(i) >> v.at(i);
	vector<vector<ll>> dp(n+1,vector<ll>(W+1));
	for(int i=1;i<=n;++i){
		for(int j=0;j<=W;++j){
			if(j-w.at(i-1)>=0) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w.at(i-1)]+v.at(i-1));
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout << dp[n][W] << endl;
}

Measured memory_bytes: 80256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;

#define ll int64_t
const ll MOD = 1e9 + 7;


int main()
{

  ll n, m;
  cin >>  n;

  vector<long> a(n);

  long num4=0;
  long num2=0;
  long num0=0;

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] %4==0)num4++;
    if (a[i] %4!=0 && a[i] %2==0)num2++;
    if (a[i] %4!=0 && a[i] %2!=0)num0++;
  }
  long ans=0;

  num0 +=num2%2;

  if (n%2==0){
    cout <<  ( num0 <=  num4 ? "Yes":"No")<< endl;
  }else{
    if (n>=1){
      cout <<  ( num0-1 <=  num4 ? "Yes":"No")<< endl;
    }else{
      cout <<  ( num0 == 0 ? "Yes":"No")<< endl;
    }
  }



  


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    unordered_map<char, int> m;
    string p;
    REP(i, n) {
        cin >> p;
        m[p[0]]++;
    }
    priority_queue<pair<int, char>> q;
    for (auto r : m) q.emplace(r.second, r.first);

    int ans = 0;
    while (sz(q) >= k) {
        ans++;
        vector<pair<int, char>> v;
        REP(i, k) {
            auto r = q.top(); q.pop();
            if (r.first > 1) v.emplace_back(r.first - 1, r.second);
        }
        for (auto r : v) q.emplace(r);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

#define rep(i, n) for(int i=0; i < n; i++)

const long long INF = 1LL << 60;

int main()
{
	int A, B, C;
	std::cin >> A >> B >> C;
 
	if( ( ( A == C ) && ( B == C ) && ( A == B ) ) &&
		( ( A != 1 ) && ( B != 1 ) && ( C != 1 ) ) )
	{
		std::cout << -1 << std::endl;
		return 0;
	}
 
	int cnt = 0;
	while( ( A % 2 == 0 ) && ( B % 2 == 0 ) && ( C % 2 == 0 ) )
	{
		int a, b, c;
		a = A / 2;
		b = B / 2;
		c = C / 2;
 
		A = b + c;
		B = a + c;
		C = a + b;
 
		cnt++;
	}
 
	std::cout << cnt << std::endl;
 
    return 0;
}


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

int main(void)
{
    long long N, K;
    cin >> N >> K;
    long long ans;
    if (K % 2 == 0)
    {
        ans = (long long)pow(N/K, 3) + (long long)pow((N+(K/2))/K, 3);
    }
    else
    {
        ans = (long long)pow(N/K, 3);
    }


    cout << ans << endl;
}

Measured memory_bytes: 4008
from itertools import product
import copy
H,W,K = list(map(int, input().split()))
A = []
for i in range(H):
  A.append(list(map(int, input())))

#SM = [np.cumsum(A[i]) for i in range(H)]

ANS = []
for pat in product(['0','1'], repeat = H-1):
  res = []
  cnt = 0
  now = copy.copy(A[0])
  for i in range(1,H):
    p = pat[i-1]
    if p == '1':
      res.append(now)
      now = copy.copy(A[i])
      cnt += 1
    else:
      for j in range(W):
        now[j] += A[i][j]
  res.append(now)
  
  """  
  print("---")
  print(pat)
  print(res)
  print(cnt)
  """  
  wk2 = [0] * len(res)
  cnt2 = 0
  flg = True
  for x in range(W):
    for j in range(len(res)):
      if res[j][x] > K:
        # 横に割った段階で、すでに最小単位がKを超えてたら実現不可能
        flg = False
        break
      if wk2[j] + res[j][x] > K:
        cnt2 += 1
        wk2 = [0] * len(res)
        break
    for j in range(len(res)):
      wk2[j] += res[j][x]
    if not flg:
      break
      
  if flg:
    ANS.append(cnt + cnt2)
    #print(pat, cnt, cnt2)
print(min(ANS))


Measured memory_bytes: 75852
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var D = input[1];
            var X = new int[N, D];
            for (int i = 0; i < N; i++)
            {
                input = ReadArrayInt();
                for (int j = 0; j < D; j++)
                {
                    X[i, j] = input[j];
                }
            }
            var cnt = 0;
            for (int i = 0; i < N - 1; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    var tmp = 0;
                    for (int k = 0; k < D; k++)
                    {
                        tmp += (int)Math.Pow(X[i, k] - X[j, k], 2);
                    }
                    var sqr = Math.Sqrt(tmp);
                    if (sqr == (int)sqr) cnt++;
                }
            }

            Console.WriteLine(cnt);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
s = str(input().rstrip())

def battle(s1, s2):
    l = {'g': {'g': 0, 'p': -1}, 'p': {'g': 1, 'p': 0}}
    return l[s1][s2]

hist = ['g']

g = 1
p = 0
ans = 0
if s[0] == 'p':
    ans = -1
for i in range(1, len(s)):
    cur = 'g'
    if s[i] == 'g':
        if p < g:
            cur = 'p'
    if s[i] == 'p':
        if p < g:
            cur = 'p'

    if cur == 'p':
        p += 1
    else:
        g += 1
    hist.append(cur)
    ans += battle(cur, s[i])

# print(list(s))
# print(hist)
print(ans)


Measured memory_bytes: 47324
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = nk[0];
            var num = 0;

            while (true)
            {
                n /= nk[1];
                num++;
                if (n == 0) break;
            }

            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,cnt=0,ans=0;
    cin >> n;
    long a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    for(long i=0;i<n-1;i++){
        cnt += a[i];
        if(2*cnt<a[i+1]) ans = max(i+1,ans);
    }
    if(ans==0) cout << n << endl;
    else cout << n-ans << endl;
}

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

int main(void){
    int a,tmp=-1,count=0;
    std::deque<int> deq;
    deque<int> mode;
    while (cin>>a) {
        deq.emplace_back(a);
    }
    for (int i=0;i<deq.size();i++) {
        for (int j=i+1;j<deq.size();j++) {
            if (deq[i]==deq[j]) {
                count++;
            }
        }
        if (tmp<count) {
            mode.clear();
            tmp=count;
            mode.emplace_back(deq[i]);
        } else if (tmp==count) {
            mode.emplace_back(deq[i]);
        }
        count=0;
    }
    sort(mode.begin(),mode.end());
    for (int k=0;k<mode.size();k++) {
        cout<<mode[k]<<endl;
    }
}



Measured memory_bytes: 3012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a =scan.nextInt();
		int b =scan.nextInt();
        int d,r;
        double f;
        d=a/b;
        r=a%b;
        f=(double)a/(double)b;
        
       System.out.print(d + " ");
       System.out.print(r + " ");
       System.out.println(String.format("%.8f",f));
		
	
		
		
	}

}



Measured memory_bytes: 26576
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main(){
	int n; cin >> n;
	int a[100000];
	int used[100000] = {};
	rep(i, n) {
		cin >> a[i]; a[i]--;
	}
	int now = 0; int cnt = 0;
	while (now != 1) {
		used[now] = 1; cnt++;
		now = a[now];
		if (used[now])break;
	}
	if (now == 1) {
		cout << cnt << endl;
	}
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1024