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

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> h;
    h.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int ans = 0;
    sort(h.begin(), h.end());
    for (int i = 0; i < n; i++) {
        if (h[i] >= k) {
            ans = n - i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		long MOD=1000000007L;

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int d=sc.nextInt();
		int mat[][]=new int[n][d];
		long L[][]=new long[n][n];
		for(int i=0;i<n;++i){
			for(int j=0;j<d;++j){
				mat[i][j]=sc.nextInt();
			}
		}
		int count=0;
		for(int i=0;i<n-1;++i){
			for(int j=i+1;j<n;++j){
				double sum=0L;
				for(int k=0;k<d;++k){
					sum=sum+(mat[i][k]-mat[j][k])*(mat[i][k]-mat[j][k]);
				}
				if (Math.pow(sum, 0.5)%1==0)++count;
			}
		}


		System.out.println(count);
	}
}

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

int main(){
    ios::sync_with_stdio(false);
    int n, d; cin >> n >> d;
    int cnt = 0;
    long long D = d; D *= d;
    for (int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        long long X = x; X *= x;
        long long Y = y; Y *= y;
        if (X + Y <= D){
            cnt++;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

long long pow_mod(long long x, long long n, const long long mod) {
	long long ret = 1;
	while (0 < n) {
		if (n & 1) ret = ret * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return ret;
}

const long long MOD = 1000000007;
int H, W, A, B;
long long fact[200001], ifact[200001];

int main() {
	scanf("%d%d%d%d", &H, &W, &A, &B);

	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= H+W; ++i) {
		fact[i] = (fact[i-1] * i) % MOD;
		ifact[i] = pow_mod(fact[i], MOD-2, MOD);
	}

	long long res = 0;

	for (int i = 0; i < W-B; ++i) {
		int row, col, n, r;
		long long c1, c2;

		row = H-A, col = B+1+i;
		n = row + col - 2, r = row - 1;
		c1 = fact[n] * ifact[n-r] % MOD * ifact[r] % MOD;

		row = A, col = W-B-i;
		n = row + col - 2, r = row - 1;
		c2 = fact[n] * ifact[n-r] % MOD * ifact[r] % MOD;

		(res += c1 * c2 % MOD) %= MOD;
	}

	printf("%lld\n", res);

	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>

int main(){

	int n;
	while (std::cin >> n, n){

		long long res = 0;

		std::vector<int>v(n), p(n, 0);

		for (int i = 0; i < n; i++)std::cin >> v[i];

		std::sort(v.begin(), v.end());

		for (int i = 1; i < n; i++)p[i] = p[i - 1] + v[i - 1];

		for (int i = 0; i < p.size(); i++)res += p[i];

		std::cout << res << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)
#define REP(i, r) for(int i =(int)0; i < (int)r; ++i)

using namespace std;
typedef long long ll;
const int Nmax = 3e3 + 11;

int n;
double p[Nmax], f[Nmax][Nmax], ans;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        cin >> p[i];
    }
    f[1][1] = p[1];
    f[1][0] = 1.0 - p[1];
    if (n == 1) {
        printf("%0.9f", p[1]);
        return 0;
    }
    FOR(i, 2, n) FOR(j, 0, i) {
        f[i][j] = f[i - 1][j] * (1.0 - p[i]);
        if (j > 0) f[i][j] += f[i - 1][j - 1] * p[i];
        if (i == n && j > n / 2) {
            ans += f[i][j];
        }
    }
    printf("%0.10f", ans);
}


Measured memory_bytes: 69248
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b ;
    if(a%2==1&&b%2==0){
        cout <<( (a+b)/2 ) + 1 <<endl;
    }else if(b%2==1&&a%2==0){
        cout << ( (a+b)/2 ) + 1 <<endl;
    }else{
        cout << (a+b)/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, k, x = 0, i;
    scanf("%d %d %d", &k, &a, &b);
    for(i = a; i <= b; i++){
        if(i % k != 0){
            x++;
        }
        else if(i % k == 0){
            printf("OK");
            break;
        }
    }
    if(x == b - a + 1){
        printf("NG");
    }

    return 0;
}



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

typedef long long ll;

int main(void){
    int N;
    cin>>N;
    
    ll a,b,c;
    ll sum[N+1][3];
    sum[0][0]=sum[0][1]=sum[0][2]=0;
  
    for(int i=1;i<=N;i++){
        cin>>a>>b>>c;
        sum[i][0]=max(sum[i-1][1],sum[i-1][2])+a;
        sum[i][1]=max(sum[i-1][2],sum[i-1][0])+b;
        sum[i][2]=max(sum[i-1][0],sum[i-1][1])+c;
    }
    
    cout<<max({sum[N][0],sum[N][1],sum[N][2]});
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll k;
    cin >> k;
    ll even = k/2;
    ll odd = k-even;
    
    cout << even*odd << endl;
    
    return 0;
}



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

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

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 == 0) continue;
        int cnt = 1;
        for(int j = 1; j < i; j++){
            if(i % j == 0){
                cnt++;
            }
        }
        if(cnt == 8){
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    x = int(readline())
    dp = [0]*(10**6)
    dp[0] = 1
    for i in range(10**5+1):
        if dp[i]==1:
            dp[i+100] = 1
            dp[i+101] = 1
            dp[i+102] = 1
            dp[i+103] = 1
            dp[i+104] = 1
            dp[i+105] = 1
    print(dp[x])

if __name__ == "__main__":
    main()


Measured memory_bytes: 46576
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int ar[] = new int[n];
		
		for(int i = 0; i < n; i++)
			ar[i] = sc.nextInt();
		long total = 0;
		for(int i = 0; i < n; i++)
			total += ar[i];
		double condition = (1.0 / (4 * m)) * total;
		int count = 0;
		for(int i = 0; i < n; i++) {
			if((double)ar[i] >= condition)
				count++;
		}
		System.out.println((count >= m) ? "Yes" : "No");
	}

	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

}


Measured memory_bytes: 21332
#include<cstdio>
#include<algorithm>
int n,f[100005],x;
int solve(int x,int y){return std::max(x-y,y-x);}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&f[i]);
	std::sort(f+1,f+n+1);
	x=1;
	for (int i=1;i<=n;i++)
	    if (solve(f[i]*2,f[n])<solve(f[x]*2,f[n])) x=i;
	printf("%d %d\n",f[n],f[x]);
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i<n; i++)
#define ll long long
#define MOD 1000000007
using namespace std;;
 
