akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int n, m;
    cin >> n >> m;


    cout << n * (n - 1) / 2 + m * (m - 1) / 2;

    return 0;   
}   

Measured memory_bytes: 892
from collections import defaultdict

def abc152_d():
    N = int(input())
    freq = defaultdict(int)
    for i in range(1, N+1):
        s = str(i)
        freq[(s[0], s[-1])] += 1  # (先頭,末尾) となる個数を数える

    ans = 0
    for i in range(1, N+1):
        s = str(i)
        ans += freq[(s[-1], s[0])]  # ペアになる (末尾, 先頭) の個数を足していく
    print(ans)

abc152_d()

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	double x, y;
	int a, b;
	cin >> a >> b;
	y = b / 2.0 - a;
	x = a - y;
	if(x >= 0 && y >= 0 && int(x) == x && int(y) == y) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 3652
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextInt64() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}


func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func absi(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

type Int64s []int64
func (f Int64s) Len() int {
	return len(f)
}
func (f Int64s) Less(i, j int) bool {
	return f[i] < f[j]
}

func (f Int64s) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}


func solve(io *Io) {
	n := io.NextInt()

	ans := 1
	for i := 2; i < n; i++ {
		for cur := i * i; cur <= n; cur *= i {
			ans = intMax(ans, cur)
		}
	}

	io.PrintLn(ans)
}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}

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

