akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;




int main (){
  ll n, c, k;
  cin >> n >> c >> k;

  ll cnt = 0;
  ll res = 1;
  ll time = 0;

  vector<ll> v(n, 0);
  for(ll i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  v.push_back(0LL);

  for(ll i = 1; i < n; i++){
    time += (v[i] - v[i-1]);
    if(time <= k){
      res++;
      if(res == c){cnt++; res = 0LL; time = v[i] - v[i+1];}
      }
    else{
      cnt++; res = 1LL; time = 0LL;
    }
    if(i == n-1 && res != 0){cnt++;}
  }
  if(c == 1){cnt = n;}
  cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n,m;
    cin >> n >> m;
    ll ans;
    if(n==1 && m==1){
        ans = 1;
    }
    else if(n==1){
        ans = (m-2);
    }
    else if(m==1){
        ans = (n-2);
    }
    else{
        ans = (m-2)*(n-2);
    }
    cout << ans;
}

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

int main() {
	vector<vector<int>> a(2,vector<int>(5));
	for(int i=0;i<5;i++){
		cin>>a[0][i];
		a[1][i] = (a[0][i]-1)%10;
	}
	int min,count;
	min=a[1][0];
	count = 0;
	for(int i=1;i<4;i++){
		if(min > a[1][i]){
			min = a[1][i];
			count = i;
		}
	}
	int ans=0;
	for(int i=0;i<5;i++){
		if(i==count)continue;
		ans+=10*((a[0][i]-1)/10)+10;
	}
	cout<<ans+a[0][count] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;cin >> a >> b >>c >> x >> y;
  if(a+b >= 2*c){
    int ans;
    if(x>y){
      ans = y * 2 * c + (x-y) * a;
      ans = min(ans, 2*x*c);   
    }else{
      ans = x * 2 * c + (y-x) * b;
      ans = min(ans, 2*y*c);   
    }
    cout << ans << endl;
  }
  else cout << a*x + b*y << endl;
}

Measured memory_bytes: 3632
module Main where

import Control.Applicative
import Control.Exception (assert)
import Control.Monad

data Test = Test Integer Integer Integer Integer
          deriving (Show, Eq)
data Result = Yes | No
            deriving (Show, Eq)

solve :: Test -> Result
solve (Test a b c d) | d < b = No
                     | a < b = No
                     | c >= b = Yes
                     | k1 < n && a' + k1 * g > c = No
                     | a' + k2 * g < b && a' + k2 * g > c = No
                     | a' + k2 * g >= b && a' + k2 * g > b + c = No
                     | otherwise = Yes
    where a' = a `mod` b
          g = b `gcd` d
          n = b `div` g
          k1 = (b - 1 - a') `div` g
          k2 = n - 1
          -- (a' + k * g) mod b <= c, where k in [0, n).
          -- For all k: k * g < b, a' < b. Therefore, a' + k * g < 2 * b
          -- a' + k * g < b => a' + k * g + 1 <= b => k <= (b - 1 - a') `div` g

tests = [Test 9 7 5 9,
         Test 9 7 6 9,
         Test 14 10 7 12,
         Test 14 10 8 12,
         Test 14 10 9 12,
         Test 14 10 7 11,
         Test 14 10 8 11,
         Test 14 10 9 11,
         Test 9 10 5 10,
         Test 10 10 5 10,
         Test 11 10 5 10,
         Test 16 10 5 10,
         Test 1000000000000000000 17 14 999999999999999985,
         Test 1000000000000000000 17 15 999999999999999985] :: [Test]

main :: IO ()
main = do
  numTests <- read <$> getLine
  replicateM_ numTests $ do
         [a, b, c, d] <- map read . words <$> getLine
         print $ solve (Test a b c d)


Measured memory_bytes: 1020
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //agc31 b
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[] c = new int[200001]; Arrays.fill(c,-1);
        int[] before = new int[n];
        for (int i = 0; i < n; i++) {
            int a = in.ni();
            if(c[a]>=0){
                before[i] = c[a];
            }else{
                before[i] = i;
            }
            c[a] = i;
        }
        long[] dp = new long[n+1];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            dp[i] = dp[i-1];
            dp[i] %= mod;
            if(i-1-before[i-1]>1){
                dp[i] += dp[before[i-1]+1];
                dp[i] %= mod;
            }
        }
        out.println(dp[n]);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 45772
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


long long GCD(long long x, long long y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main() {
    long long N, K;
    while (cin >> N >> K) {
        N %= K;
        cout << min(N, K-N) << endl;
    }
}

















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

#include<cmath>

    vector<vector<uint64_t>> comb(int n, int r) {
      vector<vector<uint64_t>> v(n + 1,vector<uint64_t>(n + 1, 0));
      for (int i = 0; i < v.size(); i++) {
         v[i][0] = 1;
         v[i][i] = 1;
      }
      for (int j = 1; j < v.size(); j++) {
         for (int k = 1; k < j; k++) {
             v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
          }
        }
        return v;
    }



int main()
{


    int n;
    cin>>n;

    map<string, int> m;
    uint64_t sum=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        if(m.count(s)){
            m.at(s)++;
            sum+=m.at(s);
        }
        else
            m[s]=0;
    }

    cout<<sum<<endl;

    return 0;
}   

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main(){
	int n;
	cin >> n;
	vector<vector<int>> num(10,vector<int>(10,0));
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		int N = s.size();
		num[s[0] - '0'][s[N - 1] - '0']++;
	}
	ll ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			ans += num[i][j] * num[j][i];
		}
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 256
def main():
    n,l = map(int,input().split())
    min_diff = float('inf')
    pies = []
    for i in range(1,n+1):
        pies.append(l+i-1)

    total = sum(pies)
    ans = 0

    for i in range(n):
        new = total
        new -= pies[i]
        if abs(new-total) < min_diff:
            min_diff = abs(new-total)
            ans = new

    print(ans)


main()


Measured memory_bytes: 3060
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
dx = [0, 1, 0, -1, 1, 1, -1, -1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            S[i][j] = 0
            for x, y in zip(dx, dy):
                ni = i + x
                nj = j + y
                if 0 <= ni < H and 0 <= nj < W:
                    if S[ni][nj] == '#':
                        S[i][j] += 1
for i in range(H):
    for j in range(W):
        if j + 1 != W:
            print(S[i][j], end='')
        else:
            print(S[i][j])

Measured memory_bytes: 3444
/*
Author:Jenil Mehta
Not yet serious but trying to be serious :)
Coding is lub
*/
 
#include <iostream>
#include <sstream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
void dfs(ll node, vector<ll> adj[], ll dp[], bool vis[]) 
{ 
    // Mark as visited 
    vis[node] = true; 
  
    // Traverse for all its children 
    for (ll i = 0; i < adj[node].size(); i++) { 
  
        // If not visited 
        if (!vis[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, vis); 
  
        // Store the max of the paths 
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
} 
ll find(vector<ll> adj[], ll n) 
{ 
    // Dp array 
    ll dp[n + 1]; 
    memset(dp, 0, sizeof dp); 
  
    // Visited array to know if the node 
    // has been visited previously or not 
    bool vis[n + 1]; 
    memset(vis, false, sizeof vis); 
  
    // Call DFS for every unvisited vertex 
    for (ll i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, adj, dp, vis); 
    } 
  
    ll ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (ll i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
} 
int main() {
   /*
   Jab Bhi Koi Ladaki Dekhun Meraa Dil Divaanaa Bole
Ole Ole Ole, Ole Ole Ole
Gaao Taraanaa Yaaraa Jhum Jhum Ke Haule Haule
Ole Ole Ole, Ole Ole Ole
Mujhako Lubhaati Hai Javaaniya Masti Lutaati Zidagaani Yahaan
Maane Na Kahanaa Paagal Mast Pavan Saa Dil Ye Dole
Ole Ole Ole, Ole Ole Ole
Ole Ole Ole, Ole Ole Ole
Jab Bhi Koi Ladaki Dekhun Meraa Dil Divaanaa Bole
Ole Ole Ole, Ole Ole Ole
Gaao Taraanaa Yaaraa Jhum Jhum Ke Haule Haule
Ole Ole Ole, Ole Ole Ole
   */
    ll n;
    cin>>n;
    ll m;
    ll i,j;
    double a[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    double dp[n+1][n+1];
    memset(dp, 0.0, sizeof(dp));
    dp[0][0]=1.0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=i;j++)
        {
            if (j == 0) 
                dp[i][j] = dp[i - 1][j] 
                           * (1.0 - a[i]); 
            else
                dp[i][j] = dp[i - 1][j] 
                               * (1.0 - a[i]) 
                           + dp[i - 1][j - 1] * a[i]; 
        }
    }
    double ans = 0.0; 
    for (int i = n/2+1; i <=n; i += 1) 
        ans += dp[n][i]; 
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 70528
A = int(input())
B = input()
count_r = B.count("R")
count_g = B.count("G")
count_b = B.count("B")
ans = count_b * count_g * count_r
for i in range(A):
    for j in range(A):
        d = i+j
        f = d+j
        if f >= A:
            break
        if B[i] != B[d] and B[d] != B[f] and B[i] != B[f]:
            ans -= 1
print(ans)

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  if((N == 1) && (M == 1)){
    cout << 1 << endl;
    return 0;
  }

  if((N == 1) || (M == 1)){
    cout << N * M - 2 << endl;
    return 0;
  }

  if((N == 2) || (M == 2)){
    cout << 0 << endl;
    return 0;
  }

  cout << (N - 2) * (M - 2) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,c,p,q,t,x,d,e,f;
    string s,ss;
    vector<ll>v1;
    deque<ll>dq;
    cin>>s;
    t=x=0;
    ll mn=876476328765;
    for(int i=0;i+2<s.size();i++)
    {
        p=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        q=abs(p-753);
        mn=min(mn,q);
    }
    cout<<mn<<endl;
}








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

int main(){
    int a;
    cin >> a;
    vint A(a);
    rep(i,a)
        cin >> A.at(i);
    int mi = 20000000;
    int count = 0;
    rep(i,a){
        if(mi >= A.at(i)){
        mi = min(mi,A.at(i));
        count++;
        }
    }
    cout << count << endl;
}
    

Measured memory_bytes: 1024
//#include "pch.h"
#include <iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	while (1) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0) {
			break;
		}
		else {
			if (x < y) {
				cout << x << " " << y << endl;
			}
			else {
				cout << y << " " << x << endl;
			}
		}
	}
}



Measured memory_bytes: 3108
#define taskname "V"

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;
#define long long long

const int N = 1e5 + 10;

int n, MOD, pre[N], suf[N];
int dp[N][2];
/// dp[v][0] = ans for subtree v if v is black
/// dp[v][1] = when v is black and none of nodes in subtree of v is black
vector<int> g[N];

void dfs(int u, int par = 0)
{
    dp[u][0] = 1;
    for (int v : g[u]) if (v != par) {
        dfs(v, u);
        dp[u][0] = ((long) dp[u][0] * (1 + dp[v][0])) % MOD;
    }
}

void dfs_res(int u, int par = 0)
{
    vector<int> childs;
    for (int v : g[u]) if (v != par) childs.push_back(v);

    pre[0] = suf[childs.size()] = 1;
    for (int i = 0; i < (int) childs.size(); ++i) pre[i + 1] = ((long) pre[i] * (1 + dp[childs[i]][0])) % MOD;
    for (int i = childs.size() - 1; i >= 0; --i) suf[i] = ((long) suf[i + 1] * (1 + dp[childs[i]][0])) % MOD;
    for (int i = 0; i < (int) childs.size(); ++i)
        dp[childs[i]][1] = 1 + ((((long) pre[i] * suf[i + 1]) % MOD) * (long) dp[u][1]) % MOD;
    for (int v : childs) dfs_res(v, u);
}

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n >> MOD;
    for (int i = 1, u, v; i < n; ++i) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(1);
    dp[1][1] = 1;
    dfs_res(1);

    for (int i = 1; i <= n; ++i) cout << ((long) dp[i][0] * dp[i][1]) % MOD << '\n';

    return 0;
}


