akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (50000)
long long p2[30];

void prpo2(void){
	p2[0] = 2;
	f(i, 29)p2[i + 1] = (p2[i] * p2[i]) % MOD;
	return;
}

long long po2(int x){
	long long re = 1;
	f(i,30){
		if (x % 2 == 1)re = (re*p2[i]) % MOD;
		x = x / 2;
	}
	return re;
}

int main(void){
	int n;
	set<int>se;
	vector<int>v;
	int x, y;
	long long cc, dd, aa, bb;
	long long c[110];
	long long d[110];
	int a[110];
	bool u[110];
	f(i, 110){
		u[i] = false;
		c[i] = -1;
	}
	prpo2();
	scanf("%d", &n);
	f(i, n){
		scanf("%d", &a[i]);
		if (se.count(a[i]) == 0){
			v.push_back(a[i]);
			se.insert(a[i]);
		}
	}
	v.push_back(0);
	sort(v.begin(), v.end(), greater<int>());
	f(i, v.size()-1){
		f(j, n){
			if (a[j] >= v[i])u[j] = true;
			else u[j] = false;
		}
		f(j, n){
			if (u[j]){
				cc = 2;
				dd = 1;
				x = j;
				y = j;
				while (u[y]){
					if (c[y] >= 0){
						cc *= c[y];
						cc = cc%MOD;
						aa = ((2 * c[y]) + d[y]) % MOD;
						dd *= aa;
						dd = dd%MOD;
					}
					else if (c[y] == -1){
						dd *= 2;
						dd = dd%MOD;
					}
					y++;
				}
				for (int ii = x; ii < y; ii++)c[ii] = -2;
				dd = (dd - cc + MOD) % MOD;
				c[x] = cc;
				d[x] = dd;
				j = y;
			}
		}
		aa = po2(v[i] - v[i + 1] - 1);
		f(i, n){
			if (c[i] >= 0)c[i] = (c[i] * aa) % MOD;
		}
	}
	aa = (c[0] + d[0]) % MOD;
	printf("%lld\n", aa);


	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
sm = sum(b)
for n in range(1,N):
  if a[n] - a[n-1] == 1:
    sm += c[a[n]-2]
print(sm)


Measured memory_bytes: 38384
N=int(input())
S=str(input())
t=[0]
s=0
for i in range(N):
  if S[i]=="I":
    s+=1
  else:
    s-=1
  t+=[s]
ans=0
for i in range(N+1):
  ans=max(ans,int(t[i]))
print(ans)

Measured memory_bytes: 3064
n,s = map(int,input().split())
al = list(map(int,input().split()))
MOD = 998244353

dp = [[0 for _ in range(s+1)] for _ in range(n+1)]



for i in range(n):
    for j in range(s+1):
        if j + al[i] <= s:
            dp[i+1][j+al[i]] += dp[i][j]
            dp[i + 1][j + al[i]] %= MOD
        dp[i+1][j] += dp[i][j]
        dp[i + 1][j] %= MOD
    dp[i+1][0] += 1
    dp[i + 1][0] %= MOD
    if al[i] <= s:
        dp[i+1][al[i]] += 1
        dp[i + 1][al[i]] %= MOD

ans = 0
for i in range(n+1):
    ans += dp[i][-1]
    ans %= MOD

print(ans)

# a
# b + ab
# c + bc + abc
# (1+x)
# (1+x)(1+x) + (1+x) = 2 + 3 + 1
# (1+x)(1+x)(1+x) + (1+x)(1+x) + (1+x) = 3 +


Measured memory_bytes: 120412
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a,a+n);
cout<<a[n-1]-a[0]<<endl;

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 2005;
int N, M, Q;
int a[maxn][maxn], b[maxn][maxn], c[maxn][maxn];
char s[maxn];
int main() {
	scanf("%d%d%d", &N, &M, &Q);
	for(int i=1; i<=N; ++i) {
		scanf("%s", s+1);
		for(int j=1; j<=M; ++j) 
			a[i][j] = s[j]-'0';
	}
	for(int i=1; i<N; ++i)
		for(int j=1; j<=M; ++j)
			if(a[i][j] && a[i+1][j]) ++b[i][j];
	for(int i=1; i<=N; ++i)
		for(int j=1; j<M; ++j)
			if(a[i][j] && a[i][j+1]) ++c[i][j];
	for(int i=1; i<=N; ++i)
		for(int j=1; j<=M; ++j) {
			a[i][j] += a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			b[i][j] += b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			c[i][j] += c[i-1][j]+c[i][j-1]-c[i-1][j-1];
		}
	int sx, sy, tx, ty, ans;
	while(Q--) {
		scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
		ans = a[tx][ty]-a[sx-1][ty]-a[tx][sy-1]+a[sx-1][sy-1];
		--tx;
		if(tx>=sx) ans-= b[tx][ty]-b[sx-1][ty]-b[tx][sy-1]+b[sx-1][sy-1];
		++tx; --ty;
		if(ty>=sy) ans-= c[tx][ty]-c[sx-1][ty]-c[tx][sy-1]+c[sx-1][sy-1];
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 48768
h, n = gets.to_s.split.map{|t|t.to_i}
m = Array.new(n){ gets.split.map{|t|t.to_i} }.sort_by{|(a,b)| 1.0 * b / a }

inf = h * (10**4)

dp = [ inf ] * ( h + 1 + 10**4 )
dp[0] = 0

m.each do |(a, b)|
  (a ... h+a).each do |i|
    dp[i] = dp[i-a] + b if dp[i] > dp[i-a] + b
  end
  break if dp[h] < inf
end
# p dp
puts dp[h .. -1].min

Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x = 0;
  cin >> x;
  ll a,b;
  vector<ll> fac(1000);
  for(int i = 0;i < 1000;i++)fac[i] = pow(i,5);
  for(int i = 0;i < 999;i++){
    for(int j = i + 1;j < 1000;j++){
      if(fac[j] - fac[i] == x){
        a = j;
        b = i;
        i = 10000;
        j = 10000;
      }
      else if(fac[j] + fac[i] == x){
        a = j;
        b = -i;
        i = 10000;
        j = 10000;
      }
    }
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
 
main(){
  int n, a, b, c, d;
  cin >> n;
  
  a = n / 1000;
  b = n % 1000 /100;
  c = n % 100 / 10;
  d = n % 10;
  
  if( (a == b && b == c) || (b == c && b == d) )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
    int l , r , d;
    cin >> l >> r >> d;
    int sum = 0;
    rep2(i,l,r+1){
        if(i%d == 0)sum++;
        else continue;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ABC = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B, C) = (ABC[0], ABC[1], ABC[2]);

        var ans = (B / A > C) ? C : (B / A);

        WriteLine(ans);
    }
}


Measured memory_bytes: 28308
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool check=true;
  vector<pair<int,int>> ba(n);
  for(int i=0;i<n;i++){
    cin >> ba[i].second >> ba[i].first;
  }
  sort(ba.begin(),ba.end());
  int64_t sum=0;
  for(int i=0;i<n;i++){
    sum+=ba[i].second;
    if(sum>ba[i].first){
      check=false;
      break;
    }
  }
  if(check){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
}



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


typedef __uint128_t Hash;
template<class T>

class RollingHash{
public:
	T src;
	vector<Hash> harr,p;
	
	vector<int> suffixArray;
	RollingHash(T src,Hash w=8999):src(src){
		p.resize(src.size()+1);
		Hash sum = 0;
		for(int i = 0 ; i < src.size() ; i++){
			sum = sum * w + src[i];
			//sum %= mod;
			harr.push_back(sum);
		}
		p[0] = 1;
		for(int i = 1 ; i < p.size() ; i++){
			p[i] = p[i-1] * w;
			//p[i] %= mod;
		}
	}
	// [l,r)
	Hash sub(int l,int r) const{
		if( l >= r ) return 0;
		return harr[r-1] - (l?harr[l-1] * p[r-l]:0);
	}
};

int main(){
	string S,T;
	cin >> S >> T;
	RollingHash<string> s(S),t(T);
	int ans = 0;
	for(int i = 0 ; i+T.size() <= S.size() ; i++){
		int l = 0, r = T.size();
		if( s.sub(i,i+r) == t.sub(0,r) ) continue;
		
		while( l != r ){
			int m = (l+r+1)/2;
			if( s.sub(i,i+m) == t.sub(0,m) ){
				l = m;
			}else{
				r = m-1;
			}
		}
		// cout << l+1 << " " << i+T.size() << ") [" << i << "," << l << ")" << endl;
		if( s.sub(i,i+l) == t.sub(0,l) && s.sub(i+l+1,i+T.size()) == t.sub(l+1,T.size()) ) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 21652
# 今、日本は 9 月 9 日です。
# 二桁の整数 N が与えられるので、十進法で N に 9 が含まれるか答えてください。

n = gets
result = false
n.length.times do |i|
    if n[i] == "9"
        result = true
        break
    end
end
puts result ? "Yes" : "No"

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a[3],k;
    REP(i,3)cin >> a[i];
    cin >> k;
    sort(a,a+3);
    REP(i,k){
        a[2]*=2;
    }
    cout << a[0]+a[1]+a[2] << endl;
    
    return 0;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
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())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

oklist = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = ir()
ind = bisect.bisect_left(oklist, n)
print(oklist[ind])

Measured memory_bytes: 77372
n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
    l[i]=int(input())
    
import itertools
 
mpmin=a+b+c+1
for i in itertools.product([0,1,2,3], repeat=n):
    aa=0
    bb=0
    cc=0
    mpa=0
    mpb=0
    mpc=0
    ia=0
    ib=0
    ic=0
    for ii in range(n):
        if i[ii]==1:
            ia=1
            if aa>0:
                mpa+=10
            aa+=l[ii]
        elif i[ii]==2:
            ib=1
            if bb>0:
                mpb+=10
            bb+=l[ii]
        elif i[ii]==3:
            ic=1
            if cc>0:
                mpc+=10
            cc+=l[ii]
    if ia==1 and ib==1 and ic==1:
        mp=mpa+abs(a-aa)+mpb+abs(b-bb)+mpc+abs(c-cc)
#        if mp<mpmin:
#            print(mp,mpa,mpb,mpc,i)
        mpmin=min(mp,mpmin)

print(mpmin)    


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	vector<int> coins;
	for (int i = 1; i * i <= 300; ++i)
		coins.push_back(i * i);

	int dp[33][333];
	clear(dp, 0);
	dp[0][0] = 1;
	//for (int i = 0; i < coins.size(); ++i)
	//	for (int j = 0; j <= 300; ++j)
	//		for (int k = 0; k * coins[i] <= j; ++k)
	//			dp[i + 1][j] += dp[i][j - k * coins[i]];
	for (int i = 0; i < coins.size(); ++i)
		for (int j = 0; j <= 300; ++j)
			dp[i + 1][j] = dp[i][j] + (j >= coins[i] ? dp[i + 1][j - coins[i]] : 0);

	int n;
	while (scanf("%d", &n), n)
		printf("%d\n", dp[coins.size()][n]);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

string s;
int d[200010][3],n;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    n = s.length();
    d[0][1] = 1; d[1][2] = 1;
    if(s[0]!=s[1]) d[1][1] = 2;
    for(int i=2;i<n;i++){
        if(d[i-1][2]) d[i][1] = d[i-1][2]+1;
        if(d[i-1][1] && d[i][1]<(d[i-1][1]+1) && s[i]!=s[i-1]) d[i][1] = d[i-1][1]+1;
        if(d[i-2][1]) d[i][2] = d[i-2][1]+1;
        if(i>2 && d[i-2][2] && d[i][2]<(d[i-2][2]+1) && (s[i]!=s[i-2] || s[i-1]!=s[i-3])) d[i][2] = d[i-2][2]+1;
    }
    printf("%d\n",max(d[n-1][2],d[n-1][1]));
    return 0;
}


Measured memory_bytes: 2964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		String s = scanner.next();
		

		if(s.equals("SUN")) {
			System.out.println(7);
		}else if(s.equals("MON")) {
			System.out.println(6);
		}else if(s.equals("TUE")) {
			System.out.println(5);
		}else if(s.equals("WED")){
			System.out.println(4);
		}else if(s.equals("THU")) {
			System.out.println(3);
		}else if(s.equals("FRI")) {
			System.out.println(2);
		}else if(s.equals("SAT")) {
			System.out.println(1);
		}

	}
}  

Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=scan.nextInt();
		}
		Arrays.parallelSort(ar);
		float ans=0;
		float lol[]=new float[n];
		lol[0]=ar[0];
		for(int i=1;i<n;i++)
		{
			lol[i]=(float) ((ar[i]+lol[i-1])/2);
		}
		
		System.out.printf("%.04f",lol[n-1]);
	}
}