int main(){
  int a,b;
  cin >>a >>b;
  if(a>=13) cout << b << endl;
  else if(a>=6 && a<=12) cout << b/2 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int t, i, dansa, n[100], max, min;
  scanf("%d",&t);
  for(;t > 0; t-- ) {
    scanf("%d",&dansa);
    max = 0;
    min = 0;
    scanf("%d",&n[0]);
    for(i = 1; i < dansa; i++ ) {
      scanf("%d",&n[i]);
      if(n[i] - n[i-1] > max) max = n[i] - n[i-1];
      if(n[i] - n[i-1] < min) min = n[i] - n[i-1];
    }
    printf("%d %d\n",max,min*-1);
  }
  return(0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;


using namespace std;

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

void solve() {
    int N; cin >> N;

    int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 21760
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int count = 0;
    rep(i,3){
        if(s[i] == '1') count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v, y, m; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int num(string& s, int l, int r) {
	int x = 0;
	for (int i = l; i < r; i++)
		x = x * 10 + (s[i] - '0');
	return x;
}

set<int> f(string& s, int l, int r) {
	set<int> Z;
	int lev = 0;
	bool flag = false;
	for (int i = l; i < r; i++) {
		char c = s[i];
		if (c == '(') lev++;
		if (c == ')') lev--;
		if (lev == 0 && (c == '+' || c == '-' || c == '*' || c == '/')) {
			set<int> X = f(s, l, i), Y = f(s, i + 1, r);
			for (set<int>::iterator ix = X.begin(); ix != X.end(); ix++)
				for (set<int>::iterator iy = Y.begin(); iy != Y.end(); iy++) {
					int x = *ix, y = *iy;
					if (c == '+') Z.insert(x + y);
					if (c == '-') Z.insert(x - y);
					if (c == '*') Z.insert(x * y);
					if (c == '/' && y != 0) Z.insert(x / y);
				}
			flag = true;
		}
	}
	if (flag) return Z;
	else if (s[l] == '(') return f(s, l + 1, r - 1);
	Z.insert(num(s, l, r));
	return Z;
}

int main() {
	for (;;) {
		string s; cin >> s;
		if (s == "#") break;
		int l = 0, r = s.length();
		set<int> Z = f(s, l, r);
		cout << Z.size() << endl;
	}
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,t,l,b;
  cin>>n>>t>>l>>b;

  while(n!=0){
    vector<ld> board1(n+1);
    vector<ld> board2(n+1);
    vector<ld> board_keep(n+1);
    vector<ld> lose(l);
    vector<ld> back(b);
    FOR(i,0,l){
      cin>>lose[i];
    }
    FOR(i,0,b){
      cin>>back[i];
    }
    board1[0] = 1;

    FOR(a,0,t){

      FOR(i,0,n){
        FOR(j,1,7){
          ll pos = i+j;
          if(pos>=n+1){
            pos = n+1 - (pos-n) - 1;
          }
          board2[pos] += board1[i]/6.0;
        }
      }
      board2[n] += board1[n];

      FOR(i,0,n+1){
        board1[i] = board_keep[i];
        board_keep[i] = 0;
      }
      FOR(i,0,l){
        board_keep[lose[i]] = board2[lose[i]];
        board2[lose[i]] = 0;
      }
      FOR(i,0,b){
        board2[0] += board2[back[i]];
        board2[back[i]] = 0;
      }
      FOR(i,0,n+1){
        board1[i] += board2[i];
        board2[i] = 0;
      }
      //cout<<"t = "<<a<<endl;
      //FOR(i,0,n+1){
      //  cout<<board1[i]<<" ";
      //}
      //cout<<endl;
      //FOR(i,0,n+1){
      //  cout<<board_keep[i]<<" ";
      //}
      //cout<<endl;

    }

    ld sum=0;
    FOR(i,0,n+1){
      sum += board1[i]+board_keep[i];
    //  cout<<board1[i]+board_keep[i]<<" ";
    }
    //cout<<endl;
    //cout<<sum<<" "<<board1[n]<<endl;
    ld res = board1[n]/sum;
    cout(10)<<res<<endl;
    cin>>n>>t>>l>>b;
  }

}



Measured memory_bytes: 3148
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

k, x = li()

ans = [i for i in range(max(-10**6, x-k+1), min(10**6, x+k-1)+1)]
print(*ans)

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

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

    int n;
    cin >> n;

    vector<int> bucket(n, 0);
    rep(i, n-1){
        int a;
        cin >> a;
        --a;

        ++bucket[a];
    }

    rep(i, n) cout << bucket[i] << endl;

    return 0;
}

Measured memory_bytes: 3992
n,m,l=map(int,input().split())
lst1=[list(map(int,input().split())) for i in range(n)]
lst2=[list(map(int,input().split())) for i in range(m)]
ans=[[0]*l for i in range(n)]
for i in range(n):
    for j in range(l):
        ans[i][j]= str(sum( lst1[i][k]*lst2[k][j] for k in range(m)))
for A in ans:
    print(*A)


Measured memory_bytes: 7268
import sys

n,m = map(int,input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)

for _ in range(m):
    x,y,z = map(int,input().split())
    uf.union(x-1, y-1)

print(uf.group_count())


Measured memory_bytes: 69592
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 1e5 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

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

//modular arithmetic
int powermod(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}


//Find all paths from a to b in an undirected graph
vector<int> g[MAX];
int visited[MAX];
//count of all the paths from 1 to n;

void dfs(int visited[MAX], int u, int v, vector<int> path)
{
	visited[u] = 1;
	if (u == v)
	{
		for (int i = 0; i < path.size(); i++)
		{
			cout << path[i] << " ";
		}
		cout << "\n";
	}
	else
	{
		for (int i = 0; i < g[u].size(); i++)
		{
			int y = g[u][i];

			if (visited[y] == 0)
			{
				visited[y] = 1;
				path.pb(y);
				dfs(visited, y, v, path);
				path.pop_back();
			}

		}
	}

	visited[u] = 0;

}

vector<int> graph[MAX];
int vis[MAX];

void dfs(int v)
{
	vis[v] = 1;
	
	for(auto x: graph[v]){
	    
		if(vis[x] == 0)
		{
		    dfs(x);
		}
		
	}
}

void solve()
{
	int n;
	cin>>n;
	vector<int> v;
	int count =0;
	while(n--)
	{
	    int x,y;
	    cin>>x>>y;
	    
	    if(x==y)
	    {
	        count++;
	    }
	    else
	    {
	        v.pb(count);
	        count = 0;
	       
	    }
	}
	
	v.pb(count);
	
	int cnt = 0;
	for(int i=0;i<v.size();i++)
    {
        if(v[i]>=3)
        {
            cnt = 1;
            break;
        }
    }
    
    if(cnt)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
	
//	cout<<x<<"\n";
}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "\n" << "Time elapsed : " << time_passed << "\n";
	return 0;
}

Measured memory_bytes: 8540
<?php
list($n,$l)=fscanf(STDIN,"%d %d");
$arrInputs=array();
for($i=0;$i<$n;++$i){
    $input=trim(fgets(STDIN));
    array_push($arrInputs,$input);
}
sort($arrInputs);
echo implode("",$arrInputs);
?>

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
        long n;
        while(cin>>n)
        {
            long a[100100],m=1000000000,x,i;
            fr(i,n)
            cin>>a[i];

            for(i=-1000;i<=1000;i++)
            {
                x=0;
                fr(j,n)
                {
                    x+=(i-a[j])*(i-a[j]);
                }
                m=min(m,x);
            }
            cout<<m<<"\n";
        }
        return 0;

}




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

int main() {
  int N;
  cin >> N;
  map<int, bool> mp;
  int in;
  while(cin >> in) {
    if (mp.find(in) == mp.end()) {
      mp[in] = true;
    }
  }
  cout << mp.size() << endl;
}


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

using namespace std;
int main()
{
  int N,K;
  string S;
  cin >> N >> K >> S;
  
  for( int i=0;i<N;i++ )
    {
      if( i!=K-1 )
	cout << S[i];
      else
	cout << (char)(S[i]-'A'+'a');
    }
  cout << endl;
}


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

int main(){
    int n;
    cin >> n;
    string flag = "Yes";
    vector<tuple<long,long>> w(n);
    for(int i=0;i<n;i++){
        long a,b;
        cin >> a >> b;
        w.at(i) = make_tuple(b,a);
    }
    sort(w.begin(),w.end());
    long past = 0;
    for(int i=0;i<n;i++){
        past += get<1>(w.at(i));
        if(past > get<0>(w.at(i))){
            flag = "No";
            break;
        }
    }
    cout << flag;


}


Measured memory_bytes: 3328
a, b, c = [input() for _ in range(3)]


x = 'a'

while True:
    if x == 'a':
        if a == []:
            print('A')
            break
        x, *a = a
    elif x == 'b':
        if b == []:
            print('B')
            break
        x, *b = b
    elif x == 'c':
        if c == []:
            print('C')
            break
        x, *c = c


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <ctime>
#include <map>
#include <set>
using namespace std;

#define fs first
#define sc second
#define pb push_back
#define mp make_pair 
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;

const int N = 1e5 + 10;
const int mo = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mo)
		if(b & 1) ans = (ll) ans * a % mo;
	return ans;
}
string s[200010];
vector<string> vec;
map<string, int> Map;
int main() {
	int n; scanf("%d", &n); int ans = 0;
	for(int i = 1; i <= n; i ++) {
		cin >> s[i];
		ans = max(ans, ++ Map[s[i]]);
	}
	for(int i = 1; i <= n; i ++) {
		if(Map[s[i]] == ans) {
			Map[s[i]] = 0;
			vec.pb(s[i]);
		}
	}
	sort(vec.begin(), vec.end());
	for(auto s : vec) printf("%s\n", s.c_str());
	return 0;
} 

