akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n,k; cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    map<int,int> mp;
    rep(i,n){
        mp[p[i]]++;
    }
    vector<int> q;
    for(auto &v: mp){
        q.push_back(v.second);
    }
    sort(btoe(q));
    int spe=q.size();
    int ans=0;
    if(spe<=k){

    }else{
        rep(i,spe-k){
            ans+=q[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
	int year,month,day,tmp,premeiji;
	char yeartype[10];

	while(scanf("%d %d %d",&year,&month,&day)!=EOF)
	{
		premeiji=0;
		tmp=year*10000+month*100+day;
		if(tmp<18680908)
		{
			premeiji=1;
			strcpy(yeartype,"pre-meiji");
		}
		else if(tmp<19120730)
		{
			strcpy(yeartype,"meiji");
			year-=1867;
		}
		else if(tmp<19261225)
		{
			strcpy(yeartype,"taisho");
			year-=1911;
		}
		else if(tmp<19890108)
		{
			strcpy(yeartype,"showa");
			year-=1925;
		}
		else
		{
			strcpy(yeartype,"heisei");
			year-=1988;
		}
		if(premeiji)
		{
			puts(yeartype);
		}
		else
		{
			printf("%s %d %d %d\n",yeartype,year,month,day);
		}
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]


def bfs(i, j):  # 引数はスタートの位置(i, j)
    q = deque()
    q.append((i, j))
    log = [[-1] * w for _ in range(h)]
    log[i][j] = 0
    distance = 0
    d = [(1, 0), (0, 1), (-1, 0), (0, -1)]  # 右、上、左、下
    while q:
        p = q.popleft()
        for item in d:
            nx = p[0] + item[0]
            ny = p[1] + item[1]
            if not(0 <= nx < h and 0 <= ny < w):  # 迷路の外にはでれない
                continue
            elif s[nx][ny] == "#":  # 壁には進めない
                continue
            elif log[nx][ny] >= 0:  # 探索済みは探索しない
                continue
            else:
                log[nx][ny] = log[p[0]][p[1]] + 1
                q.append((nx, ny))
                if distance < log[nx][ny]:
                    distance = log[nx][ny]
    return distance


distance = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":  # start地点は壁でない
            continue
        else:
            temp = bfs(i, j)
            if temp >= distance:
                distance = temp
print(distance)

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod 998244353

vector<ll> v(3*(ll)(1e5+1),0);
vector<ll> v_inv(3*(ll)(1e5+1),0);

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==0) return 1;
	ll ans=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) ans=ans*m%mod;
	return ans;
}

void factorial(ll n){
	v[0]=1;
	for(ll i=1; i<=n; i++){
		v[i]=v[i-1]*i%mod;
	}
	return;
}

void factorial_inv(ll n){
	for(ll i=0; i<=n; i++){
		v_inv[i]=pmod(v[i],mod-2);
	}
}

ll binom(ll n, ll k){
	if(n<k || n<0 || k<0) return 0;
	ll tmp=v_inv[k]*v_inv[n-k]%mod;
	return v[n]*tmp%mod;
}

