akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, a[maxn], bit[maxn];
int get(int idx){
    int sum = 0;
    for(; idx > 0 ; idx -= idx & - idx)
        sum += bit[idx];
    return sum;
}
int get(int l,int r){
    return get(r) - get(l - 1);
}
void upd(int idx,int val){
    for(; idx < 2005 ; idx += idx & -idx)
        bit[idx] += val;
    return ;
}
vector<int> b;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1 ;i<= n;i++){
        cin >> a[i];
        }
    sort(a + 1 , a + 1 + n);
    for(int i = 1 ;i <= n;i ++)
        upd(a[i] , 1);
    int ans = 0;
    /// 1 2 3 4
    /// 1 2
    for(int i = 1 ;i <= n; i++){
        for(int j = i + 1 ; j <= n; j++){
            int l = j + 1 , r = n , mid , pos = -1;
            int sum = a[i] + a[j];
            while(l <= r){
                mid = l + r >> 1;
                if(a[mid] < sum){
                    pos = mid;
                    l = mid +1 ;
                }
                else r = mid - 1;
            }
           // if(i == 2 && j == 3) cout << pos << ' ' << sum << endl;
            if(pos == -1) continue;
            ans += pos - j ;
        }
    }
    cout << ans << endl;
}
/*
    Good Luck
        -Lucina
*/


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

int main() {
  int N, A, B, C, D;
  cin >> N;
  A = N / 1000;
  N = N % 1000;
  B = N / 100;
  N = N % 100;
  C =N / 10;
  N = N % 10;
  D = N;
  if (A == B){
    if (B == C){
   		cout << "Yes" << endl;
    }
  	else{
    	cout << "No" << endl;
  	}
  }
  else if(B == C){
  	if(C == D){
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }
  }
  else{
  	cout << "No" << endl;
  }
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, w;
  while (cin >> n >> w, n) {
    vector<int> a(100);
    while (n--) {
      int v;
      cin >> v;
      ++a[v / w];
    }
    while (a.back() == 0) {
      a.pop_back();
    }
    n = a.size();
    double mx = *max_element(begin(a), end(a));
    double res = 0.01;
    for (int i = 0; i < n; ++i) {
      res += (1 - (double)i / (n - 1)) * (a[i] / mx);
    }
    cout << fixed << setprecision(20) << res << '\n';
  }
}



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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    vector<bool> find(26, false);
    for (auto c : s) find[(int)(c - 'a')] = true;

    bool is_find = false;
    for (int i = 0; i < 26; ++i) {
        if (!find[i]) {
            cout << (char)(i + 'a') << endl;
            is_find = true;
            break;
        }
    }

    if (!is_find) cout << "None\n";

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const ll LINF = 1e18;

const int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  REP(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

mint f(int n, int a) {
  if (n == 0) return 1;
  mint x = f(n/2, a);
  x *= x;
  if (n % 2 == 1) x *= a;
  return x;
}

int main() {
  IOS;
  int n; cin >> n;

  mint p1 = f(n, 10); // 全通り
  mint p2 = f(n, 9) * 2; // 0が存在しないケース/9が存在しないケース
  mint p3 = f(n, 8); // 0と9が共に存在しないケース

  // 包除原理
  // (0が存在しないケース + 9が存在しないケースから) 0と9が共に存在しないケースを
  // 引くことで、0または9が少なくとも一方が存在しないケースとなる。
  // 全体から、0または9が少なくとも一方が存在しないケースを引けば、
  // 0と9が両方存在するケースとなる
  COUT( p1 - (p2 - p3) );
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
int hon[] = {2,4,5,7,9};
int pon[] = {0,1,6,8};
int bon[] = {3};

int main() {
  int n;
  cin >> n;
  int d = n % 10;
  rep(i, 5) if(d == hon[i]) {
    cout << "hon" << endl;
    return 0;
  }
  rep(i, 4) if(d == pon[i]) {
    cout << "pon" << endl;
    return 0;
  }
  cout << "bon" << endl;
  
}

Measured memory_bytes: 3624
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
      
      string[] input2 = Console.ReadLine().Split(' ');
		int d = int.Parse(input2[0]);
		int e = int.Parse(input2[1]);
		// 文字列の入力
		//出力
		Console.WriteLine((b-d)*(c-e));
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    int N, M;
    cin >> N >> M;

    vector<int> wrong(N, 0);

    int p;
    string S;
    int AC = 0;
    int WA = 0;

    rep(i,M) {
        cin >> p >> S;
        p--;
        if (S == "AC" && wrong[p] >= 0) {
            AC++;
            WA += wrong[p];
            wrong[p] = -1;
        } else if (S == "WA" && wrong[p] >= 0) {
            wrong[p]++;
        }
    }

    cout << AC << " " << WA << endl;

    return 0;
}

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

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

    int bpos, apos = 0;
    for(bpos = 0; bpos < m; bpos++){
        while(apos < n && b[bpos] > a[apos])    apos++;
        if(apos != n && b[bpos] == a[apos]) continue;
        else    break;
    }

    cout << (bpos==m) << endl;

    return 0;
}


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