Measured memory_bytes: 28404
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int N, M;
vector<int> arr;
bool next_kms() {
	for (int i = N - 1; i >= 0; --i) {
		if (arr[i] != M) {
			++arr[i];
			for (int j = i + 1; j < N; ++j) arr[j] = arr[i];
			return true;
		}
	}
	return false;
}
int main() {
	int Q, ans = 0;
	scanf("%d %d %d", &N, &M, &Q);
	int a[Q], b[Q], c[Q], d[Q];
	for (int i = 0; i < Q; ++i) scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
	arr = vector<int>(N, 1);
	do {
		int tans = 0;
		for (int i = 0; i < Q; ++i) {
			if (arr[b[i] - 1] - arr[a[i] - 1] == c[i]) tans += d[i];
		}
		ans = max(ans, tans);
	} while (next_kms());
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

long long N,A,B;
vector<long long> V;
vector<long long> res;
vector<vector<long long>> C;

int main() {
	C.resize(51);
	C[0].resize(1);
	C[0][0] = 1;
	C[1].resize(2);
	C[1][0] = 1;
	C[1][1] = 1;
	for (int n = 2; n <= 50; n++) {
		C[n].resize(n + 1);
		C[n][0] = 1;
		for (int k = 1; k <= n - 1; k++)C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
		C[n][n] = 1;
	}
	cin >> N >> A >> B;
	V.resize(N);
	for (int n = 0; n < N; n++)cin >> V[n];
	sort(V.begin(), V.end());
	res.resize(N+1);
	//とりあえず平均最大を求める
	long long avmaxsum = 0;
	long long avmaxn = 0;
	for (int n = A; n <= B; n++) {
		long long sumtemp = 0;
		for (int l = N - 1; l >= N - n; l--)sumtemp += V[l];
		if (avmaxsum * n <= sumtemp * avmaxn) {
			avmaxsum = sumtemp;
			avmaxn = n;
		}
		res[n] = sumtemp;
	}
	long long ans = 0;
	//nのうち、平均最大となるものだけ考える
	for (int n = A; n <= B; n++) {
		if (res[n] * avmaxn != avmaxsum * n)continue;
		//V[N-n]下端
		int s = -1, e = N;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (V[m] >= V[N - n])e = m;
			else s = m;
		}
		int down = e;
		s = -1, e = N;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (V[m] > V[N - n])e = m;
			else s = m;
		}
		int up = e;
		//V[N-n]と等しい値を何個取るか
		int vn = s - (N - n) + 1;
		//(up-down)Cvn
		ans += C[up - down][vn];
	}
	cout << setprecision(24) << (long double)avmaxsum / avmaxn << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    ac = set()
    wa = [0] * (n+1)

    for _ in range(m):
        p, s = input().split()
        p = int(p)
        if p in ac:
            continue
        if s == 'AC':
            ac.add(p)
        elif s == 'WA':
            wa[p] += 1
    wa = [j for i, j in enumerate(wa) if i in ac]
    print(len(ac), sum(wa))

