akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }


signed main() {
	int x, a;
	cin >> x >> a;

	if (x < a) {
		col(0);
	}
	else {
		col(10);
	}
	return 0;
}

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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const
      noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const
      noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const
      noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const
      noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const
      noexcept {
    return x == p.x;
  }
  constexpr bool operator!=(const ModInt &p) const
      noexcept {
    return x != p.x;
  }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while(n) {
      if(n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(
      ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is,
                                       ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

vector<ModInt<>> sum(100010);

ModInt<> inv(ModInt<> x) {
  ModInt<> res = 1;
  long long k = (long long)(1e9 + 7) - 2;
  ModInt<> y = x;
  while(k) {
    if(k & 1) res = (res * y);
    y = y * y;
    k >>= 1;
  }
  return res;
}

int main(void) {
  long long n;
  cin >> n;
  vector<long long> x(n + 1);
  ModInt<> ans = 0;
  ModInt<> kaijo = 1;
  for(int i = 1; i <= n - 1; i++) kaijo = kaijo * i;
  for(int i = 0; i < n; i++) cin >> x[i + 1];
  for(int i = 0; i < n; i++)
    sum[i + 1] = (sum[i] + x[i + 1]);

  for(long long p = 1; p <= n - 1; p++) {
    ModInt<> tmp = inv(n - p) * (x[n] - x[p]);
    ans = ans + tmp;
  }
  for(long long p = 1; p <= n - 2; p++) {
    ModInt<> tmp = inv(p * (p + 1));
    ModInt<> tmp1 = sum[n - 1] - sum[p];
    ModInt<> tmp2 = sum[n - 1 - p];
    ModInt<> tmp3 = tmp1 - tmp2;
    ModInt<> tmp4 = tmp * tmp3;
    ans = ans + tmp4;
  }
  ans = ans * kaijo;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
char map[2][200000]={0};
int main(){
  int N,M;
  int a,b;
  
  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> a >> b;
    if(a==1){
      map[0][b]=1;
    }else if(a==N){
      map[1][b]=1;
    }else if(b==1){
      map[0][a]=1;
    }else if(b==N){
      map[1][a]=1;
    }
  }
  for(int i=0;i<200000;i++){
    if(map[0][i]==1&&map[1][i]==1){
      cout << "POSSIBLE" <<endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(all(h), greater<>());
    ll ans = 0;
    for(int i = k; i < n; i++) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;
typedef long long ll;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25


int main()
{
	string s;
	cin >> s;
	string a = "abcdefghijklmnopqrstuvwxyz";

	int ans = INF;
	rep (i, a.size()) {
		int start = 0;
		int ans1 = 0;
		bool flg = false;
		rep(j, s.size()) {
			if (s[j] == a[i]) {
				ans1 = max(j - start, ans1);
				start = j + 1;
				flg = true;
			}
		}
		if (flg) {
			ans1 = max((int)s.size() - start, ans1);
			ans = min(ans1, ans);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int n;cin>>n;
	vector< bitset<64> > mask(n);
	for(int i=0;i<n;++i) {
		int k,kk;cin>>k;
		while(k--) {
			cin>>kk;
			mask[i].set(kk);
		}
	}
	
	int q;cin>>q;
	bitset<64> bs(0);
	
	while(q--){
		int query,i;cin>>query;
		switch(query){
		case 0:
			// test(i)
			// iビット目が立っているか否かを判定する
			cin>>i;
			cout<<(bs.test(i))<<endl;
			break;
		case 1:
			// set(i)
			// マスクと被っているビットを立てる
			cin>>i;
			bs |= mask[i];
			break;
		case 2:
			// reset(i)
			// マスクと被っているビットを0にする
			cin>>i;
			bs &= ~mask[i];
			break;
		case 3:
			// flip(i)
			// マスクと被っているビットを反転する
			cin>>i;
			bs ^= mask[i];
			break;
		case 4:
			// all(for all)
			// 任意のビットが立っているかを確認する
			cin>>i;
			cout<<((bs&mask[i])==mask[i])<<endl;
			break;
		case 5:
			// any(exists)
			// 立っているビットが存在するかを確認する
			cin>>i;
			cout<<((bs&mask[i]).any())<<endl;
			break;
		case 6:
			// none
			// 任意のビットが0になっているかを確認する
			cin>>i;
			cout<<((bs&mask[i]).none())<<endl;
			break;
		case 7:
			// count
			// 立っているビット数を出力する
			cin>>i;
			cout<<((bs&mask[i]).count())<<endl;
			break;
		case 8:
			// val
			cin>>i;
			cout<<((bs&mask[i]).to_ulong())<<endl;
			break;
		}
	}
  return 0;
}



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

const int P = 998244353;
int upd(int x){return x + (x >> 31 & P);}
int dp[403][403][2] , pw[2][403][403] , N , h[403] , cnt;

int DP(int l , int r){
	if(l > r) return 0;
	int id = ++cnt , val = 1e9 , num = 0;
	for(int j = l ; j <= r ; ++j) val = min(val , h[j]);
	int pre = l - 1 , sz = 0; dp[id][0][0] = 1;
	for(int j = l ; j <= r + 1 ; ++j)
		if(j == r + 1 || val == h[j]){
			++num; int t = DP(pre + 1 , j - 1);
			if(t){
				static int tmp[403][2]; memset(tmp , 0 , sizeof(tmp));
				for(int p = 0 ; p <= sz ; ++p)
					for(int q = 0 ; q < j - pre ; ++q)
						for(int x = 0 ; x < 2 ; ++x)
							for(int y = 0 ; y < 2 ; ++y)
								tmp[p + q][x | y] = (tmp[p + q][x | y] + 1ll * dp[id][p][x] * dp[t][q][y]) % P;
				memcpy(dp[id] , tmp , sizeof(dp[id])); sz += j - pre - 1;
			}
			pre = j;
		}
	--num;
	for(int i = 1 ; i <= num ; ++i){
		static int tmp[403][2]; memcpy(tmp , dp[id] , sizeof(tmp));
		for(int j = 0 ; j <= r - l + 1 ; ++j){
			tmp[j + 1][0] = upd(tmp[j + 1][0] - dp[id][j][0]);
			tmp[j + 1][1] = upd(tmp[j + 1][1] + dp[id][j][0] - P);
		}
		memcpy(dp[id] , tmp , sizeof(dp[id]));
	}
	int len = val - max(h[l - 1] , h[r + 1]);
	for(int i = 0 ; i <= r - l + 1 ; ++i){
		dp[id][i][0] = 1ll * dp[id][i][0] * pw[0][r - l + 1 - i][len] % P;
		dp[id][i][1] = 1ll * dp[id][i][1] * pw[1][r - l + 1 - i][len] % P;
	}
	return id;
}

int main(){
	scanf("%d" , &N); for(int i = 1 ; i <= N ; ++i) scanf("%d" , h + i);
	for(int i = 0 ; i <= N ; ++i) pw[0][i][0] = pw[0][0][i] = 1;
	for(int j = 1 ; j <= N ; ++j){
		pw[0][j][1] = upd(pw[0][j - 1][1] + pw[0][j - 1][1] - P); pw[1][j][1] = pw[0][j][1] - 1;
		for(int k = 2 ; k <= N ; ++k){
			pw[0][j][k] = 1ll * pw[0][j][k - 1] * pw[0][j][1] % P;
			pw[1][j][k] = 1ll * pw[1][j][k - 1] * pw[1][j][1] % P;
		}
	}
	int t = DP(1 , N); int sum = 0;
	for(int i = 0 ; i <= N ; ++i) for(int j = 0 ; j <= 1 ; ++j) sum = upd(sum + dp[t][i][j] - P);
	printf("%d\n" , sum); return 0;
}


Measured memory_bytes: 2816
open Scanf
open Printf

let ($) f x = f x
let scanIntlist n = let list = ref [] in
  for i = 1 to n do
    list := (scanf (if i < n then "%d " else "%d") (fun x -> x))::!list
  done; List.rev !list

let string2charlist s = let rec proc i res =
                          try proc (i+1) $ s.[i]::res
                          with Invalid_argument _ -> res
  in List.rev $ proc 0 []

let minInt l = let rec proc l res = match l with
      [] -> res
    | x::xs -> if x < res then proc xs x else proc xs res
  in if l == [] then raise $ Failure "null list" else proc l max_int



let rec listSum = function
    [] -> 0
  | x::xs -> x+listSum xs;;


sscanf (read_line ()) "%d %d" $ fun n x ->
  let l = scanIntlist n in
  let min = minInt l in
  let sum = listSum l in
  print_int $ (x-sum) / min + n;;


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

int main () {
  string S;
  cin >> S;
   
  if (S == "Sunny") {
    S = "Cloudy";
  }
  else if (S == "Cloudy") {
    S = "Rainy";
  }
  else if (S == "Rainy") {
    S = "Sunny";
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import copy
def main():
    n, k = map(int, input().rstrip().split(' '))
    s = [c == '1' for c in input().rstrip()]

    windows = []
    current_window = None
    for i, c in enumerate(s):
        if not c:
            if current_window  == None:
                current_window = Window(False)
            elif current_window.one:
                windows.append(current_window)
                current_window = Window(False)
            current_window.count += 1
        else:
            if current_window  == None:
                current_window = Window(True)
            elif not current_window.one:
                windows.append(current_window)
                current_window = Window(True)
            current_window.count += 1
    windows.append(current_window)
    
    counts = []
    count = 0
    zero_window_count = 0
    for i, w in enumerate(windows):
        if not w.one:
            zero_window_count += 1
            if zero_window_count > k:
                counts.append(count)
                leftmost = i - (2 * k) - 1
                if leftmost >= 0:
                    count -= windows[leftmost].count #1s, if exist
                count -= windows[leftmost + 1].count #0s

        count += w.count
    counts.append(count)
    print(max(counts))

class Window:
    def __init__(self, one_or_zero):
        self.one = one_or_zero
        self.count = 0
    
    def __repr__(self):
        return ("1" if self.one else "0") + " " + str(self.count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 23336
import Control.Applicative
import Control.Monad
mul :: Num a => [[a]] -> [a] -> [a]
mul xs as = map (sum . zipWith (*) as) xs

main = do
   [n,m] <- map read . words <$> getLine
   matr <- replicateM n (map read . words <$>  getLine)
   v <- replicateM m readLn
   mapM_ print $ mul matr v

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

int main() {
  long double a,b,x;
  cin >> a >> b >> x;
  
  if(x >= a*a*b/2){
    cout << fixed << setprecision(10) << 180 * atan( (2*(a*a*b-x))/(a*a*a) ) / M_PI << endl;
  }else{
    cout << fixed << setprecision(10) << 180 * atan( (a*b*b) / (2*x) ) / M_PI << endl;
  }
  
  return(0);
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

using P = pair<ll, int>;

int n;
VV<int> g;
V<ll> lw, us;

V<set<P>> gx;

V<int> ig;
VV<int> gi;
void uf_init() {
    ig = V<int>(n); gi = VV<int>(n);
    for (int i = 0; i < n; i++) {
        ig[i] = i; gi[i] = {i};
    }
}

bool uf_same(int a, int b) {
    return ig[a] == ig[b];
}

void uf_merge(int a, int b) {
    if (uf_same(a, b)) return;
    int x = ig[a], y = ig[b];
    if (gi[x].size() < gi[y].size()) swap(x, y);
    for (int j: gi[y]) {
        ig[j] = x;
    }
    gi[x].insert(gi[x].end(), gi[y].begin(), gi[y].end());
    gi[y].clear();

    us[x] += us[y];
    us[y] = 0;

    if (gx[x].size() < gx[y].size()) swap(gx[x], gx[y]);
    for (auto d: gx[y]) {
        gx[x].insert(d);
    }
    gx[y].clear();
}

ll ans;
V<bool> vis;
priority_queue<P, V<P>, greater<P>> que;

void on(int p) {
    vis[p] = true;
    for (int d: g[p]) {
        if (vis[d]) {
            uf_merge(p, d);
        }
    }
    int x = ig[p];
    while (gx[x].size()) {
        auto tp = *(gx[x].begin());
        if (vis[tp.second]) {
            gx[x].erase(gx[x].begin());
            continue;
        }
        if (tp.first <= ans+us[x]) {
            on(tp.second);
        } else {
            que.push(P(tp.first - us[x], tp.second));
        }
        break;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    int m;
    cin >> n >> m;
    g = VV<int>(n);
    lw = V<ll>(n); us = V<ll>(n);
    ll off = 0;
    for (int i = 0; i < n; i++) {
        cin >> lw[i] >> us[i]; lw[i] -= us[i];
        off += us[i];
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b); g[b].push_back(a);
    }
    uf_init();
    
    gx = V<set<P>>(n);
    for (int i = 0; i < n; i++) {
        for (int d: g[i]) {
            gx[i].insert(P(lw[d], d));
        }
    }
    vis = V<bool>(n);

    for (int i = 0; i < n; i++) {
        que.push(P(lw[i], i));
    }
    
    ans = 0;
    while (que.size()) {
        P tp = que.top(); que.pop();
        int p = tp.second;
        if (vis[p]) continue;
        ans = max(ans, tp.first);
        on(p);
    }
    cout << ans+off << endl;
    return 0;
}


Measured memory_bytes: 39280
import scala.io.StdIn

object Main {

  def main(args: Array[String]) {

    val n: Int = StdIn.readLine().toInt
    val ds: Vector[Int] = StdIn.readLine().split(' ').toVector.map(_.toInt)

    val sorted = ds.sorted
    println(sorted(n / 2) - sorted(n / 2 - 1))

  }

}


Measured memory_bytes: 46964
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make(ll,n);
    makevec(ll,vec,n);
    ll s=0;
    sort(vec.begin(),vec.end());
    ll j=1;
    fr(i,n) s+=vec[i];
    if(s%10!=0) {cout<<s<<endl; return 0;}
    ll ans=-1;
    for(ll i=0;i<n;i++) {if(vec[i]%10!=0){ans=vec[i]; break;}}
    if(ans==-1) {cout<<"0 \n"; return 0;}
    cout<<s-ans<<endl;



    return 0;
}


Measured memory_bytes: 3600
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class BinaryIndexedTree:
    # 1-indexed
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
    
    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def sum(self, i):
        res = 0
        while i:
            res += self.data[i]
            i -= i & -i
        return res
    
    def bisect_left(self, w):
        if w <= 0:
            return 0
        i = 0
        k = 1 << (self.n.bit_length() - 1)
        while 0 < k:
            if i + k <= self.n and self.data[i + k] < w:
                w -= self.data[i + k]
                i += k
            k >>= 1
        return i + 1


def solve():
    N = int(rl())
    P = list(map(int, rl().split()))
    
    p_to_idx = [0] * (N + 1)
    for i, x in enumerate(P):
        p_to_idx[x] = i + 1
    
    bit = BinaryIndexedTree(N)
    ans = 0
    for pi in range(N, 0, -1):
        idx = p_to_idx[pi]
        left = bit.sum(idx)
        bit.add(idx, 1)
        right = N - pi - left
        l0 = bit.bisect_left(left - 1) if 2 <= left else 0
        l1 = bit.bisect_left(left) if 1 <= left else 0
        r0 = bit.bisect_left(left + 2) if 1 <= right else N + 1
        r1 = bit.bisect_left(left + 3) if 2 <= right else N + 1
        cnt = 0
        if l1 != 0:
            cnt += (l1 - l0) * (r0 - idx)
        if r0 != 0:
            cnt += (r1 - r0) * (idx - l1)
        ans += pi * cnt
    print(ans)


if __name__ == '__main__':
    solve()


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



int main() {
    int n, x, y;
    cin >> n >> x >> y;
    
    vector<int> a(n);
    
    for(int i = 1; i < n; i++) {
        for(int j = i+1; j <= n; j++) {
            int d = min(j-i, abs(x-i) + 1 + abs(y-j));
            a[d]++;
        }
    }
    
    for(int i = 1; i < n; i++) {
        cout << a[i] << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3604
N, M = map(int, input().split())
A = [ int(x) for x in input().split() ]

d = {0:1}
ans, s = 0, 0
 
for a in A:
    s += a
    s %= M
    ans += d.get(s, 0)
    d[s] = d.get(s, 0) + 1

print(ans) 


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll n;

int f(int x){
	int t=0;
	while(x){
		x/=10;
		t++;
	}
	return t;
}

int main(){
	cin>>n;
	ll res=0;
	for(int i=1;i<=n;i++) if(n/i>=8){
		if(n%i==0) (res+=Pow(10,n/i-1)*9-i+1+mod)%=mod;
		else res++;
	}
	res%=mod;
	ll I=1,t=0;
	for(int i=1;i<10000000;i++){
		t-=f(i-1);
		while(t<n) t+=f(I++);
		if(t==n) res++;
	}
	res%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , one_a;
  cin >> n >> one_a;
  
  n = n % 500;
 
  if ( n <= one_a ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n,y; cin >> n >> y;
    rep(i,n+1){
        rep(j,n+1-i){
            ll rest = y-10000*i-5000*j;
            if(rest>=0 && rest/1000+i+j==n){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    puts("-1 -1 -1");
}


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

int main(){
  char str[1001];
  int sum = 0;
  
  while(1){
    scanf("%s",str);
    
    if(strcmp(str,"0") == 0){
      break;
    }
    
    for(int i = 0;str[i] != '\0';i++){
      sum += str[i] - '0';
    }
    
    printf("%d\n",sum);
    sum = 0;
  }
    
  return 0;
}


Measured memory_bytes: 2060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    sort(a.begin(), a.end());
    int r = 0;
    for(int l = 0; l < n; l++){
        int cnt = 0;
        while(r < n && a[l] == a[r]){
            r++;
            cnt++;
        }
        if(cnt%2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4028
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            checked
            {
                string[] s;
#if false
                int N = int.Parse(Console.ReadLine());
#else
                s = Console.ReadLine().Split(' ');
                int A = int.Parse(s[0]);
                int B = int.Parse(s[1]);
#endif

                Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
            }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int r;
	cin >> r;
	cout << r * r << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define maxn 300005
using namespace std;
int arr[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int m = n * 3;
	for(int i=1;i<=m;i++)
		cin >> arr[i];
	multiset<int> L;
	ll sum1 = 0;
	for(int i=1;i<=n;i++) {
		sum1 += arr[i];
		L.insert(arr[i]);
	}
	multiset<int> R1,R2;
	ll sum2 = 0;
	for(int i=n+1;i<=m;i++) {
		if((int)R1.size() < n || *R1.rbegin() > arr[i]) {
			if((int)R1.size() == n) {
				sum2 -= *R1.rbegin();
				R2.insert(*R1.rbegin());
				R1.erase(R1.lower_bound(*R1.rbegin()));
			}
			sum2 += arr[i];
			R1.insert(arr[i]);
		}
		else
			R2.insert(arr[i]);
	}
	ll ans = sum1 - sum2;
	for(int i=n+1;m-i>=n;i++) {
		if(R1.count(arr[i]) > 0) {
			sum2 -= arr[i];
			R1.erase(R1.lower_bound(arr[i]));
			sum2 += *R2.begin();
			R1.insert(*R2.begin());
			R2.erase(R2.begin());
		}
		else
			R2.erase(R2.lower_bound(arr[i]));
		
		if(arr[i] > *L.begin()) {
			sum1 -= *L.begin();
			L.erase(L.begin());
			sum1 += arr[i];
			L.insert(arr[i]);
		}
		ans = max(ans,sum1 - sum2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15488
# @author 

import sys

class CDivideTheProblems:
    def solve(self):
        n = int(input())
        d = [int(_) for _ in input().split()]
        d.sort()
        if n % 2 == 0:
            print(d[(n - 1) // 2 + 1] - d[(n - 1) // 2])
        else:
            print(1)

solver = CDivideTheProblems()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 52764
#define N 200005
#include <stdio.h>
int main() {
    int n = 0;
    int R[N];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &R[i]);
    }
    int maxv = -2000000000;
    int minv = R[0];
    for (int i = 1; i < n; i++) {
        if (R[i] - minv > maxv) {
            maxv = R[i] - minv;
        }
        if (R[i] < minv) {
            minv = R[i];
        }
    }
    printf("%d\n", maxv);
    return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n;
	vector<int> a[n+1];
	for(int i=2;i<=n;i++){
		cin>>x;
		a[x].push_back(x);
	}
	for(int i=1;i<=n;i++){
		cout<<a[i].size()<<'\n';
	}
}

Measured memory_bytes: 14548
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define INF 10000000000000ll
#define M 300020
using namespace std;
namespace IO{
	const int BS=(1<<20)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(LL x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
int n,m,p[M];
LL H[M],G[M],F[M],S[M],top,D[M],P[M];
LL X[M],Y[M];
#define calc(b,a) x[b]-S[a-1]+S[b]+((LL)(a-b-1)*(LL)(a-b)>>1)
#define conv(a,b,c) ((double)(Y[b]-Y[a])/(double)(X[b]-X[a])>(double)(Y[c]-Y[b])/(double)(X[c]-X[b]))
#define Transl(b,a) G[a+1]-S[a]+S[b]+F[b]+((LL)(a-b)*(LL)(a-b+1)>>1)
#define Transr(b,a) F[a-1]-S[a]+S[b]+G[b]+((LL)(b-a)*(LL)(b-a+1)>>1)
void init(LL *x){
	S[top=1]=0,Y[0]=X[0]=S[0]=0;
	for(LL i=1;i<=n+1;i++) S[i]=S[i-1]+p[i];
	for(LL i=0;i<=n+1;i++){
		while(top>1&&calc(P[top-1],i)>=calc(P[top],i)) top--;
		if(top) x[i]=calc(P[top],i);else x[i]=0;
		X[i]=i,Y[i]=x[i]+S[i]+((i*i+i)>>1);
		while(top>1&&!conv(P[top-1],P[top],i)) top--; P[++top]=i;
	}
}
void solve(int l,int r){
	if(l==r){H[l]=max(H[l],F[l-1]+G[r+1]-p[l]+1);return;}
	int mid=((l+r)>>1); solve(l,mid),solve(mid+1,r);
	top=S[l-1]=S[r+1]=X[l-1]=X[r+1]=Y[l-1]=Y[r+1]=0;
	D[l-1]=D[r+1]=-INF; top=0;
	
	for(int i=l;i<=r;i++) D[i]=-INF,S[i]=S[i-1]+p[i]; top=0;
	for(int i=l-1;i<=mid;i++){
		X[i]=i,Y[i]=F[i]+S[i]+(((LL)i*(LL)i+(LL)i)>>1);
		while(top>1&&!conv(P[top-1],P[top],i)) top--; P[++top]=i;
	}
	for(int i=mid+1;i<=r;i++){
		while(top>1&&Transl(P[top-1],i)>=Transl(P[top],i)) top--;
		D[i]=Transl(P[top],i);
	}
	for(int i=r;i>mid;i--) D[i]=max(D[i+1],D[i]),H[i]=max(H[i],D[i]);
	
	for(int i=r;i>=l;i--) S[i]=S[i+1]+p[i]; top=0;
	for(int i=r+1;i>mid;i--){
		X[i]=i,Y[i]=G[i]+S[i]+(((LL)i*(LL)i+(LL)i)>>1);
		while(top>1&&!conv(i,P[top],P[top-1])) top--; P[++top]=i;
	}
	for(int i=mid;i>=l;i--){
		while(top>1&&Transr(P[top-1],i)>=Transr(P[top],i)) top--;
		D[i]=Transr(P[top],i);
	}
	for(int i=l;i<=mid;i++) D[i]=max(D[i-1],D[i]),H[i]=max(H[i],D[i]);
}
int main(){
 	n=read(); for(int i=1;i<=n;i++) p[i]=read(),H[i]=-INF;
	init(F),reverse(p+1,p+n+1),init(G),reverse(p+1,p+n+1);
	reverse(G+1,G+n+1),G[0]=G[n+1],G[n+1]=0; solve(1,n);
	for(int TT=read();TT;TT--,Putchar('\n')){
		LL pos=read(),K=read();
		write(max(F[pos]+G[pos],H[pos]+p[pos]-K));
	} flush(); return 0;
}

Measured memory_bytes: 24576
#include <iostream> 
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i=0; i<n; i++) cin >> d[i];
  sort(d.begin(),d.end());
  if (d[n/2-1]==d[n/2]) cout << 0 << endl;
  else cout << d[n/2]-d[n/2-1] << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, c;
	cin >> n >> c;
	vvi d(c, vi(c));
	rep(i, 0, c) rep(j, 0, c) cin >> d[i][j];
	vvi cou(3, vi(c));
	rep(i, 0, n) rep(j, 0, n) {
		int x;
		cin >> x;
		cou[(i + j) % 3][x - 1]++;
	}
	int ans = INF;
	rep(i, 0, c) rep(j, 0, c) rep(k, 0, c) {
		if (i == j || j == k || k == i) continue;
		int tmp = 0;
		rep(x, 0, c) tmp += cou[0][x] * d[x][i];
		rep(x, 0, c) tmp += cou[1][x] * d[x][j];
		rep(x, 0, c) tmp += cou[2][x] * d[x][k];
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

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

const unsigned LIMIT = 105000;

int main(){
	bool table[ LIMIT ] = { false };
	table[ 2 ] = true;
	for ( int i = 3; i < LIMIT; i += 2 ){
		table[ i ] = true;
	}
	for ( int i = 3; i < LIMIT; i += 2 ){
		if ( !table[ i ] ) continue;
		for ( int j = i + i; j < LIMIT; j += i ){
			table[ j ] = false;
		}
	}

	int n;
	while ( cin >> n ){
		if ( !n ) break;
		int sum = 0;
		for ( int i = 0, j = 2; i < n; ++i ){
			while ( !table [ j ] ) ++j;
			sum += j;
			++j;
		}
	cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define MOD 1000000007

int gcd(int a, int b){
    if( a < b){
        swap(a,b);
    }
    return (a % b == 0)? b:gcd(a, a%b);
}

int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<double> expectations(n);
    vector<double> imos(n);
    vector<double> dice_nums(n);
    rep(i,n){
        cin >> dice_nums[i];
    }

    rep(i,n){
        expectations[i] = ( 1.0 + dice_nums[i]) / 2.0;
    }

    imos[0] = expectations[0];

    repn(i,1,n){
        imos[i] = imos[i-1] + expectations[i];
    }

    double ans = imos[k-1];


    repn(i,k,n){
        double target = imos[i] - imos[i-k];
        ans = max(ans, target);
    }

    printf("%.10f", ans);

}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

pair<int, int> analyze(int n)
{
	int e = n % 10;
	while (n >= 10) {
		n /= 10;
	}
	int b = n;

	return { b, e };
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	int arr[10][10] = { 0 };

	FOR_LE(i, 1, n) {
		auto val = analyze(i);
		arr[val.first][val.second]++;
	}

	int64_t ans = 0;
	FOR_LE(i, 1, 9) {
		FOR_LE(j, 1, 9) {
			ans += arr[i][j] * arr[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

// comb(n,2)
int choose2(int n)
{
  if (n <= 1) return 0;
  return n * (n - 1) / 2;
}

int main()
{
  int N,M;
  cin >> N >> M;
  cout << choose2(N) + choose2(M) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 100009
int A[M],dp[M],mx;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	for(int i=1;i<=n;i++){
		if(A[i]<=A[i-1])dp[i]=dp[i-1]+1;
		else dp[i]=1;
		if(dp[i]>mx)mx=dp[i];
	}
	printf("%d",mx-1);
	return 0;
}

Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	public static void solve() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = (n-1) * (m-1);
        sc.close();
        out.println(ans);
        out.flush();
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll INF = 1e18;
vector<vector<ll>> nxt;
void warshall_floyd(vector<vector<ll>>& d) {
  ll n = SZ(d);
  REP(i, n) REP(j, n) REP(k, n) if (d[j][k] > d[j][i] + d[i][k]) {
    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
    nxt[j][k] = nxt[j][i];
  }
}

int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> to(n, vector<ll>(n, INF));
  nxt = vector<vector<ll>>(n, vector<ll>(n, -1));
  REP(i, n) REP(j, n) { nxt[i][j] = j; }
  REP(i, n) { to[i][i] = 0; }
  vector<vector<ll>> inv(n, vector<ll>(n, -1));
  REP(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    to[a][b] = 1;
    to[b][a] = 1;
    inv[a][b] = i;
    inv[b][a] = i;
  }
  warshall_floyd(to);
  ll m;
  cin >> m;
  vector<vector<bool>> route(m, vector<bool>(n - 1, false));
  REP(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    for (ll cur = a; cur != b; cur = nxt[cur][b]) {
      ll t = nxt[cur][b];
      ll num = inv[cur][t];
      route[i][num] = true;
    }
  }

  // REP(i, m) REP(j, n - 1) { cout << route[i][j] << " \n"[j == n - 2]; }

  ll ans = 1LL << (n - 1);
  //包除原理
  FOR(bit, 1LL, 1LL << m) {
    //白の枝
    vector<bool> used(n - 1, false);
    ll con = 0;  // 成約の数
    REP(j, m) if (bit & (1LL << j)) {
      con++;
      REP(k, n - 1) if (route[j][k]) { used[k] = true; }
    }
    // falseの数
    ll c = 0;
    REP(j, n - 1) {
      if (!used[j]) c++;
    }
    ll t = (1LL << c);
    // DUMP(bit);
    // DUMP(t);
    if (con % 2 == 0) {
      ans += t;
    } else {
      ans -= t;
    }
  }
  cout << ans << endl;
}

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

#define F first
#define S second

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-7;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}

int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1; //L
  if (cross(b,c) < -EPS) return -1; //R
  if (dot(b,c)   < -EPS) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}

P proj(P a1, P a2, P p) { return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1); }

P crosspointLL(P a1, P a2, P b1, P b2) {
  D d1 = cross(b2-b1, b1-a1);
  D d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;
  if (EQ(d2, 0)) throw "HiGYAAAAA!!!!!";
  return a1 + d1/d2 * (a2-a1);
}

// p1を基準にpをa度回転
L rot(P p,double a,P p1){
  a=a*M_PI/180.0;  p-=p1;
  D x=p.X*cos(a)+p.Y*(-sin(a))+p1.X;
  D y=p.X*sin(a)+p.Y*cos(a)+p1.Y;
  return L(p1,P(x,y));
}

// segをpにぶつける
L segdon(P p,L seg){
  P a=seg.F , b=seg.S;
  P c=proj(a,b,p);
  P z=crosspointLL(a,b,p,c);
  p-=z; a+=p; b+=p;
  return L(a,b);
}

int n;
VP v;

// off L = 1,R = -1  : zu 回す向き  
bool check(L seg,int id,int off,int zu){
  L p=segdon(v[id],seg);
  return ccw(v[(id+zu+n)%n],p.F,p.S) == off;
}

double calc(L a,L b,L c){
  P x=crosspointLL(a.F,a.S,b.F,b.S);
  P y=crosspointLL(a.F,a.S,c.F,c.S);
  return abs(x-y);
}

signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    D x,y;
    scanf("%lf%lf",&x,&y);
    v.push_back(P(x,y));
  }
  L ls=rot(v[1],60,v[0]);
  L rs=rot(v[0],-60,v[1]);

  int l=0,r=1;
  while(check(ls,l,1,-1))  l=(l-1+n)%n;
  while(check(rs,r,-1,1)) r=(r+1+n)%n;

  double ans=calc(segdon(v[l],ls),segdon(v[r],rs),L(v[1],v[0]));

  for(int i=n-1;i>0;i--){
    int nex=(i+1)%n;
    ls=rot(v[nex],60,v[i]);
    rs=rot(v[i],-60,v[nex]);

    while(check(ls,l,1,-1))  l=(l-1+n)%n;
    while(check(rs,r,-1,-1)) r=(r-1+n)%n;

    ans=min(ans,calc(segdon(v[l],ls),segdon(v[r],rs),L(v[i],v[nex])));
  }
  printf("%.9f\n",ans);
}


Measured memory_bytes: 3548
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from itertools import product
import sys
def main(X, Y, Z, K, A, B, C):
    AB = sorted([a + b for a, b in product(A, B)], reverse=True)
    ABC = sorted([ab + c for ab, c in product(AB[:K], C)], reverse=True)
    for k in range(K):
        print(ABC[k])

if __name__ == '__main__':
    input = sys.stdin.readline
    X, Y, Z, K = map(int, input().split())
    *A, = map(int, input().split())
    *B, = map(int, input().split())
    *C, = map(int, input().split())
    main(X, Y, Z, K, A, B, C)


Measured memory_bytes: 253384
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; i < n; i++) {
    cin >> c[i];
    for(int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int price = -1;
  int tmp;
  for(int bit = 0; bit < (1 << n); bit++) {
    //cout << "bit:" << bitset<3>(bit) << endl;;
    bool flag = true;
    for(int i = 0; i < m; i++) {
      int und = 0;
      for(int j = 0; j < n; j++) {
        if(bit & (1 << j)) {
          und += a[j][i];
        }
      }
      //cout << und << endl;
      if(und < x) flag =false;
    }
    if(flag == true) {
      tmp = 0;
      for(int j = 0; j < n; j++) {
        if(bit & (1 << j)) {
          tmp += c[j];
        }
      }
      if(price == -1 || tmp < price) price = tmp;
    }
  }
  cout << price << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  int n; cin >> n;
  vector<vector<int> > g(15,vector<int>(10, 0));

  for(int i = 0; i < n; i++){
    int b,f,r,v; cin >> b >> f >> r >> v;
    f--; r--;
    if(b == 1) g[f][r] += v;
    else if(b == 2) g[f+4][r] += v;
    else if(b == 3) g[f+8][r] += v;
    else if(b == 4) g[f+12][r] += v;
  }
  for(int i = 0; i < 15; i++){
    for(int j = 0; j < 10; j++){
      if(i == 3 || i == 7 || i == 11){
        cout << "##";
      }else{
        cout << " " << g[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int k; cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  ll tens = 1;
  ll curr = 0;
  for (int i = 0; i < k; i++) {
    curr = (curr + tens*7) % k;
    if (curr == 0) {
      cout << i+1 << endl;
      break;
    }
    tens = (tens * 10) % k;
  }

  return 0;
}

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

const long long MOD=1e9+7;
long long N,K;
vector<int> g[100100];
int used[100100]={};
long long ans=1;

void solve(int s){
    ans*=K;
    queue<pair<int,int>> que;
    que.push({s,K-1});
    used[s]=true;
    while(!que.empty()){
        pair<int,int> p=que.front(); que.pop();
        int u=p.first; int tmp=p.second;
        int loop=tmp;
        for(auto v:g[u]){
            if(used[v]) continue;
            if(u==0){
                ans*=loop%MOD;
            }else{
                ans*=(loop-1)%MOD;
            }
            ans%=MOD;
            que.push({v,tmp});
            used[v]=true;
            loop--;
        }
    }
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N-1;i++){
        int a,b; cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    solve(0);
    cout << ans%MOD << endl;
}

Measured memory_bytes: 7288
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;

int main() {
    long long int N, K;
    cin >> N >> K;
    if(K % 2 == 1) cout << (long long  int)pow(N / K, 3) << endl;
    else cout << (long long  int)pow(N / K, 3) + (long long int)pow((N + (K / 2)) / K, 3) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

        int total = inp.nextInt();

        ArrayList<Integer> list = new ArrayList<>();

        int count = 0;

        while (count != total) {
            int num = inp.nextInt();

            list.add(num);

            count++;
        }

        ArrayList<Integer> listTemp = new ArrayList<>();

        for (int i = 0; i < list.size(); i++) {
            listTemp.add(0, list.get(i));
        }

        for (int i = 0; i < listTemp.size(); i++) {
            if (i != listTemp.size()-1) {
                System.out.print(listTemp.get(i) + " ");
            } else {
                System.out.print(listTemp.get(i));
            }
        }

        System.out.print("\n");
    }
}



Measured memory_bytes: 26168
#include <stdio.h>
#define N 10000
#define MAX 2000001

int A[MAX],B[MAX];

void CountingSort(int n,int k){
  int i,C[N],j;
  
  for(i=0;i<=k;i++){
    C[i] = 0;
  }
  for(i=0;i<n;i++){
    C[A[i]]++;
  }
  for(i=1;i<=k;i++){
    C[i] = C[i] + C[i-1];
  }
  for(j=n-1;j>=0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

int main()
{
  int i,k=0,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k) k = A[i];
  }
  CountingSort(n,k);
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);
  return 0;
}



Measured memory_bytes: 17372