int main(){
	ll n, a, b, k;
	cin >> n >> a >> b >> k;
	factorial(n);
	factorial_inv(n);

	ll ans=0;
	for(ll i=0; a*i<=k; i++){
		if((k-a*i)%b==0){
			ll j=(k-a*i)/b;
			ans+=binom(n, i)*binom(n, j)%mod;
			ans%=mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
import sys
from itertools import combinations


def main():
    ll = read_ll()
    result = c(ll)
    print(result)

def c(ll):
    count = 0
    for i, j, k in combinations(ll, 3):
        if i != j and j != k and i != k:
            if i + j > k:
                count += 1
    return count

def read_ll():
    n = int(input())

    ll = input().split()
    ll = list(map(int, ll))
    ll.sort()
    return ll

main()


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

int h, w, n, r, c, to, mn[200005];
int main() {
	int i;
	cin >> h >> w >> n;
	for(i=1; i<=h; i++) mn[i] = 1e9;
	while(n--) {
		scanf("%d%d", &r, &c);
		mn[r] = min(mn[r], c);
	}
	for(i=1; i<=h; i++) {
		if(mn[i] <= to) break;
		if(to+1 < mn[i]) to++;
	}
	cout << i-1;
	return 0;
}

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

int main()
{
  int k=0;
  int length=0;
  char s[101];
  
  scanf("%d",&k);
  scanf("%s",s);
  
  length = strlen(s);
  
  if(length > k)
    {
      printf("%.*s...",k,s);
    }else{
    printf("%s",s);
  };
  return 0;
};

Measured memory_bytes: 2100
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	double mx=-1,mn=100000;
	double a;
	while(scanf("%lf",&a)!=EOF)
	{
		mx=max(mx,a);
		mn=min(mn,a);
	}
	printf("%.5lf\n",mx-mn);
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000007;
//------------------------------------------//

int main(){
  	int x;cin>>x;
    if(x==0) cout<<1<<endl;
    if(x==1) cout<<0<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
// #define N  100005

void solve()
{
    ll n,W;
    cin>>n>>W;
    ll w[n+1];
    ll v[n+1];
    ll sum=0;
    rep(i,1,n+1)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    ll N=sum+1;
    vi dp(N,-1);
    dp[0]=0;
    rep(i,1,n+1)
    {
        vi new_dp(N,-1);
        new_dp[0]=0;
        // cout<<i<<endl;
        // rep(i,0,N)
        // {
        //     cout<<dp[i]<<" ";
        // }
        // cout<<endl;
        rep(j,0,N)
        {
            if(dp[j]!=-1)
            {
                if(new_dp[j+v[i]]==-1)
                new_dp[j+v[i]]=dp[j]+w[i];
                else
                new_dp[j+v[i]]=min(new_dp[j+v[i]],dp[j]+w[i]);
            }

        }
        rep(j,0,N)
        {
            if(dp[j]!=-1)
            {
                if(new_dp[j]!=-1)
                {
                    new_dp[j]=min(new_dp[j],dp[j]);
                }
                else
                {
                    new_dp[j]=dp[j];
                }
            }
        }
        // rep(i,0,N)
        // {
        //     cout<<new_dp[i]<<" ";
        // }
        // cout<<endl;
        dp=new_dp;
    }
    // rep(i,0,N)
    // {
    //     cout<<i<<" "<<dp[i]<<endl;
    // }
    for(int i=N-1;i>=1;i--)
    {
        if(dp[i]!=-1&&dp[i]<=W)
        {
            cout<<i<<endl;
            return;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}
/*
3 4
1 2
2 3
4 1
*/

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


ll mul(ll x, ll y) {
  x %= MOD;
  y %= MOD;
  return x * y % MOD;
}

ll mul(ll x, ll y, ll z) {
  return mul(mul(x, y), z);
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll x[100000], y[100000];

  for(ll i = 0; i < n; i++) {
    cin >> x[i];
  }

  for(ll i = 0; i < m; i++) {
    cin >> y[i];
  }

  vector<ll> x_len, y_len;

  for(ll i = 1; i < n; i++) {
    x_len.push_back(mul(x[i] - x[i - 1], i, n - i));
  }

  for(ll i = 1; i < m; i++) {
    y_len.push_back(mul(y[i] - y[i - 1], i, m - i));
  }

  ll x_len_sum = 0, y_len_sum = 0;

  for(ll i: x_len) {
    x_len_sum += i;
  }

  for(ll i: y_len) {
    y_len_sum += i;
  }

  cout << mul(x_len_sum, y_len_sum) << endl;
  

}


Measured memory_bytes: 4084
Edge = Struct.new(:from, :to, :cost)

N = gets.to_i
edges = Array.new(N+1) { [] }
(N-1).times do |i|
  a, b, c = gets.split.map(&:to_i)
  edges[a] << Edge.new(a, b, c)
  edges[b] << Edge.new(b, a, c)
end

Q, K = gets.split.map(&:to_i)
queries = Array.new(Q) { gets.split.map(&:to_i) }

visit = Array.new(N+1, false)
visit[K] = true
dist = Array.new(N+1, Float::INFINITY)
dist[K] = 0

queue = []
edges[K].each { |edge| queue << edge }

until queue.empty?
  edge = queue.shift
  unless visit[edge.to]
    cost = dist[edge.from] + edge.cost
    if dist[edge.to] > cost
      dist[edge.to] = cost
      visit[edge.to] = true
      edges[edge.to].each { |edge| queue << edge }
    end
  end
end

queries.each do |x, y|
  puts dist[x] + dist[y]
end

Measured memory_bytes: 42236
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	boolean ans = false;
        int x,y;
	x = sc.nextInt();
	y = sc.nextInt();
	for(int i=0;i<=x;i++){
	    if((2*i+4*(x-i))==y) ans = true;
	}
	if(ans){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


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

typedef long long ll;
const int N = 123;
int n, dep[N];
vector<int> G[N], diam;
void dfs(int x, int pr) {
  dep[x] = dep[pr] + 1;
  for (auto y : G[x]) if (y != pr) {
    dfs(y, x);
  }
}
bool dfs2(int x, int tar, int pr) {
  diam.push_back(x);
  if (x == tar) return true;
  for (auto y : G[x]) if (y != pr) {
    if (dfs2(y, tar, x)) return true;
  }
  diam.pop_back();
  return false;
}
int cnt[N];
void dfs3(int x, int pr, int d) {
  cnt[d] = max(cnt[d], (int) G[x].size() - 1);
  for (auto y : G[x]) if (y != pr) {
    dfs3(y, x, d + 1);
  }
}

inline ll solve(int x, int y) {
  for (int i = 1; i <= n; i++) {
    cnt[i] = 1;
  }
  dfs3(x, y, 0);
  if (~y) dfs3(y, x, 0);
  cnt[0] = ~y ? (int) max(G[x].size(), G[y].size()) - 1 : (int) G[x].size();
  ll ret = 1;
  for (int i = 0; i <= n; i++) {
    ret *= cnt[i];
  }
  return ret * (~y ? 2 : 1);
}

int main() {
  scanf("%d", &n);
  if (n == 2) {
    puts("1 2");
    return 0;
  }
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, 0);
  int g = 0, h = 0;
  for (int i = 1; i <= n; i++) {
    if (dep[i] > dep[g]) g = i;
  }
  dfs(g, 0);
  for (int i = 1; i <= n; i++) {
    if (dep[i] > dep[h]) h = i;
  }
  dfs2(g, h, 0);
  printf("%d ", (int) (diam.size() + 1) / 2);
  if ((int) diam.size() & 1) {
    int x = diam[diam.size() / 2];
    ll ans = solve(x, -1);
    for (auto y : G[x]) {
      ans = min(ans, solve(x, y));
    }
    printf("%lld\n", ans);
  } else {
    printf("%lld\n", solve(diam[diam.size() / 2 - 1], diam[diam.size() / 2]));
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &nums[i])
	}

	total := 1
	for i := 0; i < n; i++ {
		if nums[i] == 0 {
			total = 0
			break
		}
	}

	if total == 0 {
		fmt.Println(total)
	} else {
		for i := 0; i < n; i++ {
			if nums[i] > 1e18/total {
				total = -1
				break
			} else {
				total = total * nums[i]
			}
		}

		fmt.Println(total)
	}
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    int n;
    cin >> n;
    vector<ll> spots(n);
    rep(i, n) cin >> spots[i];
    vector<ll> costs(n + 1);
    ll sum = 0;

    auto get_cost = [&](int start, int end) {
        if (start == -1) return abs(spots[end]);
        if (end == n) return abs(spots[start]);
        return abs(spots[start] - spots[end]);
    };

    rep(i, n + 1) {
        ll cost = get_cost(i - 1, i);
        costs[i] = cost;
        sum += cost;
    }

    rep(i, n) {
        ll prev_cost = costs[i];
        ll next_cost = costs[i + 1];
        ll direct_cost = get_cost(i - 1, i + 1);

        ll now = sum - prev_cost - next_cost + direct_cost;
        cout << now << endl;
    }
}



Measured memory_bytes: 2816
n = gets.to_i
a = $<.map(&:to_i).sort.reverse

def f(a, select = [])
	max = select.flatten.max || 0
	if a.empty?
		return max
	end
	
	k = a[0]
	ans = []
	[k, select.size].min.downto(1){|r|
		(1..max).to_a.combination(r){|b|
			if check(select, b)			
				ans << f(a[1..-1], select + [b + (max+1..max+k-r).to_a])
			end
		}
	}
	ans << f(a[1..-1], select + [(max+1..max+k).to_a])
	ans.min
end

def check(select, a)
	select.all?{|b| (b & a).size <= 1}
end

s = 0
(0..n-1).each{|i|
	if a[i] > n-1
		s += a[i]-n+1
		a[i] = n-1
	end
}
p s + f(a, [])

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22996
h, w, m =  map(int, input().split())
bom_list = []
h_list = [0] * h
w_list = [0] * w

for i in range(m):
    a, b =  map(int, input().split())
    bom_list.append([a - 1, b - 1])
    h_list[a - 1] += 1
    w_list[b - 1] += 1

max_h = max(h_list)
max_w = max(w_list)
ans = max_h + max_w
count = 0

for bom in bom_list:
    if h_list[bom[0]] == max_h and w_list[bom[1]] == max_w:
        count += 1

if h_list.count(max_h) * w_list.count(max_w) == count:
    ans -= 1

print(ans)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int n;

int main(){
    cin>>n;
    vint p(n);
    rep(i,n)cin>>p[i];
    sort(all(p));
    p[n-1]/=2;
    int sum=0;
    rep(i,n)sum+=p[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;


int main(){
    string a;
    cin >> a;
    for(size_t i = 0; i < a.size(); i++)
    {
        if(a[i] == ','){
            a[i] = ' ';
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	cin >> n;
	vector<string> s(n);
	int nP2 = n * (n - 1);
	vector<int> a(3, 1000010001);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	int k = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i == j) continue;
			m = atoi((s[i] + s[j]).c_str());
			if (a[2] > m)
			{
				a[2] = m;
				sort(a.begin(), a.end());
			}
		}
	}
	cout << a[2] << endl;
	return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  string S;
  cin>>N;
  cin>>S;
  int cnt=0,ans[N]={};
  for(int j=0;j<0;j++){
    if(S[j]=='W') cnt++;
  }
  for(int k=1;k<N;k++){
    if(S[k]=='E') cnt++;
  }
  ans[0]=cnt;
  for(int i=1;i<N;i++){
    if(S[i-1]=='E' && S[i]=='E'){ans[i]=ans[i-1]-1;}
    else if(S[i-1]=='E' && S[i]=='W'){ans[i]=ans[i-1];}
    else if(S[i-1]=='W' && S[i]=='E'){ans[i]=ans[i-1];}
    else if(S[i-1]=='W' && S[i]=='W'){ans[i]=ans[i-1]+1;}
  }
  int answer=N;
  for(int i=0;i<N;i++){
    if(answer>=ans[i])answer = ans[i];
  }
  cout<<answer;

  return 0;
}

Measured memory_bytes: 1812
from math import sqrt

N = int(input())

ans = 0

for i in range(1, N + 1, 2):
    cnt = 0

    for j in range(1, int(sqrt(i)) + 1):
        if i % j == 0:
            cnt += 2

    if sqrt(i).is_integer():
        cnt -= 1

    if cnt == 8:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';
bool s[200050];
bool t[200050];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		if (a == 1) t[b] = 1;
		if (b == n) s[a] = 1;
	}

	rep(i, 200050)
	{
		if (s[i] && t[i]) {
			cout << "POSSIBLE";
			return 0;
		}
	}

	cout << "IMPOSSIBLE";
}



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;

int N, M;
bool A[MAX_N];
int dp[MAX_N];

signed main()
{
  cin >> N >> M;
  REP(m,M) {
    int a; cin >> a;
    A[a] = true;
  }

  dp[0] = 1;
  REP(n,N) {
    FOR(d,1,3) {
      if(!A[n+d]) {
        dp[n+d] += dp[n];
        dp[n+d] %= MOD;
      }
    }
  }

  cout << dp[N] << endl;

  return 0;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int m, d;
    cin >> m >> d;

    int ans = 0;
    for(int x=1; x<=m; ++x){
        for(int y=1; y<=d; ++y){
            int y1 = y % 10;
            int y2 = y / 10;
            if(y1 >= 2 && y2 >= 2 && y1 * y2 == x)
                ++ ans;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  char input[100001];
  int i,len;
  
  scanf("%s",input);
  len=strlen(input);
  
  for(i=0;i<(len-1);i++){
    if(input[i]==input[i+1]){
      printf("%d %d",i+1,i+2);
      return 0;
    }
  }
  
  for(i=0;i<(len-2);i++){
    if(input[i]==input[i+2]){
      printf("%d %d",i+1,i+3);
      return 0;
    }
  }
  
  printf("-1 -1");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Mat = vector<vector<int>>;
const int mod = 1000000007;
Mat mul(Mat a, Mat b){
  int n = a.size();
  Mat r = vector<vector<int>>(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        r[i][j] += 1ll * a[i][k] * b[k][j] % mod;
        if(r[i][j] >= mod) r[i][j] -= mod;
      }
    }
  }
  return r;
}
int main(){
  int n; long long k; cin >> n >> k;
  Mat a = vector<vector<int>>(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];
  Mat b = vector<vector<int>>(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++) b[i][i] = 1;
  for(; k ; k >>= 1, a = mul(a, a)) if(k&1) b = mul(b, a);
  int ans = 0;
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) {
    ans += b[i][j];
    if(ans >= mod) ans -= mod;
  }
  cout << ans << endl;
  return 0;
}
        


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = (a + b) * 2;
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 26116
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int n,m,k;
bool g[15][1005];
int sum[15][1005];
int ans=1e9;
int a[15];

bool check(int cnt,int j,int la)
{
    int s=0;
    for(int i=1;i<=cnt;i++)
	{
        s=sum[a[i]][j]-sum[a[i]][la]-sum[a[i-1]][j]+sum[a[i-1]][la];
        if(s>k)
			return false;
    }
    return true;
}

void div(int t)
{
	int s=t,l=0;
	a[t+1]=n;
	for(int i=1;i<=m;i++)
	{
		if(!check(t+1,i,l))
		{
			s++;
			l=i-1;
		}
	}
	if(check(t+1,m,m-1))
	{
		ans=min(ans,s); 
	}
}
void dfs(int x,int t)
{
	if(x==n)
	{
		div(t);
		return;
	}
	a[t+1]=x;
	dfs(x+1,t+1);
	dfs(x+1,t);
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>m>>k;
	string s;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		for(int j=1;j<=m;j++)
		{
			g[i][j]=(s[j-1]=='0'?false:true);
			sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+g[i][j];
		}	
	}	
	dfs(1,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int N, M;
int a[110][110];

int main() {
    cin >> M >> N;
    for (int j = 0; j < M; ++j) {
        for (int k = 0; k < N; ++k) {
            cin >> a[j][k];
        }
    }

    int ret = 0;

    if (N == 1) {
        for (int j = 0; j < M; ++j) {
            ret += a[j][0];
            a[j+1][0] = 1 - a[j+1][0];
        }
        cout << ret << endl;
        return 0;
    }

    for (int j = 0; j < M; ++j) {
        for (int k = 1; k < N-1; ++k) { a[j][k] = 1 - a[j][k]; }

        int inc = 0;
        for (int k = 0; k < N; ++k) {
            int t = 0;
            for (int l = 0; l < N; ++l) {
                if (k == l) {
                    t += 1 - a[j][l];
                } else {
                    t += a[j][l];
                }
            }
            inc = max(inc, t);
        }

        ret += inc;
        for (int k = 0; k < N; ++k) { a[j+1][k] = 1 - a[j+1][k]; }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<algorithm>

using namespace std;

int X[100];

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
	}
	sort(X,X+N);

	cout << (X[N - 1] - X[0]) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(void){
    string a,b,c;
    cin >> a >> b >> c;
    char now='a';
    bool flag = true;
    string ans;
    while(flag){
        if(now=='a'){
            if(a.length()==0){
                flag = false;
                ans="A";
            }else{
                now = a[0];
                a.erase(0,1);
            }
        }else if(now=='b'){
            if(b.length()==0){
                flag = false;
                ans="B";
            }else{
                now = b[0];
                b.erase(0,1);
            }
        }else{
            if(c.length()==0){
                flag = false;
                ans="C";
            }else{
                now = c[0];
                c.erase(0,1);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
int main(){
	int n,k,x,y;
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n<=k)
		printf("%d\n",n*x);
	else
		printf("%d\n",k*x+(n-k)*y);
	return 0;
}

Measured memory_bytes: 256
def c_remainder_minimization_2019(L, R):
    ans = float('inf')
    for i in range(L, min(R, L + 2019)):
        for j in range(i + 1, min(R + 1, L + 2020)):
            ans = min(ans, (i * j) % 2019)
    return ans

L, R = [int(i) for i in input().split()]
print(c_remainder_minimization_2019(L, R))

Measured memory_bytes: 3060
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????
		int n = ss.Next<int>();
		int m = ss.Next<int>();
		int[,] a = new int[n, m];
		int[] b = new int[m];
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				int num = ss.Next<int>();
				a[i,j] = num;

			}
		}
		for (int i = 0; i < m; i++)
		{
			int num = ss.Next<int>();
			b[i] = num;
		}

		for (int j = 0; j < n; j++)
		{
			int ans = 0;
			for (int i = 0; i < m; i++)
			{

				ans += a[j, i] * b[i];
			}
			Console.WriteLine(ans);
		}

		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

			//?????°???????????????????????¨?????????????????????????????????????????????????´???????
			//int[] array = ss.Next<int>(10);
		//---------------------------------
	}
}

public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

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

bool bingo(ll a[3][3]){
    for(int i = 0; i < 3; i++){
        if(a[i][0] + a[i][1] + a[i][2] == 0) {
            return true;
        }
        if(a[0][i] + a[1][i] + a[2][i] == 0) {
            return true;
        }
    }
    if(a[0][0] + a[1][1] + a[2][2] == 0) return true;
    else if(a[0][2] + a[1][1] + a[2][0] == 0) return  true;
  else return false;
}

int main(){
    ll temp,n;
    ll a[3][3];
    ll judge = false;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> temp;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(temp == a[j][k]) a[j][k] = 0;
            }
        }
        judge = bingo(a);
        if(judge) break;
    }
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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(){
    string s; cin >> s;
    string t; cin >> t;
    int ls = s.size(), lt = t.size();
    int ans = 1e9;
    rep(i,ls-lt+1){
        int tmp = 0;
        rep(j,lt){
            if(t[j] != s[i+j]) tmp++;
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
/// Bismillah Hir Rahmanir Rahim

#include <bits/stdc++.h>

using namespace std;

#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define ff                    first
#define ss                    second
#define pb                    push_back
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define clr(ar)               memset(ar, 0, sizeof(ar))
#define eprintf(...)          fprintf(stderr, __VA_ARGS__)

/*
template <class T> T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); }
template <class T> T lcm(T a, T b ){ return ( a * b ) / gcd( a,b ); }
template<class T> string ToString(const T &x){ stringstream s; s << x; return s.str(); }
template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }
*/

const int dr[] = { -1, 1, 0, 0 }; /// 4 side moves.
const int dc[] = { 0, 0, -1, 1 };
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }; /// 8 side moves.
const int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int kr[] = { 1, 1, -1, -1, 2, 2, -2, -2 }; /// Knight Moves.
const int kc[] = { 2, -2, 2, -2, 1, -1, 1, -1 };

typedef  long long int            ll;
typedef  map<string,int>          msi;
typedef  map<string, string>      mss;
typedef  map<int,int>	          mii;
typedef  map<ll, ll>              mll;
typedef  map<char,int>            mci;
typedef  map<int,string>	      mis;
typedef  pair<int,int> 	          ii;
typedef  pair<string, int>        psi;
typedef  pair<string, string>     pss;
typedef  vector<int> 	          vi;
typedef  vector<string> 	      vs;
typedef  vector<char>	          vc;
typedef  vector< ii >             vii;

template<class T1> void deb(T1 e1)
{
    cout << e1 << endl;
}
template<class T1,class T2> void deb(T1 e1, T2 e2)
{
    cout << e1 << space << e2 << endl;
}
template<class T1,class T2,class T3> void deb(T1 e1, T2 e2, T3 e3)
{
    cout << e1 << space << e2 << space << e3 << endl;
}

#define sf                    scanf
#define pf                    printf

#define sf1(a)                scanf("%d", &a)
#define sf2(a,b)              scanf("%d %d",&a, &b)
#define sf3(a,b,c)            scanf("%d %d %d", &a, &b, &c)
#define sf4(a,b,c,d)          scanf("%d %d %d %d", &a, &b, &c, &d)

#define sf1ll(a)              scanf("%I64d", &a)
#define sf2ll(a,b)            scanf("%I64d %I64d", &a, &b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d", &a, &b, &c)
#define sf4ll(a,b,c,d)        scanf("%I64d %I64d %I64d %I64d", &a, &b, &c, &d)

#define READ                  freopen("in.txt", "r", stdin);
#define WRITE                 freopen("out.txt", "w", stdout);
/// The End.

void check_time()
{
#ifdef the_badcoder
    eprintf("%.5lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}

const int res = 1e5 + 10;
const ll mod = 1e9 + 7;

int main()
{
    string s;
    int digit = 0;
    
    cin >> s;
    
    for( int i = 0; i < s.size(); i++ )
    {
        char ch = s[i];
        
        if( ch == '1' ){
            digit++;
        } 
    }
    
    deb( digit );
    return 0;
}


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

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T=1;
//cin>>T;
while(T--){
long long int x,y=100;
cin>>x;
int ans=0;
while(x>y){
    y+=y/100;
    ans++;
}
cout<<ans;
}
return 0;
}
/*_*/

Measured memory_bytes: 3664
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <limits.h>
#include <stack>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<double,double> pdd;
typedef long long ll;
const int maxn = 1005;
int N,M;
bool conn[maxn][maxn];
int col[maxn],cnt[maxn],f[maxn][maxn];
bool dfs(int u,int c){
    cnt[c]++;
    col[u] = c;
    for(int i = 1; i <= N; i++){
        if(!conn[u][i]){
            if(!col[i]){
                if(!dfs(i,3 - c)) return 0;
            }
            else if(col[i] == c) return 0;
        }
    }
    return 1;
}
int main(){
    FAST_IO
    cin>>N>>M;
    for(int i = 1; i <= M; i++){
        int a,b;
        cin>>a>>b;
        conn[a][b] = conn[b][a] = 1;
    }
    for(int i = 1; i <= N; i++) conn[i][i] = 1;
    f[0][0] = 1;
    int now = 0;
    for(int i = 1; i <= N; i++){
        if(!col[i]){
            now++;
            cnt[1] = cnt[2] = 0;
            if(!dfs(i,1)){
                cout<<-1<<endl;
                return 0;
            }
            for(int j = 0; j <= N; j++) if(f[now - 1][j]) f[now][j + cnt[1]] = f[now][j + cnt[2]] = 1;
        }
    }
    int ans = INT_MAX;
    for(int i = 0; i <= N; i++){
        if(f[now][i]){
            ans = min(ans, i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int n,q; cin>>n>>q;
	string s; cin>>s;
	
	vector<int> cnt(n+5,0);
	cnt[0]=0;
	
	for(int i=1;i<n;i++)
		if(s[i-1]=='A' && s[i]=='C') cnt[i]=cnt[i-1]+1;
		else cnt[i]=cnt[i-1];
	
	for(int i=0;i<q;i++){
		int l,r; cin>>l>>r;	
		l--; r--;
		cout<<cnt[r]-cnt[l]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1408
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def min(a,b)
    return a>b ? b : a
end
INF=Float::INFINITY
H,W=get_i
s=array(H)
H.times do|i|
    s[i]=get_nsp
end
dp=Array.new(H){Array.new(W){Array.new(2){INF}}}
dp[0][0][0]=0
dp[0][0][1]=0
if s[0][0]=="#"
    dp[0][0][1]+=1
else
    dp[0][0][0]+=1
end
H.times do|i|
    W.times do|j|
        if i-1>=0
            if s[i-1][j]==s[i][j]
                dp[i][j][0]=min(dp[i-1][j][0],dp[i][j][0])
                dp[i][j][1]=min(dp[i-1][j][1],dp[i][j][1])
            else
                dp[i][j][0]=min(dp[i-1][j][0]+(s[i][j]=="." ? 1 : 0),dp[i][j][0])
                dp[i][j][1]=min(dp[i-1][j][1]+(s[i][j]=="#" ? 1 : 0),dp[i][j][1]) 
            end
        end
        if j-1>=0
            if s[i][j-1]==s[i][j]
                dp[i][j][0]=min(dp[i][j-1][0],dp[i][j][0])
                dp[i][j][1]=min(dp[i][j-1][1],dp[i][j][1])
            else
                dp[i][j][0]=min(dp[i][j-1][0]+(s[i][j]=="." ? 1 : 0),dp[i][j][0])
                dp[i][j][1]=min(dp[i][j-1][1]+(s[i][j]=="#" ? 1 : 0),dp[i][j][1]) 
            end
        end
    end
end
puts dp[H-1][W-1][1]
#p dp[H-1][W-1]

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
    string  n;
    cin >> n;
    ll ans = (n.size()-1)*9;
    ans+=ctoi(n.at(0)-1);
    int che = 0;
    for(int i=1;i<n.size();i++){
        if(n.at(i)=='9')che++;
    }
    if(che+1==n.size())ans++;
    cout << ans<<endl;
}
 


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception{
		// System.setIn(new FileInputStream("file"));
		try(BufferedReader  kb = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter out = new PrintWriter(System.out)){
			for(String in; (in= kb.readLine())!= null; ){
				out.println(solve(in.trim()));
			}
		}
	}

	static String solve(String trim) {
		boolean[] xd = new boolean[4];

		for(int i= 0;i<trim.length(); i++ ){
			if(trim.charAt(i)=='N')
					xd[0]=true;
			if(trim.charAt(i)=='S')
				xd[1]=true;
			if(trim.charAt(i)=='E')
				xd[2]=true;
			if(trim.charAt(i)=='W')
				xd[3]=true;
			
			
		}

		return (xd[0]==xd[1]&&xd[2]==xd[3])?"Yes":"No";


	}

}


Measured memory_bytes: 21332
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0

if 2 not in a:
  print(-1)
  exit()

x = 1
for i in range(n-1):
 
  x = a[x-1]
  cnt += 1

            
  if x == 2:
    print(cnt)
    exit()

print(-1)

Measured memory_bytes: 13020
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int dp; // i個目までの文字列を分割した時の分割数の最小値
vector<int> dp2(1<<26, 1e9); // ハッシュ値ごとの分割数の最小値
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int N = s.length();
  ll x = 0; // i個目までのハッシュ値
  dp = 0; 
  dp2[0] = 0;
  FOR(i,0,N) {
    x ^= 1LL << (s[i] - 'a');
    int ma = min((int)1e9, dp2[x]);
    FOR(j,0,26) {
      ll y = x ^ (1LL << j);
      ma = min(ma, dp2[y]);
    }
    dp2[x] = min(dp2[x], ma + 1);
    dp = ma + 1;
  }
  cout << dp << endl;
  return 0;
}

Measured memory_bytes: 262992
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-02-22 20:38:23
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b && a != c ||
        a == c && a != b ||
        b == c && a != b) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

    return 0;
}


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

int n, a[MAXN];
vector<pair<int, int>> sol;

int sign(int x) {
    return (x >= 0) ? 1 : -1;
}

int main() {
    ios::sync_with_stdio(0);

    cin >> n;

    int best = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (abs(a[i]) > abs(a[best]))
            best = i;
    }

    for (int i = 1; i <= n; ++i) {
        if (sign(a[i]) != sign(a[best]))
            sol.push_back(make_pair(best, i));
    }

    if (sign(a[best]) == 1) {
        for (int i = 1; i < n; ++i)
            sol.push_back(make_pair(i, i + 1));
    }
    else {
        for (int i = n; i > 1; --i)
            sol.push_back(make_pair(i, i - 1));
    }

    cout << sol.size() << "\n";
    for (auto x: sol)
        cout << x.first << " " << x.second << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,h[100003],tmp[100003];
bool check(long long times){
	for(int i=0;i<n;i++)
		tmp[i]=max(0ll,h[i]-times*b);
	for(int i=0;i<n;i++)
		if(tmp[i])
			times=times-(tmp[i]-1)/(a-b)-1;
	return times>=0;
}
int main(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>h[i];
	long long l=0,r=pow(10,9);
	while(l<r){
		long long mid=(l+r)/2;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<r;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		long K = scan.nextLong();
		long result = 0;

			if(N%K==0) {
			result = 0;
		}else {
			if(N%K<K-N%K) {
				result = N%K;
			}else {
				result = K-N%K;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    for(int i=0; i<N; i++)
    {
        cin >> B.at(i);
    }
    for(int i=0; i<N-1; i++)
    {
        cin >> C.at(i);
    }
    int ans=0;
    for(int i=0; i<N; i++)
    {
        ans+=B.at(i);
    }
    for(int i=0; i<N-1; i++)
    {
        if(A.at(i)+1==A.at(i+1))
        {
            ans+=C.at(A.at(i)-1);
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#A

"""
s = input().split("/")
if int(s[1]) <= 4:
    print("Heisei")
else:
    print("TBD")
"""
#B
"""
n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)
"""

#C
import itertools

n, a, b, c = map(int, input().split())
abc = [a, b, c]
ans = float("INF")
x = [int(input()) for i in range(n)]
nums = list(itertools.product([0, 1, 2, 3], repeat = n))
#print(nums)
for i in nums:
    tmp = 0
    aa = 0
    ba = 0
    ca = 0
    for number, k in enumerate(i):
        if k == 1:
            if aa != 0:
                tmp += 10
            aa += x[number]
        if k == 2:
            if ba != 0:
                tmp += 10
            ba += x[number]
        if k == 3:
            if ca != 0:
                tmp += 10
            ca += x[number]
    if aa == 0 or ba == 0 or ca == 0:
        tmp = float("INF")
    else:
        tmp += abs(aa - a)
        tmp += abs(ba - b)
        tmp += abs(ca - c)
    ans = min(tmp, ans)
print(ans)
        
        
            


#D

"""
a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
s.sort()
t.sort()

import bisect


for i in range(q):
    x = int(input())
    s_l = bisect.bisect_left(s, x) - 1
    t_l = bisect.bisect_left(t, x) - 1
    s_r = s_l + 1
    t_r = t_l + 1
    if s_l == -1:
        s_l = 0
    if t_l == -1:
        t_l = 0
    if s_l == a :
        s_l = a - 1
        s_r = a - 1
    if s_r == a:
        s_r = a - 1
    if t_l == b:
        t_l = b - 1
        t_r = b - 1
    if t_r == b:
        t_r = b - 1
    ans = min(abs(t[t_l] - s[s_r]) + min(abs(t[t_l] - x), abs(s[s_r] - x)),
    abs(s[s_l] - t[t_r]) + min(abs(s[s_l] - x), abs(t[t_r] - x)),
    abs(s[s_l] - t[t_l]) + min(abs(s[s_l] - x), abs(t[t_l] - x)),
    abs(s[s_r] - t[t_r]) + min(abs(s[s_r] - x), abs(t[t_r] - x)),
    )
    
    print(ans)
"""


Measured memory_bytes: 53556
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main(){
    int c1x, c1y, c1r, c2x, c2y, c2r;
    scanf("%d %d %d",&c1x,&c1y,&c1r);
    scanf("%d %d %d",&c2x,&c2y,&c2r);

    if(pow(c1x-c2x,2)+pow(c1y-c2y,2) > pow(c1r+c2r,2)) cout << 4 << endl;
    else if(pow(c1x-c2x,2)+pow(c1y-c2y,2) == pow(c1r+c2r,2)) cout << 3 << endl;
    else if((pow(c1x-c2x,2)+pow(c1y-c2y,2) < pow(c1r+c2r,2)) && (pow(c1x-c2x,2)+pow(c1y-c2y,2) > pow(c1r-c2r,2))) cout << 2 << endl;
    else if(pow(c1x-c2x,2)+pow(c1y-c2y,2) == pow(c1r-c2r,2)) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int a;
    long long int n[2000002],b[2000002],c[2000002],m=0,i;
    
    scanf("%d",&a);

    for(i=1;i<=a;i++)
    {
         b[i]=0;
         c[i]=0;
    }

    for(i=1;i<=a;i++)
    {
        scanf("%lld",&n[i]);
        b[n[i]]++;
    }

    for(i=1;i<=a;i++)
    {
        c[i]=b[i]*(b[i]-1)/2;
        m+=c[i];
    }

    for(i=1;i<=a;i++)
    {
        printf("%lld\n",m-b[n[i]]+1);
    }
    return 0;
}


Measured memory_bytes: 9344