if __name__ == '__main__':
    main()


Measured memory_bytes: 12652
x=[int(i)for i in input().split()]
y=[[int(0)for i in range(4)]for i in range(3)]
y[0][1]=x[0]
y[1][1]=x[1]
y[1][2]=x[2]
y[1][0]=x[3]
y[1][3]=x[4]
y[2][1]=x[5]
m=[i for i in input()]
for i in range(len(m)):
    if m[i]=='N':
        y[0][1],y[1][1]=y[1][1],y[0][1]
        y[1][1],y[2][1]=y[2][1],y[1][1]
        y[2][1],y[1][3]=y[1][3],y[2][1]
    elif m[i]=='S':
        y[0][1],y[1][3]=y[1][3],y[0][1]
        y[1][3],y[2][1]=y[2][1],y[1][3]
        y[2][1],y[1][1]=y[1][1],y[2][1]
    elif m[i]=='W':
        y[0][1],y[1][2]=y[1][2],y[0][1]
        y[1][2],y[2][1]=y[2][1],y[1][2]
        y[2][1],y[1][0]=y[1][0],y[2][1]
    elif m[i]=='E':
        y[0][1],y[1][0]=y[1][0],y[0][1]
        y[1][0],y[2][1]=y[2][1],y[1][0]
        y[2][1],y[1][2]=y[1][2],y[2][1]
print(y[0][1])
        

Measured memory_bytes: 7944
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,A;
int main() {
	cin>>N>>A;

	cout<<N*N-A<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  const int N = 4001;
  const int M = 4;
  int dp[M + 1][N] = {};
  dp[0][0] = 1;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < N; j++){
      for(int k = 0; j + k < N && k <= 1000; k++){
        dp[i + 1][j + k] += dp[i][j];
      }
    }
  }
  int n;
  while(cin >> n) cout << dp[M][n] << endl;
  return 0;
}

Measured memory_bytes: 1244
n=int(input())
p=[int(x) for x in input().split()]


cnt=0
for i in range(n-1):
  if i+1 == p[i]:
    cnt+=1
    p[i+1]=p[i]
  else:
    mae=p[i]

if p[n-1]==n:
  print(cnt+1)
else:
  print(cnt)


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int N, M;
string pict1[MAX_N] = {};
string pict2[MAX_N] = {};