int main(){
  int K, A, B, ans = 0, len = 0 ;
  cin >> K >> A >> B ;
  for(int i=A;i<(B+1);i++){
    if(i % K == 0) ans = 1 ;
  }
  if(ans){
    cout << "OK" << endl ;
  }  
  else{
    cout << "NG" << endl ;
  }  
  return 0 ;
}  


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n-1) a.at(i+1) += a.at(i);
  rep(i,n) b.at(i) = a.at(i);
  ll now1 = 0;
  ll count1 = 0;
  rep(i,n){
    if(i%2 == 0){
      a[i] += now1;
      if(a[i] <= 0){
        now1 += 1-a[i];
        count1 += 1-a[i];
      }
    }else{
      a[i] += now1;
      if(a[i] >= 0){
        now1 -= a[i]+1;
        count1 += a[i]+1;
      }
    }
  }
  ll now2 = 0;
  ll count2 = 0;
  rep(i,n){
    if(i%2 ==1){
      b[i] += now2;
      if(b[i] <= 0){
        now2 += 1-b[i];
        count2 += 1-b[i];
      }
    }else{
      b[i] += now2;
      if(b[i] >= 0){
        now2 -= b[i]+1;
        count2 += b[i]+1;
      }
    }
  }
  cout << min(count1,count2) << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//const ll mod =998244353;

// int main()
// {
//     ll n;
//     cin>>n;
//     ll a[n][n],v[n];
//     for (int i = 0; i < n; ++i)
//     {
//         for (int j = 0; j < n; ++j)
//         {
//             cin>>a[i][j];
//         }
//     }
//     for (int i = 0; i < n; ++i)
//     {
//         cin>>v[i];
//     }

// }
ll vis[100002],dp[100002];
vector<ll> adj[100002];
void dfs(ll x)
{
    vis[x]=1;
    for (int i = 0; i < adj[x].size(); ++i)
    {
        if(!vis[adj[x][i]])
        {
            dfs(adj[x][i]);
        }
        dp[x]=max(dp[x],1+dp[adj[x][i]]);
    }
}
int main()
{
    memset(vis,0,sizeof(vis));
    memset(dp,0,sizeof(dp));
    ll n,m,ans=0,x,y;
    cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
        cin>>x>>y;
        adj[x].pb(y);
    }
    for (int i = 1; i <= n; ++i)
    {
        if(!vis[i])
            dfs(i);
    }
    for (int i = 1; i <= n; ++i)
    {
        //cout<<dp[i]<<endl;
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}



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

namespace ConsoleApp15
{
    class Class33
    {
        static void Main()
        {
            var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int h = hw[0], w = hw[1];
            int count = 0;
            for(int i = 0; i < h; i++)
            {
                var r = Console.ReadLine();
                count += r.Count(x => x == '#');
            }
            Console.WriteLine(count == h + w - 1 ? "Possible" : "Impossible");
        }
    }
}


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

h,w = map(int,input().split())
s = [0]*(h+2)
s[0]= ["."]*(w+2)
for i in range(h):
    s[i+1] = ["."] + list(input()) + ["."]

ans = True
for i in range(1,h):
    for j in range(1,w):
        if s[i][j] == "#":
            if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
                ans = False
                break

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        a: i32,
        b: i32,
    }

    let add = a + b;
    let sub = a - b;
    let mul = a * b;
    if add >= sub && add >= mul{
        println!("{}", add);
    } else if sub >= add && sub >= mul{
        println!("{}", sub);
    } else if mul >= add && mul >= sub{
        println!("{}", mul);
    }
}

Measured memory_bytes: 4352
# https://qiita.com/drken/items/56a6b68edef8fc605821#%E5%95%8F%E9%A1%8C-1-aoj-0516---%E6%9C%80%E5%A4%A7%E3%81%AE%E5%92%8C-joi-2006-%E6%9C%AC%E9%81%B8-a

INPUT_MAX = 101010

is_prime = [1] * INPUT_MAX  # True or False
is_prime[0] = 0
is_prime[1] = 0

# エラトステネスのふるい
for i in range(2, INPUT_MAX):
    if not is_prime[i]:
        continue
    for k in range(i * 2, INPUT_MAX, i):
        is_prime[k] = 0

# 2017-like 数かどうか
a = [0] * INPUT_MAX
for i in range(INPUT_MAX):
    if i % 2 == 0:
        continue
    if (i + 1) % 2 != 0: continue
    if is_prime[i] and is_prime[int((i + 1) / 2)]:
        a[i] = 1

# 累積和
s = [0] * (INPUT_MAX + 1)
for i in range(INPUT_MAX):
    s[i + 1] = s[i] + a[i]

Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    r += 1
    print(s[r] - s[l])