Measured memory_bytes: 17664
// AOJ Volume 0 Problem 0004

#include <stdio.h>

int main(void)
{
    float a, b, c, d, e, f;
    float x, y;
    
    while (scanf("%f%f%f%f%f%f", &a, &b, &c, &d, &e, &f) != EOF){
        y = (c * d - a * f) / (b * d - a * e);
        
        x = (c - b * y) / a;
        
        printf("%.3f %.3f\n", x, y);
    }
    
    return (0);
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        long ans = 0;
        for (int torukazu = 0; torukazu <= k; torukazu++) {
            int tumerukazu = k - torukazu;
            for (int hidarikara = 0; hidarikara <= torukazu; hidarikara++) {
                int migikara = torukazu - hidarikara;

                PriorityQueue<Integer> queue = new PriorityQueue<>();
                int[] v_copy = Arrays.copyOf(v, v.length);

                for (int i = 0; i < Math.min(hidarikara, n); i++) {
                    queue.add(v_copy[i]);
                    v_copy[i] = 0;
                }
                for (int i = 0; i < Math.min(migikara, n); i++) {
                    queue.add(v_copy[n-1-i]);
                    v_copy[n-1-i] = 0;
                }

                for (int i = 0; i < tumerukazu; i++) {
                    Integer e = queue.peek();
                    if(e == null) break;
                    if(e <= 0) queue.poll();
                }
                long sum = 0L;
                for (int p : queue) {
                    sum += p;
                }
                ans = Math.max(ans, sum);
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    cin >> n;
    map<int, int> mp;

    roop(i, n-1){
        int x; cin >> x;
        mp[x-1]++;
    }

    roop(i, n){
        cout << mp[i] << endl;
    }

    return 0;
}


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

typedef long long int ll;
ll mod = 1000000007;
ll mask = 0;

ll n;
ll arr[25][25];
ll dp[25][1<<22];
ll fmask = 0;


ll solve(ll i,ll mask){
	
	//cout<<i<<" "<<mask<<endl;
	if(i==n and mask == fmask)return 1;
	if(i==n)return 0;
	
	if(dp[i][mask]==-1){
		
		ll z = 0;
		
		for(ll j=0;j<n;++j){
			
			if(arr[i][j]==1 and (mask&(1<<j)) == 0)
			{
				//cout<<i<<" "<<mask<<endl;
				z = ((z)%mod+(solve(i+1,mask+(1<<j)))%mod)%mod;
				//z+=solve(i+1,mask+(1<<j));
			}
		}
		
		dp[i][mask] = z;
	}
	return dp[i][mask];
	
	
}

int main(){
	
	cin>>n;
	
	fmask = (1<<(n))-1;
	//cout<<fmask<<endl;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++)cin>>arr[i][j];
	}
	
	cout<<solve(0,0)<<endl;
	
}

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

//不足しているカードを検出するプログラム
int main(){
    char mark;
    int i, j, n, number, mark_number;
    int array[4][13] = {};          //始めに、4行13列の二次元配列を用意してすべてに0を格納する。
                                    //行がトランプのマーク、列が数字に対応する。
    cin >> n;
    
    i = 0;
    while(i < n){           //手札にあるカードを処理するループ
        cin >> mark >> number;

        if (mark == 'S') mark_number = 0;           //文字のままでは配列を操作できないので、それぞれ順番に0~3を対応させる。
        if (mark == 'H') mark_number = 1;
        if (mark == 'C') mark_number = 2;
        if (mark == 'D') mark_number = 3;

        array[mark_number][number-1] = 1;           //手札にあったカードの場所には始めに用意した4行13列の配列に1を格納する。
        i++;
    }
    
    i = 0;
    while(i < 4){           //結果を出力するループ
        j = 0;
        while (j < 13){
            if (array[i][j] == 0){          //不足しているカードの場所には0が格納されたままなので、i行j列が0であるカードを出力する。
                if (i == 0) cout << "S" << " " << j+1 << endl; 
                if (i == 1) cout << "H" << " " << j+1 << endl;
                if (i == 2) cout << "C" << " " << j+1 << endl;
                if (i == 3) cout << "D" << " " << j+1 << endl;
            }
            j++;
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 3044
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<list>
#include<string>
#include<algorithm>
 
using namespace std;

int main() {
  long long k,n;
  vector<long long> dis;
  vector<long long> vc;
  cin >> k >> n;
  for(int i=0;i<n;i++){
    long long a;
    cin >> a;
    vc.push_back(a);
  }
  for(int i=0;i<vc.size();i++){
    if(i!=vc.size()-1){
      dis.push_back(vc[i+1]-vc[i]);
    }else{
      dis.push_back((k-vc[i])+vc[0]);
    }
  }
  sort(dis.begin(),dis.end());
  long long ans=0;
  for(int i=0;i<n-1;i++){
    ans += dis.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, K; cin >> N >> K;
  vector<int> hs(N); for (auto &h : hs) cin >> h;
  vector<int64_t> dp(N, 1e15); dp[0] = 0;
  for (int i = 0; i < N; ++i) for (int j = 1; j <= K; ++j)
    if (i + j < N) dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i] - hs[i + j]));
  cout << dp[N - 1] << endl;}

Measured memory_bytes: 4276
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

int main() {
    int n, t, a[100000];
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int c = 1000000000,p = 0;
    for ( int i = 0;i < n;i ++) {
        c = min(c,a[i]);
        p = max(p,a[i]-c);
    }
    c = 1000000000;
    int r = 0;
    for(int i = 0;i < n;i++) {
        c = min(c,a[i]);
        if(a[i] - c == p) r++;
    }
    cout << r << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
long long int N,M,V,E,A[200000],t[2000],d[2000],tim[2000];
long long int dp[2000005]={},sum[100050][22]={},fin[2000050]={};
pll edge[30][30];
string S;



int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    if((N*M)%2==0){
        cout<<"Even"<<endl;
    }else{
        cout<<"Odd"<<endl;
    }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static int n;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		dfs("", 'a');
		sc.close();
	}
	
	static void dfs(String s, char max) {
		if (s.length() == n)
			System.out.println(s);
		else
			for (char c = 'a'; c <= max; c++)
				dfs(s + c, c == max ? (char) (max + 1) : max);
	}
}


Measured memory_bytes: 42944
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
using namespace std;

char S[1000000];

int main() {
	scanf("%s", S);
	int l = strlen(S);
	S[l - 8] = '\0';
	printf("%s\n", S);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 1;
const ll mo = 1000000007;
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> x(n);
rep(i, n){
  cin >> x[i];
}
vector<ll> fac = factorial(100000);
ll a=1,cnt=0;
rep(i,n){
  if(x[i]<a){
    ans*=i+1-cnt;
    ans%=mo;
    cnt++;
  }
  else{
    a+=2;
  }
}
ans*=fac[n-cnt];
ans%=mo;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    int h;
    int w;
    int n;
    vector<int> a;
    int tmp_a;
    cin >> h >> w;
    cin >> n;
    vector<vector<int>> ans(h, vector<int>(w));
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }

    int idx=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int tmp_j;
            if(i%2==0){
                tmp_j=j;
            }else{
                tmp_j=w-1-j;
            }
            if(a[idx]==0){
                idx++;
            }
            a[idx]--;
            ans[i][tmp_j]=idx+1;
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long LL;
const int MM = 200000;
LL fac[MM + 10],rev[MM + 10];
LL H,W,A,B;
const int MOD = 1e9 + 7;


LL quick_pow(LL a,LL x)
{
    LL ret = 1;
    while(x)
    {
        if (x & 1) ret = ret * a % MOD;
        x >>= 1;
        a = a * a % MOD;
    }
    return ret;
}

LL rv(LL x)
{
    return quick_pow(x, MOD - 2);
}

LL C(LL N,LL M)
{
    return fac[N] * rev[M] % MOD * rev[N - M] % MOD;
}

int main()
{
    fac[0] = 1;
    for (int i=1;i<=MM;i++)fac[i] = 1LL * fac[i-1] * i % MOD;
    rev[MM] = rv(fac[MM]);
    for (int i=MM - 1;i >= 0;i--)rev[i] = 1LL * rev[i + 1] * (i + 1) % MOD;
    scanf("%lld%lld%lld%lld",&H,&W,&A,&B);
    LL ans = C(H + W - 2, H - 1);
    //printf("%lld\n",ans);
    for (LL i=1;i<=B;i++) ans -= C(H - A - 1 + i - 1, i - 1) * C(W - i + A - 1, A - 1) % MOD;
    ans %= MOD;
    if (ans < 0) ans += MOD;
    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	ll N, x;
	cin >> N >> x;
	vl a(N);
	REP(i, N) {
		cin >> a[i];
	}

	ll ans = 0;
	REP(i, N - 1) {
		if (a[i] + a[i + 1] > x) {
			if (a[i] >= x) {
				ans += a[i + 1];
				a[i + 1] = 0;
				ans += a[i] - x;
				a[i] = x;
			} else {
				ll aa = (a[i] + a[i + 1]) - x;
				ans += aa;
				a[i + 1] -= aa;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        private string Calc(long N)
        {
            var answer = new StringBuilder();
            while (true)
            {
                N -= 1;
                answer.Insert(0, (char)((long)'a' + (N % 26)));
                N /= 26;
                if (N == 0)
                {
                    break;
                }
            }

            return answer.ToString();
        }
        public void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            Console.WriteLine(this.Calc(N));
        }
    }
}


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

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

    bool ans = false;

    for(int i = 1;i <= 9;i++) 
    {
        if(N % i == 0 && N / i <= 9) 
        {
            ans = true;
        }
    }

    if(ans) 
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int sz[]={0, 5, 9, 13};
int dx[] = {0, 0, 0, 1, -1, 1, 1, -1, -1, 0, 0, 2, -2};
int dy[] = {0, 1, -1, 0, 0, 1, -1, 1, -1, 2, -2, 0, 0}; 
int fld[11][11]={{0}};
int cnt = 100;
int mx = 0;

bool inborder(int x, int y){
	return (x>=0&&x<10&&y>=0&&y<10);
}

int main(){

	int x, y, siz;
	char c;

	while(cin >> x >> c >> y >> c >> siz, !cin.eof()){
		
		for(int i=0; i<sz[siz]; i++){
			
			int nx = x+dx[i], ny = y+dy[i];
			
			if( inborder(nx, ny) ){
				
				if(fld[nx][ny]==0)
					cnt--;
				
				mx = max(mx, ++fld[nx][ny]);
			}
		}
	}
	
	cout << cnt << '\n' << mx << endl;

	return 0;
}

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

int main(){
	int n;
	vector<pair<int,int> > rank(101);
	for(int i=0; i<101; i++ ) rank[i] = make_pair(0,i);
	while( cin >> n ){
		rank[n].first++;
	}
	sort(rank.begin(), rank.end(),greater<pair<int,int> >());
	vector<int> ans;
	ans.push_back(rank[0].second); 
	for(int i=1; rank[i-1].second>rank[i].second; i++) ans.push_back(rank[i].second);
	sort(ans.begin(), ans.end());
	for(int i=0; i<ans.size(); i++ ) cout << ans[i] << endl;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <fstream>
#include <iostream>
using namespace std;

int p[20005];

int main() {
    //ifstream cin("f.in");
    int n;
    cin >> n;
    for (int x, i = 1; i <= n; ++ i) {
        cin >> x;
        p[x] = i;
    }
    for (int i = 1; i <= n; ++ i) {
        cout << n * i << (i == n ? "\n" : " ");
    }
    for (int i = 1; i <= n; ++ i) {
        cout << (n - i) * n + p[i] << (i == n ? "\n" : " ");
    }
    return 0;
}


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

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> p(m, vector<int>(n));
    for (int j = 0; j < m; ++j)
      for (int k = 0; k < n; ++k)
        cin >> p[j][k];

    if (n == 0 && m == 0)
      break;

    int ans = 0;
    for (int k = 0; k < n; ++k) {
      int sum = 0;
      for (int j = 0; j < m; ++j)
        sum += p[j][k];
      ans = max(sum, ans);
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 3296
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        if (x < 1200){
            System.out.println("ABC");
        }else{
            System.out.println("ARC");
        }
    }
}

Measured memory_bytes: 20820
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<chrono>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K;
ll A,B,C,D,X,Y;
ll ans=INF;
string G[100010];
string S,T,U;
ll F[100010];
bool ok=true;
std::queue<ll> Q;
ll Z[]={1,2,3,6,7,8,9,0};
int main(){
    cin>>A>>B;
    cout<<A*B;
    
}


Measured memory_bytes: 6764
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main
{

  public static void main(String[] args)
  {
    try (Scanner scanner = new Scanner(System.in))
    {
      while (scanner.hasNextLine())
      {
        int n = Integer.valueOf(scanner.nextLine());
        int[][] data = new int[n][2];
        for (int i = 0; i < n; i++)
        {
          String[] tmp = scanner.nextLine().split(" ");
          data[i][0] = Integer.valueOf(tmp[0]);
          data[i][1] = Integer.valueOf(tmp[1]);
        }
        solver(data);
      }
    }
  }

  private static void solver(int[][] data)
  {
    int ans = Integer.MAX_VALUE;
    int diffX = Integer.MAX_VALUE;

    Arrays.parallelSort(data, new Comparator<int[]>() {
      @Override
      public int compare(int[] o1, int[] o2)
      {
        return Integer.compare(o1[0], o2[0]);
      }
    });

    for (int i = 0; i < data.length; i++)
    {
      for (int j = i + 1; j < data.length; j++)
      {
        
        if (diffX < Math.abs(data[i][0] - data[j][0]))
        {
          break;
        }
    
        int tmp = (data[i][0] - data[j][0]) * (data[i][0] - data[j][0])
            + (data[i][1] - data[j][1]) * (data[i][1] - data[j][1]);

        if (ans > tmp)
        {
          ans = tmp;
          diffX = (int) Math.sqrt(ans);
        }
      }
    }

    System.out.println(ans);
  }

}



Measured memory_bytes: 560228
use std::io;

fn next_vec() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn main() {
    let v = next_vec();
    let a = v[0];
    let b = v[1];

    let ans = if a <= 0 && b >= 0 {
        "Zero"
    } else if a > 0 {
        "Positive"
    } else if (b - a) % 2 == 0 {
        "Negative"
    } else {
        "Positive"
    };

    println!("{}",ans);
}


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

int main(){
    int n,d,a;
    cin>>n>>d>>a;
    vector<pair<int,int>>monsters;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        y=(y+a-1)/a;
        monsters.emplace_back(x,y);
    }
    sort(monsters.begin(),monsters.end());
    long long running_sum=0;
    vector<long long>change(n+1);
    long long ans =0;
    for(int i=0;i<n;i++){
        running_sum+=change[i];
        int cmh = monsters[i].second-running_sum;
        if(cmh<=0)continue;
        int low=i;int high=n-1;
        int ok=-1;
        while(low<=high){
            int mid = (low+high)/2;
            if(monsters[mid].first<=monsters[i].first+2LL*d){
                ok = mid;
                low = mid+1;
            }
            else{
                high = mid-1;
            }
        }
        running_sum+=cmh;
        ans+=cmh;
        change[ok+1]-=cmh;
    }
    cout<<ans;
}

Measured memory_bytes: 3440
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
int main () {
    
    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k;

    char a = s[k-1];
    for (int i = 0; i < s.length(); i++) {
        if(s[i] != a) {
            s[i] = '*';
        } 
    }

    cout << s << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,t,s[100],sa[100];
void angel(int turn){
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int o=0;o<n;o++){
            if(sa[i]==sa[o]){
                cnt++;
            }
        }
        s[i]=cnt;
        cnt=0;
    }
    int check=0;
    for(int i=0;i<n;i++){
        if(s[i]!=sa[i]){
            check=1;
        }
    }
    if(check==0){
        t=turn;
    }
    else{
        for(int i=0;i<n;i++){
            sa[i]=s[i];
        }
        angel(turn+1);
    }
}
int main(void){
    cin>>n;
    while(n!=0){
        for(int i=0;i<n;i++){
            cin>>s[i];
            sa[i]=s[i];
        }
        angel(0);
        cout<<t<<endl;
        for(int i=0;i<n;i++){
            if(i<n-1){
                cout<<s[i]<<' ';
            }
            else{cout<<s[i];}
        }
        cout<<endl;
        cin>>n;
    }
    return 0;
}

