akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
typedef pair<ll, ll> pint;

ll mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

const int m = 2019;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    int x = 1, tot = 0;
    vector<int> cnt(m);
    ll ans = 0;
    rep(i, n) {
        cnt[tot]++;
        tot += (s[i] - '0')*x;
        tot %= m;
        ans += cnt[tot];
        x = x*10%m;
    }
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 3752
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,x,s=0,t=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	{
		if(i*500+j*100+k*50==x)
		s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)
def resolve():
    N = int(input())
    X = list(map(int, input().split(" ")))
    inputOrder = [{"idx": i, "value": v} for i, v in enumerate(X)]
    valueOrder = sorted(inputOrder, key=lambda x: x["value"])
    for i, v in enumerate(valueOrder):
        v["order"] = i

    for i in range(N):
        # valueOrderからiに対応するidxを持つdictを見つける
        # そのdictのorderがN/2-1より小さければ、valueOrder[N/2-1]を返す
        # 　　　　　　　　　　　　　　　大きければ、valueOrder[N/2]を返す
        o = inputOrder[i]
        if o["order"] < N//2:
            print(valueOrder[N//2]["value"])
        else:
            print(valueOrder[N//2-1]["value"])
        

    
if '__main__' == __name__:
    resolve()

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


const int N = 1e5 + 5;
bitset< N> prime;
vector< int> v;

void sieve() {
    prime.set();
    prime[0] = prime[1] = false;

    for (int i = 2; i < N; i++) if (prime[i]) {
            for (int j = i + i; j < N; j += i) prime[j] = false;

            if (i & 1) {
                if (prime[(i + 1) / 2]) v.emplace_back(i);
            }
        }
}

int main() {
    sieve();

    int q;
    scanf("%d", &q);
    while (q--) {
        int a, b;
        cin >> a >> b;
        int res = distance(lower_bound(begin(v), end(v), a), upper_bound(begin(v), end(v), b));
        cout << res << endl;
    }
}

Measured memory_bytes: 640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	ll ans = 0;
	int n, k;
	cin >> n >> k;
	for (int b = k + 1; b <= n; ++b) {
		int l = k;
		int r = b;
		for (; l <= n; l += b, r += b) {
			if (l != 0)
				ans += min(n + 1, r) - l;
			else
				ans += max(0, min(n + 1, r) - (l + 1));
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s; cin>>s;
    if(s.size()<4){
        cout<<"No"<<endl;
    }else{
        if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    
}


Measured memory_bytes: 3528
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long A, B, C;
    cin >> A >> B >> C;
    if(C-(A-B) > 0) cout << (C-(A-B)) << endl;
    else cout << 0 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int n;
	std::cin >> n;
	std::pair <std::pair<std::string, int>, int> p[101];

	for (int i = 0; i < n; ++i) {
		std::string s;
		int a;
		std::cin >> s >> a;
		p[i] = std::make_pair(std::make_pair(s, -a), i+1);
	}

	std::sort(p, p + n);

	for (int i = 0; i < n; ++i) {
		std::cout << p[i].second << std::endl;
	}

}

Measured memory_bytes: 256
INF = 1 << 60

n, k = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

dp = [0]
# refer ahead
n.times do |i|
  # i + 1..k & 1...n
  (i + 1).upto([i + k, n - 1].min) do |j|
    # change min
    cost = dp[i] + (hs[i] - hs[j]).abs
    dp[j] = cost if (dp[j] || INF) > cost
  end
end

p dp.last


Measured memory_bytes: 12940
cnt = Array.new(5, 0)
while ln = gets
  m, n = ln.chomp.split.map(&:to_i)
  cnt[m] += 1
  cnt[n] += 1
end

for i in 1..4
  if cnt[i] == 0 || cnt[i] > 2
    puts "NO"
    break
  end
  if i == 4
    puts "YES"
  end
end

Measured memory_bytes: 1788
N = input()
# N = N[0]
# N = np.array(list(map(int, input().split())))
# print(N, K)
# print(N)
 
if (N[0] == "7") or (N[1] == "7") or (N[2] == "7"):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9040
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextInt();
		PriorityQueue<Shop> queue = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
		    queue.add(new Shop(sc.nextInt(), sc.nextInt()));
		}
		long total = 0;
		while (queue.size() > 0 && m > 0) {
		    Shop s = queue.poll();
		    total += s.price * Math.min(m, s.count);
		    m -= s.count;
		}
		System.out.println(total);
   }
   
   static class Shop implements Comparable<Shop> {
       int price;
       int count;
       
       public Shop (int price, int count) {
           this.price = price;
           this.count = count;
       }
       
       public int compareTo(Shop another) {
           return price - another.price;
       }
   }
}


Measured memory_bytes: 87704
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

def get_val(a):
    return (1+a)/2

current = 0
for i in range(k):
    current += get_val(p_list[i])
max = current

for i in range(k, n):
    current -= get_val(p_list[i-k])
    current += get_val(p_list[i])
    if max < current:
        max = current

print(max)


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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e3;
int na, nb, nc, m;
num a[nsz + 5], b[nsz + 5], c[nsz + 5];

struct triple {
    int a, b, c;
    
    inline triple() {}
    
    inline triple(int a, int b, int c) {
        this->a = a;
        this->b = b;
        this->c = c;
    }
};

bool inline operator < (triple a, triple b) {
    return a.a != b.a ? a.a < b.a : (a.b != b.b ? a.b < b.b : a.c < b.c);
}

bool inline operator < (pair<num, triple> a, pair<num, triple> b) {
    return a.first != b.first ? a.first > b.first : a.second < b.second;
}

set<pair<num, triple>> q;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> na >> nb >> nc >> m;
    cont (i, na) {
        cin >> a[i];
    }
    sort(a + 1, a + na + 1);
    reverse(a + 1, a + na + 1);
    cont (i, nb) {
        cin >> b[i];
    }
    sort(b + 1, b + nb + 1);
    reverse(b + 1, b + nb + 1);
    cont (i, nc) {
        cin >> c[i];
    }
    sort(c + 1, c + nc + 1);
    reverse(c + 1, c + nc + 1);
    m = min(m, na * nb * nc);
    q.insert({a[1] + b[1] + c[1], triple(1, 1, 1)});
    cont (i, m) {
        num sum = (*q.begin()).first;
        triple cur = (*q.begin()).second, nxt;
        q.erase(q.begin());
        cout << sum << endl;
        if (cur.a < na) {
            nxt = cur;
            ++nxt.a;
            q.insert({a[nxt.a] + b[nxt.b] + c[nxt.c], nxt});
        }
        if (cur.b < nb) {
            nxt = cur;
            ++nxt.b;
            q.insert({a[nxt.a] + b[nxt.b] + c[nxt.c], nxt});
        }
        if (cur.c < nc) {
            nxt = cur;
            ++nxt.c;
            q.insert({a[nxt.a] + b[nxt.b] + c[nxt.c], nxt});
        }
    }
}


Measured memory_bytes: 640
import sys
for e in sys.stdin:
    a, op, b = e.split()
    a = int(a)
    b = int(b)
    if op == "+":
        print("%d"%(a+b))
    if op == "-":
        print("%d"%(a-b))
    if op == "*":
        print("%d"%(a*b))
    if op == "/":
        print("%d"%(a/b))
    if op == "?":
        break



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int main() {
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(all(v));
    int count = 0;
    for(int i = 1; i < 3; i++){
        count += v[i] -v[i-1]; 
    }
    print(count);
}

Measured memory_bytes: 764
import Data.Array

main = do
  li <- getLine
  let [n,m] = map read $ words li
  li <- getLine
  let hs = map read $ words li
  co <- getContents
  let abs = map (l2p . map read . words) $ lines co
  let ans = compute n m hs abs
  print ans

l2p [a,b] = (a,b)

compute :: Int -> Int -> [Int] -> [(Int,Int)] -> Int
compute n m hs abs = length [ () | b <- elems ba, b ]
  where
    ha = listArray (1,n) hs
    ba = accumArray (&&) True (1,n) [ (x, ha ! x > ha ! y) | (a,b) <- abs, (x,y) <- [(a,b),(b,a)] ]


Measured memory_bytes: 128712
import java.io.*
import java.util.*

fun solve(A: Long, B: Long){
    listOf(A-B, A+B, A*B).max()!!.let{ println(it) }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    solve(A, B)
}



Measured memory_bytes: 33960
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n;
	cin >> n;
	while(n >= 0){
		if(n%4==0){
			cout << "Yes" << endl;
			return 0;
		}
		n -= 7;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc168_c
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

const double PI = 3.141592653590;
int a, b, h, m;

double go(double d) {
    return sqrt(a*a + b*b - 2*a*b*cos(d * PI / 180));
}

int main() {
    scanf("%d %d %d %d", &a, &b, &h, &m);
    int t = 60*h + m;
    double x = (t/2)%360 + (t%2==1?0.5:0);
    if(x>=360) x -= 360;
    double y = (6*t)%360;
    double rs = min(go(abs(x-y)), go(360-abs(x-y)));
    printf("%.10lf\n", rs);
}


Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int ans = 0;
    string S, T;
    cin >> S >> T;
    rep(i, S.size()) {
        if (S[i] != T[i]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int a[maxn], b[maxn], c[maxn], dp[maxn][3];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0], dp[0][1]=b[0], dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 2560
#pragma warning(disable:6031)
#include<stdio.h>
typedef struct{int Parent,Rank;}UnionFind;
static inline int Root(int x,UnionFind *uf)
{
  if(uf[x].Parent==x)return x;
  else return uf[x].Parent=Root(uf[x].Parent,uf);
}
static inline int Unite(int x,int y,UnionFind *uf)
{
  x=Root(x,uf),y=Root(y,uf);
  if(x==y)return 0;
  uf[x].Parent=y;uf[y].Rank+=uf[x].Rank;return 1;
}
static inline int Size(int x,UnionFind *uf){return uf[Root(x,uf)].Rank;}
static inline int Belong(int x,int y,UnionFind *uf){return Root(x,uf)==Root(y,uf);}
int main(void)
{
  int A,B,C,D,N,M,K;
  scanf("%d %d %d",&N,&M,&K);
  int known[N];
  UnionFind uft[N];
  for(int i=0;i<N;i++){known[i]=0;uft[i].Parent=i;uft[i].Rank=1;}
  while(M--)
  {
    scanf("%d %d",&A,&B);
    A--,B--;known[A]++,known[B]++;Unite(A,B,uft);
  }
  while(K--)
  {
    scanf("%d %d",&C,&D);
    C--,D--;if(Belong(C,D,uft))known[C]++,known[D]++;
  }
  for(int i=0;i<N;i++){printf("%d ",Size(i,uft)-known[i]-1);}
  return printf("\n"),0;
}

Measured memory_bytes: 2304
import math
import numpy as np
N = int(input())
Xs = [int(x) for x in input().split()]
best_position_float = np.average(Xs)
best_position1 = math.floor(best_position_float)
best_position2 = math.ceil(best_position_float)
cost1 = sum([(best_position1 - x)**2 for x in Xs])
cost2 = sum([(best_position2 - x)**2 for x in Xs])
best_cost = min(cost1, cost2)
print(best_cost)

Measured memory_bytes: 14304
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = abs(abs(x)-abs(y));
    if(x > y){
        if(x<0||y>0)ans+=2;
        else ans++;
    }
    else if(ans!=y-x)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	static int N;
	static final double EPS = 1e-8;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			N=cin.nextInt();
			if(N==0)break;
			double[][] p=new double[N][3];
			for(int i=0;i<N;i++){
				for(int j=0;j<3;j++){
					p[i][j]=cin.nextDouble();	
				}
			}
			double[] s=smallestSphere(p);
			double ans=-1;
			for(int i=0;i<N;i++){
				ans=Math.max(ans,dist(s,p[i]));
			}
			System.out.printf("%.5f\n",ans);
		}
	}
	static double dist(double[] a,double[] b){
		double re=0;
		for(int i=0;i<3;i++){
			re+=Math.pow(a[i]-b[i],2.0);
		}
		
		return Math.sqrt(re);
	}
	
	static double[] smallestSphere(double[][] p){
		int n = p.length;
		double[] pos = new double[3];
		for(int i=0;i<n;i++)for(int j=0;j<3;j++)pos[j]+=p[i][j];
		for(int j=0;j<3;j++)pos[j]/=n;
		double ratio = 0.5;
		while(ratio > EPS){
			for(int t=0;t<50;t++){
				double max = -1;
				int id = -1;
				for(int i=0;i<n;i++){
					double d = 0;
					for(int j=0;j<3;j++)d+=(pos[j]-p[i][j])*(pos[j]-p[i][j]);
					if(max < d){
						max = d; id = i;
					}
				}
				double dx = p[id][0]-pos[0], dy = p[id][1]-pos[1], dz = p[id][2]-pos[2];
				pos[0]+=dx*ratio;
				pos[1]+=dy*ratio;
				pos[2]+=dz*ratio;
			}
			ratio/=2;
		}
		return pos;
	}
}

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