Measured memory_bytes: 9940
#include<iostream>
#define INF (1e9)
using namespace std;

int main(){
  int n,m,t[100],h[100],ts,hs,a,mint,minh;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    for(int i=0;i<n;i++)
      cin>>t[i];

    for(int i=0;i<m;i++)
      cin>>h[i];
    a=0;
    mint=minh=INF;
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++){
	swap(t[i],h[j]);
	ts=0;
	hs=0;
	for(int k=0;k<n;k++)
	  ts+=t[k];
	for(int l=0;l<m;l++)
	  hs+=h[l];

	if(ts==hs && mint+minh>h[j]+t[i]){
	  mint=h[j];
	  minh=t[i];
	  if(a==0)a=1;
	}
	swap(t[i],h[j]);
      }

    if(a==0)
      cout<<"-1"<<endl;
    else
      cout<<mint<<' '<<minh<<endl;
  }
  return 0;
}

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

const int MAX_N = (int)(2e5);

int n;
vector<pair<int, int>> x_with_index;

unordered_map<int, int> po;

int main(void){
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    x_with_index.push_back(make_pair(tmp, i));
  }

  sort(x_with_index.begin(), x_with_index.end(), [] (auto a, auto b) {return a.first > b.first;});

  int left = x_with_index[n / 2 - 1].first;
  int right = x_with_index[n / 2].first;

  for (int i = 0; i < n; ++i) {
    if (i < (n / 2)) po[x_with_index[i].second] = right;
    else po[x_with_index[i].second] = left;
  }

  for (int i = 0; i < n; ++i) printf("%d\n", po[i]);

  return 0;
}


Measured memory_bytes: 12016
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n, a, b;
int H[100000];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> a >> b;
    a -= b;
    for (int i = 0; i < n; ++i) cin >> H[i];
    int s = 1, e = 1e9;
    while (s < e) {
        int m = (s + e) / 2;
        llong add = 0;
        for (int i = 0; i < n; ++i) {
            add += (max(H[i] - (llong)b * m, 0ll) + a - 1) / a;
        }
        if (add <= m) e = m;
        else s = m + 1;
    }
    printf("%d\n", s);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b[200010],c;