Measured memory_bytes: 3048
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Data.Char
import Data.List
import Data.Function
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main :: IO()
main = do
  [a, b] <- getIntList
  print . ceiling $ on (/) fromIntegral (b-1) (a-1)

-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine


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

const int N = 3000;

double exdp[N];
double dp[N];
double p[N];

int main()
{
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> p[i];
	}
	
	exdp[0] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < i; j++)
		{
			dp[j] += exdp[j] * (1.f - p[i]);
			dp[j + 1] += exdp[j] * p[i];
		}
		
		for(int j = 0; j <= i; j++)
		{
			exdp[j] = dp[j];
			dp[j] = 0;
		}
	}
	
	double res = 0;
	
	for(int i = n / 2 + n % 2; i <= n; i++)
	{
		res += exdp[i];
	}
	
	cout << setprecision(12) << res;
	
	return 0;
}

Measured memory_bytes: 256
// #include <iostream>
// #include <cmath>
// #include <vector>

// using namespace std;

// struct Circle {
//     int x, y, r, c;
//     Circle() {}
//     Circle(int x, int y, int r, int c)
//         : x(x), y(y), r(r), c(c) {}
// };

// int n, ans;
// vector<char> dp, up;
// vector<Circle> c;

// inline bool isOverlap(const Circle &a, const Circle &b)
// {
//     int r = (a.r + b.r) * (a.r + b.r);
//     int d = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
//     return r > d;
// }