int main() {
  int N,K,ans =0; cin >> N >> K;
  int l[N]; rep(i,0,N) cin >> l[i];
  
  sort(l,l+N);
  rep(i,0,K) ans += l[N-i-1];    
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
	char ca = *(char *) a;
	char cb = *(char *) b;

	return ca - cb;
}

int main() {
	static char s[5];

	scanf("%s", s);
	qsort(s, 4, sizeof *s, compare);
	printf(s[0] == s[1] && s[2] == s[3] && s[0] != s[2] ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn];
double ans;
vct e[maxn];
int dfs(int to,int from,int Plus)
{
    Plus+=a[to];
    b[to]=Plus;
    fa(i,e[to])
    {
        if(i==from)continue;
        dfs(i,to,Plus);
    }
}
int32_t main()
{
    IOS
    cin>>n>>m;
    fun(i)
    {
        if(i==1)continue;
        int u,v;
        cin>>u>>v;
        e[u].pb(v);
        e[v].pb(u);
    }

    fum(i)
    {
        int p,x;
        cin>>p>>x;
        a[p]+=x;
    }
    dfs(1,0,0);
    fun(i)cout<<b[i]<<" ";
    return 0;
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    int d, t, s;
    cin >> d >> t >> s;

    if(d <= s * t){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int a, b, c, d, e, f;
  int x, y;
  double xx, yy;
  while(cin>>a>>b>>c>>d>>e>>f){
    x = round(10000*(b*f-c*e)/(b*d-a*e));
    y = round(10000*(c*d-a*f)/(b*d-a*e));
    xx = x;
    yy = y;
    cout<<fixed<<setprecision(3)<<xx/10000<<" "<<yy/10000<<endl;
  }
}



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

int n, m;
int f[1<<12];

void upd(int &a, int b) {
	if (a<0 || a>b) a = b;
}

int main() {
	scanf("%d%d", &n, &m);
	
	memset(f, -1, sizeof f);
	f[0] = 0;
	
	for(int i=0;i<m;i++){
		int price, cnt;
		scanf("%d%d", &price, &cnt);
		
		int mask = 0;
		for(int j=0;j<cnt;j++) {
			int x; scanf("%d", &x);
			mask |= (1<<(x-1));
		}
		
		for(int j=0;j<(1<<n);j++) {
			if (f[j]<0) continue;
			upd(f[j|mask], f[j] + price);
		}
	}
	printf("%d\n", f[(1<<n)-1]);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  bool ok=true;
  if(a[0]!=b[2]) ok=false;
  if(a[1]!=b[1]) ok=false;
  if(a[2]!=b[0]) ok=false;
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    string w1 = "dream";
    string w2 = "dreamer";
    string w3 = "erase";
    string w4 = "eraser";

    reverse(w1.begin(), w1.end());
    reverse(w2.begin(), w2.end());
    reverse(w3.begin(), w3.end());
    reverse(w4.begin(), w4.end());

    for (ll i = 0; i < S.size();) {
        if (S.substr(i, w1.size()) == w1) {
            i += w1.size();
        } else if (S.substr(i, w2.size()) == w2) {
            i += w2.size();
        } else if (S.substr(i, w3.size()) == w3) {
            i += w3.size();
        } else if (S.substr(i, w4.size()) == w4) {
            i += w4.size();
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include <math.h>
#include <string>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;

int main(){
	string s; cin >>s;
	string t="CODEFESTIVAL2016";
	int cnt=0;
	for(int i=0;i<16;i++){
		if(t[i]-s[i]!=0)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<list>
#include<iterator>
#include<cmath>
using namespace std;

long long a[211111];
long long b[211111];
long long c = 0;

long long p1 = 0;
long long p2 = 0;

list<long long>old;

list<long long>ans;

int main()
{
	long long n;
	scanf("%lld", &n);

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

	sort(a, a + n);
	
	for (long long i = 0; i < n; i++)
	{
		old.push_back(a[i]);
	}

	//放入最小
	ans.push_back(old.front());
	old.pop_front();
	n--;

	bool turn = true;
	while (n >= 2)
	{
		if (turn)
		{
			turn = false;
			ans.push_front(old.back());
			old.pop_back();
			n--;

			ans.push_back(old.back());
			old.pop_back();
			n--;
		}

		else
		{
			turn = true;
			ans.push_front(old.front());
			old.pop_front();
			n--;

			ans.push_back(old.front());
			old.pop_front();
			n--;
		}

	}

	if (n == 1)
	{
		ans.push_front(old.front());
	}

	for (auto it = ans.begin(); it != ans.end(); it++)
	{
		b[c++] = (*it);
	}

	for (long long i = 0; i < c - 1; i++)
	{
		long long k = b[i] - b[i + 1];

		if (k > 0)
			p1 += k;
		else
			p1 -= k;
	}


	while (!ans.empty())
		ans.pop_back();

	while (!old.empty())
		old.pop_back();


	n = c;
	c = 0;

	for (long long i = 0; i < n; i++)
	{
		old.push_back(a[i]);
	}


	ans.push_back(old.back());
	old.pop_back();
	n--;

	turn = true;
	while (n >= 2)
	{
		if (turn)
		{
			turn = false;
			ans.push_front(old.front());
			old.pop_front();
			n--;

			ans.push_back(old.front());
			old.pop_front();
			n--;
		}

		else
		{
			turn = true;
			ans.push_front(old.back());
			old.pop_back();
			n--;

			ans.push_back(old.back());
			old.pop_back();
			n--;
		}

	}

	if (n == 1)
	{
		ans.push_front(old.front());
	}

	for (auto it = ans.begin(); it != ans.end(); it++)
	{
		b[c++] = (*it);
	}

	for (long long i = 0; i < c - 1; i++)
	{
		long long k = b[i] - b[i + 1];

		if (k > 0)
			p2 += k;
		else
			p2 -= k;
	}


	printf("%lld\n", max(p1, p2));

	return 0;
}


Measured memory_bytes: 6912
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    unordered_map<ll, ll> Q;
    int N;
    cin >> N;
    ll sum = 0;
    Q[sum]++;
    for (int i = 0;i < N;i++) {
    	ll r;
    	cin >> r;
    	sum += r;
    	Q[sum]++;
    }
    ll sol = 0;
    for (unordered_map<ll, ll>::iterator it = Q.begin();it != Q.end();++it) {
    	sol += (it->second - 1) * (it->second) / 2;
    }
    cout << sol << endl;
    return 0;
}

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

typedef long long ll;

ll n;

int cnt = 0;

ll dfs(ll now, ll seven, ll five, ll three) {
	if (n < now) return 0;
	
	if (seven >= 1 && five >= 1 && three >= 1) {
		cnt++;
	}	
	dfs(now * 10 + 7, seven + 1, five, three);
	dfs(now * 10 + 5, seven, five + 1, three);
	dfs(now * 10 + 3, seven, five, three + 1);
}

int main() {
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	int n;
	cin>>n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1]<<"\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){fastio
    
    ll n,m;cin>>n>>m;
    
    ll dp[1<<n][m+1];//jまで見てiを開けるための最小cost
    rep(i,0,(1<<n)-1)rep(j,0,m)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,1,m){
        ll a,b;
        ll c=0;
        cin>>a>>b;
        rep(x,1,b){
            ll p;cin>>p;p--;
            c+=(1ll<<p);
        }
        rep(j,0,(1<<n)-1){
            Min(dp[j][i],dp[j][i-1]);
            Min(dp[j|c][i],dp[j][i-1]+a);
        }
        for(ll j=(1<<n)-1;j>=0;j--){
            rep(k,0,n-1){
                ll p=1<<k;
                if(j&p){
                    ll next=j-p;
                    Min(dp[next][i],dp[j][i]);
                }
            }
        }
    }
    /*
    rep(i,0,(1<<n)-1){
        rep(j,0,m){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }
     */
    if(dp[(1<<n)-1][m]==inf)cout<<-1;
    else cout<<dp[(1<<n)-1][m]<<endl;
    
    return 0;
}


Measured memory_bytes: 32256
package main

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

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

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

type segmentTree struct {
	data   []int
	offset int
}

func newSegmentTree(n int) segmentTree {
	var result segmentTree
	t := 1
	for t < n {
		t *= 2
	}
	result.offset = t - 1
	result.data = make([]int, 2*t-1)
	return result
}

func (st segmentTree) updateAll(a []int) {
	for i, v := range a {
		st.data[st.offset+i] = v
	}
	for i := st.offset - 1; i > -1; i-- {
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) update(index, value int) {
	i := st.offset + index
	st.data[i] = value
	for i >= 1 {
		i = (i - 1) / 2
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) _query(start, stop, index, left, right int) int {
	if right <= start || stop <= left {
		return 0
	}
	if start <= left && right <= stop {
		return st.data[index]
	}
	a := st._query(start, stop, index*2+1, left, (left+right)/2)
	b := st._query(start, stop, index*2+2, (left+right)/2, right)
	return gcd(a, b)
}

func (st segmentTree) query(start, stop int) int {
	//return st._query(start, stop, 0, 0, st.offset+1)
	result := 0
	q := make([][3]int, 1)
	q = append(q, [3]int{0, 0, st.offset + 1})
	for len(q) != 0 {
		index := q[0][0]
		left := q[0][1]
		right := q[0][2]
		q = q[1:]
		if right <= start || stop <= left {
			continue
		}
		if start <= left && right <= stop {
			result = gcd(result, st.data[index])
			continue
		}
		q = append(q, [3]int{index*2 + 1, left, (left + right) / 2})
		q = append(q, [3]int{index*2 + 2, (left + right) / 2, right})
	}
	return result
}

func main() {
	N := readInt()
	A := readInts(N)

	st := newSegmentTree(N)
	//for i, v := range A {
	//	st.update(i, v)
	//}
	st.updateAll(A)

	result := st.query(1, N)
	for i := 1; i < N-1; i++ {
		result = max(result, gcd(st.query(0, i), st.query(i+1, N)))
	}
	result = max(result, st.query(0, N-1))

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


Measured memory_bytes: 17052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int a;
  cin >> a;
  int ans = a + a * a + a * a * a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#define MAX 10000

int main(){
    int n, a[MAX], i, j, max, min, tmp;
    long long int total = 0;
    scanf("%d", &n);

    for(i = 0; i < n; i++) scanf("%d", &a[i]);

    for(i = 0; i < n; i++){
        total += a[i];
    }

    for(i = 0; i < n; i++){
        for(j = i + 1; j < n; j++){
            if(a[i] > a[j]){
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }

    min = a[0];
    max = a[n - 1];

    printf("%d %d %Ld\n", min, max, total);

    return 0;
}



Measured memory_bytes: 2104
def main():
    S = input()
    from collections import deque
    S = deque(S)
    T = input()
    for i in range(len(S) + 1):
        Z = "".join(S)
        if Z == T:
            return print("Yes")
        S.rotate()
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K; cin >> N >> K;
    string S; cin >> S;
    int h = 0;
    for(int i = 0; i < N-1; i++) if(S[i] == S[i+1]) h++;
    cout << min(h+2*K, N-1) << endl;
}

Measured memory_bytes: 512
def f(): return map(int,raw_input().split())
def f1(n): return sum([e**n for e in x])**(1.0/n)
def f2(n): print '%.6f' %(n)

raw_input()
x = [abs(a-b) for a,b in zip(f(),f())]
f2(f1(1))
f2(f1(2))
f2(f1(3))
f2(max(x))

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<bool> sunuke(N + 1, false);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int ak;
            cin >> ak;
            sunuke[ak] = true;
        }
    }
    ll cnt = 0;
    rep(i, N) {
        if(!sunuke[i + 1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3596
# -*- coding: utf-8 -*-

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
if len(xy) == 1:
    print(1)
    exit()

xy.sort()
xy = xy[::-1]
aaa = []
for i in range(len(xy)-1):
    for j in range(i+1, len(xy)):
        a, b = xy[i]
        c, d = xy[j]
        aaa.append(str(a-c)+str(b-d))

# import itertools
#
# # itertools.permutations(xy, 2)
#
# aaa = []
# for i in list(itertools.combinations(xy, 2)):
#     a, b, c, d = sum(i, [])
#     aaa.append([str(a-c)+str(b-d)])
#     # print(a,b,c,d)
# # print(aaa)
# aaa = sum(aaa, [])
# print(aaa)
import collections
bbb = collections.Counter(aaa)
# print(bbb.most_common())
print(n-bbb.most_common()[0][1])






Measured memory_bytes: 39664
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
b=sorted(a,reverse=True)
a1=b[0]
a2=b[1]
m=a.index(a1)
for i in range(n):
  if i==m:
    print(a2)
  else:
    print(a1)

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

static const int MAX = 100;
int row[MAX], col[MAX];

int main(){
    int w, h, n, x, y, a;
    cin >> w >> h >> n;
    for(int i = 0; i < max(w, h); i++){
        row[i] = col[i] = 0;
    }
    for(int k = 0; k < n; k++){
        cin >> x >> y >> a;
        switch(a){
            case 1:
            for(int j = 0; j < x; j++){
                col[j]++;
            }
            break;
            case 2:
            for(int j = x; j < w; j++){
                col[j]++;
            }
            break;
            case 3:
            for(int i = h-y; i < h; i++){
                row[i]++;
            }
            break;
            case 4:
            for(int i = 0; i < h-y; i++){
                row[i]++;
            }
            break;
        }
    }
    int cnt = 0;
    int ans = h * w;
    for(int i = 0; i < h; i++){
        if(row[i]){
            ans -= w;
            cnt++;
        }
    }
    for(int j = 0; j < w; j++){
        if(col[j]){
            ans -= h-cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits//stdc++.h>
using namespace std;
int main(){
    int a,b,c;cin >> a >>b>>c;
    if(a+b <c){
        cout <<"NA" << endl;
        return 0;
    }else if(a >= c){
        cout << 0 <<endl;
    }else{
        cout << c - a << endl;
    }
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<vector<int>>cnt(10,vector<int>(10));
  rep(i, 1, n+1){
    string s = to_string(i);
    int m = s.size();
    cnt[s[0]-'0'][s[m-1]-'0']++;
  }
  int ans=0;
  rep(i, 1, 10)rep(j, 1, 10)ans += cnt[i][j]*cnt[j][i];
  cout << ans << endl;
}

Measured memory_bytes: 3612
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
string s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_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(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll dist = b - a + 1;
    ll ans = dist / x;
    ll c = a / x * x;
    if (c < a) {
        c += x;
    }
    if (c + ans * x <= b) {
        ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            int i =  In.Int();
            Out(Math.Pow(i, 3));
            return ;
        } 

        private static void Out(Object arg)
        {
            Console.WriteLine(arg);
        }
    }

    class In
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] Ints()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
    }
}

Measured memory_bytes: 9616
#include <stdio.h>

#define N 1000000

int main(){

  int i;
  int j;
  int n;
  int q;
  int count=0;
  int s[N];
  int t[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  
  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(t[i]==s[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);

  return 0;
}

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

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

  int cnt[100001] = {0};
  for(int i = 0; i < n; i++){
    cnt[a[i]]++;
    if(a[i] > 0) cnt[a[i] - 1]++;
    cnt[a[i] + 1]++;
  }

  int ans = 0;
  for(int i = 0; i < 100001; i++)
    if(cnt[i] > ans) ans = cnt[i];

  cout << ans << endl;
}


Measured memory_bytes: 1024
n,l = map(int ,input().split())
a = list(map(int ,input().split()))
ans = [0]
c = 1
for i in range(len(a)):
    ans.append(ans[i]+a[i])
    # print (ans[i])
    if ans[-1]<=l:
        #print(ans[-1])
        c+=1

print(c)

Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include <set>

using namespace std;

int main(void)
{
	int n;
	int k,l,t;
	int i1,i2,i3,i4;

	while(1){
		cin>>n;
		if(n==0)break;

		k=n;
		set<multiset<int> > s;

		for(i1=floor(sqrt(k));i1>0;i1--){
			k-=(i1*i1);
			l=k;
			for(i2=floor(sqrt(l));i2>=0;i2--){
				l-=(i2*i2);
				t=l;
				for(i3=floor(sqrt(t));i3>=0;i3--){
					t-=(i3*i3);
					i4=floor(sqrt(t));
					t-=(i4*i4);
					
					if(t==0) {
						//cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<endl;
						multiset<int> m;
						m.insert(i1);
						m.insert(i2);
						m.insert(i3);
						m.insert(i4);
						s.insert(m);
					}
					t=l;
				}
				l=k;
			}
			k=n;
		}

		cout<<s.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1676
from sys import stdin, setrecursionlimit
from collections import deque


def main():
    input = stdin.buffer.readline
    n = int(input())
    g = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        g[u - 1].append([v - 1, w])
        g[v - 1].append([u - 1, w])

    ans = [-1] * n

    q = deque([0])
    ans[0] = 0

    while q:
        u = q.popleft()

        for v, w in g[u]:
            if ans[v] == -1:
                ans[v] = (ans[u] + w) % 2
                q.append(v)

    print(*ans, sep='\n')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

const long long baseNum = 3,bases[] = {10007,10009,10037};

template<long long mod = 1000000007>
struct RollingHash{
	using ll = long long;
	vector<ll> hashes[baseNum],powers[baseNum];
	RollingHash(string &s){
		int n = s.length();
		for(int i = 0;i < baseNum;i++){
			hashes[i].resize(n + 1,0);
			powers[i].resize(n + 1,1);
			for(int j = 0;j < n;j++){
				powers[i][j + 1] = powers[i][j] * bases[i] % mod;
				hashes[i][j + 1] = (hashes[i][j] * bases[i] + s[j]) % mod;
			}
		}
	}
	ll getHash(int l,int r,int b){
		return (hashes[b][r] - hashes[b][l] * powers[b][r - l] % mod + mod) % mod;
	}
	vector<ll> getHash(int l = 0,int r = -1){
		if(r == -1) r = hashes[0].size() - 1;
		vector<ll> ret(baseNum);
		for(int i = 0;i < baseNum;i++){
			ret[i] = getHash(l,r,i);
		}
		return ret;
	}
	static bool sameString(vector<ll> v1,vector<ll> v2){
		assert(v1.size() == v2.size());
		for(int i = 0;i < v1.size();i++){
			if(v1[i] != v2[i]) return false;
		}
		return true;
	}
};

signed main(){
	int n,m,l = 0,r = 1;
	string s;
	set<vector<long long>> st;
	cin >> n >> m >> s;
	RollingHash<> hashedS(s);
	for(int i = 0;i < m;i++){
		string q;
		cin >> q;
		if(q == "R++") r++;
		else if(q == "R--") r--;
		else if(q == "L++") l++;
		else l--;
		st.insert(hashedS.getHash(l,r));
	}
	cout << st.size() << endl;
}


Measured memory_bytes: 45196
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
	
  	int N, a[110], alice = 0, bob = 0;
  	cin >> N;
  	for(int i=0; i<N; i++){
  		cin >> a[i];
  	}
  	
	sort(a,a+N);
	
	int eo = (N-1) % 2;
	
	for(int i=N-1;i>=0;i--){
		if(eo == i % 2){
			alice += a[i];
		}else{
			bob += a[i];
		}

	}
  	
  	cout << alice - bob << endl;
   	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int [] nx = inputval();
        int n = nx[0];
        int x = nx[1];

        int sum = 0;
        int min = Integer.MAX_VALUE;
        for (int i=0; i<n; i++){
            int m = Integer.parseInt(br.readLine());
            sum += m;
            if (m < min){
                min = m;
            }
        }
        int minCnt = (x -sum) / min;
        System.out.println(n+minCnt);

    }

}



Measured memory_bytes: 32592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


LL dp[3100][3100][5];
LL it[3100][3100];

int main() {
    LL R,C,K;cin >> R >> C >> K;
    vector<LL> r(K);
    vector<LL> c(K);
    vector<LL> v(K);
    rep(i,K){
        int rr,cc,vv;cin >> rr >> cc >> vv;
        rr--;cc--;
        r[i] = rr;
        c[i] = cc;
        v[i] = vv;
    }

    memset(it,0,sizeof(it));
    
    rep(i,K)it[r[i]][c[i]] = v[i];

    memset(dp,0,sizeof(dp));

    rep(i,R){
        rep(j,C){
            if(i == 0 && j == 0){
                chmax(dp[0][0][1],it[0][0]);
            }
            for(int k = 0;k <= 3;k++){
                if(i != R-1){
                    chmax(dp[i+1][j][0],dp[i][j][k]);   // 拾わないで下
                    chmax(dp[i+1][j][1],dp[i][j][k] + it[i+1][j]);  // 拾って下
                }
                if(j != C-1){
                    chmax(dp[i][j+1][k],dp[i][j][k]);   // 拾わないで右
                    if(k != 3)chmax(dp[i][j+1][k+1],dp[i][j][k] + it[i][j+1]);    // 拾って右
                }
            }
        }
    }

    LL ans = 0;

    rep(i,4)chmax(ans,dp[R-1][C-1][i]);

    cout << ans << endl;
}

Measured memory_bytes: 458408
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    n: usize,
    sv: [String; n]
  };

  let res = sv.into_iter().collect::<HashSet<_>>().len();
  println!("{}", res);
}


Measured memory_bytes: 21488
func main() {
    var xkd = readLine()!.split(separator: " ").map{Int($0)!}
    if xkd[0] < 0 {
        xkd[0] = -xkd[0]
    }
    let remainder = xkd[0] % xkd[2]
    let devided = xkd[0] / xkd[2]
    if devided >= xkd[1] {
        print(xkd[0]-xkd[1]*xkd[2])
    } else {
        xkd[1] -= devided
        print(xkd[1] % 2 == 0 ? remainder : xkd[2] - remainder)
    }
    return
}

main()


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

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	int l = e-a;
	string ans;
	if (l <= k) ans = "Yay!";
	else ans = ":(";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
Q,H,S,D = map(int, input().split())
N = int(input())

c = D,S,H,Q
v = 2,1,0.5,0.25
cosp =  [ D*1, S*2, H*4, Q*8 ]
ans = 0

for _ in range(3):
    x = cosp.index(min(cosp))
    a = v[x]
    b = int(N//a)
    if b == 0:
        cosp[x] = 10**9
        continue
    N = N - a*b
    ans = ans + b*c[x]
    if N == 0:
        break

print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,X,T;
  cin>>N>>X>>T;
  int count=T;
  for(int i=X;i<N;i+=X)
    {
       count+=T;
    } 
  cout<<count<<endl;
return 0;

}


Measured memory_bytes: 3576
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    X = [0] * N
    X[-1] = A[-1]
    for i, a in enumerate(A[:-1]):
        if i % 2:
            X[-1] += a
        else:
            X[-1] -= a

    for i in range(N - 2, -1, -1):
        X[i] = 2 * A[i] - X[i + 1]

    print(*X)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20388
m = 10**9 + 7
n = int(input())
an = list(map(int, input().split()))
wa = []
total = 0
for i in reversed(range(1, len(an))):
    total = total + an[i]
    wa.append(total)
wa = sorted(wa, reverse=True)
ans = 0
for i in range(0, n-1):
#     print(an[i] * wa[i])
    ans = ans + an[i] * (wa[i]%m)
    ans = ans % m
print(ans)

Measured memory_bytes: 31412
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	bool isShown[26] = { 0 };
	string sInput;
	int i;
	cin >> sInput;
	for (i = 0; i < sInput.length(); ++i){
		isShown[sInput[i] - 'a'] = true;
	}
	for (i = 0; i < 26; ++i){
		if (!isShown[i]){
			cout << char('a' + i) << endl;
			goto endapp;
		}
	}
	cout << "None\n";
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  if(N%2==0) cout << N << endl;
  else cout << 2*N << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int> M;
string Ver[]={"AC","WA","TLE","RE"};
int main()
{
  int N;
  cin>>N;
  while(N--)
  {
    string S;
    cin>>S;
    M[S]++;
  }
  for(int i=0;i<4;i++)
    cout<<Ver[i]<<" x "<<M[Ver[i]]<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;
typedef long long ll;

int value(int a) {
	if (a == 4 || a == 6 || a == 9 || a == 11)return 0;
	else return 1;
}

int main(void) {
	int x, y;
	cin >> x >> y;
	if (x == 2 || y == 2)cout << "No" << endl;
	else {
		int num = value(x) + value(y);
		if (num == 0 || num == 2)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
'use strict';
const main = n => {
  n = parseInt(n[0], 10);
  let ans = 0;
  for(let i=1; i<n+1; i++) if (i.toString().length%2) ans++;
  console.log(ans);
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 10944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<(ll)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
const ll mod=1e9+7;
const ll INF = 1e9;

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

bool is_prime(ll x){
    if(x==1) return false;
    for(ll i=2; i*i<=x;i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    fast_io
    
    int n, m;
    cin>>n>>m;
    vector<int> a(m), dp(n+1);
    vector<bool> ok(n+1, true);
    rep(i,m) {
        cin>>a[i];
        ok[a[i]]=false;
    }
    dp[0]=1;
    for(int now=0;now<n;now++){
        for(int next=now+1;next<=min(n, now+2);next++){
            if(ok[next]){
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }

    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,t;
	cin>>n>>t;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int mx=0,deltamx=0;
	int ans=0;
	for(int i=n-1;i>=0;i--){
		if(mx){
			if(a[i]<mx){
				int d=mx-a[i];
				if(d>deltamx){
					deltamx=d;
					ans=1;
				}
				else if(d==deltamx) ans++;
			}
		}
		mx=max(mx,a[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640