long long sum;
int main(){
	cin >> a;
	for(int i=1;i<=a;i++){
		cin >> b[i];
		b[i]-=i;
	}
	sort(b+1,b+a+1);
	if(a%2==0){
		for(int i=1;i<=a;i++){
			sum+=abs(b[i]-b[a/2]);
		}
		cout<<sum;
	}
	else{
		for(int i=1;i<=a;i++) {
			sum+=abs(b[i]-b[(a+1)/2]);
		}
		cout<<sum;
	}
}
	

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,x[100005],a,b,ans=0;
int main(){
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	for(int i=1;i<=n-1;i++){
		ans+=min((x[i+1]-x[i])*a,b);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	ll N, Z, W;
	cin >> N >> Z >> W;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	{
		ll z = a[N - 1];
		ans = abs(W - z);
	}
	if(N != 1){
		ll z = a[N - 2];
		ll w = a[N - 1];
		ans = max(ans, abs(w - z));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
input = sys.stdin.readline

N, X, Y = map(int, input().split())
skip = Y - X  - 1
ans = []

for i in range(1, N):
    for j in range(i+1, N+1):
        dist = j - i
        if i < X and j >= X and j <= Y:
            left = j - X
            right = Y - j + 1
            if right < left:
                dist = j - i + right - left
        elif i >= X and i <= Y and j >= X and j <= Y:
            r1 = j - i
            r2 = i - X + Y - j + 1
            if r2 < r1:
                dist = r2
        elif i >= X and i < Y and j > Y:
            left2 = i - X + 1
            right2 = Y - i
            if left2 < right2:
                dist = j - i + left2 - right2
        elif i <= X and j >= Y:
            dist = j - i - skip
        ans.append(dist)
out = Counter(ans)

for i in range(1, N):
    if i in out:
        print(out[i])
    else:
        print(0)

Measured memory_bytes: 67776
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	
	ll n;
	cin>>n;
	long double a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	long double ans[n+1][n+1];
	for(int i=0;i<=n;i++)
	{
	    ans[0][i]=0;
	}
	ans[1][0]=(double)(1-a[0]);
	for(int i=2;i<=n;i++)
	{
	    ans[i][0]=((long double)ans[i-1][0])*((long double)(1-a[i-1]));
	}
	ans[1][1]=(long double)a[0];
	for(ll i=2;i<=n;i++) ans[1][i]=0;
	for(ll i=2;i<=n;i++)
	{
	    for(ll j=1;j<=n;j++)
	    {
	        if(j>i) ans[i][j]=0;
	        else
	        {
	            ans[i][j]=((long double)ans[i-1][j-1]*(long double)a[i-1])+((long double)ans[i-1][j]*(long double)(1-a[i-1]));
	        }
	    }
	}
	long double k=0;
	ll m=n/2;
	for(ll i=m+1;i<=n;i++)
	{
	    k+=(long double)ans[n][i];
	}
	cout<<fixed<<setprecision(12)<<k<<endl;
	
	return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rng(i,a,b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define repd(i, n) for(ll i = (ll)(n)-1;i>=0;--i)
#define rngd(i,b,a) for(ll i = (ll)(b);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define ctoi(x) ((x)-'0')

int main() {
  double ans=0;
  int n;
  
  cin>>n;
  vector<pair<int,int> > t(n);
  rep(i,n){
    int x,y;
    cin>>x>>y;
    t[i]=make_pair(x,y);
  }
  sort(all(t));
  do{
    rep(i,n){
      if(i+1>=n){
        continue;
      }
      ans+=hypot(t[i].first-t[i+1].first,t[i].second-t[i+1].second);
    }    
  }while(next_permutation(all(t)));
  rng(i,1,n+1){
    ans/=i;
  }
  cout<<fixed<<setprecision(7)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

const int PN = 1e7;
int isprime[PN + 5];
vector<long long> prime;
void primechk() {
	for (int i = 2; i <= PN; i++) isprime[i] = i;
	for (long long i = 2; i <= PN; i++)
		if (isprime[i] == i) {
			prime.push_back(i);
			for (long long j = i * i; j <= PN; j += i)
				isprime[j] = i;
		}
}

ll f(int n) {
	ll ret = 1;
	while (1) {
		if (n == 1) break;
		int d = isprime[n];
//		cout << n << ' ' << d << '\n';
		int cnt = 0;
		while (n % d == 0) n /= d, cnt++;
		ret *= cnt + 1;
	}
	return ret;
}

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

	int N; cin >> N;
	primechk();

	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += i * f(i);	
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 50624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

map<string,int> ma;//1:cat,-1:rabbit

bool f(string s){
    if(s == "")return true;
    int n = s.size();
    bool ret = false;
    if(ma[s] == 1)ret = true;
    if(ma[s] == 0){
        if(s[0] == 'm' && s[n-1] == 'w'){
            loop(i,1,n-1)if(s[i] == 'e'){
                if(f(s.substr(1,i-1)) && f(s.substr(i+1,n-i-2)))ret = true;
            }
        }
        if(ret) ma[s] = 1;
        else ma[s] = -1;
    }
    return ret;
}

int main(void) {
    int i,j;
    string s;
    cin >> s;
    if(f(s)) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;

}



Measured memory_bytes: 7724
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>

int main(void)
{
	char s[3][10+1];
	scanf("%s %s %s\n",s[0],s[1],s[2]);
	int i;
	for (i=0;i<3;i++){
		printf("%c",(char)((int)s[i][0]+'A'-'a'));
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N,M; cin >> N >> M;
    vector<int> P(M),Y(M);
    vector<vector<int>> memo(N);
    for(int i = 0; i < M; i++){
        cin >> P[i] >> Y[i];
        P[i]--;
        memo[P[i]].push_back(Y[i]);
    }
    for(int i = 0; i < N; i++) sort(memo[i].begin(),memo[i].end());
    for(int i = 0; i < M; i++){
        int id = lower_bound(memo[P[i]].begin(),memo[P[i]].end(),Y[i])-memo[P[i]].begin();
        printf("%06d",P[i]+1);
        printf("%06d\n",id+1);
    }
}

Measured memory_bytes: 7808
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	H, W := getInt(), getInt()
	a := make([]string, H)
	for i := 0; i < H; i++ {
		a[i] = getString()
	}
	// out(H, W, a)

	cnt := 0
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if a[y][x] == '#' {
				cnt++
			}
		}
	}

	if cnt == W+H-1 {
		out("Possible")
	} else {
		out("Impossible")
	}

}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <ctime>

using namespace std;

const int mod = 1000000007;

struct condition {
  int l, r, x;
};

vector<vector<condition>> conditions;

int n, m;
int dp[303][303][303]; // last position

int calculateDP(int lastRpos, int lastGpos, int lastBpos) {
  int &res = dp[lastRpos][lastGpos][lastBpos];
  if (res != -1)
    return res;
  int lastPosition = max(lastRpos, max(lastGpos, lastBpos));
  for (const auto &cond : conditions[lastPosition]) {
    int cnt = 0;
    if (cond.l <= lastRpos) cnt++;
    if (cond.l <= lastGpos) cnt++;
    if (cond.l <= lastBpos) cnt++;
    if (cnt != cond.x)
      return res = 0;
  }
  if (lastPosition == n)
    return res = 1;

  long long sub = 0;
  sub += calculateDP(lastPosition + 1, lastGpos, lastBpos);
  sub += calculateDP(lastRpos, lastPosition + 1, lastBpos);
  sub += calculateDP(lastRpos, lastGpos, lastPosition + 1);
  sub %= mod;
  return res = sub;
}

int main() {
  scanf("%d%d", &n, &m);
  conditions.resize(n + 1);
  map<int, int> startCnt;
  for (int i = 0; i < m; i++) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    condition c;
    c.l = l, c.r = r, c.x = x;
    conditions[r].push_back(c);
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        dp[i][j][k] = -1;
      }
    }
  }

  int ans = calculateDP(0, 0, 0);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 108800
#include <stdio.h>

int main(void) {

	int r, c, i, ii;
	int xy[100][100] = { {0},{0} };
	int yall[100] = { 0 };
	int xall[100] = { 0 };
	int xyall = 0;

	scanf("%d%d", &r, &c);

	for (i = 0; i < r; i++) {
		for (ii = 0; ii < c; ii++) {
			scanf("%d", &xy[i][ii]);
			yall[i] += xy[i][ii];
		}
	}

	for (i = 0; i < c; i++) {
		for (ii = 0; ii < r; ii++) {
			xall[i] += xy[ii][i];
		}
		xyall += xall[i];
	}
    
	for (i = 0; i < r; i++) {
		for (ii = 0; ii < c; ii++) {
			printf("%d ", xy[i][ii]);
		}
		printf("%d\n", yall[i]);
	}

	for (i = 0; i < c; i++) {
		printf("%d ", xall[i]);
	}
	printf("%d\n", xyall);
	return 0;
}

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

const char nl = '\n';

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int x = a; x <= b; x++) {
        if (x % k == 0) {
            cout << "OK" << nl;
            return 0;
        }
    }
    cout << "NG" << nl;
    return 0;
}



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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define eps 1e-6
#define pf printf
#define sf scanf
#define sd(n) scanf("%d", &n)
#define sdd(n1, n2) scanf("%d %d", &n1, &n2)
#define sddd(n1, n2, n3) scanf("%d %d %d", &n1, &n2, &n3)
#define sl(n) scanf("%lld", &n)
#define sll(n1, n2) scanf("%lld %lld", &n1, &n2)
#define slll(n1, n2, n3) scanf("%lld %lld %lld", &n1, &n2, &n3)
#define rep(i, n) for (i = 0; i < n; ++i)
#define rep0(i, n) for (i = 0; i <= n; ++i)
#define rep1(i, n) for (i = 1; i <= n; ++i)
#define repp(i, a, n) for (i = a; i <= n; ++i)
#define repb(i, a, n) for (i = a; i >= n; --i)
#define asort(a) sort(a.begin(), a.end())
#define all(a) (a).begin(), (a).end()
#define sq(n) (n)*(n)
#define mem(a, n) memset(a, n, sizeof(a))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n, i, a, b, t = 0;
    sd(n);

    vector<pair<int, int> > v(n);
    rep(i, n) {
        sdd(a, b);
        v[i] = make_pair(b, a);
    }
    asort(v);

    bool f = 1;
    rep(i, n) {
        t += v[i].second;
        if (t > v[i].first) {
            f = 0;
            break;
        }
    }

    if (f) pf("Yes\n");
        else pf("No\n");

    return 0;
}


