akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int n;
int a[20];
int q;
int m[200];

int main(void){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	cin >> q;
	for(int i = 0; i < q; i++) cin >> m[i];

	set<int> st;
	for(int i = 0; i < 1<<n; i++){
		int sum = 0;
		for(int j = 0; j < n; j++){
			if(i>>j & 1) sum += a[j];
		}
		st.insert(sum);
	}

	for(int i = 0; i < q; i++){
		cout << (st.count(m[i]) ? "yes" : "no") << endl;
	}

	return 0;
}


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

int main(){
    int n,cnt{},prev{};
	cin >> n;
	for(int i=0; i<n; i++){
		int h;
		cin >> h;
		if(prev<h) cnt += h-prev;
		prev = h;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import Data.List

solver::Int->Int->Int->Int
solver x y z = let c:b:a:[]=sort [x,y,z] in
               if mod  ((a-b)+(a-c)) 2 == 0 then div ((a-b)+(a-c)) 2 else div (((a-b)+(a-c))+3) 2

main::IO()
main=do
  abcc<-getLine
  let a:b:c:[]=map read (words abcc)
  print (solver a b c)


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

int main() {
	int n,w;
	cin >> n >> w;
	int we[n], val[n];
	for(int i = 0;i < n;i++)
	cin >> we[i] >> val[i];
	long long int dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	for(int i = n-1;i > -1;i--)
	for(int j = 0;j < w+1;j++)
	if(j - we[i] > -1)
	dp[i][j] = max(dp[i+1][j],val[i] + dp[i+1][j - we[i]]);
	else
	dp[i][j] = dp[i+1][j];
	cout << dp[0][w] << "\n";
	return 0;
}

Measured memory_bytes: 79104
/**
*    author:  yuya1234
*    created: 24.06.2020 11:12:30
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

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

    int N;
    int t[100001], x[100001], y[100001];
    bool flg = true;

    cin >> N;

    t[0] = x[0] = y[0] = 0;

    FOR(i, 1, N)
    {
        cin >> t[i] >> x[i] >> y[i];
        int time = t[i] - t[i - 1];
        int dx = abs(x[i] - x[i - 1]);
        int dy = abs(y[i] - y[i - 1]);

        if (time < dx + dy || (time - dx + dy) % 2 == 1)
        {
            flg = false;
            break;
        }
    }

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

    return 0;
}

Measured memory_bytes: 4632
#include<stdio.h>

int main(void){

    int a,b;

    scanf("%d %d",&a,&b);

    if(a<b){
       printf("a < b\n");
    }else if(a>b){
       printf("a > b\n");
    }else{
       printf("a == b\n");
    }

    return 0;

}

Measured memory_bytes: 1748
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
    int N,M;
    cin >> N >> M;
    int like;
    vector<int> K(N);
    vector<int> A(M);
    for(int i=0; i < M; i++){
      A[i] = 0;
    }

    for(int i=0; i < N; i++){
      cin >> K[i];
      for(int j=0; j < K[i]; j++){
        cin >> like;
        A[like-1] += 1;
      }
    }

    int count = 0;
    for(int i=0; i < M; i++){
      if(A[i] == N){
        count++;
      }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
N,W = list(map(int,input().split()))

w = []
v = []

for i in range(N):
    a,b = list(map(int,input().split()))
    w.append(a)
    v.append(b)

DP = [[float('inf')]*(100001) for i in range(N+1)]

DP[0][0] = 0

for i in range(N):
    for j in range(100001):
        DP[i+1][j] = DP[i][j]
        if j >= v[i]:
            DP[i+1][j] = min(w[i]+DP[i][j-v[i]],DP[i+1][j])

for i in range(100001):
    if DP[N][100000-i] <= W:
        break
print(100000-i)

Measured memory_bytes: 310936
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main(){
    
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> v[i];
    
    vector<ll> sum0(n + 1), sum1(n + 1); //sum0：時計回り , sum1：反時計回り
    
    sum0[0] = sum1[0] = 0;
    
    for(int i = 1; i <= n; i++){
        sum0[i] = sum0[i - 1] + v[i - 1];
        sum1[i] = sum1[i - 1] + v[n - i];
    }
    
    vector<ll> ma0(n + 1), ma1(n + 1);
    ma0[0] = ma1[0] = 0;
    
    for(int i = 1; i <= n; i++){
        ma0[i] = max(ma0[i - 1], sum0[i] - x[i - 1]);
        ma1[i] = max(ma1[i - 1], sum1[i] - (c - x[n - i]));
    }
    
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, sum0[i] - x[i - 1]);
        ans = max(ans, sum1[i] - (c - x[n - i]));
        ans = max(ans, sum0[i] - 2* x[i - 1] + ma1[n - i]);
        ans = max(ans, sum1[i] - 2* (c - x[n - i]) + ma0[n - i]);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc2(x,y);
	if(y==1)rpr(0);
	fu(i,1,100){
		if(x*i-i+1>=y)re pr(i),0;
	}
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/10/19.
//  Copyright © 2019 Hashizo. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {

	ll a,b;
	ll ans = 0;
	cin >> a >> b;

	
	
	ans = a-(b*2);
	if (ans <= 0){
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer :: n, m, i, j, a, ans
integer,allocatable :: x(:), dx(:),dx1(:),bar(:)

read(*,*) n, m
allocate(x(m))
allocate(dx(m-1))
allocate(dx1(m-1))
allocate(bar(n-1))
read(*,*) (x(i), i=1,m)

if(n >= m) then
	ans = 0
	write(*,'(i0)') ans
    stop
end if

call qs(x,m) !昇順に並び替え

if(n == 1) then
	ans = x(m) - x(1)
    write(*,'(i0)') ans
    stop
end if

do i =1, m-1
	dx(i) = x(i+1) - x(i)
end do

call qs(dx,m-1)

ans = sum(dx)

do i = m-1, m-n+1, -1
	ans = ans - dx(i)
end do

write(*,'(i0)') ans

END PROGRAM ATCODER


recursive subroutine qs(x,n)
   integer,intent(in) :: n
   integer,intent(inout) :: x(n)
   integer :: p,i,imin,imax,it,is
   if(n == 1) return    
   p = x(1)   
   imin = 1   
   imax = n   
   do while(imin < imax)
      do while(x(imin) < p .and. imin < imax)
         imin = imin + 1
      enddo
      do while(p <= x(imax) .and. imin < imax)
         imax = imax - 1
      enddo
      if(imin < imax)then
         it = x(imax)
         x(imax) = x(imin)
         x(imin) = it
      endif
   enddo
   is = imax - 1
   if(is == 0) is = 1
   call qs(x(1:is),is)
   call qs(x(is + 1:n),n - is)
end subroutine qs

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

int main() {
  int n;
  string s;
  string t;
  string u;
  int a;
  int b;

  cin >> s >> t >> a >> b >> u;

  if (s == u) { --a; } 
  else if (t == u) { --b ;} 

  cout << a << " " << b << endl;

}

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n;
int a[N];
int ans;

int main()
{
    read(n);
    Rep(i,1,n)read(a[i]);
    Rep(i,1,n)
        if((a[i]&1)&&(i&1))ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static _T tp_gcd(_T first, _T second)
{
	_T num1 = first, num2 = second;
	_T remainder = 0, common = 0;

	if (!num1) return num2;
	if (!num2) return num1;

	while (!common) {
		remainder = num1 % num2;

		if (remainder == 0) {
			common = num2;
		}
		else {
			num1 = num2;
			num2 = remainder;
		}
	}
	return(common);
}
template <class _T> static _T tp_lcm(_T first, _T second) {
	_T gcd = tp_gcd<_T>(first, second);

	return first * second / gcd;

#if 0
	_T num1 = first;
	_T num2 = second;

	if ((!num1) || (!num2)) return 0;
	while (num1 != num2) {
		if (num1 < num2) {
			num1 += first;
		}
		else if (num1 > num2) {
			num2 += second;
		}
	}
	return num1;
#endif
}
static void C_task();

int main()
{
	C_task();

	fflush(stdout);
	return 0;
}

static void C_task()
{
	LLONG A, B, C, D;
	get3int<LLONG>(A, B, C); get1int<LLONG>(D);

	LLONG lcm = tp_lcm<LLONG>(C, D);

	LLONG cCount = (B / C) - (A / C) + ((A % C) == 0 ? 1 : 0);
	LLONG dCount = (B / D) - (A / D) + ((A % D) == 0 ? 1 : 0);
	LLONG cdCount = (B / lcm) - (A / lcm) + ((A % lcm) == 0 ? 1 : 0);

	printf("%lld\n", (B - A + 1) - (cCount + dCount - cdCount));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (long long)(1e16)
using namespace std;

struct edge {
  long long to, dis;
};
struct p {
  long long p, c;
};
bool operator<(const p &l, const p &r) {
  if(l.c != r.c) return l.c > r.c;
  return l.p < r.p;
}

long long n, m, l, q;
long long dist[500][500] = {0};
vector<edge> edges[305];
vector<vector<long long>> memo;

void solve();
void ch(int s);

int main() {
  cin >> n >> m >> l;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      if(i != j) dist[i][j] = inf;
  for(int i = 0; i < m; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    if(c > l) continue;
    dist[a][b] = dist[b][a] = min(c, dist[a][b]);
  }
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        dist[i][j] =
            min(dist[i][j], dist[i][k] + dist[k][j]);
  solve();
  cin >> q;
  for(int i = 0; i < q; ++i) {
    long long s, t;
    cin >> s >> t;
    cout << memo[--s][--t] << endl;
  }
  return 0;
}

void solve() {
  memo.assign(n, vector<long long>(n, inf));
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) {
      if(dist[i][j] <= l) edges[i].push_back({j, 1});
    }
  for(int i = 0; i < n; ++i) ch(i);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      if(memo[i][j] == inf) memo[i][j] = -1;
}

void ch(int s) {
  priority_queue<p> pq;
  for(int i = 0; i < n; ++i)
    if(dist[s][i] <= l) {
      memo[s][i] = 0;
      pq.push({i, 0});
    }
  while(!pq.empty()) {
    p now = pq.top();
    pq.pop();
    if(memo[s][now.p] != now.c) continue;
    ++now.c;
    for(int i = 0; i < edges[now.p].size(); ++i) {
      p nextp = now;
      nextp.p = edges[now.p][i].to;
      if(memo[s][nextp.p] > nextp.c) {
        memo[s][nextp.p] = nextp.c;
        pq.push(nextp);
      }
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll N;
    cin >> N;
    vector<string> names(N);
    cin >> names;
    unordered_map<char, ll> hashMap;
    for (auto& s : names) {
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
            hashMap[s[0]]++;
        }
    }
    if (hashMap.size() < 3) {
        cout << 0 << endl;
        return 0;
    }
    vector<pair<char, ll>> nums;
    for (auto& it : hashMap) {
        nums.push_back(it);
    }
    ll ans = 0;
    for (int i = 0; i < nums.size() - 2; ++i) {
        for (int j = i + 1; j < nums.size() - 1; ++j) {
            for (int k = j + 1; k < nums.size(); ++k) {
                ans += nums[i].second * nums[j].second * nums[k].second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  long long N, Y, o, f, t, r;

  cin>>N>>Y;
  o=Y/1000;
  r=o-N;
  t=r;
  f=-2*r;
  while(t>=0){
    if(f>=0){
      o=o-10*t-5*f;
      if(o<0)break;
      cout<<t<<" "<<f<<" "<<o<<endl;
      return 0;
    }
    f+=9;
    t-=4;
  }
  cout<<"-1 -1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 256
S = int(input())
li = [1,2,3,4,5,6,7,8,9]
count = 0
for i in range(9):
    if S//(li[i]) <= 9 and S % li[i] == 0:
        print("Yes")
        count += 1
        break
if count != 1:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int h, w, n;
	scanf("%d",&h);
	scanf("%d",&w);
	scanf("%d",&n);
	if (h < w) {
		h = w;
	}
	int ans = (n / h);
	if (n % h != 0) {
		ans++;
	}
	printf("%d", ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    scanf( "%d\n", &n );
    while( n > 0 )
    {
        double x, y, b, p, ret;
        scanf( "%lf %lf %lf %lf\n", &x, &y, &b, &p );
        ret = x * b + y * p;
        if( 5 <= b && 2 <= p )
        {
            printf( "%.0lf\n", 80 * ret / 100 );
        } 
        else if( 5 <= b && p < 2)
        {
            double comp1 = (b * x + 2.0 * y) * 80 / 100; 
            printf( "%.0lf\n", min( comp1, ret ) );
        }
        else if( 2 <= p && b < 5)
        {
            double comp2 = (5.0 * x + p * y) * 80 / 100; 
            printf( "%.0lf\n", min( comp2, ret ) );
        }
        else
        {
            double comp3 = (5.0 * x + 2.0 * y) * 80 / 100; 
            printf( "%.0lf\n", min( comp3, ret ) );
        }
        n--;
    }
    return 0;
}


Measured memory_bytes: 2732
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        self.mod=mod
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return self.f[n]*self.i[n-k]%self.mod*self.i[k]%self.mod if n>=k else 0
M=10**9+7
n,k,*a=map(int,open(0).read().split())
comb=Factorial(n,M).comb
s=0
for i,a in enumerate(sorted(a)):
    s+=a*comb(i,k-1)-a*comb(~i+n,k-1)
    s%=M
print(s)

Measured memory_bytes: 70636
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
C = read().rstrip().decode()

l, r = 0, N - 1
cost = 0
while l < r:
    # [l,r] がまだ
    if C[l] == 'R':
        l += 1
    elif C[r] == 'W':
        r -= 1
    else:
        # R...W
        cost += 1
        l += 1
        r -= 1

print(cost)

Measured memory_bytes: 9372
#include <bits/stdc++.h>
#define int long long
using namespace std;

constexpr int MOD = 1e9 + 7;

// MODint
template <typename T, T Modulus> struct Mint {
  T v;
  Mint() : v(0) {}
  Mint(long long t) {
    v = t % Modulus;
    if (v < 0)
      v += Modulus;
  }

  Mint pow(long long k) {
    Mint res(1), tmp(v);
    while (k) {
      if (k & 1)
        res *= tmp;
      tmp *= tmp;
      k >>= 1;
    }
    return res;
  }

  Mint inv() { return pow(Modulus - 2); }

  Mint &operator+=(Mint a) {
    v += a.v;
    if (v >= Modulus)
      v -= Modulus;
    return *this;
  }
  Mint &operator-=(Mint a) {
    v += Modulus - a.v;
    if (v >= Modulus)
      v -= Modulus;
    return *this;
  }
  Mint &operator*=(Mint a) {
    v = 1LL * v * a.v % Modulus;
    return *this;
  }
  Mint &operator/=(Mint a) { return (*this) *= a.inv(); }
  Mint operator+(Mint a) const { return Mint(v) += a; };
  Mint operator-(Mint a) const { return Mint(v) -= a; };
  Mint operator*(Mint a) const { return Mint(v) *= a; };
  Mint operator/(Mint a) const { return Mint(v) /= a; };
  Mint operator-() { return v ? Modulus - v : v; }
  bool operator==(const Mint a) const { return v == a.v; }
  bool operator!=(const Mint a) const { return v != a.v; }
  bool operator<(const Mint a) const { return v < a.v; }
};

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  Mint<int, MOD> ans(0);
  for (int i = 0; i < 60; i++) {
    int bit = (1LL << i);

    int cnt0 = 0, cnt1 = 0;
    for (int j = 0; j < N; j++) {
      if ((A[j] & bit)) {
        cnt1++;
      } else {
        cnt0++;
      }
    }

    Mint<int, MOD> a(bit);

    ans = ans + a * cnt1 * cnt0;
  }

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


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int solve( VI cards )
{
	const int N = cards.size();
	int cap = cards[0];

	int s = 1, t = 1, numSpace = cards[1] == 0, res = 0;

	while ( s < N )
	{
		while ( t + 1 < N && numSpace <= cap )
		{
			numSpace += cards[ ++t ] == 0;
		}

		res = max( res, t - s );
		numSpace -= cards[ s++ ] == 0;
	}

	return res;
}

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

	while ( true )
	{
		int n, k;
		cin >> n >> k;

		if ( !( n | k ) )
		{
			break;
		}

		VI cards( 100001 );
		REP( i, 0, k )
		{
			int tmp;
			cin >> tmp;
			cards[ tmp ] = 1;
		}
		cout << solve( cards ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1868
import bisect

n,*a = map(int, open(0).read().split())
if n == 2:
    print(*a)
else:
    a.sort()
    f = a[-1]
    h = f / 2
    bs = bisect.bisect_left(a,h)
    if abs(a[bs-1]-h) >= abs(a[bs]-h):
        s = a[bs]
    else:
        s = a[bs-1]
    print(f,s)

Measured memory_bytes: 14028
#include <stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d" , &W,&H,&x,&y,&r);
    if(!(y+r <= H && 0 <= y-r && x+r <= W && 0 <= x-r)){
       printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 2680
import java.util.*;

public class Main {
  static int count = 0;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[][] edge = new int[N][N];
    for(int i = 0; i < M; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      edge[a - 1][b - 1] = 1;
      edge[b - 1][a - 1] = 1;
    }
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(0);
    dfs(N, edge, 1, list);
    System.out.println(count);
  }

  public static void dfs(int n, int[][] edge, int mask, ArrayList<Integer> list) {
    if(list.size() == n) {
      boolean flg = true;
      for(int i = 0; i < n - 1; i++) {
        if(edge[list.get(i)][list.get(i + 1)] == 0) {
          flg = false;
          break;
        }
      }
      if(flg) count++;
    } else {
      for(int j = 0; j < n; j++) {
        if((mask & (1 << j)) == 0) {
          ArrayList<Integer> list2 = (ArrayList<Integer>)list.clone();
          list2.add(j);
          dfs(n, edge, mask + (1 << j), list2);
        }
      }
    }
  }
}

Measured memory_bytes: 25096
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

vector<int> g[100'009];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (m - x >= 0) {
      g[m - x].push_back(y);
    }
  }
  multiset<int> s;
  for (int i = 0; i < m; ++i) {
    for (int e : g[i]) {
      s.insert(e);
      if ((int)s.size() > i + 1) {
        s.erase(s.begin());
      }
    }
  }
  int ans = 0;
  for (int e : s) {
    ans += e;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 10112
// https://beta.atcoder.jp/contests/abc066

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    auto ans = min<int>({a + b, b + c, c + a});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int n, k;
int a[200010];

bool check(int len, int cutCount) {
	int curCut = 0;
	for (int i = 0 ; i < n ; i++) {
		if (a[i] <= len)
			continue;
			
		int left = a[i];
		int thisCut = a[i] / len;
		if ((a[i] % len) == 0)
			thisCut--;
			
		curCut = curCut + thisCut;
		if (curCut > cutCount)
			return false;
	}
	
	return true;
}


int main()
{
	scanf("%d%d", &n, &k);
	
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(a[i]));
	}
	
	int head = 1;
	int tail = 1000000000;
	int result = -1;
	int mid;
	
	while (head <= tail)
	{
		mid = (head + tail) / 2;
//		printf("%d\n", mid);
		if (check(mid, k))
		{
			tail  = mid - 1;
			result = mid;
		}
		else
		{
			head = mid + 1;
		}
	}
	
	printf("%d\n", result);
	
	return 0;
}



Measured memory_bytes: 2508
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
	int n; 
  	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++)
	cin >> arr[i];
 
	int count=0;
 
	for(int i = 0; i < n;) {
		int j = i;
		while(arr[j] == arr[i] && j < n) {
			j++;
		}
		count += (j - i) / 2;
		i = j;
	}
	cout<<count;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cmath>

int main(){

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		int h, m;
		scanf("%d:%d", &h, &m);

		long double ang ;
		ang = 6 * m - (30 * h + 30 * ((long double)m / 60));
		ang = std::abs(ang);
		if (ang > 180)ang = 360 - ang;

		if (0 <= ang && ang < 30)printf("alert\n");
		else if (90 <= ang && ang <= 180)printf("safe\n");
		else printf("warning\n");
	}

	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,ma,mb;cin>>n>>ma>>mb;
  int dp[n+10][440][440];
  for(int i=0;i<n+10;i++)
    for(int j=0;j<440;j++)
      for(int k=0;k<440;k++)
	dp[i][j][k]=INF;
  dp[0][0][0]=0;
  for(int i=1;i<=n;i++){
    int a,b,c;cin>>a>>b>>c;
    for(int j=0;j<410;j++){
      for(int k=0;k<410;k++){
	if(dp[i-1][j][k]!=INF){
	  dp[i][j+a][k+b]=min(dp[i][j+a][k+b],dp[i-1][j][k]+c);
	  // cout<<dp[i][j+a][k+b]<<endl;
	}
	dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
      }
    }
  }
  int ans=INF;
  int num=ma,num2=mb;
    while(1){
      if(num>=410||num2>=410)break;
      ans=min(dp[n][num][num2],ans);
      num+=ma;num2+=mb;
    }
  
  if(ans==INF)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int N, dp[100009];
vector < int > v[100009];

void dfs (int nod, int tata)
{
    for (auto it : v[nod])
        if (it != tata)
            dfs (it, nod), dp[nod] ^= (dp[it] + 1);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<N; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
dfs (1, -1);
if (dp[1]) printf ("Alice\n");
else printf ("Bob\n");
return 0;
}


Measured memory_bytes: 12416
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;

    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '2') cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
N,Y=map(int,input().split())
for x in range(N+1):
  for y in range(N+1-x):
    z=N-x-y
    if 10000*x+5000*y+1000*z == Y and 2000>=z>=0:
      print(x,y,z)
      exit()
      
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	int cnt[100001];
	FOR(x, 1, 101){
		FOR(y, 1, 101){
			FOR(z, 1, 101){
				cnt[x * x + y * y + z * z + x * y + y * z + x * z]++;
			}
		}
	}
	FOR(a, 1, N + 1)
		cout << cnt[a] << endl;
}

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

long long power(long long n,long i,long long m)
{
    if(i==0)
    {
        return 1;
    }
    
    else if(i%2==0)
    {
        return power(n*n,i/2 % m,m);
    }
    
    else
    {
        return n* power(n*n,i/2 % m,m);

    }
}
int main()
{
    long long n,sum=0;
    cin>>n;
    
    for(long long i=0;i<=log2(n);i++)
    {
        sum+=power(2,i,10000000000);
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 512
m,d=map(int,input().split())
if d<=21:print(0)
elif m<=3:print(0)
else:
  cnt=0
  for i in range(4,m+1):
    for j in range(22,d+1):
      if j%10<=1:continue
      if i==int(str(j)[0])*int(str(j)[1]):
        cnt+=1
  print(cnt)


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

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
  
  	int p,q,r; cin >> p >> q >> r;
  
    cout << min(p+q, min(q+r, r+p));
    
    return 0;
}


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

using namespace std;

vector<int> g[1000001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  string s;
  cin>>n>>s>>k;
  for(int i=0;i<n;i++) {
  	if(s[i]!=s[k-1]) s[i]='*';
  }
	cout<<s;
  return 0;
}

Measured memory_bytes: 23680
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int k = int.Parse(ReadLine());
         int ans = 0;
         for(int n = 1; n <= k; n++){
             for(int m = 1; m <= k; m++){
                 for(int l = 1; l <= k; l++){
                     ans += Gcd(n,m,l);
                 }
             }
         }
         WriteLine(ans);
      }

      public static int Gcd(int a, int b) 
      {
         if (a < b)
             // 引数を入替えて自分を呼び出す
             return Gcd(b, a);
         while (b != 0) {
             var remainder = a % b;
             a = b;
             b = remainder;
         }
         return a;
     }

     public static int Gcd(int a, int b, int c){
         return Gcd(Gcd(a, b), c);
     }
   }
}

Measured memory_bytes: 27528
N=input()
N_int=int(N)
order = len(N)
ans = 0
for i in range(1,int(N)+1):
    str_i = str(i)
    if i%10==0:
        continue
    if str_i[0]==str_i[-1]:
        ans += 1
    for j in range(1,order):
        num = int(str_i[-1])*10**j+int(str_i[0])
        if num <= N_int:
            ans += min(10**(len(str(num))-2),(N_int-num)//10+1)
print(ans)

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

long long mod = 1e9 + 7;

int main(){
    long long s;
    cin >> s;

    vector<long long> a(s+1, 0);

    a[0] = 1;

    for(long long i = 0; i <= s; i++){
        if(i - 3 >= 0) a[i] = a[i-3] + a[i-1];
        a[i] %=  mod;
    }

    cout << a[s] << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

#ifdef QLEG_DEBUG
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << '{'; string sep; for (const auto& x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

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

  int N; cin >> N;
  map<pii, ll> cnt;
  for (int i=0;i<N;i++) {
    long double x; cin>>x;
    ll n = llround(x * 1000000000.0);
    int two=-9, five=-9;
    while (n%2==0) n/=2, two++;
    while (n%5==0) n/=5, five++;
    ++cnt[{two,five}];
    dbg(two,five);
  }

  ll tot = 0;
  ll same = 0;
  for (auto [pr, c] : cnt) {
    dbg(pr,c);
    if (pr.fst>=0 && pr.snd>=0) {
      same += c;
    }
  }
  for (auto [pr1, c1] : cnt) {
    for (auto [pr2, c2] : cnt) {
      auto [x1, y1] = pr1;
      auto [x2, y2] = pr2;
      if (x1+x2>=0 && y1+y2>=0) {
        tot += c1*c2;
      }
    }
  }

  dbg(tot,same);
  cout << (tot-same)/2 << '\n';
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int a , b;
    cin >> a >> b;
    cout << (b%a ? b-a : a+b);
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 1e9 + 7;

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

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct query {
    int a, b, c, d;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<query> A(Q);
    rep(i, Q){
        cin >> A[i].a >> A[i].b >> A[i].c >> A[i].d;
        A[i].a--;
        A[i].b--;
    }
    
    vector<int> B(10);
    int ans = 0;
    rep(b0, 1, M + 1) rep(b1, b0, M + 1) rep(b2, b1, M + 1) rep(b3, b2, M + 1) rep(b4, b3, M + 1) rep(b5, b4, M + 1) rep(b6, b5, M + 1) rep(b7, b6, M + 1) rep(b8, b7, M + 1) rep(b9, b8, M + 1) {
        B[0] = b0; B[1] = b1; B[2] = b2; B[3] = b3; B[4] = b4; B[5] = b5; B[6] = b6; B[7] = b7; B[8] = b8; B[9] = b9;
        int tmp = 0;
        rep(i, Q) {
            if(B[A[i].b] - B[A[i].a] == A[i].c) tmp += A[i].d;
        }
        ans = max(ans, tmp);
    }
    output(ans);
    
    
    return 0;
}


Measured memory_bytes: 3600
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int SZ = 200000;
class UF {
public:
	int P[SZ + 1], saidai;
	UF() : P(), saidai() {
		saidai = -1;
		rep1(i, SZ) P[i] = -1;
	}
	int find(int A) {
		if (P[A] < 0) return A;
		return P[A] = find(P[A]);
	}
	bool unite(int A, int B) {
		int a = find(A);
		int b = find(B);
		if (a == b) return false;
		if (P[a] > P[b]) swap(a, b);
		P[a] += P[b];
		if (P[a] < saidai) saidai = P[a];
		P[b] = a;
		return true;
	}
} uf;

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

	int N = getint(), M = getint();

	rep(i, M) {
		uf.unite(getint(), getint());
	}

	printf("%d\n", -uf.saidai);


	Would you please return 0;
}

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"

void testCase() {
    int n, k;
    cin >> n >> k;
    ll arr[n+1];
    for (int i=0; i<n; i++)
        cin >> arr[i];
    ll dp[n+3];
    for (int i=0; i<=n; i++)
        dp[i] = inf;
    dp[n-1] = 0;
    for (int i=n-1; i>0; i--) {
        for (int j=1; j<=k; j++) {
            if (i-j>=0)
                dp[i-j] = min (dp[i-j], dp[i]+abs(arr[i]-arr[i-j]));
        }
    }
    cout << dp[0] << endl;
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String order = s.nextLine();
    int cost = 700;
    for(int i = 0; i < 3 ; i++)
      if(order.charAt(i) == 'o')cost += 100;
    System.out.printf("%d",cost);
  }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

vector<vector<ll>> com(51, vector<ll>(51, 0));

void combination()
{
    rep(i, com.size())
    {
        com[i][0] = 1;
    }
    for (int i = 1; i < com.size(); i++)
    {
        for (int j = 1; j < com.size(); j++)
        {
            com[i][j] = com[i - 1][j - 1] + com[i - 1][j];
        }
    }
}

int main()
{
    combination();
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(ALL(v), greater<ll>());

    double sumv = 0;
    rep(i, a) sumv += v[i];
    printf("%.10f\n", sumv / a);

    ll ans = 0;
    int m = count(ALL(v), v[a - 1]);

    if (v[0] == v[a - 1])
    {
        for (int i = a; i <= b; i++)
        {
            ans += com[m][i];
        }
    }
    else
    {
        int r = 0;

        rep(i, a)
        {
            if (v[a - 1] == v[i])
                r++;
        }
        ans = com[m][r];
    }
    OP(ans);

    return 0;
}

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

class B
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(Enumerable.Range(1, h[0]).Reverse().Where(i => h.Take(2).All(x => x % i == 0)).ElementAt(h[2] - 1));
	}
}


Measured memory_bytes: 13396
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 17:09:50
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

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;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

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

bool is_exponential(int n, int b) {
    if (n == 1) return true;
    else {
        if (n % b == 0) {
            return is_exponential(n/b, b);
        } else {
            return false;
        }
    }
}

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

    int ok = 0;
    for (; x > 0; x--) {
        for (int b = 2; b < x; b++) {
            if (is_exponential(x, b)) {
                ok = 1;
            }
        }

        if (ok) break;
    }

    if (x < 1) x = 1;
    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;

	int N, M, K;


	vector<int> X;
	cin >> N >> K;
	rep(i, 0, N) {
		int x;
		cin >> x;
		X.push_back(x);
	}
	ll ans = abs(X[0])*2 + abs(X[N - 1])*2;

	rep(i, 0, N-K+1) {
		ll a = min(abs(X[i]), abs(X[i + K-1]));
		ll b = max(abs(X[i]), abs(X[i + K-1]));
		if (X[i] < 0 && X[i + K - 1]>0) {
			ans = min(ans, a * 2 + b);
		}
		else {
			ans = min(ans,b);
		}

	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 892