akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
	#include<algorithm>
	#include<vector>
	#include<set>
	#include<cmath>
	#include<unordered_set>
	#include<map>
	#include<deque> 
	#include<cstring>
	#include<utility>
	#include<queue>
	#include<string>
	#include<iomanip>
	#include<unordered_map>
	#include<list>
	using namespace std;
	#define int /*unsigned*/long long
	#define pb push_back
	#define fr(i,n) for(int i=0;i<n;i++)
	#define F first
	#define S second
	#define LM LONG_MAX
	#define LS LONG_MIN
	#define ccM 1000000007
	#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
	int max(int b,int a){if(b>a)return b;else return a;}
	int min(int b,int a){if(b<a)return b;else return a;}
	int Abs(int b){return max(b,-b);}
	void print(vector<pair<int,int> >&v){fr(i,v.size())cout<<v[i].F<<" "<<v[i].S<<endl;cout<<endl;}
	void print(int arr[],int n){for(int i=0;i<n;i++)cout<<arr[i]<<" ";cout<<endl;}
	bool sortbysec(const pair<pair<int,int>,int> &a,const pair<pair<int,int>,int> &b){return (a.first.second < b.first.second);}

	/*void buildTree(int *a,int s,int *tree,int index)
	{
		if(s==e){
			tree[index]=a[s];
			return;
		}
		//Recursive case
		//The Parent Node's Value is obtained from the minimum of the
		//left subtree and right subtree. So we need to construct them first.
		int m=(s+e)/2;
		buildTree(a,s,mid,tree,2*index);//right subtree
		buildTree(a,mid+1,e,tree,2*index+1);//left subtree
		tree[index]=min(tree[2*index+1],tree[2*index]);
	}
	//THREE CASES FOR OVERLAPPING IN NODE RANGE AND QUERY RANGE
	/*
	1. QUERY RANGE SMALLER THAN NODE RANGE (PARTIAL)
	2. QUERY RANGE GREATER THAN NODE RANGE (COMPLETE)
	3. QUERY RANGE EQUAL TO NODE RANGE     (COMPLETE)
	4. QUERY RANGE BELONGS TO 2 OR MORE NODE RANGE (PARTIAL)
	5. IN CASE NO OVERLAP RETURN
	In case of partial overlap we need to call on both sides.

	int32_t main()
	{
		int a[]={1,3,2,-5,6,4};
		int n=sizoef(a)/sizeof(int);
		int *tree=new int[4*n+1];//worst case size of a segment tree array
		buildTree(a,0,n-1,tree,1);
		for(int i=1;i<4*n+1;i++)
			cout<<tree[i]<<" ";
		cout<<endl;
	}*/
	int32_t main()
	{
		string s,t;
		cin>>s>>t;
		int m=s.length();
		int n=t.length();
		int dp[n+1][m+1];
		//memset(dp,0,sizeof(dp));
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=m;j++)
			{
				dp[i][j]=0;
			}
		}
		string temp="";
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(t[i-1]==s[j-1])
				{
					dp[i][j]=1+dp[i-1][j-1];
				}
				else
				{
					if(dp[i-1][j]>dp[i][j-1]){
						dp[i][j]=dp[i-1][j];
					}
					else
					{
						dp[i][j]=dp[i][j-1];
					}
	 
	 
				}
			}
		}
		int i=n,j=m;
		while(i>0 && j>0)
		{
			//cout<<dp[i][j]<<" ";
			if(t[i-1]==s[j-1])
			{
				temp+=t[i-1];i--;j--;
			}
			else if(dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
		reverse(temp.begin(), temp.end());
		cout<<temp<<endl;
	}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

Int N, K;
Int A[100005];

int main() {
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for (Int i = 0; i < N; i++) cin >> A[i];
    Int x = 0;
    bool less = false;
    for (Int i = 40; i >= 0; i--) {
        if ((1LL<<i) > K) continue;
        Int cnt0, cnt1;
        cnt0 = cnt1 = 0;
        for (Int j = 0; j < N; j++) {
            if ((A[j] & (1LL<<i)) > 0) {
                cnt1++;
            }
            else {
                cnt0++;
            }
        }
        //cout << cnt0 << " " << cnt1 << endl;
        if (less) {
            if (cnt0 > cnt1) {
                x += (1LL<<i);
            }
        }
        else {
            //cout << (1LL<<i) << endl;
            if (cnt0 <= cnt1 && ((1LL<<i) & K) > 0) {
                less = true;
            }
            if (cnt0 > cnt1 && ((1LL<<i) & K) > 0) {
                x += (1LL<<i);
            }
        }
    }
  // dump(x);
    Int res = 0;
    for (Int i = 0; i < N; i++) {
        res += (A[i] ^ x);
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,i,ans = 0;scanf("%lld",&n);
  ll a[n];
  for(i=0;i<n;i++) scanf("%lld",&a[i]);
  sort(a,a+n,greater<ll>());
  for(i=1;i<n;i++) ans += a[i/2];
  printf("%lld\n",ans);
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

ll perm_to_num(vector<ll> p, ll N){
  ll res = 0;
  REP(i,N){
    res *= 10;
    res += p[i];
  }
  return res;
}

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

  ll N;
  cin >> N;
  ll p = 0;
  REP(i,N){ 
    ll pi;
    cin >> pi;
    p = p*10 + pi;
  }
  ll q = 0;
  REP(i,N){ 
    ll qi;
    cin >> qi;
    q = q*10 + qi;
  }


  vector<ll> digs(N);
  REP(i,N){ digs[i] = i+1;}
  vector<ll> nums(0);
  do {
    nums.push_back(perm_to_num(digs, N));
  } while (next_permutation(digs.begin(), digs.end()));

  sort(nums.begin(), nums.end());

  ll ans = abs(distance(find(nums.begin(), nums.end(), p), find(nums.begin(), nums.end(), q)));
  cout << ans << "\n";
  return 0;
}


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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007

string s;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>s;
    ll x=8;
    while(x--) s.pop_back();
    cout<<s<<'\n';
}


Measured memory_bytes: 256
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	A := stdin.ReadInt()
	B := stdin.ReadInt()
	M := stdin.ReadInt()
	a := make([]int, A)
	b := make([]int, B)
	x := make([]int, M)
	y := make([]int, M)
	c := make([]int, M)
	for i := 0; i < A; i++ {
		a[i] = stdin.ReadInt()
	}
	for i := 0; i < B; i++ {
		b[i] = stdin.ReadInt()
	}
	for i := 0; i < M; i++ {
		x[i] = stdin.ReadInt() - 1
		y[i] = stdin.ReadInt() - 1
		c[i] = stdin.ReadInt()
	}

	ans := Min(a[0], a[1:]...) + Min(b[0], b[1:]...)
	for i := 0; i < M; i++ {
		ans = Min(ans, a[x[i]]+b[y[i]]-c[i])
	}
	stdout.Println(ans)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 7552
#include<iostream>
using namespace std;
string n;int A,k;
int g(int a,int b){A=6;while(b--)A*=(a-b)*9,A/=b+1;return A/6;}
int f(int i,int a){int A=n.size()-i;return A<a?0:a?n[i]=='0'?f(i+1,a):f(i+1,a-1)+(n[i]-'1')*g(A-1,a-1)+g(A-1,a):1;}
main(){cin>>n>>k;cout<<f(0,k);}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s.at(i) != t.at(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<ll>> xdp(h, vector<ll>(w + 1, 0)), ydp(w, vector<ll>(h + 1, 0));
    rep(i, h) {
        rep(ii, w) {
            if (s[i][ii] == '.') xdp[i][ii + 1] = xdp[i][ii] + 1;
            else xdp[i][ii + 1] = 0;
        }
        ll be = 0;
        rrep(ii, w) {
            if (xdp[i][ii + 1] == 0) {
                be = 0;
                continue;
            }
            if (be > xdp[i][ii + 1]) {
                xdp[i][ii + 1] = be;
            }
            else {
                be = xdp[i][ii + 1];
            }
        }
    }
    // rep(i, h) {
    //     rep(ii, w) {
    //         printf("%lld%s", xdp[i][ii + 1], (ii == (w - 1)) ? "\n" : " ");
    //     }
    // }
    rep(i, w) {
        rep(ii, h) {
            if (s[ii][i] == '.') ydp[i][ii + 1] = ydp[i][ii] + 1;
            else ydp[i][ii + 1] = 0;
        }
        ll be = 0;
        rrep(ii, h) {
            if (ydp[i][ii + 1] == 0) {
                be = 0;
                continue;
            }
            if (be > ydp[i][ii + 1]) {
                ydp[i][ii + 1] = be;
            }
            else {
                be = ydp[i][ii + 1];
            }
        }
    }
    // rep(i, w) {
    //     rep(ii, h) {
    //         printf("%lld%s", ydp[i][ii + 1], (ii == (h - 1)) ? "\n" : " ");
    //     }
    // }
    ll ans = 0;
    rep(i, h) {
        rep(ii, w) {
            ans = max(ans, xdp[i][ii + 1] + ydp[ii][i + 1] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67200
H, W, K = list(map(int, input().split()))

c = []

ans = 0

for i in range(H):
    C = list(input())
    c.append(C)

k = 0

for i in range(2**(H+W)):
    x = []
    y = []
    for j in range(H+W):
        if i >> j & 1:
            if j < W:
                x.append(j)
            else:
                y.append(j-W)
    k = 0
    for X in x:
        for Y in y:
            if c[Y][X] == '#':
                k += 1
    if k == K:
        ans +=1


print(ans)


Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    vector<int> hat(n, 0);

    ll ans = 1;
    rep(i, n){
        int num = a[i];
        if (num == 0){
            ans *= (3-hat[num]);
        } else {
            ans *= hat[num-1]-hat[num];
        }
        hat[num]++;
        //cout << num << " " << ans << endl;
        ans %= MOD;
    }
    cout << ans << endl;

}


Measured memory_bytes: 1144
N = gets.to_i
a = gets.split.map(&:to_i)
if a == [*1..N] then
  puts 0
  exit
end
s = 1
cnt = 0
a.each do |i|
  if s != i then
    cnt += 1
  else
    s += 1
  end
end
puts s == 1 ? -1 : cnt


Measured memory_bytes: 18564
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int H1,M1,H2,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int st,ed;
    st = H1*60+M1;
    ed = H2*60+M2-K;

    fin(ed-st);

    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
using ll = long long;

const int INF = 1001001001;

int main()
{
	ll h, a, ans(0);
	cin>>h>>a;
	while(h>0){
	    h-=a;
	    ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vecll p(a);
  for(auto&& e:p)cin>>e;
  boost::sort(p, greater<ll>());
  vecll q(b);
  for(auto&& e:q)cin>>e;
  boost::sort(q, greater<ll>());
  vecll r(c);
  for(auto&& e:r)cin>>e;
  boost::sort(r, greater<ll>());
  vecll pp(a+1), pq(b+1), pr(c+1);
  boost::partial_sum(p, begin(pp)+1);
  boost::partial_sum(q, begin(pq)+1);
  boost::partial_sum(r, begin(pr)+1);
  p.push_back(0);
  q.push_back(0);
  ll ans = pp[x] + pq[y];
  FOR(i,1,c+1) {
    if (i > x+y) break;
    ll sum = pr[i];
    ll lo = max(0l, i-y)-1;
    ll hi = min((ll)i, x);
    while (hi-lo > 1) {
      ll mid = (hi+lo)/2;
      if (x == mid) {
        hi = mid;
        continue;
      }
      ll diff = -p[x-mid-1] + q[y-i+mid];
      //cerr<<i<<" "<<mid<<" "<<diff<<endl;
      if (diff > 0) {
        lo = mid;
      } else {
        hi = mid;
      }
    }
    //cerr<<"T"<<i<<" "<<lo<<" "<<hi<<endl;
    if (lo >= max(0l, i-y)) {
      ans = max(ans, sum + pp[x-lo] + pq[y-i+lo]);
    }
    if (hi <= min((ll)i, x)) {
      ans = max(ans, sum + pp[x-hi] + pq[y-i+hi]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
char tr(char c){
  int a = c - 'A';
  int b = c - 'a';
  if(0 <= a && a < 26) return (char)(a + 'a');
  return c;
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s;

  while(1){
    cin >> s;
    if(s == "-") break;
    int m;
    cin >> m;
    REP(i,m){
      int k;
      cin >> k;
      s = s.substr(k,SZ(s)-k) + s.substr(0,k);
    }
    cout << s <<endl;
  }




  return 0;
}



Measured memory_bytes: 3232
mod = pow(10, 9) + 7

def main():
    N, K = map(int, input().split())
    table = [0]*(K+1)
    for k in range(K, 0, -1):
        m = K//k
        tmp = pow(m, N, mod)
        for l in range(2, m+1):
            tmp -= table[l*k]
            tmp %= mod
        table[k] = tmp

    ans = 0
    for i in range(len(table)):
        ans += (i * table[i])%mod
    ans %= mod
    #print(table)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11164
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    if(N == 25)cout << "Christmas\n";
    if(N == 24)cout << "Christmas Eve\n";
    if(N == 23)cout << "Christmas Eve Eve\n";
    if(N == 22)cout << "Christmas Eve Eve Eve\n";
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    int a, b, c, k; cin >> a >> b >> c >> k;

    //int k; cin >> k;
    /*
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */
    FOR(i, 0, k)
    {
        int b2 = b * pow(2, i);
        int c2 = c * pow(2, k-i);
        if(c2 > b2 && b2 > a)
        {
            result = 1;
            break;
        }
    }
    if(result)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    //cout << 2*pow(2, 0);

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 4032
# LDS最長減少部分列
# 解説放送
# dilworthの定理
# パスを通してどの2点間も移動できないような点集合の点の個数 = 最小パス被覆
# 移動できないような点は
# 右側（大きい値側）から見て以上になっているような数列

from bisect import bisect_right

inf = 10 ** 9 + 1

n = int(input())
a = [int(input()) for _ in range(n)]

t = [inf]
for x in reversed(a):
    if t[-1] <= x:
        t.append(x)
    else:
        insert_pos = bisect_right(t, x)
        t[insert_pos] = x

ret = len(t)

print(ret)


Measured memory_bytes: 7832
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int n;

	while (scanf("%d", &n), n != 0){
		int x[2], y[2], z[2], w[2];
		int xr, yr, zr, wr;

		for (int i = 0; i < n; i++){
			for (int j = 0; j < 2; j++){
				scanf("%d%d%d%d", &x[j], &y[j], &z[j], &w[j]);
			}	
			xr = x[0] * x[1] - y[0] * y[1] - z[0] * z[1] - w[0] * w[1];
			yr = x[0] * y[1] + y[0] * x[1] + z[0] * w[1] - w[0] * z[1];
			zr = x[0] * z[1] + z[0] * x[1] - y[0] * w[1] + w[0] * y[1];
			wr = x[0] * w[1] + w[0] * x[1] + y[0] * z[1] - z[0] * y[1];
			
			printf("%d %d %d %d\n", xr, yr, zr, wr);
		}
	}

	return (0);
}

Measured memory_bytes: 1188
n, k = map(int,input().split())
x = list(map(int,input().split()))

ret = 10**20

for i in range(n-k+1):
	left = x[i]
	right = x[i+k-1]
	ret = min(ret, min(abs(left), abs(right)) + right - left )

print(ret)


Measured memory_bytes: 62576
#include<stdio.h>

int main()
{
	int x, n, m;
	
	scanf("%d %d %d", &x, &n, &m);
	
	int sum1 = n - x;
	int sum2 = m - x;
	
	if(sum1 < 0){
		sum1 *= -1;
	}
	if(sum2 < 0){
		sum2 *= -1;
	}
	
	if(sum1 < sum2){
		printf("A\n");
	}else{
		printf("B\n");
	}

}

Measured memory_bytes: 1644
def maxSum(arr, n, k): 
   
    res = 0.0
    for i in range(k): 
        res += arr[i] 
  
    curr_sum = res 
    for i in range(k, n): 
      
        curr_sum += arr[i] - arr[i-k] 
        res = max(res, curr_sum) 
  
    return res 
  
n,k = map(int,input().split())
a = list(map(int,input().split()))
ep = []
for i in range(n):
    p = a[i]
    ep.append((1/p)*((p*(p+1))//2))
print ("{0:.15f}".format(maxSum(ep,n,k))) 



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

int main(){
  int m,n;
  int mx=0;
  cin >> m >> n;
  for( int i=0;i<m;i++ ){
    int s=0, a;
    for( int j=0;j<n;j++ ){
      cin >> a;
      s += a;
    }
    mx = max(mx, s);
  }
  cout << mx << endl;

  return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] inputs = Console.ReadLine().Split();
        int otherCount = 0;
        int fiveCount = 0;
        int sevenCount = 0;

        foreach(var input in inputs){
            if(input == "5") fiveCount++;
            else if(input == "7") sevenCount++;
            else otherCount++;
        }
        
        if(otherCount == 0 && fiveCount == 2 && sevenCount == 1)  Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

Measured memory_bytes: 11092
#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()




int main(){
    int a,b; cin>>a>>b;
    a=b-a;
    a=(a+1)*a/2;
    cout<<a-b<<endl;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#define N 1000
int main(){
	int a,b,c,t;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
	if(a<=b){
		t=a;a=b;b=t;
	}
	if(a<=c){
		t=a;a=c;c=t;
	}
	if(b<=c){
		t=b;b=c;c=t;
	}		
	printf("%d\n",a-c);		
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] alpha = scanner.next().toCharArray();
			System.out.println(((alpha[0] >= 'A') && (alpha[0] <= 'Z')) ? "A" : "a");
		}
	}
}


Measured memory_bytes: 35592
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[20];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (
            (min(p[i - 1], p[i + 1]) < p[i]) && (p[i] < max(p[i - 1], p[i + 1])))
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

set<string>st;
string s="AKIHABARA";
main(){
  for(int i=1;i<(1<<9);i++){
    string res;
    for(int j=0;j<9;j++){
      if((1<<j)&i){
        //if(s[j]!='A')goto L;
        res+=s[j];
      }
      else{
      if(s[j]!='A')goto L;
    }
    }
    st.insert(res);
    L:;
  }
  string t;
  cin>>t;
  if(st.count(t))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
A,B,K = list(map(int,input().split(" ")))
if K <= A:
    A = A - K
    print(str(A) + " " + str(B))
else:
    K -= A
    A = 0
    if B >= K:
        B -= K
        print(str(A) + " " + str(B))
        exit()
    if B < K:
        print("0 0")

Measured memory_bytes: 3060
list_1 = []
list_2 = []
list_3 = []

for i in range(5):
    list_1.append(input())

for i in range(5):
    list_2.append(int(list_1[i]) % 10)

for i in range(5):
    if list_2[i] != 0:
        list_3.append(-(list_2[i] - 10))
    else:
        list_3.append(0)

max_num = 0
max_num_2 = 0
for i in range(5):
    if list_3[i] > max_num:
        max_num = list_3[i]
        max_num_2 = i

a1 = int(list_1.pop(max_num_2))
a2 = int(list_3.pop(max_num_2))

ans = 0

for i in range(4):
    ans += int(list_1[i])
    ans += list_3[i]

ans += a1

print(ans)


Measured memory_bytes: 3064
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var a = Console.ReadLine().Trim();
            if (a == ".") break;
            var count = 0;
            for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                    for (int k = 0; k < 3; k++)
                    {
                        var b = a.Replace('P', i.ToString()[0]);
                        var c = b.Replace('Q', j.ToString()[0]);
                        var d = c.Replace('R', k.ToString()[0]);
                        var ans = getAns(d);
                        if (ans == 2) count++;
                    }
            Console.WriteLine(count);
        }
    }
    static int getAns(string s)
    {
        var k = s.Length - s.Replace("(", "").Length;
        if (k == 0) return calc(s);
        var kp0 = -1; var kp1 = -1;
        var p = 0;
        while (true)
        {
            if (s[p] == '(') kp0 = p;
            if (s[p] == ')')
            {
                kp1 = p;
                var s2 = s.Substring(kp0 + 1, kp1 - kp0 - 1);
                var s3 = s.Substring(0, kp0) + calc(s2).ToString() + s.Substring(kp1 + 1);
                return getAns(s3);
            }
            p++;
        }
    }

    static int calc(string s)
    {
        if (s.IndexOf('+') < 0 && s.IndexOf('*') < 0) return minuss(s);
        else
        {
            string[] line = s.Split('+', '*');
            var w0 = minuss(line[0]);
            var w1 = minuss(line[1]);
            return s.IndexOf('+') >= 1 ? plus(w0, w1) : multi(w0, w1);
        }
    }
    static int minuss(string s)
    {
        var sL = s.Length;
        var ans = s[sL - 1] - '0';
        var p = 0;
        while (p++ < sL - 1)
            ans = 2 - ans;
        return ans;
    }
    static int plus(int a, int b) => a >= b ? a : b;
    static int multi(int a, int b) => a <= b ? a : b;
}



Measured memory_bytes: 17936
#include<bits/stdc++.h>
using namespace std;
int n,a[100],num,b[100];
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++) b[i]=a[i];
	sort(a,a+n);
	for (int i=0;i<n;i++) if (a[i]!=b[i]) num++;
	if (num>2)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
 *	Argorithms and Data Structures
 *	Lectuire 1
 *	Greatest Common Divisor
 */

#include <stdio.h>

#define Swap_int(a,b) { int temp = a; a = b; b = temp; }


int main(void){
	int x, y, d;

	scanf("%d %d", &x, &y);
	if( x < y) Swap_int(x,y);

	while( y > 0){
		d = x % y;
		x = y;
		y = d;
	}
	printf("%d\n", x);
	
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int n;
int a[1000000];
int cnt=0;

int main(){
  scanf("%d",&n);
  REP(i,n){
    scanf("%d",&a[i]);
  }
  REP(i,n){
    if(a[i]==i+1){
      cnt++;
      if(i<n){
        swap(a[i],a[i+1]);
      }
    }
  }
  printf("%d\n",cnt );
}


Measured memory_bytes: 512
import bisect

N = int(input())
Xs = list(map(int, input().split()))

Ss = sorted(Xs)

for i in range(N):
  j = bisect.bisect_left(Ss, Xs[i])
  if j < N//2:
    print(Ss[N//2])
  else:
    print(Ss[N//2-1])

Measured memory_bytes: 95700
package main

import "fmt"

func main(){
	var N, M int
	fmt.Scan(&N)
	T := make([]int, N+1)
	for i := 1 ; i <= N ; i++ {
		fmt.Scan(&T[i])
	}

	fmt.Scan(&M)
	X := make([]int, M)
	P := make([]int, M)
	for i := 0 ; i < M ; i++ {
		fmt.Scan(&P[i], &X[i])
	}

	ans := 0
	for i := 0 ; i < M ; i++ {
		ans = 0
		for j := 1 ; j <= N ; j++ {
			if j == P[i]{
				ans += X[i]
			}else {
				ans += T[j]
			}
			//fmt.Printf("%d ", ans)
		}
		fmt.Println(ans)
	}
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
  int s[13],h[13],c[13],d[13],i,r,x;
  char type;
  for(i=0; i<13; i++)
    {
      s[i]=h[i]=c[i]=d[i]=0;
    }
  scanf("%d",&r);
  for(i=0; i<r*2; i++)
    {
      scanf("%c %d",&type,&x);
      if(type=='S') s[x-1]=1;
      if(type=='H') h[x-1]=1;
      if(type=='C') c[x-1]=1;
      if(type=='D') d[x-1]=1;

    }
  for(i=0; i<13; i++)
    {
      if(s[i]==0) printf("S %d\n",i+1);
    }
  for(i=0; i<13; i++)
    {
      if(h[i]==0) printf("H %d\n",i+1);
    }
  for(i=0; i<13; i++)
    {
      if(c[i]==0) printf("C %d\n",i+1);
    }
  for(i=0; i<13; i++)
    {
      if(d[i]==0) printf("D %d\n",i+1);
    }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
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 a,b;
  cin >> a >> b;
  cout << 6-a-b << endl;
}


Measured memory_bytes: 256
program prob5
    implicit none
    character(len=200000) :: S
    integer(8) :: ans, cnt, i
    read(*,*) S

    cnt = 0
    ans = 0
    do i = 1, len_trim(S)
        if(S(i:i) == 'W') then
            ans = ans + cnt
        else
            cnt = cnt + 1
        end if
    end do

    write(*,*) ans

    stop
contains
end program prob5

Measured memory_bytes: 1084
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
h=0
ans=0
for i in range(n):
    if h<=a[i]:
        h=a[i]
    else:
        ans+=h-a[i]
print(ans)

Measured memory_bytes: 97064
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int height, width;
  (void)scanf("%d", &height);
  (void)scanf("%d", &width);
  char input[width + 1];

  for (int i = 0; i < width + 2; i++) putchar('#');
  putchar('\n');

  for (int i = 0; i < height; i++) {
    putchar('#');
    scanf("%s", input);
    printf("%s", input);
    putchar('#');
    putchar('\n');
  }

  for (int i = 0; i < width + 2; i++) putchar('#');
  return 0;
}


Measured memory_bytes: 128
def main():
    N = int(input())

    a = []
    for _ in range(N):
        a.append(list(map(int, input().split())))

    n = []
    c1 = 0
    for _ in range(3):
        hoge = []
        for x in range(N):
            hoge.append(a[x][c1])
        c1 += 1
        n.append(hoge)

    b = [0] * N
    for x in range(3):
        for y in range(N):
            c2 = 0
            for z in range(N):
                if n[x][y] == n[x][z]:
                    c2 += 1
                else:
                    pass
            if c2 == 1:
                b[y] += n[x][y]

    for x in range(N):
        print(b[x])


if __name__ == "__main__":
    main()

Measured memory_bytes: 7820
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s;
bool fl=1;
int main()
{
	cin >>s;
	for (int i=0;i<3;i++) if (s[i]==s[i+1]) fl=0;
	cout <<(fl ? "Good" : "Bad");
	return 0;
}

Measured memory_bytes: 256
def ABC120_D():
    class UnionFind():
        def __init__(self, n):
            self.parent = [-1 for _ in range(n)]
            # 正==子: 根の頂点番号 / 負==根: 連結頂点数

        def find(self, x):
            # 要素xが属するグループの根を返す
            if self.parent[x] < 0:
                return x
            else:
                self.parent[x] = self.find(self.parent[x])
                return self.parent[x]

        def unite(self, x, y):
            # 要素xが属するグループと要素yが属するグループとを併合する
            x, y = self.find(x), self.find(y)
            if x == y:
                return False
            else:
                if self.size(x) < self.size(y):
                    x, y = y, x
                self.parent[x] += self.parent[y]
                self.parent[y] = x

        def same(self, x, y):
            # 要素x, yが同じグループに属するかどうかを返す
            return self.find(x) == self.find(y)

        def size(self, x):
            # 要素xが属するグループのサイズ（要素数）を返す
            x = self.find(x)
            return -self.parent[x]

        def is_root(self, x):
            # 要素の根をリストで返す
            return self.parent[x] < 0

        def roots(self):
            # すべての根の要素をリストで返す
            return [i for i, x in enumerate(self.parent) if x < 0]

        def members(self, x):
            # 要素xが属するグループに属する要素をリストで返す
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def group_count(self):
            # グループの数を返す
            return len(self.roots())

        def all_group_members(self):
            # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
            return {r: self.members(r) for r in self.roots()}
    N, M = LI()
    P = [[]for _ in range(M)]
    for i in range(M):
        P[i] = LI()
    uf = UnionFind(N)
    ans = [N*(N-1)//2]*M
    for i,[a,b] in enumerate(P[M-1:0:-1]):
        #print(i,a,b)
        a -= 1; b -= 1
        if uf.same(a,b):
            ans[i+1] = ans[i]
        else:
            cur = uf.size(a)*uf.size(b)
            ans[i+1] = ans[i]-cur
            uf.unite(a,b)
    for v in ans[::-1]:
        print(v)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque

def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    ABC120_D()
"""

"""


Measured memory_bytes: 36316
A = [list(map(int, input().split())) for i in range(3)]

n = 0

for i in range(2):
    s = A[0][i+1] - A[0][i]
    for j in range(1,3):
        if A[j][i+1] - A[j][i] != s :
            n = 1
for i in range(2):
    s = A[i+1][0] - A[i][0]
    for j in range(1,3):
        if A[i+1][j] - A[i][j] != s :
            n = 1

if n == 0 :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3064
N = int(input())
choices = []
for i in range(N):
  choices.append(list(map(int, input().split())))
dp = [[0, 0, 0] for _ in range(N+1)]
for i, choice in enumerate(choices):
  if i==0:
    dp[0]=choice
    continue
  else:
    for j in range(3):
      dp[i][j] = max(dp[i-1][j-1]+choice[j], dp[i-1][j-2]+choice[j])
print(max(dp[N-1]))

Measured memory_bytes: 47344
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1e9 + 7;

int main() {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<int> l(N);
    REP(i, N)cin >> l[i];

    int ans = 105000000;
    REP(i, 1 << N * 2) {
        int mp = 0;
        int l1 = 0, l2 = 0, l3 = 0;
        for (int j = 0; j < N * 2; j += 2) {
            int k = i >> j & 3;
            int idx = N - j / 2 - 1;
            if (k == 0) {
                if (l1 != 0)
                    mp += 10;
                l1 += l[idx];
            }
            else if (k == 1) {
                if (l2 != 0)
                    mp += 10;
                l2 += l[idx];
            }
            else if (k == 2) {
                if (l3 != 0)
                    mp += 10;
                l3 += l[idx];
            }
        }
        if (l1 == 0 || l2 == 0 || l3 == 0)continue;
        mp += abs(A - l1) + abs(B - l2) + abs(C - l3);
        ans = min(ans, mp);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - LIS on Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;

/* global variables */

int as[MAX_N], bs[MAX_N];
vi nbrs[MAX_N];
int ps[MAX_N], cis[MAX_N];
int dp[MAX_N], ids[MAX_N], lis[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    nbrs[u].push_back(v);
    nbrs[v].push_back(u);
  }

  ps[0] = -1;
  fill(dp, dp + n, INF);
  
  for (int u = 0; u >= 0;) {
    vi &nbru = nbrs[u];
    int &ciu = cis[u], up = ps[u];

    if (ciu == 0) {
      ids[u] = lower_bound(dp, dp + n, as[u]) - dp;
      bs[u] = dp[ids[u]];
      dp[ids[u]] = as[u];
      lis[u] = (up >= 0) ? max(lis[up], ids[u]) : ids[u];
    }

    if (ciu < nbru.size() && nbru[ciu] == up) ciu++;
    if (ciu < nbru.size()) {
      ps[nbru[ciu]] = u;
      u = nbru[ciu++];
    }
    else {
      dp[ids[u]] = bs[u];
      u = up;
    }
  }

  for (int u = 0; u < n; u++) printf("%d\n", lis[u] + 1);
  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;

  for (int i = 0; i < w + 2; i++)cout << '#';
  cout << endl;

  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    cout << '#' << s << '#' << endl;
  }

  for (int i = 0; i < w + 2; i++) cout << '#';
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mp make_pair
#define endl "\n"
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define MOD 1000000007  //1e9+7

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void solve()
{
	int a,b,k,temp;
	cin>>a>>b>>k;
	temp=a;
	a-=k;
	if(a<0) a=0;
	k-=temp;
	if(k>0)
		b-=k;
	if(b<0) b=0;
	cout<<a<<" "<<b<<endl;
}
	
int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin>>t;
    //while(t--)
    solve();
    return 0;
}

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


def main():
    T1, T2 = [int(x) for x in input().split()]
    A1, A2 = [int(x) for x in input().split()]
    B1, B2 = [int(x) for x in input().split()]

    if (T1 * A1 + T2 * A2) == (T1 * B1 + T2 * B2):
        print("infinity")
        return


    x = (T1 * A1 + T2 * A2) - (T1 * B1 + T2 * B2)
    y = (T1 * A1) - (T1 * B1)
    if (y > 0 and x > 0) or (y < 0 and x < 0):
        print("0")
        return
    x = abs(x)
    y = abs(y)
    count = (y // x) * 2
    if y % x != 0:
        count += 1
    print(count)






if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=100005;
int a[MAX_N],b[MAX_N];
int n,H;
int main()
{
	cin>>n>>H;
	rep(i,0,n)cin>>a[i]>>b[i];
	sort(b,b+n);
	reverse(b,b+n);
	sort(a,a+n);
	reverse(a,a+n);
	int cnt=0;
	rep(i,0,n)
	{
		if(b[i]>a[0] && H>0)
		{
			H-=b[i];
			cnt++;
		}
	}
	cout<<(LL)(ceil(1.0*H/a[0])>0?ceil(1.0*H/a[0]):0)+cnt<<endl;
	return 0;
}



Measured memory_bytes: 1024
def main():
    N, M = map(int, input().split())
    U = [set() for _ in range(N)]
    for _ in range(M):
        u, v = map(int, input().split())
        U[u - 1].add(v - 1)
    S, T = map(int, input().split())
    S, T = S - 1, T - 1
    V = [False] * N
    V[S] = True
    cur = set([S])
    r = 0
    while cur and T not in cur:
        r += 1
        for _ in range(3):
            nxt = set()
            for c in cur:
                nxt |= U[c]
            cur = nxt
        nxt = set()
        for c in cur:
            if not V[c]:
                V[c] = True
                nxt.add(c)
        cur = nxt
    return r if T in cur else -1

print(main())


Measured memory_bytes: 73324
MOD=1000000007
N,M=map(int,input().split())
a=[]
dp=[0]*100010
for i in range(M):
    tmp=int(input())
    a.append(tmp)
    dp[tmp]=-1
dp[0]=1
for i in range(1,N+1):
    if(dp[i]==-1):
        continue
    if(dp[i-1]!=-1):
        dp[i]=(dp[i]+dp[i-1])%MOD
    if(i>1):
        if(dp[i-2]!=-1):
            dp[i]=(dp[i]+dp[i-2])%MOD
print(dp[N])

Measured memory_bytes: 7848
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin>>x;
  int y = x/500;
  y*=1000;
  int z = x-(y/2);
  z/=5;
  z*=5;
  cout<<(y+z);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,m,a,i;
    scanf("%d%d",&n,&m);
    int dp[n+2],broken[n+1];
    for(i=0;i<n;i++){
        broken[i]=0;
        dp[i]=0;
    }
    for(i=0;i<m;i++){
        scanf("%d",&a);
        broken[a] = 1;
    }
    dp[n]=1;
    dp[n+1]=0;
    const long MOD=1000000007;
    for(i=n-1;i>=0;i--){
        if(broken[i]) continue;
        dp[i] = (dp[i+1]+dp[i+2])%MOD;
    }
    printf("%d",dp[0]);
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-
"""
Created on Thu May 30 18:10:37 2019

@author: またの
"""

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0

for i in range(N):
    if V[i]-C[i]>0:
        ans += V[i]-C[i]
print(ans)

Measured memory_bytes: 3064
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, m; readV(n, m);

  auto g = Graph!int(n);
  foreach (_; 0..m) {
    int a, b; readV(a, b); --a; --b;
    g.addEdgeB(a, b);
  }

  foreach (i; 0..n)
    writeln(g[i].length);
}

struct Graph(N = int)
{
  alias Node = N;
  Node n;
  Node[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Node[][](n); }
  void addEdge(Node u, Node v) { g[u] ~= v; }
  void addEdgeB(Node u, Node v) { g[u] ~= v; g[v] ~= u; }
}


Measured memory_bytes: 256