// char Rec(char s)
// {
//     if (dp[s] != -1)
//         return dp[s];

//     int res = 0;
//     // 取り除く2つの円の選択
//     for (int i = 0; i < n; ++i) {
//         // c[i]がないか取り除けない
//         if (!(s >> i & 1) || s & up[i])
//             continue;

//         for (int j = i + 1; j < n; ++j) {
//             // c[i]とc[j]の色が異なる
//             if (c[i].c != c[j].c)
//                 continue;
//             // c[j]がないか取り除けない
//             if (!(s >> j & 1) || s & up[j])
//                 continue;

//             int nxt = s & ~(1 << i) & ~(1 << j);
//             res = max(res, (int)Rec(nxt) + 2);
//         }
//     }

//     ans = max(ans, res);

//     return dp[s] = res;
// }

// int main()
// {
//     while (cin >> n, n) {
//         dp.assign(1 << n, -1);
//         up.assign(n, 0);
//         c.resize(n);

//         // 円の入力
//         for (int i = 0; i < n; ++i)
//             cin >> c[i].x >> c[i].y >> c[i].r >> c[i].c;

//         // 円の重なり，上下関係
//         for (int i = 0; i < n; ++i)
//             for (int j = i + 1; j < n; ++j)
//                 if (isOverlap(c[i], c[j]))
//                     up[j] |= (1 << i);