bool check(int y, int x) {
    REP(i, M) {
        REP(j, M) {
            if(pict1[y+i][x+j] != pict2[i][j]) { return false; }
        }
    }
    return true;
}

signed main()
{
    cin >> N >> M;
    REP(i, N) { cin >> pict1[i]; }
    REP(i, M) { cin >> pict2[i]; }
    for(int i = 0; i <= N - M; ++i) {
        for(int j = 0; j <= N - M; ++j) {
            if(check(i, j)) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


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


int main()
{
    stringstream ss;
    // 入力
    int H,W;
    cin>>H>>W;

    string s[H+1];
	for(int j=1;j<=H;j++){
		cin>>s[j];
	}

    for(int i=1;i<=W;i++){
    	for(int j=1;j<=H;j++){
    		int canpaint=0;
    		if(s[j].substr(i-1,1)=="#"){
		    	if(i!=1){
		    		if(s[j].substr(i-2,1)=="#") canpaint=1; 
		    	}
		    	if(i!=W){
		    		if(s[j].substr(i,1)=="#") canpaint=1; 
		    	}
		    	if(j!=1){
		    		if(s[j-1].substr(i-1,1)=="#") canpaint=1; 
		    	}
		    	if(j!=H){
		    		if(s[j+1].substr(i-1,1)=="#") canpaint=1; 
		    	}
		    	if(canpaint==0){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}

    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//const int mod=(int)1e9+7;

const llint big=(llint)(2.19e15+1)*18;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
#define dme cout<<"-1\n";return 0
int main(void){
	int n,i;cin>>n;
	map<pair<int,int>,int>ban;
	for(i=0;i<n;i++){
		int a,b;cin>>a>>b;
		if((i==0)^(a==0)){dme;}
		if((i==1)^(b==0)){dme;}
		ban[mp(a+b,a)]++;
	}
	//dpで解く
	int ans=-2,sen=0;
	pair<int,int>maebas=mp(-1,-1);
	for(auto it:ban){
		int a=it.fir.sec;
		int b=it.fir.fir-a;
		int kaz=it.sec;
		if(kaz==0){continue;}
		if(!(maebas.fir==it.fir.fir&&maebas.sec+1==it.fir.sec)){sen=0;}//前と連結してない
		if(ban[mp(a-1+b-1,a-1)]>0){ans+=kaz;mineq(sen,kaz);}//接続あり
		else{
			ans+=kaz;ans+=max(0,kaz-sen);sen=kaz;
			if(ban[mp(a-1+b,a-1)]+ban[mp(a+b,a-1)]==0&&a>0&&b>0){dme;}
			if(ban[mp(a+b-1,a)]+ban[mp(a+b,a+1)]==0&&a>0&&b>0){dme;}
		}
		maebas=it.fir;
		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 18944
n =gets.to_i
d = []
n.times do 
  d.push(gets.to_i)
end
d.sort!
sum = 1
a = d[0]
1.upto(n-1) do |i|
  if a < d[i]
    sum += 1
    a = d[i]
  end
end
puts sum

  

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

struct UnionFind{
  vector<int> p;
  vector<ll> weight;
  UnionFind(int n){
    p.resize(n, -1);
    weight.resize(n, 0);
  }

  int find(int x){
    if(p[x] == -1)return x;
    else{
      int r = find(p[x]);
      weight[x] += weight[p[x]];
      return p[x] = r;
    }
  }

  ll get_weight(int x){
    find(x);
    return weight[x];
  }

  void unite(int x, int y, ll w){
    w += get_weight(x); 
    w -= get_weight(y); 

    x = find(x);
    y = find(y);
    if(x == y)return;
    p[y] = x;
    weight[y] = w;
  }

  ll diff(int x, int y){
    return get_weight(y) - get_weight(x);
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for(int i = 0; i < m; ++i){
    int l, r;
    ll d;
    cin >> l >> r >> d;
    --l;
    --r;
    if(uf.find(l) == uf.find(r)){
      if(uf.diff(l, r) != d){
        cout << "No" << endl;
        return 0;
      }
    }
    else uf.unite(l, r, d);      
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1536
import math
from sys import *
inp=stdin.readline

zip=zip 
def linp(x):
    return list(map(int,x.split()))
def minp(x):
    return map(int,x.split())

n=int(inp())
a=linp(inp())
dic={i:0 for i in range(n)}
for i in a:
    dic[i-1]+=1
for i in range(n):
    print(dic[i])
    




    

Measured memory_bytes: 40024
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

int main() {
	ll n, m;
	cin >> n >> m;
	if (n > m) {
		swap(n, m);
	}
	if (n == 1) {
		if (m == 1) {
			cout << 1 << endl;
		} else {
			cout << max(0ll, m - 2) << endl;
		}
	} else {
		cout << n * m - 2 * n - 2 * m + 4 << endl;
	}
}

Measured memory_bytes: 256
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri f head =
    let rec doit i ite =
      if ite != head then begin
        f i ite.data;
        doit (i + 1) ite.next
      end in
    doit 0 head.next
end

module L = DoublyLinkedList

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i < n then begin
      begin match split_on_char ' ' (read_line ()) with
      | ["insert"; n] -> L.insert (int_of_string n) head
      | ["delete"; n] -> L.delete_node (int_of_string n) head
      | ["deleteFirst"] -> L.delete_first head
      | _ -> L.delete_last head
      end;
      read (i + 1)
    end in
  read 0;
  L.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) head;
  print_newline ()

Measured memory_bytes: 41144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CBuyanInteger solver = new CBuyanInteger();
        solver.solve(1, in, out);
        out.close();
    }

    static class CBuyanInteger {
        static int[] x;
        static int[] y;
        static int n;
        static double sum;

        static void bt(ArrayList<Integer> p, int a, int b, int o, double now) {
            ArrayList<Integer> act = new ArrayList<>(p);
            if (o == -1) {
                for (int i = 0; i < act.size(); i++) {
                    bt(act, x[i], y[i], i, 0);
                }
                return;
            }
            if (o >= 0) {
                act.remove(o);
            }
            if (act.size() == 0) {
                sum += now;
                return;
            }
            for (int i = 0; i < act.size(); i++) {
                double t = Math.sqrt((x[act.get(i)] - a) * (x[act.get(i)] - a) + (y[act.get(i)] - b) * (y[act.get(i)] - b));
                bt(act, x[act.get(i)], y[act.get(i)], i, now + t);
            }
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            n = sc.nextInt();
            x = new int[n];
            y = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = sc.nextInt();
                y[i] = sc.nextInt();
            }
            ArrayList<Integer> p = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                p.add(i);
            }
            bt(p, 0, 0, -1, 0);
            long fact = 1;
            for (int i = 1; i <= n; i++) {
                fact *= i;
            }
            out.println(sum / fact);

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

vector<ll> num;
ll d, k, c,m,mod=1e9+7;
ll arr[100001][4],dp[100001][4];
ll mxlids,cnt,res;
ll a,b,n,pt,nt;
set<ll> s;
ll maxn=1e18+1;

ll func(int curr,int idx)
{
    if(idx==n) return 0;

    if(dp[idx][curr]!=-1) return dp[idx][curr];

    ll mx=0;

    if(curr==0)
    {
        mx=func(1,idx+1)+arr[idx][1];
        mx=max(mx,func(2,idx+1)+arr[idx][2]);
        mx=max(mx,func(3,idx+1)+arr[idx][3]);
    }
    else if(curr==1)
    {
        mx=max(mx,func(2,idx+1)+arr[idx][2]);
        mx=max(mx,func(3,idx+1)+arr[idx][3]);
    }
    else if(curr==2)
    {
        mx=max(mx,func(1,idx+1)+arr[idx][1]);
        mx=max(mx,func(3,idx+1)+arr[idx][3]);
    }
    else
    {
        mx=max(mx,func(1,idx+1)+arr[idx][1]);
        mx=max(mx,func(2,idx+1)+arr[idx][2]);
    }

    return dp[idx][curr] = mx;
}

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        
    cin>>n;

    for (int i = 0; i < n; ++i)
    {
        for (int j=1;j<=3;j++)
        {
            cin>>arr[i][j];
        }
    }

    memset(dp,-1,sizeof(dp));
    cout<<func(0,0);
    
}

Measured memory_bytes: 14492
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9 + 10)
#define PI (acos(-1))
#define MOD (1000000007)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
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; }

int main() {
    int A, B;
    cin >> A;
    cin >> B;
    string s[100];
    string black(100, '#');
    string white(100, '.');
    REP(i, 100) {
        if (i < 50){
            s[i] = black;
        } else {
            s[i] = white;
        }
    }
    int cc = 0;
    A -= 1;//ひとつ分を削除
    while (A){
        s[cc/50 * 2][cc%50*2] = '.';
        A -= 1;
        cc += 1;
    }
    cc = 0;
    B -= 1;//ひとつ分を削除
    while (B){
        s[51 + cc/50 * 2][cc%50*2] = '#';
        B -= 1;
        cc += 1;
    }
    cout << "100 100" << endl;
    REP(i, 100) {
        cout << s[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
int n;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    a[n] = a[n - 1];
    int ans = 1;
    int st;
    bool flag;
    for (st = 0; a[st] == a[st + 1]; st++);
    if (a[st] < a[st + 1]) flag = 1;
    else flag = 0;
    for (int i = st; i < n - 1; i++) {
        if (a[i] == a[i + 1]) continue;
        if (a[i] < a[i + 1]) {
            if (!flag) {
                ans++;
                i++;
                for (; a[i] == a[i + 1]; i++);
                if (a[i] < a[i + 1]) flag = 1;
                else flag = 0;
            }
        }
        if (a[i] > a[i + 1]) {
            if (flag) {
                ans++;
                i++;
                for (; a[i] == a[i + 1]; i++);
                if (a[i] < a[i + 1]) flag = 1;
                else flag = 0;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(void) {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    bool ok = false;
    long long b = B, c = C;
    for (int i = 0; i < K; i++) {
        c *= 2;
    }
    for (int i = 0; i < K + 1; i++) {
        if (b > A && c > b) {
            ok = true;
        }
        b *= 2;
        c /= 2;
    }
    if (ok) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3632
a = gets.to_i
arr = gets.split(' ').map(&:to_i)
h = {}
max = arr.max
slime = (max+1..10000).to_a
alloc = {}
arr.each_with_index do |num, i|
  if h[alloc[num]] && arr[i-1] == num
    h[alloc[num]] += 1
  elsif i > 0 && arr[i-1] != num && arr[i+1] == num
    alloc[num] = slime.shift
    h[alloc[num]] = 1
  elsif i == 0 && arr[i+1] == num
    alloc[num] = slime.shift
    h[alloc[num]] = 1
  end
end

ret = 0

h.each do |_,v|
  ret += v/2
end

puts ret


Measured memory_bytes: 1916
#include<stdio.h>

int main(void){
  int n,k,i,ans=1;
  scanf("%d",&n);
  scanf("%d",&k);
  for(i=0;i<n;i++){
    if(ans<k) ans*=2;
    else ans+=k;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;
 
typedef long double ld;
using namespace std;
 
 
int main() {
    ll N;
    cin>>N;
    double v[N];
    REP(i,N){
        cin>>v[i];
    }
    sort(v,v+N);
        double k=v[0];
    for(int i=1;i<N;i++){
        k=(k+v[i])/2.0;
    }
    cout<<k<<endl;
}

Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000

long long max(long long a, long long b) { return a > b ? a : b; }

int main() {
	static int kk[40];
	static long long pp[40];
	int n, h, i;
	long long x, sum, ans;

	scanf("%d%lld", &n, &x), x++;
	for (i = 0; i < n; i++) {
		long long a;

		scanf("%lld", &a);
		for (h = 0; h < 40; h++)
			if (a & 1LL << h)
				kk[h]++;
	}
	for (h = 0; h < 40; h++)
		pp[h] = max(kk[h], n - kk[h]) << h;
	for (h = 1; h < 40; h++)
		pp[h] += pp[h - 1];
	ans = sum = 0;
	for (h = 39; h >= 0; h--)
		if (x & 1LL << h) {
			ans = max(ans, sum + ((long long) kk[h] << h) + (h == 0 ? 0 : pp[h - 1]));
			sum += (long long) n - kk[h] << h;
		} else
			sum += (long long) kk[h] << h;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int a[100000],n,k,q,i,j,l;
  scanf("%d%d%d",&n,&k,&q);
  a[n]=0; 
  l=k-q;
  
  for(i=0;i<n;i++){
    a[i]=l;
  };
  for(i=0;i<q;i++){
    scanf("%d",&j);
    a[j-1]++;
  }
  for(i=0;i<n;i++){
    if(a[i]>0){
      printf("Yes\n");
    }
    else
      printf("No\n");
  }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{    
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,k,n,m;
     ll t;
     long double a,b;
     cin>>a>>b;
     ll p=a*b;
     cout<<p;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    ll ans = 1000;
    rep(i, n-1) if (a[i] < a[i+1]) ans = ans / a[i] * a[i+1] + ans % a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
/*
  -------------
  Prateek Celly
  DA-IICT
  -------------
*/
#include<bits/stdc++.h>
using namespace std;

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll a,p;
  cin>>a>>p;
  a*=3;
  cout<<(a+p)/2;
  return 0;
}


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

bool checkPalindrome(int num){
    vector<int>result;
    while(num!=0)
    {
        result.push_back((num%10));
        num/=10;
    }
    for(int i=0;i<(result.size())/2;i++)
    {
        if(result[i]!=result[result.size()-1-i]){
            return false;
        }
    }
    return true;
}


int main(){
    int a,b;
    cin>>a>>b;
    int count=0;
    for(int i=a;i<=b;i++)
    {
        if(checkPalindrome(i)){
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 3556
#include<stdio.h>
int main()
{
    int a,b,c,d;
    while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
    {
        if(b<=c||a>=d) printf("0\n");
        else if(c>=a&&d<=b) printf("%d\n",d-c);
        else if(a>=c&&b<=d) printf("%d\n",b-a);
        else if(b>=c&&b<=d&&a<=c) printf("%d\n",b-c);
        else if(d>=a&&d<=b&&c<=a) printf("%d\n",d-a);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 2;
const int MAXV = 1e5 + 5;
const int INF = 1e9 + 7;
int val[MAXN], w[MAXN];
int dp[MAXN][MAXV];
int main(){
    int n, W;
    cin >> n >> W;
    int V = 0;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> val[i];
        V += val[i];
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= V; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= V; j++){
            if(val[i] <= j){
                dp[i][j] = min(dp[i - 1][j - val[i]] + w[i], dp[i - 1][j]);
            }
            else{
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= V; i++){
        if(dp[n][i] <= W){
            ans = max(ans, i);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 39808
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>
#include <cstring>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

long double dp[310][310][310];
Int N;

long double solve(Int i, Int j, Int k) {
	if (i==0&&j==0&&k==0) {//終端条件
		return dp[i][j][k] = 0.0;
	}
	if (dp[i][j][k]>=0) {//既に探索済みならreturn
		return dp[i][j][k];
	}

	long double res = 0.0;
	if (i > 0) {
		res += solve(i - 1, j, k) * i;
	}
	if (j>0) {
		res += solve(i + 1, j - 1, k) * j;
	}
	if (k>0) {
		res += solve(i, j + 1, k - 1) * k;
	}
	res += N;
	res *= 1.0 / (i + j + k);

	return 	dp[i][j][k] = res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N;

	Int a;
	Int cnt1 = 0;
	Int cnt2 = 0;
	Int cnt3 = 0;
	for (Int i = 0; i < N; i++) {
		cin >> a;
		if (a==1) {
			cnt1++;
		}
		else if (a==2) {
			cnt2++;
		}
		else {
			cnt3++;
		}
	}

	//for (Int i = 0; i < 310; i++) {
	//	for (Int j = 0; j < 310; j++) {
	//		for (Int k = 0; k < 310; k++) {
	//			dp[i][j][k] = -1.0;
	//		}
	//	}
	//}

	memset(dp, -1, sizeof(dp));

	long double ans = solve(cnt1, cnt2, cnt3);
	cout << fixed << setprecision(10) << ans << "\n";
}


Measured memory_bytes: 465920