Measured memory_bytes: 22100
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#include <ctime>
#include <set>
#define endl '\n'
#define ll unsigned long long
#define mod 1000000007
#define NCONS 100001
#define MACRO(a) for(int a = 1; a < 1001; a++)

using namespace std;
ll max(ll a, ll b) { return a > b ? a : b; }

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	ll N, M; cin >> N >> M;

	ll ret = min(N, M / 2);

	M = max(0, M - 2 * ret);
	ret += M / 4;

	cout << ret << endl;
	return 0;
}

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

int main() {
	int a, b;
	
	cin >> a >> b;
	
	if (a == b) {
		cout << "a == b"<< endl;
		
	}
	
	else if (a > b){
		cout << "a > b" << endl;
	}
	
	else if (a < b){
		cout << "a < b" << endl;
	}
	
	return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n ;
	vector<VI> sk(n, VI(26));
	rep(i, n){
		string s;
		cin >>s;
		for(auto x: s) sk[i][x-'a']++;
	}
	
	rep(i, 26){
		int cnt = 9999;
		rep(j, n){
			cnt = min(cnt, sk[j][i]);
		}
		if(cnt > 0) cout << string(cnt, char(i+'a'));
	}
	cout <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;
typedef long long int LLI;

int main()
{
    int n, k, different = 0;
    cin >> n >> k;
    LLI tmp;
    unordered_map <LLI, LLI> arr;
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        if( arr[tmp] == 0 )
            different++;
        arr[tmp]++;
    }
    if( different <= k )
        cout << 0;
    else{
        int sorted[arr.size()], i = 0;
        for(auto x: arr)
            sorted[i++] = x.second;
        sort(sorted,sorted+arr.size());
        int sum = 0;
        for(int i = 0; i < different - k; i++)
            sum += sorted[i];
        cout << sum;
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll a,b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;     
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string S[202];

template<class V> class MaxFlow_Ford {
public:
	struct edge { int to,reve;V cap;};
	static const int MV = 30000;
	vector<edge> E[MV];
	int vis[MV];
	void add_edge(int x,int y,V cap,bool undir=false) {
		E[x].push_back((edge){y,(int)E[y].size(),cap});
		E[y].push_back((edge){x,(int)E[x].size()-1,undir?cap:0});
	}
	V dfs(int from,int to,V cf) {
		V tf;
		if(from==to) return cf;
		vis[from]=1;
		FORR(e,E[from]) if(vis[e.to]==0 && e.cap>0 && (tf = dfs(e.to,to,min(cf,e.cap)))>0) {
			e.cap -= tf;
			E[e.to][e.reve].cap += tf;
			return tf;
		}
		return 0;
	}
	V maxflow(int from, int to) {
		V fl=0,tf;
		while(1) {
			ZERO(vis);
			if((tf = dfs(from,to,numeric_limits<V>::max()))==0) return fl;
			fl+=tf;
		}
	}
};

MaxFlow_Ford<int> mf;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) cin>>S[y];
	FOR(y,H) if(S[y][0]=='X' || S[y][W-1]=='X') return _P("-1\n");
	FOR(x,W) if(S[0][x]=='X' || S[H-1][x]=='X') return _P("-1\n");
	
	FOR(y,H) FOR(x,W) {
		mf.add_edge(y*100+x,10000+y*100+x,(S[y][x]=='X')?101010:1);
		if(S[y][x]=='X') mf.add_edge(20010,y*100+x,101010);
		if(y==0 || x==0 || y==H-1 || x==W-1) mf.add_edge(10000+y*100+x,20011,101010);
		if(y) mf.add_edge(10000+y*100+x,(y-1)*100+x,101010);
		if(x) mf.add_edge(10000+y*100+x,y*100+(x-1),101010);
		if(y<H-1) mf.add_edge(10000+y*100+x,(y+1)*100+x,101010);
		if(x<W-1) mf.add_edge(10000+y*100+x,y*100+(x+1),101010);
	}
	cout<<mf.maxflow(20010,20011)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 3328
import heapq
x,y,z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
q=[(-(A[0]+B[0]+C[0]),0,0,0)]
S=set()

for n in range(K):
  p,i,j,k=heapq.heappop(q)
  print(-p)
  if i+1<x and ((i+1,j,k) not in S):
    S.add((i+1,j,k))
    heapq.heappush(q,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
  if j+1<y and ((i,j+1,k) not in S):
    S.add((i,j+1,k))
    heapq.heappush(q,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
  if k+1<z and ((i,j,k+1) not in S):
    S.add((i,j,k+1))
    heapq.heappush(q,(-(A[i]+B[j]+C[k+1]),i,j,k+1))

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

typedef long long LL;
const int MN=105;
const int MV=1e5+5;
const LL INF=0x3f3f3f3f3f3f3f3f;

int w[MV],v[MV];
LL dp[MV];

int main()
{
	int n,ww; scanf("%d%d",&n,&ww);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&w[i],&v[i]);
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=MV-1;j>=v[i];j--)
		{
			if(dp[j-v[i]]!=INF)
			{
				//cout<<j<<" "<<dp[j-v[i]]<<endl;
				dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			}
		}
	}
	int ans=-1;
	for(int i=MV-1;i>=0;i--)
		if(dp[i]<=ww)
		{
			ans=i;
			break;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

N = int(input())
lst_a = list(map(float, input().split()))
one, two , three = lst_a.count(1),lst_a.count(2),lst_a.count(3),

dp = [[[0.0 for _ in range(N+1)]for _ in range(N+1)]for _ in range(N+1)]

for k in range(three + 1):
    for j in range(two + three + 1  - k):
        for i in range(one + two + three + 1 - k -j):
            if i == 0 and j == 0 and k == 0:
                continue
            tmp = 1.0 * N
            if i > 0 : 
            	tmp += dp[i-1][j][k] * i
            if j > 0 :
            	tmp += dp[i+1][j-1][k] * j
            if k > 0 :
            	tmp += dp[i][j+1][k-1] * k

            dp[i][j][k] = tmp / (i+j+k)

print(dp[one][two][three])


Measured memory_bytes: 258832
#include <iostream>

int IIRT(int a, int b, int c);

int main()
{
    int n;
    std::cin >> n;
    for (int i=0; i<n; i++) {
        int a,b,c;
        std::cin >> a >> b >> c;
        if (IIRT(a,b,c)) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO"  << std::endl;
        }
    }
}

int IIRT(int a, int b, int c)
{
    if ((a*a + b*b) == c*c) {
        return 1;
    } else if ((b*b + c*c) == a*a) {
        return 1;
    } else if ((c*c + a*a) == b*b) {
        return 1;
    } else {
        return 0;
    }
}

Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int c[12], a[12][12];
  for(int i=0; i<n; i++){
    cin >> c[i];
    for(int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }
  int ans=0;
  for(int k=0; k<pow(2, n); k++){
    int csum=0;
    int aa[12];
    for(int i=0; i<m; i++){
      aa[i]=0;
    }
    for(int i=0; i<n; i++){
      if((k>>i)%2==1){
        csum+=c[i];
        for(int j=0; j<m; j++){
          aa[j]+=a[i][j];
        }
      }
    }
    bool b=true;
    for(int i=0; i<m; i++) if(x>aa[i]) b=false;
    if(b){
      if(ans==0 || ans>csum) ans=csum;
    }
  }
  if(ans==0) cout << "-1";
  else cout << ans;
  return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<long> p(A), q(B), r(C);
    REP(i, A) {
        READ(p[i]);
    }
    REP(i, B) {
        READ(q[i]);
    }
    REP(i, C) {
        READ(r[i]);
    }

    // main procedure
    sort(ALL(p), std::greater<long>());
    sort(ALL(q), std::greater<long>());

    vector<long> p_top, q_top, r_top;
    p_top.assign(p.begin(), p.begin() + X);
    q_top.assign(q.begin(), q.begin() + Y);

    p_top.insert(p_top.end(), ALL(q_top));
    p_top.insert(p_top.end(), ALL(r));

    sort(ALL(p_top), std::greater<long>());

    vector<long> all_top;
    all_top.assign(p_top.begin(), p_top.begin() + X + Y);
    long ans = accumulate(ALL(all_top), 0L);

    // output
    WRITE_N(ans);

    return 0;
}


Measured memory_bytes: 7488
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;
#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;

#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i <= (int)n; ++i)
#define REPT(i, t, n)  for(int i = t; i <= (int)n; ++i)
const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;
typedef pair<int, int> Pi;

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

const int MAX_N = 3000 + 10;

ll dp[MAX_N][MAX_N];

int N, W;

int main() {
    string S, T;
    string ans = "";
    cin >> S;
    cin >> T;
    REP(s, S.length()) {
        REP(t, T.length()) {
            if (S[s] == T[t]) dp[s + 1][t + 1] = max(dp[s][t], dp[s][t] + 1);
            else dp[s + 1][t + 1] = max(dp[s + 1][t], dp[s][t + 1]);
        }
    }
    int s = S.length();
    int t = T.length();
    while (s > 0 && t > 0) {
        if (dp[s][t] == dp[s - 1][t])s--;
        else if (dp[s][t] == dp[s][t - 1])t--;
        else {
            ans = S[s - 1] + ans;
            s--;
            t--;
        }
    }
    PRI(ans);
    return 0;
}


Measured memory_bytes: 70784
#include<cstdio>
#include<string.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,a[100005],vis[100005],sum;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
    	scanf("%d",&a[i]);
    	if(a[i]<=n)vis[a[i]]++;
    	else sum++;
	}
	for(int i=1;i<=n;i++){
		if(vis[i]<i)sum+=vis[i];
		else sum+=(vis[i]-i);
	}
	cout<<sum;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> a(N);
	int amax = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		amax = max(amax,a[i]); 
	}

	int lim = (amax)/2;
	vector< pair<int,bool> > norm;
	for (int i = 0; i < N; ++i) {
		if (a[i] != amax) {
			if (a[i] > lim) {
				norm.push_back({amax-a[i],true});
			}
			else {
				norm.push_back({a[i],false});
			}
		}
	}
	sort(norm.begin(),norm.end());
	cout << amax << " ";

	if (norm[norm.size()-1].second) {
		cout << amax-norm[norm.size()-1].first << endl;
	}
	else {
		cout << norm[norm.size()-1].first << endl;
	}

	return 0;
}