Measured memory_bytes: 1792
use v5.18;
use warnings;
use List::Util qw( sum min );
sub read_line { chomp(my $str = <STDIN>); $str }
sub splited_read_line { split / /, read_line }
my ($n, $m, $start) = splited_read_line;
my @stations = splited_read_line;
my %stations_table = (
  ( map { $_ => 1 } @stations ),
  0  => 0,
  $n => 0,
);
my $right = sum map { $stations_table{$_} // () } $start + 1 .. $n;
my $left = sum map { $stations_table{$_} // () } 0 .. $start - 1;
say min($right, $left);


Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    string s;
    cin >> s;

    int ans = 0;
    rep(i, 0, s.size()) {
        int j = 0;
        while(i + j < s.size()) {
            if (s[i + j] == 'A' || s[i + j] == 'C' || s[i + j] == 'G' || s[i + j] == 'T') j++;
            else break;
        }
        ans = max(ans, j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
s=input().rstrip().split()

if int(s[0])==5 and int(s[1])==5 and int(s[2])==7:
  print("YES")
elif int(s[0])==7 and int(s[1])==5 and int(s[2])==5:
  print("YES")
elif int(s[0])==5 and int(s[1])==7 and int(s[2])==5:
  print("YES")
else:
  print("NO")

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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef  long long int lli; 

int main(){
    
    lli i,x,j,k,n,y,m,t,a,b; 	
    AndIamIronMan;
//    cin>>t;
//    while(t--){
	string s1,s2;
	cin>>s1>>s2;
	n=s1.length();
	x=0;
	for(i=0;i<n;i++){
		if(s1[i]!=s2[i]){
			x++;
		}
	}
	cout<<x;
//	}
	return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll xor_sum(ll num)
{
    switch(num%4)
    {
        case 0:
            return num;
        case 1:
            return 1;
        case 2:
            return num+1;
        case 3:
            return 0;
    }
}
int main()
{
    ll a, b;
    cin >> a >> b;
    ll ans = xor_sum(a-1) ^ xor_sum(b);
    cout << ans << "\n";    
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
 	int n;
  	cin >> n;
  
  	int cnt = 0;
  	int res = 0;
  	while(n--) {
     	int x, y;
      	cin >> x >> y;
      
      	if (x == y) { 
      	    res++;
      	    cnt = max(cnt, res);   
      	}
      	else {
      	    cnt = max(cnt, res);
      	    res = 0;
      	}
    }
  
  	if (cnt >= 3) {
      	cout << "Yes" << endl;
    } else {
     	cout << "No" << endl; 
    }
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int S;
    cin >> S;
    S--;
    while(1){
        S++;
        int A = S/100;
        int B = S%100;
        int C = B/10;
        int D = B%10;
        if (A==C && C==D){
            break;
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc147/tasks/abc147_e

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll H, W;
  cin >> H >> W;

  VVL as(H, VL(W));
  rep(h, H) rep(w, W) cin >> as[h][w];

  VVL bs(H, VL(W));
  rep(h, H) rep(w, W) cin >> bs[h][w];

  ll abs_max = 0;
  rep(h, H) rep(w, W) { chmax(abs_max, abs(as[h][w] - bs[h][w])); }

  ll abs_sum_max = (W + H - 1) * abs_max;

  ll res = INF;

  // dp[h][w][k]: h, w (>= 1) までの経路で偏りが k となるか
  // k はマイナスも扱うために abs_sum_max を足した値としておく
  V<V<V<bool>>> dp(H, V<V<bool>>(W, V<bool>(2 * abs_sum_max + 1)));
  dp[0][0][abs_sum_max + as[0][0] - bs[0][0]] = true;
  dp[0][0][abs_sum_max + bs[0][0] - as[0][0]] = true;

  // 配る DP
  rep(h, H) rep(w, W) rep(k, 2 * abs_sum_max + 1) {
    if (!dp[h][w][k]) continue;

    rep(h_diff, 2) rep(w_diff, 2) {
      if (h_diff == w_diff) continue;
      if (h + h_diff >= H || w + w_diff >= W) continue;

      ll a = as[h + h_diff][w + w_diff];
      ll b = bs[h + h_diff][w + w_diff];

      dp[h + h_diff][w + w_diff][k + a - b] = true;
      dp[h + h_diff][w + w_diff][k + b - a] = true;
    }
  }

  rep(k, abs_sum_max + 1) if (dp[H - 1][W - 1][abs_sum_max + k]) drop(k);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 22144
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    string s;
    int n,k;
    int ans = 0;
    vector<int> v;
    cin >> n >> k;
    rep(i,n){
        int a;
        cin >>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    rep(i,k){
        ans += v[i];
    }
    cout  << ans << endl;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
int read(){
	int x=0,f=1;char c;
	do{c=getchar();if(c=='-')f=-1;}while(!isdigit(c));
	do{x=x*10+c-'0';c=getchar();}while(isdigit(c));
	return x*f;
}
using Int = signed long long int;
const int N=100000+10;
const Int mod=Int(1e9)+7LL;

int vis[N],phi[N],prime[N],pcnt;
Int qpow(Int a,Int p){
	Int r=1; while(p){
		if(p&1) r=r*a%mod;
		a=a*a%mod; p>>=1;
	} return r;
}

void sieve(){
	phi[1]=1;
	for(int i=2;i<N;i++){
		if(!vis[i]){
			prime[pcnt++]=i;
			phi[i]=i-1;
		}
		for(int j=0;j<pcnt&&1LL*i*prime[j]<N;j++){
			int t=i*prime[j]; vis[t]=1;
			if(i%prime[j]==0){ phi[t]=phi[i]*prime[j]%mod; break; }
			phi[t]=phi[i]*(prime[j]-1)%mod;
		}
	}
}

int main(){
	int n=read(),k=read();
	sieve();


	Int ans=0;
	for(int i=1;i<=k;i++) ans=(ans+qpow(k/i,n)*phi[i]%mod)%mod;
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 4408
#include<cstdio>
using namespace std;
int n,k,ans,p;
int map[12][6]={
    {4,2,0,9,7},
    {1,10,8,6,4},
    {9,7,5,3,1},
    {6,4,2,0,9},
    {3,1,10,8,6},
    {0,9,7,5,3},
    {8,6,4,2,0},
    {5,3,1,10,8},
    {2,0,9,7,5},
    {10,8,6,4,2},
    {7,5,3,1,10}};
int main()
{
    scanf("%d%d",&n,&k);n-=2;
    p=n%11;n/=11;
    ans=n*5;
    for(int i=0;i<p;i++)
     for(int j=0;j<5;j++)
      if(map[i][j]==k)ans++;
    printf("%d\n",ans);
    return 0;//OK.
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#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()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll H,W; cin >> H >> W;
    ll h,w; cin >> h >> w;
    ll ans = H*W - h * W - (H - h) * w;
    cout << ans << endl;
    
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<pii> v(N);
    REP(i, N) {
        int t, d;
        cin >> t >> d;
        t--;
        v[i] = pii(d, t);
    }
    sort(all(v), greater<pii>());
    
    vector<int> variety(N + 1);
    vector<int> w;
    variety[0] = 0;
    vector<bool> used(N, false);
    REP(i, N) {
        if (!used[v[i].second]) {
            used[v[i].second] = true;
            variety[i + 1] = variety[i] + 1;
            w.pb(v[i].first);
        } else {
            variety[i + 1] = variety[i];
        }
    }

    vector<ll> acc_v_first(N + 1);
    acc_v_first[0] = 0;
    REP(i, N) {
        acc_v_first[i + 1] = acc_v_first[i] + v[i].first;
    }

    vector<ll> acc_w(w.size() + 1);
    acc_w[0] = 0;
    REP(i, w.size()) {
        acc_w[i + 1] = acc_w[i] + w[i];
    }

    ll result = 0;
    
    REP(l, K + 1) {
        PRINT(l);
        int x0 = variety[l];
        int x1 = K - l;
        PRINT(x0);
        PRINT(x1);
        ll x = x0 + x1;
        if (x > w.size()) {
            continue;
        }
        ll variety_bonus = x * x;
        ll base_total_deliciousness = acc_v_first[l] + (acc_w[x] - acc_w[x0]);
        PRINT(variety_bonus);
        PRINT(base_total_deliciousness);
        ll satisfaction = base_total_deliciousness + variety_bonus;
        PRINT(satisfaction);
        amax(result, satisfaction);
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3580
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type point struct {
	no, val int
}

type pointList []point

func (a pointList) Len() int           { return len(a) }
func (a pointList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a pointList) Less(i, j int) bool { return a[i].val < a[j].val }

type edge struct {
	to, dist int
}

type edgeList []edge

type node struct {
	edgeL     edgeList
	isVisited bool
}

type graph []node

func (a edgeList) Len() int           { return len(a) }
func (a edgeList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a edgeList) Less(i, j int) bool { return a[i].dist < a[j].dist }
func (a *edgeList) Push(x interface{}) {
	*a = append(*a, x.(edge))
}
func (a *edgeList) Pop() interface{} {
	old := *a
	n := len(old)
	x := old[n-1]
	*a = old[0 : n-1]

	return x
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	X, Y := make(pointList, N), make(pointList, N)
	for i := 0; i < N; i++ {
		X[i].no, X[i].val = i, scanInt()
		Y[i].no, Y[i].val = i, scanInt()
	}
	sort.Sort(X)
	sort.Sort(Y)

	G := make(graph, N)
	for i := 0; i < N-1; i++ {
		xa, xb, xwei := X[i].no, X[i+1].no, X[i+1].val-X[i].val
		ya, yb, ywei := Y[i].no, Y[i+1].no, Y[i+1].val-Y[i].val

		G[xa].edgeL = append(G[xa].edgeL, edge{to: xb, dist: xwei})
		G[xb].edgeL = append(G[xb].edgeL, edge{to: xa, dist: xwei})
		G[ya].edgeL = append(G[ya].edgeL, edge{to: yb, dist: ywei})
		G[yb].edgeL = append(G[yb].edgeL, edge{to: ya, dist: ywei})
	}

	E := make(edgeList, 0)
	heap.Init(&E)
	G[0].isVisited = true
	for _, ed := range G[0].edgeL {
		heap.Push(&E, ed)
	}

	ans := 0
	for i := 1; i < N; i++ {
		haveAdded := false
		for !haveAdded {
			edkouho := heap.Pop(&E).(edge)
			if !G[edkouho.to].isVisited {
				ans += edkouho.dist
				G[edkouho.to].isVisited = true
				haveAdded = true
				for _, ed := range G[edkouho.to].edgeL {
					heap.Push(&E, ed)
				}
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 38972
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveA();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a <= c && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21588
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
constexpr double eps = 1e-8;

int main() {
  double a, b, c, d, e, f, x, y;
  while (cin >> a >> b >> c >> d >> e >> f) {
    x = (c * e - b * f) / (a * e - b * d);
    y = (c - a * x) / b;
    if (fabs(x) < eps) x = 0;
    if (fabs(y) < eps) y = 0;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
}

Measured memory_bytes: 3268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  char c;
  rep(i,4){
    cin>>c;
    cout<<c;
  }
  cout<<" ";
  rep(i,8){
    cin>>c;
    cout<<c;
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define p_q priority_queue
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    
    fast_io;

    string s;
    cin>>s;

    int cnt = 0;
    for(int i=0;i<3;i++)
    {
        if(s[i] == 'R')
            cnt++;
    }

    if(cnt == 0)
    cout<<"0";

    else if(cnt == 1 || cnt == 3)
    cout<<cnt;

    else
    {
        if(s[1] == 'R')
        cout<<"2";
        else
        cout<<"1";
    }

return 0;
}


Measured memory_bytes: 3656
dice = list(map(int, input().split()))
cmd = input()

mask = {
    'N': (1, 5, 2, 3, 0, 4),
    'E': (3, 1, 0, 5, 4, 2),
    'S': (4, 0, 2, 3, 5, 1),
    'W': (2, 1, 5, 0, 4, 3)
    }

for s in cmd:
    dice = [dice[x] for x in mask[s]]

print(dice[0])



Measured memory_bytes: 5600
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] P = new int[N];
    int count = 1;
    for(int i =0; i<N; i++){
      	P[i] = sc.nextInt();
    }
    int min = P[0];
    
    for(int i = 1; i<N; i++){
      if(min >= P[i]){
        count++;
        min = P[i];
      }

    } 
    System.out.println(count);
  }
}


Measured memory_bytes: 84616
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
const int N = 2e7 + 1;
const int mod = 1e9 + 7;
long long a[N], ni[N];
int H, W, K;
long long ans;
long long C(int x , int y)
{
    if (x < y || y < 0) return 0;
    return a[x] * ni[y] % mod * ni[x - y] % mod;
}
long long calc(long long x, long long y)
{
    long long z = 1;
    while (y)
    {
        if (y & 1) (z *= x) %= mod;
        (x *= x ) %= mod, y /= 2;
    }
    return z;
}
int main()
{
    a[0] = 1;
    for (int i = 1 ; i < N ; i ++)
        a[i] = a[i -  1] * i % mod;
    ni[N - 1] = calc(a[N - 1], mod - 2);
    for (int i = N - 2 ; i>=0;  i --)
        ni[i] = ni[i+1] * (i + 1) % mod;
    scanf("%d %d %d", &H, &W, &K);
    ans = C(H + W, K) * a[K] % mod * K % mod;
    for (int i = 2; i <= K ; i ++)
    {
        ans = (ans + (long long)(i - 1) * 2 * H % mod * W % mod * (K - i + 1) % mod * C(H + W - 2, K - 2) % mod * a[K - 2] % mod) % mod;
    }
    for (int i = 1; i <= K ; i ++)
    {
        ans = (ans + (long long)H * C(H + W - 1, K - 1) % mod * a[K - 1] % mod * (K - i + 1) % mod) % mod;
        ans = (ans + (long long)W * C(H + W - 1, K - 1) % mod * a[K - 1] % mod * (K - i + 1) % mod) % mod;
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> yui(n), kyoko(n);
    vector<i_i> data(n);
    for (int i = 0; i < n; i++) {
        cin >> yui[i] >> kyoko[i];
        if (yui[i] > kyoko[i]) swap(yui[i], kyoko[i]);
        data[i].fir = yui[i]; data[i].sec = kyoko[i];
    }

    sort(all(yui)); sort(all(kyoko));
    int ans = (yui.back() - yui[0]) * (kyoko.back() - kyoko[0]);

    bool min_ok = true, max_ok = true;
    if (yui[0] == yui[1]) min_ok = false;
    if (kyoko[n-1] == kyoko[n-2]) min_ok = false;

    sort(all(data));
    //swap(data[0].fir, data[0].sec);
    //sort(all(data));

    int emin = INF, emax = 0;
    rep(i, n-1) {
        //if (data[i].sec == yui[0] && min_ok) continue;
        //if (data[i].sec == kyoko[n-1] && max_ok) continue;
        /*
        emin = min({emin, data[i+1].fir, data[i].sec});
        emax = max({emax, data[n-1].fir, data[i].sec});
        ans = min(ans, (kyoko[n-1] - yui[0]) * (emax - emin));
        */
        emin = min({emin, data[i].sec});
        emax = max({emax, data[i].sec});
        ans = min(ans, (kyoko[n-1] - yui[0]) * 
                (max(emax, data[n-1].fir) - min(emin, data[i+1].fir)));
    }
    emin = min(emin, data[n-1].sec);
    emax = max(emax, data[n-1].sec);
    cout << min(ans, (kyoko[n-1] - yui[0]) * (emax - emin)) << endl;

    /*
    swap(data[0].fir, data[0].sec);
    sort(all(data));
    rep(i, n) cout << data[i].fir << " " << data[i].sec << endl;

    int ans2 = kyoko.back() - yui[0], funami = data[0].fir,
        toshino = data[n-1].fir;

    ans = min(ans, ans2 * (toshino - funami));
    rep(i, n) {
        if (data[i].sec == yui[0] && min_ok) continue;
        if (data[i].sec == kyoko[n-1] && max_ok) continue;
        toshino = min(toshino, data[i].sec);
        funami = max(funami, data[i].sec);
        cout << ans2 * (toshino - funami) << endl;
        ans = min(ans, ans2 * (toshino - funami));
    }
    cout << ans << endl;
    */

    return 0;
}


Measured memory_bytes: 6528