int main(){

    while(1){
        int n, m;
        cin >> n >> m;
        if(n == 0){
            break;
        }

        vector<int> a(n);
        vector<int> b(m);

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

        int ansSum = 10000;
        pair<int, int> ans;
        int aSum = accumulate(a.begin(), a.end(), 0);
        int bSum = accumulate(b.begin(), b.end(), 0);
        int diff = bSum - aSum;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(2 * (b[j] - a[i]) == diff){
                    if(a[i] + b[j] < ansSum){
                        ansSum = a[i] + b[j];
                        ans.first = a[i];
                        ans.second = b[j];
                    }
                }
            }
        }

        if(ansSum == 10000){
            cout << -1 << endl;
        }
        else{
            cout << ans.first << " " << ans.second << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3060
N,D=map(int,input().split())
X=[[0]*D for i in range(N)]
for i in range(N):
  X[i]=list(map(int,input().split()))
ans=0
for i in range(N):
  for j in range(i+1,N):
    Norm=0
    for k in range(D):
      Diff=abs(X[i][k]-X[j][k])
      Norm+=Diff*Diff
    flag=False
    for k in range(Norm+1):
      if k*k==Norm:
        flag=True
    if flag==True:
      ans+=1
print(ans)


Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define speed_demon; ios_base::sync_with_stdio(0);
#define ll long long
using namespace std;
int main(){
	speed_demon;
	ll n,m,l=0;
	cin>>n>>m;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n-m;i++){
		l+=a[i];
	}
	cout<<l;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll mult_mod(ll x, ll y, ll mod){
    return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
}

ll pow_mod(ll a, ll b, ll p){
    ll res = 1;
    while (b){
        if (b & 1)
            res = mult_mod(res, a, p);
        a = mult_mod(a, a, p);
        b >>= 1;
    }
    return res % p;
}

ll gcd(ll a, ll b){
    return b ? gcd(b, a % b) : a;
}

int a, b;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b;
    if (a <= 9 && b <= 9)
        cout << a * b << "\n";
    else
        cout << "-1\n";
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int k=0,l=0;
  for(int i=0;i<N;i++){
    int j;
    cin>>j;
    if(k<j){
      l+=k;
      k=j;
    }else
      l+=j;
  }
  if(l>k)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;

double dis(int a, int b, int c, int d) {
  double dx = a - b;
  double dy = c - d;
  return sqrt(dx * dx + dy * dy);
}

int main() {
  int n, cnt = 0;
  cin >> n;
  vector<int>x(n), y(n), v(n);
  double sum = 0.0;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (int i = 0; i < n; i++) v[i] = i;
  do {
    for (int i = 0; i < n - 1; i++) {
      sum += dis(x[v[i]], x[v[i + 1]], y[v[i]], y[v[i + 1]]);
    }
    cnt++;
  } while (next_permutation(v.begin(), v.end()));
  cout << setprecision(10) << sum / cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

ll max(ll x, ll y)
{
  if(x > y) return x;
  return y;
}

int main()
{
  __;
  int k,n;
  cin >> k >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin >> v[i];

  ll sum1 = 0;
  ll max1 = 0;
  for(int i=0;i<n;i++)
  {
    if( i == 0)
    {
      int temp = v[i] + k-v[n-1];
      max1 = max(max1,temp);
      sum1 += temp;
    }
    else 
    {
      max1 = max(max1,v[i]-v[i-1]);
      sum1 += v[i]-v[i-1];
    }
  }

  cout << sum1 - max1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

class Solution{

public:
    int numOfColors(int a, int b, int c){

        if(a == b && b == c) return 1;
        if(a == b || a == c || b == c) return 2;
        return 3;
    }
};


int main() {

    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", Solution().numOfColors(a, b, c));

    return 0;
}

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

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> red(a);
    rep(i, a) {
        cin >> red[i];
    }
    vector<int> green(b);
    rep(i, b) {
        cin >> green[i];
    }
    vector<int> clear(c);
    rep(i, c) {
        cin >> clear[i];
    }
    sort(red.begin(), red.end(), greater<int>());
    sort(green.begin(), green.end(), greater<int>());
    sort(clear.begin(), clear.end(), greater<int>());
    red.resize(x);
    green.resize(y);
    red.insert(red.end(), green.begin(), green.end());
    sort(red.begin(), red.end(), greater<int>());
    int k = red.size() - 1;
    rep(i, c) {
        if (k >= 0 && red[k] < clear[i]) red[k--] = clear[i];
        else break;
    }
    ll ans = 0;
    for (auto v : red) ans += v;
    cout << ans << endl;

    return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define rALL(x) x.rbegin(),x.rend()

using namespace std;
using ll=long long;



int main(){
  int x;cin>>x;
  cout<< lcm(360,x)/x;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h)yn;
    return 0;
}
 
 



Measured memory_bytes: 3084
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, j;
    int[] ice = new int[10];
    for(;;){
      n = sc.nextInt(); if(n == 0)break;
      for(i = 0;i < 10;i++)ice[i] = 0;
      for(;n-- > 0;)ice[sc.nextInt()]++;
      for(i = 0;i < 10;i++){
        if(ice[i] == 0)out.print("-");
        else for(;ice[i]-- > 0;)out.print("*");
        out.println();
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 60076
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

s, w = load_list()

if w >= s:
    print('unsafe')
else:
    print('safe')

Measured memory_bytes: 9516
def bunsu(N,h,w):
  q = 4*h*w -(N * h + N * w)
  p = N*h*w
  if q != 0 and p % q == 0:
    p //=q
    q = 1
  return p,q # q/p
N = int(input())
for h in range(1,3501):
  for w in range(1,3501):
    p,q =bunsu(N,h,w)
    if q == 1 and p >0:
      print(h,p,w)
      exit()


Measured memory_bytes: 41308
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  rep(i,n)cin >> a[i];
  ll s[n+1];
  s[0]=0;
  rep(i,n)s[i+1]=s[i]+a[i];
  rep(i,n+1)s[i]-=i;
  rep(i,n+1){
    s[i]%=k;
    //if(s[i]<0)s[i]+=k;
  }
  //rep(i,n+1)cout << s[i] << endl;
  map<int,int> mp;
  ll ans = 0;
  rep(i,n+1){
    if(i<k){
      ans += mp[s[i]];
      mp[s[i]]++;
    }else{
      mp[s[i-k]]--;
      ans += mp[s[i]];
      mp[s[i]]++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;char s2;
    cin>>s;
    cin>>t;ll x=s.size();
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    for(int i=1;i<=x;i++){
        s2=s[0];
        s.erase(0,1);
        s+=s2;
//        cout<<s<<endl;
//        cout<<t<<endl;
        if(s==t){
            cout<<"Yes";return 0;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
 int N,M,c=0;
cin >> N>> M;
int s[M];
vector<int> diff;
diff.resize(M-1);
if(N>=M)diff.resize(N);
for(int i=0;i<M;i++){
    cin>>s[i];
}
sort(s,s+M);
for(long long int i=0;i<M-1;i++){
    diff[i]=s[i+1]-s[i];
}
sort(diff.begin(),diff.end(),greater<int>());
for(long long int i=0;i<N-1;i++){
    diff[i]=0;
}
for(long long int i=0;i<M-1;i++){
    c+=diff[i];
}
if(N>=M)c=0;
cout <<c;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n-1; i++)
    {
        if(p[i-1] < p[i] && p[i] < p[i+1] || p[i-1] > p[i] && p[i] > p[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int n, m, in;
    string key;
    set<int> A;
    set<int> B;
    vector<int> result;
    cin >> n;
    rep(i, n)
    {
        cin >> in;
        A.insert(in);
    }
    cin >> m;
    rep(i, m)
    {
        cin >> in;
        B.insert(in);
    }
    set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(result, result.end()));
    
    rep(i, result.size())
    {
        cout << result[i] << endl;
    }
}



Measured memory_bytes: 22684
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
 
two = []
four = []
for k,v in c.items():
    if v >= 2:
        two.append(k)
    if v >= 4:
        four.append(k)
 
two.sort(reverse=True)
 
t = 0
if len(two) >= 2:
    t = two[0]*two[1]
    
s = 0
if len(four) >= 1:
    s = max(four)**2

print(max(s,t))

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




int main(){
  bool j=false;
  int n;
  cin>>n;
  string a[1000];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    string b;
    cin>>b;
    bool done=false;
    for(int t=0;t<n;t++){
      if(b==a[t]){
	cout<<(j==true? "Closed by ":"Opened by ")<<b<<endl;
	if(j){j=false;}
	else{j=true;}
	done=true;
	break;
      }
    }
    if(!done){cout<<"Unknown "<<b<<endl;}
  }

  
  return 0;
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll n; 
        cin >> n;
        vector<ll> f(n+1,1);
        for(ll i=2;i<=n;i++){
            ll j = i;
            while(j<=n){
                f[j]++;
                j+=i;
            }
        }
        ll ans = 0;
        FOR(i,1,n+1){
            ans += i*f[i];
        }
        cout << ans;
    }   
}

Measured memory_bytes: 81312
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int Roundup(int a,int b){
    return (a+b-1)/b;
}


signed main(){
    int N;
    int A[114514],B[114514];
    int Sum=0;
    cin >> N;
    REP(i,N){cin >> A[i];}
    REP(i,N){cin >> B[i];A[i]-=B[i];Sum+=A[i];}
    
    if(Sum<0){cout << -1 << endl;return 0;}
    sort(A,A+N,greater<>());
    
    int minus=0;
    int Y=0;
    REP(i,N){
        if(A[i]<0){
            minus-=A[i];
            Y++;
        }
    }
    int Ans=0;
    while(minus>0){
        minus-=A[Ans];
        Ans++;
    }
    cout << Ans+Y << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{

	ll n,p,ans=1,prime=2;
	int cnt=0;
	scanf("%lld%lld",&n,&p);
	if(n==1)
		printf("%lld",p);
	else if(p==1)
		printf("1\n");
	else{
		while(p>1&&prime*prime<=p){
			while(p%prime==0)
			{
				cnt++;
				p/=prime;
				if(cnt==n){
					ans*=prime;
					cnt=0;
				}
			}
			cnt=0;
			if(prime==2) prime++;
			else 
				prime+=2;	
		}
		printf("%lld",ans);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second

using namespace std;

const int maxN = 2e5 + 10;
const int inf = 1e9 + 7;

string s, ans;
int n;
int f[maxN], p[30], t[maxN][30];

void trace(int pos)
{
    if(f[pos] == 0){
        int tmp = -1;
        for(int i = 0; i < 26; ++i){
            if(t[pos][i] == -1){
                tmp = i;
                break;
            }
        }
        ans += (tmp + 'a');
    }
    else{
        int tmp = -1;
        for(int i = 0; i < 26; ++i){
            if(f[t[pos][i]] + 1 == f[pos]){
                tmp = i;
                break;
            }
        }
        ans += (tmp + 'a');
        trace(t[pos][tmp]);
    }
}

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

    cin >> s;
    n = s.length();

    s = " " + s;

    for(int i = 0; i < 26; ++i)
        p[i] = -1;
    for(int i = n; i >= 0; --i){
        for(int j = 0; j < 26; ++j)
            t[i][j] = p[j];
        if(i) p[s[i] - 'a'] = i;
    }

    for(int i = n; i >= 0; --i){
        int minn = inf, flag = 1;
        for(int j = 0; j < 26; ++j){
            if(t[i][j] == -1){
                flag = 0;
                break;
            }
            else
                minn = min(minn, f[t[i][j]]);
        }
        if(flag) f[i] = minn + 1;
        else f[i] = 0;
    }

    //cout << f[0] + 1 << endl;
    trace(0);
    cout << ans;
}


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

int main(){
	int n, ans = 0, t[12];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &t[i]);
		ans += t[i];
	}
	sort(t, t+n);
	ans -= t[n-1]/2;
	printf("%d", ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int A, B, C, X, Y;
  int cost = 0;
  scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);

  if (A + B > 2*C) {
    if (X < Y) {
      cost += 2 * X * C;
      Y -= X;
      cost += ((B < 2*C) ? B : 2*C) * Y;
    } else {
      cost += 2 * Y * C;
      X -= Y;
      cost += ((A < 2*C) ? A : 2*C) * X;
    }
  } else {
    if (X < Y) {
      cost += X * (A + B);
      Y -= X;
      cost += ((B < 2*C) ? B : 2*C) * Y;
    } else {
      cost += Y * (A + B);
      X -= Y;
      cost += ((A < 2*C) ? A : 2*C) * X;
    }
  }
  printf("%d\n", cost);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	vector<int>a(n),b(n),c(n-1);
	rep(i,n)cin>>a.at(i);
	rep(i,n)a.at(i)--;
	rep(i,n)cin>>b.at(i);
	rep(i,n-1)cin>>c.at(i);
	rep(i,n){
		sum+=b.at(a.at(i));
		if(a.at(i)==n-1||i==n-1)continue;
		if(a.at(i+1)==a.at(i)+1)sum+=c.at(a.at(i));
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(void) {
	double L;
	cin >> L;
	double A = L / (double)3;
	double B = L - A * 2;
	double ans = A * A * B;
	
	printf("%lf\n", ans);
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll N, M, Q;
ll cnt;
vector<ll> A, B, C, D;

// 重複あり順列(のうち単調増加するもの)の列挙
ll search(vector<ll> in){
    if (in.size() == N){
        ll ans = 0;
        rep(i, Q){
            if ((in.at(B.at(i)) - in.at(A.at(i))) == C.at(i)){ans += D.at(i);}
        }
        return ans;
    } else {
        ll start;
        if (in.size() == 0){
            start = 1;
        } else {
            start = in.at(in.size() - 1);
        }

        ll ans = -INF;
        rep2(i, start, M + 1){
            vector<ll> vec(in);
            vec.push_back(i);
            ll tmp = search(vec);
            if (tmp > ans){ans = tmp;}
        }
        return ans;
    }
}

void Main() {
    cin >> N >> M >> Q;
    rep(i, Q){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        A.push_back(a); B.push_back(b); C.push_back(c); D.push_back(d);
    }
    vector<ll> base;
    cout << search(base) << endl;
    // https://www.geeksforgeeks.org/combinations-with-repetitions/
    // 丸がM個，仕切りが
}

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


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MAX = 100;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > d(n+1, vector<int>(m+1));
    for(int x=1; x<=n; ++x){
        for(int y=1; y<=m; ++y){
            cin >> d[x][y];
        }
    }

    int size = 2 * MAX + 2;
    vector<tuple<int, int, int>> ans;
    for(int i=0; i<MAX; ++i)
        ans.push_back(make_tuple(i, i+1, -1));
    for(int i=0; i<MAX; ++i)
        ans.push_back(make_tuple(size-2-i, size-1-i, -2));

    vector<vector<bool> > check(n+1, vector<bool>(m+1, false));
    int cnt = n * m;
    for(int a=0; a<=MAX; ++a){
        for(int b=0; b<=MAX; ++b){
            int c = 0;
            for(int x=1; x<=n; ++x){
                for(int y=1; y<=m; ++y){
                    int tmp = d[x][y] - a * x - b * y;
                    c = max(c, tmp);
                }
            }
            for(int x=1; x<=n; ++x){
                for(int y=1; y<=m; ++y){
                    int tmp = d[x][y] - a * x - b * y;
                    if(tmp == c && !check[x][y]){
                        check[x][y] = true;
                        -- cnt;
                    }
                }
            }
            if(c <= MAX)
                ans.push_back(make_tuple(a, 2*MAX+1-b, c));
        }
    }

    if(cnt == 0){
        cout << "Possible" << endl;
        cout << size << ' ' << ans.size() << endl;
        for(const auto& t : ans){
            int a, b, c;
            tie(a, b, c) = t;
            ++ a;
            ++ b;
            cout << a << ' ' << b << ' ';
            if(c == -1)
                cout << 'X' << endl;
            else if(c == -2)
                cout << 'Y' << endl;
            else
                cout << c << endl;
        }
        cout << 1 << ' ' << size << endl;
    }
    else{
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 704
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 1000005
int l;
int n;
vector<pair<pii, int> > e;

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

    cin >> l;
    if(l == 1){
        cout << "2 1\n1 2 0\n";
        return 0;
    }
    n = 1;
    while(1<<(n+1) <= l) n++;
    FOR(i, 1, n){
        e.pb({{i, i+1}, 0});
        e.pb({{i, i+1}, 1<<(i-1)});
    }
    int cur = (1<<n);
    RFOR(i, n-1, 0){
        if((1<<i) & l){
            e.pb({{i+1, n+1}, cur});
            cur += (1<<i);
        }
    }
    cout << n+1 << " " << e.size() << "\n";
    for(auto u : e) cout << u.f.f << " " << u.f.s << " " << u.s << "\n";
    
    return 0;
}


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

#define int long long

int n;
vector<int> a;

signed main() {
   cin >> n;
   a.resize(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }
   sort(a.begin(), a.end());

   int Max = a.back();
   a.pop_back();

   int p = Max / 2, q = Max / 2+1;
   if (Max&1) {
      p++;
   }

   int r = 0, dif = 1e10;
   for (int i = 0; i < a.size(); i++) {
      int t = min(abs(p - a[i]), abs(q - a[i]));
      if (t < dif) {
         r = a[i];
         dif = t;
      }
   }

   printf("%lld %lld\n", Max, r);


   return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){

  int n,m=2,ans[10001];

  fill(ans,ans+10001,0);
  ans[1]=2;

  for(int i=2;i<10001;i++)
    ans[i]=ans[i-1]+m++;
  
  while(cin >> n)cout << ans[n] << endl;

  return 0;
}

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

const int N=2e5+20;

int n,k,a[N];
double sum,mx;

double f(long long x)
{
	return (x+1)/2.;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);

	for(int i=0;i<k;i++) sum+=f(a[i]);
	mx=sum;
	for(int i=k;i<n;i++)
	{
		sum+=f(a[i])-f(a[i-k]);
		mx=max(mx,sum);
	}

	cout<<fixed<<setprecision(12)<<1.*mx;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    long int N, K;
    cin >> N >> K;

    long int count = 0;

    vector<long int> A(N);
    vector<int> flag(N);

    flag.at(0) = 1;

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

    long int i = 0;
    long int temp = 0;

    while(1){
        if(flag.at(i) > 1){
            break;
        }
        count += 1;
        temp = A[i];
        i = temp - 1;
        flag.at(i) += 1;
    }

    int roop_count = 0;
    int shokiti;

    shokiti = i;

    while(1){
        roop_count += 1;
        temp = A[i];
        i = temp - 1;
        if(i == shokiti){
            break;
        }
    }

    long int num = 0;

    long int temp_K = 0; 

    temp_K = K - count;
    if(temp_K < 0){
        i = 0;
        for(int j = 0; j < K; j++){
            temp = A[i];
            i = temp - 1;
        }
    
        cout << i+1 << endl;

        return 0;

    }

    K = temp_K;

    num = K % roop_count;
    i = shokiti;

    for(long int j = 0; j < num; j++){
        temp = A[i];
        i = temp - 1;
    }

    cout << i+1 << endl;

    return 0;

}

Measured memory_bytes: 5640