Measured memory_bytes: 1784
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		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 -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		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()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

s = readChar()

d = {"N":0,"W":0,"S":0,"E":0}

for i in s:
	d[i]+=1

flg = 1
if not(d["N"]+d["S"]==0 or (d["N"]>0 and d["S"]>0)):
	flg = 0

if not(d["W"]+d["E"]==0 or (d["W"]>0 and d["E"]>0)):
	flg = 0

if flg==1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int D;
    cin >> D;
    string ans;
    if(D==25)ans = "Christmas";
    else if(D==24)ans = "Christmas Eve";
    else if(D==23)ans = "Christmas Eve Eve";
    else if(D==22)ans = "Christmas Eve Eve Eve";

    cout << ans << endl;
}


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

using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
    bool operator < (const P& a, const P& b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
}
double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

typedef vector<P> G;

double area2(const G& P) {
    double A = 0;
    for (int i = 0; i < P.size(); ++i)
        A += cross(P[i], P[(i+1)%P.size()]);
    return A;
}

int main(){
    double x, y;
    G g;
    while(scanf("%lf,%lf", &x, &y) != EOF){P p(y, x); g.push_back(p);}
    printf("%lf\n", abs(area2(g)/2.));
}

Measured memory_bytes: 1240
using System;
using System.Linq;

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            int[] nums = Console.ReadLine().Trim().Split(' ').Select(_ => int.Parse(_)).ToArray();

            int[] takahashi = new int[2] { nums[0], nums[1] };
            int[] aoki = new int[2] { nums[2], nums[3] };

            while (true) {
                aoki[0] -= takahashi[1];
                if (aoki[0] <= 0) {
                    Console.Write("Yes");
                    break;
                }
                takahashi[0] -= aoki[1];
                if (takahashi[0] <= 0) {
                    Console.Write("No");
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 28088
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

vector<vvl> memo(55,vvl(55));

vl rec(ll from, ll to){
    vl res;
    if(from == to){
        res.push_back(0);
        return res;
    }
    REP(i,1,from+1){
        if(from % i >= to){ 
            auto v = rec(from % i, to);
            if(v.empty()) continue;
            for(auto j : v) res.push_back(j + (1LL<<i));
        }
    }
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    return res;
}

int main(){
    ll n; cin >> n;
    vl a(n); rep(i,n) cin >> a[i];
    vl b(n); rep(i,n) cin >> b[i];
    vvl c(n);
    rep(i,n){
        c[i] = rec(a[i], b[i]);
        if(c[i].empty()){
            puts("-1");
            return 0;
        }
    }
    ll ans = 0;
    while(1){
        int k = -1;
        rep(i,n){
            if(c[i][0] == 0) continue;
            for(int j=50; j>=0; j--){
                if(c[i][0]>>j & 1){
                    chmax(k,j);
                    break;
                } 
            }
        }
        if(k == -1) break;
        ans += 1LL<<k;
        rep(i,n){
            for(auto &j : c[i]){
                j &= ~(1LL<<k);
            }
            sort(all(c[i]));
        }
    }
    cout << ans << "\n";
}

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

int main() {
 long int as=0,bs=0,cs=0,ds=0;
 char zs;
 while(1){
   cin >> as >> zs >> bs;
   if(zs == '?'){
     break;
   }
   else if(zs == '+'){
     cs = as+bs;
   }
   else if(zs == '-'){
     cs = as-bs;
   }
   else if(zs == '*'){
     cs = as*bs;
   }
   else if(zs == '/'){
     cs = as/bs;
   }
   cout << cs << endl;
 }
}



Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int k,t;
  cin >> k >> t;
  vector<int>a(t);
  int maxx = 0;
  for(int i=0;i<t;i++){
    cin >> a[i];
    maxx = max(maxx,a[i]);
  }
  cout << max((2*maxx)-k-1,0) << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc = initScanner(os.Stdin)
	h, w, k := scanInt(sc), scanInt(sc), scanInt(sc)

	fmt.Println(resolve(h, w, k))
}

func resolve(h, w, k int) int {
	matrix := make([][]string, h)
	for i := 0; i < h; i++ {
		cell := scanString(sc)
		matrix[i] = strings.Split(cell, "")
	}

	ans := 0
	for r := 0; r < (1 << uint64(h)); r++ {
		for c := 0; c < (1 << uint64(w)); c++ {
			black := 0
			for i := 0; i < h; i++ {
				for j := 0; j < w; j++ {
					if ((r>>i)&1 == 0) && ((c>>j)&1 == 0) && matrix[i][j] == "#" {
						black++
					}
				}
			}
			if black == k {
				ans++
			}
		}
	}

	return ans
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


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

int main() {
    int n,k; cin >> n >> k;
    vector<int> a(n);
    vector<long> score(n,0);
    
    for(int i=1; i<=n; i++){
        cin >> a[i-1];
        if(i >= k+1){
            if(a[i-1] > a[i-1-k]) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, D, A;
pll XH[202020];
ll mk[202020];
ll i, j, k, ans;
int main(){
    scanf("%lld%lld%lld", &N, &D, &A);
    fornum(i,0,N){
        ll x, h;
        scanf("%lld%lld", &x, &h);
        h = (h - 1) / A + 1;
        XH[i] = {x, h};
        mk[i] = 1e18;
    }
    sort(XH, XH + N);
    j = 0;
    ans = 0;
    fornum(i,0,N){
        //printf("%lld %lld %lld\n", i, j, XH[i].first);
        if(ans-mk[i]>=XH[i].second)
            continue;
        while (j < N&&XH[j].first<=XH[i].first+D*2){
            //printf("a%lld %lld\n", XH[i].first, XH[j].first);
            mk[j] = ans;
            ++j;
        }
        //printf("b%lld %lld\n", XH[i].first, XH[j].first);
        ans += XH[i].second - ans + mk[i];
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 4992
package main

import "fmt"

func main() {
	var N int
	ends := make([]int, 3)
	fmt.Scanf("%d %d %d %d", &N, &ends[0], &ends[1], &ends[2])

	bars := make([]int, N)
	for i := range bars {
		fmt.Scanf("%d", &bars[i])
	}

	groups := make([]int, N)
	ans := pick(ends, bars, 0, groups)
	fmt.Println(ans)
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

const maxInt = 99999999

func pick(ends, bars []int, i int, groups []int) int {
	if i == len(bars) {
		cur := make([]int, 4)
		joint := 0
		for n := range bars {
			if groups[n] != 3 {
				if cur[groups[n]] > 0 {
					joint += 10
				}
			}
			cur[groups[n]] += bars[n]
		}
		if cur[0] == 0 || cur[1] == 0 || cur[2] == 0 {
			return maxInt
		}

		ans := abs(cur[0]-ends[0]) +
			abs(cur[1]-ends[1]) +
			abs(cur[2]-ends[2]) +
			joint
		return ans
	}

	min := maxInt
	for g := 0; g < 4; g++ {
		groups[i] = g
		n := pick(ends, bars, i+1, groups)
		if n < min {
			min = n
		}
	}
	return min
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=200010;
//const ll mod=1e9+7;
const ll mod=998244353;

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

int main(){
  int n,s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }

  vector<vector<mint>> dp(3010, vector<mint>(3010,0));
  dp[0][0]=1;
  rep(i,n)rep(j,s+1){
    dp[i+1][j] += dp[i][j]*2;
    if(j+a[i]<=s){
      dp[i+1][j+a[i]] += dp[i][j];
    }
  }
  ll ans = dp[n][s].x;
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 74272
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;
int main(void){
	double h;
	double maxh=0.0,minh=0.0;
	scanf("%d",&h);
	maxh=h;
	minh=h;
	while(~scanf("%lf",&h)){
		maxh=max(maxh,h);
		minh=min(minh,h);
	}
	cout << maxh-minh << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    string s;
    cin >> N >> s;
    long long r = 0, g = 0, b = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++; 
    }
    long long ans = r* g * b;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j < s.size() / 2 + 1; j++){
            if(i + 2*j >= s.size()) break;
            if(s[i] != s[i + j] && s[i + j] != s[i + 2*j] && s[i] != s[i + 2*j]) ans--; 
        }
    }
    cout << ans << endl;
}

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

using namespace std;
int dp[3000][3000];
int choice[3000][3000];
int main()
{
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    dp[0][0] = 0;
    if(s[0]==t[0])
    {
        dp[0][0] = 1;
        choice[0][0]=2;
    }
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            if(i>0)
            {
                dp[i][j] = dp[i-1][j];
                choice[i][j] = 0;
            }
            if(j>0)
            {
                if(dp[i][j-1]>dp[i][j])
                {
                    dp[i][j] = dp[i][j-1];
                    choice[i][j] = 1;
                }
            }
            if(s[i]==t[j])
            {
                int ans = 1;
                if(i>0 && j>0)
                {
                    ans = 1+dp[i-1][j-1];
                }
                if(ans>dp[i][j])
                {
                    dp[i][j] = ans;
                }
                choice[i][j] = 2;
            }
        }
    }
    string subsequence;
    int i = n-1;
    int j = m-1;
    while(i>=0 && j>=0)
    {
        if(choice[i][j]==0)
        {
            i--;
        }
        else if(choice[i][j]==1)
        {
            j--;
        }
        else
        {
            subsequence.push_back(s[i]);
            i--;
            j--;
        }
    }
    reverse(subsequence.begin(),subsequence.end());
    cout<<subsequence<<endl;
    return 0;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
string S;

int main(){
    cin >> N >> S;
    for(int f1 = 0; f1 < 2; f1++){
        for(int f2 = 0; f2 < 2; f2++){
            vector<int> ans;
            ans.push_back(f1);
            ans.push_back(f2);
            for(int i = 2; i < N; i++){
                int val = (ans[i-1] == 0) ? ans[i-2] : !ans[i-2];
                if(S[i-1] == 'o') ans.push_back(val);
                else ans.push_back(!val);
            }
            bool ok = true;
            // last
            if((S[N - 1] == 'o') ^ (ans[N - 1] == 1)) ok &= (ans[N - 2] == ans[0]);
            else ok &= (ans[N - 2] != ans[0]);
            // first
            if((S[0] == 'o') ^ (ans[0] == 1)) ok &= (ans[N - 1] == ans[1]);
            else ok &= (ans[N - 1] != ans[1]);
            if(ok){
                for(int a : ans){
                    cout << (a == 0 ? 'S' : 'W');
                }cout << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;
    
    

    return 0;
}


Measured memory_bytes: 1444
object Main{
  def main(args: Array[String]) ={ 
    val N = io.StdIn.readLine().toLong
    val v = io.StdIn.readLine().split(' ').map(_.toDouble).sorted

    val value = v.reduce{
      (lhs, rhs) =>
        (lhs + rhs) / 2.0
    }

    println(value)
  }
}

Measured memory_bytes: 27200
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,c=0,count=0,sa=1e6,sz=-1;
	char s[200005];
	scanf("%s",s);
	int l = strlen(s);
	for(int i=0;i<l;i++){
		if(s[i] == 'A'){
			sa = min(sa,i);
		}
		if(s[i] == 'Z'){
			sz = max(sz,i);
		}
	}
	printf("%d",sz-sa+1);
}

Measured memory_bytes: 384