//         ans = 0;
//         Rec((1 << n) - 1);

//         cout << ans << endl;
//     }

//     return 0;
// }
#include <iostream>
#include <cstring>
using namespace std;

int n;
int x[24],y[24],c[24],r[24];
char memo[1<<24];
int hit(int i,int j){
	int L = r[i]*r[i] + r[j]*r[j] + 2 * r[i] * r[j];
	int X = (x[i]-x[j])*(x[i]-x[j]);
	int Y = (y[i]-y[j])*(y[i]-y[j]);
	return X + Y < L;
}
int nocover(int n,int bit){
	for(int i = 0 ; i < n ; i++){
		if( (bit>>i&1) && hit(i,n) ) return false;
	}
	return true;
}
int dfs(int bit){
	if(~memo[bit]) return memo[bit];
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		for(int j = i+1 ; j < n ; j++){
			if( (bit >> j & 1) && (bit >> i & 1) && c[i] == c[j] && nocover(i,bit) && nocover(j,bit) ){
				ans = max(ans , dfs( bit & ~(1<<j) & ~(1<<i) ) + 2);
			}
		}
	}
	return memo[bit] = ans;
}
int main(){
	while(cin >> n , n){
		for(int i = 0 ; i < n ; i++){
			cin >> x[i] >> y[i] >> r[i] >> c[i];
		}
		memset(memo,-1,sizeof(memo));
		cout << dfs((1<<n)-1) << endl;
	}
}

Measured memory_bytes: 17552
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n:usize,
        vs:[usize;n],
    }

    let mut vs = vs;
    vs.sort();
    let ans = vs.iter().fold(0.0,|acc,cur|{
        if acc == 0.0 {
            return *cur as f32;
        }else{
            return (acc + *cur as f32) / 2.0;
        }
    });
    println!("{}",ans);

}  


Measured memory_bytes: 4352
/*input
10
1 3 2 3 3 2 3 2 1 3
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 300005
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

long double dp[305][305][305];


int main() 
{
    off;
    ll n,ones=0,twos=0,threes=0,x;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        if(x==1)
            ones++;
        if(x==2)
            twos++;
        if(x==3)
            threes++;
    } 
    memset(dp,0,sizeof(dp));
    for(ll k=0;k<=n;k++)
    {
        for(ll j=0;j<=n;j++)
        {
            for(ll i=0;i<=n;i++)
            {
                if((i==0&&j==0&&k==0)||(i+j+k>n))
                    continue;
                ll total=(i+j+k);
                double ans=n;
                if(i)
                    ans+=i*dp[i-1][j][k];
                if(j)
                    ans+=j*dp[i+1][j-1][k];
                if(k)
                    ans+=k*dp[i][j+1][k-1];
                ans=ans/(total*1.0);
                dp[i][j][k]=ans;
            }
        }
    }
    cout<<setprecision(10);
    cout<<dp[ones][twos][threes];
    return 0;
}

Measured memory_bytes: 443520