akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;




int main() {

    
    int a, b;
    cin >> a >> b;

    int ans = -1;
    for (int i = 1; i <= 10000; ++i) {
        if ((i*8/100) == a && (i*10/100) == b) {
            ans = i;
            break;
        }
    }

    out(ans);
}




//              g++ -std=c++1z






Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

ll n;
vector<pll> v;
vector<vector<ll>> e;
vector<pll> D;
vector<pair<bool,ll>> de;

pair<bool,pll> dfs(ll where,ll parent,pll lmt,bool F){
    if(de[where].F){
        if(de[where].S%2!=(F?1:0)){return {false,{0,0}};}
        if(lmt.F<de[where].S || lmt.S>de[where].S){return {false,{0,0}};}
        lmt={de[where].S,de[where].S};
    }
    for(int i=0;i<e[where].size();i++){
        ll to=e[where][i];
        if(to==parent){continue;}
        pair<bool,pll> ret=dfs(to,where,{lmt.F+1,lmt.S-1},!F);
        lmt.F=min(lmt.F,ret.S.F);
        lmt.S=max(lmt.S,ret.S.S);
        if(lmt.F<lmt.S || !ret.F){return {false,{0,0}};}
    }
    v[where].F=lmt.F; v[where].S=lmt.S;
    lmt.F++; lmt.S--;
    return {true,lmt};
}

bool dfs2(ll where,ll parent,pll lmt){
    v[where].F=min(lmt.F,v[where].F);
    v[where].S=max(lmt.S,v[where].S);
    lmt.F=v[where].F; lmt.S=v[where].S;
    if(lmt.F<lmt.S){return false;}
    for(int i=0;i<e[where].size();i++){
        ll to=e[where][i];
        if(to==parent){continue;}
        if(!dfs2(to,where,{lmt.F+1,lmt.S-1})){return false;}
    }
    return true;
}

vector<int> color;

void dfsC(ll where){
    for(int i=0;i<e[where].size();i++){
        ll to=e[where][i];
        if(color[to]==-1){
            color[to]=color[where]==1?0:1;
            dfsC(to);
        }
    }
}




int main(){
    cin>>n;
    e.resize(n);
    v.resize(n);
    de.resize(n,{false,-1});
    color.resize(n,-1);
    for(int i=0;i<n-1;i++){
        ll u,v;
        cin>>u>>v; u--; v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    ll k;
    cin>>k;
    D.resize(k);
    for(int i=0;i<k;i++){
        cin>>D[i].F>>D[i].S;
        --D[i].F;
        de[D[i].F]={true,D[i].S};
    }
    assert(k!=0);
    color[D[0].F]=D[0].S%2;
    dfsC(D[0].F);
    for(int i=0;i<k;i++){
        if(color[D[i].F]!=D[i].S%2){cout<<"No"<<endl; return 0;}
    }
    if(!dfs(D[0].F,-1,{D[0].S,D[0].S},D[0].S%2).F){cout<<"No"<<endl; return 0;}
    if(!dfs2(D[0].F,-1,v[D[0].F])){cout<<"No"<<endl; return 0;}
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++){
        cout<<v[i].F<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 22784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

class writeInfo{
public:
	int from;
	int to;
	int discripter;
};

int main(){
	int N;
	bool fst=false;
	while(cin>>N&&N!=0){
		vector<writeInfo> info;
		for(int i = 0; i < N; i++){
			char order;
			cin>>order;
			if(order=='W'){
				int discripter;
				int leftWritingSize=0;
				int finTo=0;
				cin>>discripter>>leftWritingSize;
				int prvPlace=0;
				for(int j = 0; j < info.size(); j++){
					if(leftWritingSize==0)
						break;
					// àµó«Xy[Xª³©Á½ç
					if(prvPlace==info[j].from){
						prvPlace=info[j].to+1;
						finTo=info[j].to+1;
						continue;
					}
					// ó«Xy[Xª Á½êA«ßé¾¯«Þ
					else{
						int to=min(leftWritingSize,info[j].from-prvPlace);
						leftWritingSize-=to;
						writeInfo wi;
						wi.discripter=discripter;
						wi.from=prvPlace;
						wi.to=prvPlace+to-1;
						//info.push_back(wi);
						info.insert(info.begin()+j,wi);
						if(leftWritingSize==0)
							break;
						finTo=info[j].to+1;
						prvPlace=info[j].to+1;
					}
				}
				if(leftWritingSize>0){
					writeInfo wi;
					wi.discripter=discripter;
					wi.from=finTo;
					wi.to=finTo+leftWritingSize-1;
					info.push_back(wi);
				}
			}
			else if(order=='R'){
				int secter;
				cin>>secter;
				bool isFind=false;
				// from-toÌÔÉsecterª é©²×é
				for(int j = 0; j < info.size(); j++){
					if(info[j].from<=secter&&info[j].to>=secter){
						cout<<info[j].discripter<<endl;
						isFind=true;
						break;
					}
				}
				if(!isFind)
					cout<<-1<<endl;
			}
			else if(order=='D'){
				int discrepter;
				cin>>discrepter;
				// fBXNv^ªêv·éàÌð·×Äí
				for(int j = info.size()-1; j>=0; j--){
					if(info[j].discripter==discrepter){
						info.erase(info.begin()+j);
					}
				}
			}
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

bool pressed[100500];

void solve(){
    int n;
    cin >> n;
    int a[100500];
    for(int i = 0; i < n; i++){
        cin >> a[i + 1];
    }
    int but = 1;
    int cnt = 0;
    while(but != 2){
        pressed[but] = true;
        but = a[but];
        if(pressed[but]){
            cout << -1;
            return;
        }
        cnt++;
    }
    cout << cnt;
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 768
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;
double dp[MAX][MAX];
vector<double>v;

void solve()
{  ll i,j,k,n,m,b;
     cin>>n;
   double a,sum;
     for(i=0;i<n;i++)
    {
   	cin>>a;
   	v.pb(a);
    }  
    for(i=0;i<n;i++)
    {  
    	for(j=0;j<=(i+1);j++)
    	{   dp[i][j]=0;
    		if(i==0)
    		{   if(j==0)
    			dp[i][j]=(1-v[i]);
    			else if(j==1)
    			dp[i][j]=v[i];
    		    else
    		    dp[i][j]=0;
    		   continue;
    		}
    		
    		if(j!=0)
    	    dp[i][j]+=(dp[i-1][j-1]*(v[i]));
    	    dp[i][j]+=(dp[i-1][j]*(1-v[i]));
    	 //   cout<<dp[i][j]<<" "<<i<<" "<<j<<"//";
         }
    }
for(i=ceil((n*(1.0))/2);i<=n;i++)
	sum+=dp[n-1][i];
cout<<setprecision(10)<<sum<<"\n";
}
           
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
     


Measured memory_bytes: 49912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}



struct edge { int to, cost; };
struct dijkstra {
    vector<vector<edge>> g;
    vector<int> d;
    vector<int> from_v;
    int V;
    
    dijkstra(int v){
        V = v;
        d.resize(V);
        g.resize(V);
        from_v.assign(V,-1);
    }
    
    void solve_d(int s){
        from_v[s] = 1;
        pq1<pii> que;
        rep(i,V) d[i] = infi;
        d[s] = 0;
        que.push({0,s});
        
        while (!que.empty()) {
            pii p = que.top();
            que.pop();
            int v = p.se;
            if(d[v] < p.fi) continue;
            rep(i,int(g[v].size())){
                edge e = g[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    from_v[e.to] = v;
                    que.push({d[e.to],e.to});
                }
            }
        }
    }
    
    int dis(int a){
        return d[a];
    }
};



int main(){

    int N,X,Y;
    cin >> N >> X >> Y;
    X--,Y--;
    
    dijkstra G(N);
    G.g[X].pb({Y,1});
    G.g[Y].pb({X,1});
    reps(i,1,N){
        G.g[i].pb({i-1,1});
        G.g[i-1].pb({i,1});
    }
    vl ans(N+1,0);
    rep(i,N){
        G.solve_d(i);
        //outve(G.d);
        reps(j,i,N) ans[G.d[j]]++;
    }
    
    reps(i,1,N) cout << ans[i] << endl;
    
    

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
    string s;
    cin>>s;
    int f,b;
    string sf,sb;
    sf = string(1,s[0]) + s[1];
    sb = string(1,s[2]) + s[3];
    f = stoi(sf);
    b = stoi(sb);
    // cout<<f<<" "<<b<<endl;
    string ans;
    if(0 < f && f <= 12){
        ans = "MMYY";
        if(0 < b && b <= 12){
            ans = "AMBIGUOUS";
        }
    }
    else if (0 < b && b <= 12){
        ans = "YYMM";
        if(0 < f && f <= 12){
            ans = "AMBIGUOUS";
        }
    }
    else{
        ans = "NA";
    }
    cout<<ans<<endl;
    return 0;
}



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


int check() {
	char a[105];
	int len;

	scanf("%s", &a);
	len = strlen(a);

	// i 文字目と len-i-1文字目 が違ったら回文ではない
	for (int i = 0; i < len; i++)
	{
		if (a[i] != a[len - i - 1]) return 0;
	}
	// 前半部について、i文字目と(len/2)-i-1文字目が違ったら回分ではない
	for (int i = 0; i < len / 2; i++)
	{
		if (a[i] != a[len / 2 - i - 1]) return 0;
	}
	// 後半部について、回文だったら前半部と同じ文字なので調べないで良い
	//強い回文だったらtrueを返す
	return 1;
}

int main()
{
	if (check()) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
function Main(input) {
	const [l, r, d] = input.split(" ").map(Number);
	
	var ans = 0;
	for(i=l; i<=r; i++){
	  if(i % d == 0){
	    ans++;
	  }
	}
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29632
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=1e18;


int main(){
    int N,P;
    cin >> N >> P;
    int t[2]={};
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        t[a%2]++;
    }
    LL ans=1,u=1;
    for(int i=0;i<t[0];i++) ans*=2;
    for(int i=1;i<t[1];i++) u*=2;
    if(t[1]==0&&P) u=0;
    cout << u*ans << endl;
    return 0;
}

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

ll dp[100001][101];
ll vis[100001][101];

ll solve(ll c, ll i, ll n, ll w[], ll v[])
{
	if(i==n) return 0;
	if(vis[c][i]) return dp[c][i];
	vis[c][i] = 1;
	if(c<w[i]) return dp[c][i] = solve(c,i+1,n,w,v);
	return dp[c][i] = max(solve(c,i+1,n,w,v), solve(c-w[i],i+1,n,w,v) + v[i]);
}

int main()
{
	ll n, c;
	cin>>n>>c;
	ll w[n], v[n];
	for(ll i=0; i<n; i++) cin>>w[i]>>v[i];
	cout<<solve(c,0,n,w,v);
	return 0;
}

Measured memory_bytes: 157952
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define int long long
using namespace std;

signed main() {
	int N, x;
	cin >> N >> x;
	vector <int> a(N);
	
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int res=1000000000000000000;
	int t;
	int b;
	for (int i = 0; i < N; i++) {
		t = i*x;
		for (int j = 0; j < N; j++) {
			t = t + a[j];
		}
		res = min(res, t);
		b = a[N - 1];
		for (int j = N - 1; j >= 1; j--) {
			a[j] = min(a[j - 1], a[j]);
		}
		a[0] = min(a[0], b);

	}

	
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, m, all = 0;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n)
  {
    cin >> a[i];
    all += a[i];
  }
  int flg = all % (4 * m);
  all /= 4 * m;
  sort(a.begin(), a.end(), greater<int>());
  rep(i,m)
  {
    if(flg){
      if (a[i] <= all) {
        cout << "No";
        return 0;
      }
    }else{
      if (a[i] < all) {
        cout << "No";
        return 0;
      }

    }
  }
  cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll s, w;

    cin >> s >> w;

    if(w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3620
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$cs = array_count_values($a);
krsort($cs);
$x = $y = 0;
foreach ($cs as $b => $c) {
	if ($c >= 2) {
		if ($x > 0) {
			$y = $b;
			break;
		} else {
			$x = $b;
			if ($c >= 4) {
				$y = $b;
				break;
			}
		}
	}
}
echo $x * $y;

Measured memory_bytes: 19316
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <queue>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, k, h;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> h;
        p[i] = h;
    }
    
    sort(p.begin(), p.end());
    int m = 999999999;
    for(int i = 0; i+k-1 < n; i++){
        m = min(m, p[i+k-1]-p[i]);
    }
    cout << m << endl;
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll h, n;
  cin >> h >> n;
  rep(i, n) {
    ll x;
    cin >> x;
    h -= x;
  }
  cout << (h <= 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k; cin >> n >> k;
  vector<int> l(k),r(k);
  REP(i,k) cin >> l[i] >> r[i];

  vector<ll> dp(n+1), dpsum(n+1);
  // マス1から始まるため dp[1] = 1 にする
  dp[1] = 1;
  dpsum[1] = 1; // dpの累積和

  for (int i = 2; i <= n; i++) {
    REP(j,k) {
      int li = i-r[j];
      int ri = i-l[j];
      if (ri < 0) continue;
      li = max(li, 1);

      dp[i] += dpsum[ri] - dpsum[li-1];
      if (dp[i] < 0) dp[i] += MOD;
      else dp[i] %= MOD;
    }
    dpsum[i] = (dpsum[i-1]+dp[i]) % MOD;
  }
  COUT(dp[n]);
  return 0;
}

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

using namespace std;

int main(void){
	int N,K;
	cin >> N >> K;
	long long ans = 1;
	for(int i=0;i<N;i++){
		if(i==0){
			ans *=K;
		}else{
			ans *=(K-1);
		}
	}
	cout << ans;
}

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo INT_MAX

const int N = 4e2 + 5;
ll n , res;
ll a[N] , f[N];
ll dp[N][N];

int main()
{
    //freopen("N.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
        cin >> a[i];
    FOR(i , 1 , n)
        FOR(j , 1 , n)
            dp[i][j] = 1e18;
    FOR(i , 1 , n)
        dp[i][i] = 0;
    FOR(i , 1 , n)
        f[i] = f[i - 1] + a[i];
    FOR(r , 1 , n)
        FORD(l , r - 1, 1)
            FOR(k , l , r)
                dp[l][r]= min(dp[l][r] , dp[l][k] + dp[k + 1][r] + f[r] - f[l - 1]);
    cout << dp[1][n];
}


Measured memory_bytes: 1536
from collections import deque

N, P = [int(x) for x in input().split()]

even = 0
odd = 0

for a in input().split():
    check = int(a)

    if check % 2 == 0:
        even += 1
    else:
        odd += 1


def comb(n, r):
    up = 1
    down = 1
    for i in range(r):
        up *= n - i
        down *= i + 1
    return up // down


# 奇数にする場合
result = 0
if P == 1:
    # 奇数を奇数個選ぶ
    for i in range(1, odd+1, 2):
        result += comb(odd, i)

# 偶数にする場合
else:
    # 奇数を選ばない、もしくは偶数個選ぶ
    for i in range(0, odd+1, 2):
        result += comb(odd, i)

if even == 0:
    mul = 1
else:
    mul = 2 ** even

result *= mul
print(result)


Measured memory_bytes: 9428
from collections import defaultdict
N,C = map(int,input().split())
D=[[int(i) for i in input().split()] for j in range(C)]
co=[[int(i) for i in input().split()] for j in range(N)]
d0= defaultdict(int)
d1= defaultdict(int)
d2= defaultdict(int)
for i in range(N):
    for j in range(N):
        if (j+i) %3==0:
            d0[co[j][i]] +=1
        elif (j+i)%3==1:
            d1[co[j][i]] +=1
        else:
            d2[co[j][i]] +=1
A0=[]#i色に帰るのに必要な違和感
A1=[]
A2=[]
for i in range(C):
    iwa =0
    for s in d0.keys():
        iwa += D[s-1][i-1]*d0[s] 
    A0.append([iwa,i])
for i in range(C):
    iwa =0
    for s in d1.keys():
        iwa += D[s-1][i-1]*d1[s] 
    A1.append([iwa,i])
for i in range(C):
    iwa =0
    for s in d2.keys():
        iwa += D[s-1][i-1]*d2[s] 
    A2.append([iwa,i])

A0.sort()
A1.sort()
A2.sort()
B=[[] for i in range(3)]
for i in range(3):
    B[0].append(A0[i])
for i in range(3):
    B[1].append(A1[i])
for i in range(3):
    B[2].append(A2[i])
ans =[]
for i in range(3):
    for j in range(3):
        for k in range(3):
            if B[0][i][1] ==B[1][j][1]:
                continue
            if B[0][i][1] ==B[2][k][1]:
                continue
            if B[1][j][1] ==B[2][k][1]:
                continue
            ans.append(B[0][i][0]+B[1][j][0]+B[2][k][0])
print(min(ans))

Measured memory_bytes: 5868
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
const int MAXN=2e3+10;
int cnt[MAXN];

int main(void)
{
    sync;
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;++i)
    {
        for(int j=i+1;j<=n;++j)
        {
            int d=min(j-i,abs(i-x)+abs(j-y)+1);
            ++cnt[d];
        }
    }
    for(int i=1;i<n;++i)
        cout<<cnt[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int,input().split())
if a == 5:
    if (b == 7 and c == 5) or (b == 5 and c == 7):
        print("YES")
    else:
        print("NO")
elif a == 7:
    if b == 5 and c == 5:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))

for i in range(1, N):
    if H[i] - H[i - 1] > 0:
        H[i] -= 1
    if H[i] - H[i - 1] < 0:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 14396
using System;

namespace abc112
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split();
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);

            var x = m / n;

            for (int i = x; 0 < i; i--)
            {
                if (m % i == 0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 13140
N, K = list(map(int,input().split()))
p = list(map(int,input().split()))

temp = sum(p[:K])
ind = 0
ma = 0

for i in range(N - K):
    temp = temp - p[i] + p[i + K]
    if temp > ma:
        ind = i + 1
        ma = temp

def calc_e(N):
    ans = 0
    for j in range(1, N + 1):
        ans += j / N
    return ans

ans = 0
for i in range(K):
    ans += calc_e(p[ind + i])
print(ans)

Measured memory_bytes: 98984
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		
		// 計算
		int result = 0;
		result += (x/500)*1000;
		result += ((x%500)/5)*5;
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 22740
n, m, x = gets.split.map(&:to_i) 
arr = gets.split.map(&:to_i) 

if arr.select{ |i| i > x }.size < m/2.0
	puts arr.select{ |i| i > x }.size
else
	puts m -arr.select{ |i| i > x }.size
end

 

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    set<int> st;
    rep(i, 1, n) {
        int x;
        cin >> x;
        st.insert(x);
    }
    cout << (sz(st) == n ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 9600
<?php
fscanf(STDIN, "%d %d", $h, $w);
for ($i = 0; $i < $h; $i++) {
	fscanf(STDIN, "%s", $s);
	if (strpos($s, '#') !== false) {
		$a[] = $s;
		for ($j = 0; $j < $w; $j++) {
			if ($s[$j] == '#') $f[$j] = 1;
		}
	}
}
foreach ($a as $s) {
	$t = null;
	for ($j = 0; $j < $w; $j++) {
		if (isset($f[$j])) $t .= $s[$j];
	}
	$x[] = $t;
}
echo implode("\n", $x);

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

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if((i % 2 == 0 && S.at(i) == 'L') || (i % 2 == 1 && S.at(i) == 'R')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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


w=[0 for i in range(N)]
v=[0 for i in range(N)]

Wsum = [0 for i in range(N+1)]
Vsum = [0 for i in range(N+1)]

for i in range(N):
    w[i],v[i] = map(int, input().split())
    


Wmin = min(w)    
w.insert(0,"0")
v.insert(0,"0")
for i in range(N):
    Wsum[i+1] = Wsum[i] + w[i+1]
    Vsum[i+1] = Vsum[i] + v[i+1]



nap_memo ={}

def nap(i,W2):
    kagi = str(i) + ':' +str(W2)
    if kagi in nap_memo:
        return nap_memo[kagi]
    elif i ==0:
        r=0
    elif W2<Wmin:
        r=0
    elif W2 < w[i]:
        r=nap(i-1,W2)
    elif Wsum[i]<=W2:
        r=Vsum[i]
    else:
        r=max( nap(i-1,W2-w[i])+v[i],nap(i-1,W2))
        
    nap_memo[kagi]=r
    return r

print(nap(N,W))

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

int main(){
    long n;cin>>n;
    vector<long> a(n);
    vector<long> num(100001,0);
    long sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        num[a[i]]++;
    }
    long q;cin>>q;
    for(int i=0;i<q;i++){
        long b,c;cin>>b>>c;
        sum=sum-b*num[b]+num[b]*c;
        num[c]+=num[b];
        num[b]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 4748
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;typedef vector<int> v;int h,w,k;v x(v a,v b){return a.size()>b.size()?a:a.size()<b.size()?b:max(a,b);}int main(){while(cin>>w>>h&&h){v d[75][75],s;r(i,h)r(j,w){char z;cin>>z;z-='0';if(!(z/10)&&(z||d[i][j].size())){d[i][j].push_back(z);d[i+1][j]=x(d[i+1][j],d[i][j]);d[i][j+1]=x(d[i][j+1],d[i][j]);}s=x(s,d[i][j]);}r(i,s.size())cout<<s[i];cout<<endl;}return 0;}

Measured memory_bytes: 3528
#include<iostream>
#include<cstdio>
using namespace std;
long long gcd(long long a,long long b)
{
  return b==0? a:gcd(b,a%b);
}
int main()
{
  int n;
  long long a[110];
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%lld",&a[i]);
  }
  if(n==1){
    printf("%lld\n",a[0]);
    return 0;
  }
  long long c=a[0];
  for(int i=1;i<n;i++)
  {
    c=c/gcd(c,a[i])*a[i];
  }
  printf("%lld\n",c);
  return 0;
}

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

using namespace std;

typedef long long LL;
#define N 300000

LL n,m,a[N],sum;
vector<LL> g[N];
bool vis[N];
char s[N];

void add(LL x,LL y){
	g[x].push_back(y);
	g[y].push_back(x);
}

void dfs(LL u){
	vis[u]=1;
	sum+=a[u];
	for (LL v:g[u]){
		if (!vis[v]) dfs(v);
	}
}

int main(){
	scanf("%s",s+1); m=strlen(s+1);
	for (LL i=1;i<=m/2;++i) a[i]=s[i]-s[m-i+1];
	a[m/2+1]-=a[m/2];
	for (LL i=m/2;i;--i) a[i]-=a[i-1];
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i){
		LL x,y; scanf("%lld%lld",&x,&y);
		if (x<=m/2&&y>=m-m/2+1){
			LL l1=m/2-x,l2=y-(m-m/2+1);
			if (l1>l2){
				y=m-y+1;
			}
			else{
				y=m-y+1;
				swap(x,y);
			}
			--y;
		}
		if (x>m/2){
			x=m-x+1; y=m-y+1;
			swap(x,y);
		}
		if (y>m/2) y=m/2;
		if (x<=y) add(x,y+1);
	}
	for (LL i=1;i<=m/2+1;++i){
		sum=0;
		if (!vis[i]) dfs(i);
		if (sum%26){puts("NO"); return 0;}
	}
	puts("YES");
	
	return 0;
}
			

Measured memory_bytes: 12032
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, k: usize, h:[i32; n]};
    let mut dp = vec![std::i32::MAX; n];
    dp[0] = 0;

    for i in 0..n {
        for j in i + 1..i + k + 1 {
            if j > n - 1 {
                break;
            }
            dp[j] = std::cmp::min(dp[j], dp[i] + (h[j] - h[i]).abs());
        }
    }

    println!("{}", dp[n - 1]);
}


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int day,type;

int ncake[105];

int main(){
    int i,j,k,l;
    
    cin >> day >> type;
    
    for (int i=0;i<type;i++){
        scanf("%d",ncake+i);
    }
    
    sort(ncake,ncake+type);
    
    k = (ncake[type-1] - 1)  - (day - ncake[type-1] );
    
    cout << max(0,k) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    ll m;
    cin>>m;
    vector<ll> v;
    ll mn=1e18;
    for(i=1;(ll)i*i<=m;i++)
    {
        if(m%i==0)
        {
            v.pb(i);
            ll x=m/i;
            ll sum=x+i-2;
            mn=min(mn,sum);
        }
    }
    cout<<mn;
    
    return 0;
}



Measured memory_bytes: 384
while True:
    N=raw_input()
    if N=="0000":break
    cnt=0
    if len(set(N))==1:
        print "NA"
    else:
        while N!="6174":
            N="0"*(4-len(N))+N
            S="".join(sorted(N))
            L=S[::-1]
            N=str(int(L)-int(S))
            cnt+=1
        print cnt

Measured memory_bytes: 4228
import sys
from collections import Counter
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input().rstrip())
    c = Counter(s)
    for s in ["AC", "WA", "TLE", "RE"]:
        print("{} x {}".format(s, c[s]))
   


if __name__ == '__main__':
    main()


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



char s[3];
void solve(){
	cin >> s[0] >> s[1] >> s[2];
	bool b = 0,c = 0;
	for(int i = 0; i < 3; i++){
		if(s[i] =='A') b = 1;
		if(s[i] == 'B') c = 1;
	}
	if(b&&c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        if(R < 1200){
            System.out.println("ABC");
        }else if(1200 <= R && R < 2800){
            System.out.println("ARC");
        }else if(2800 <= R){
            System.out.println("AGC");
        }
    }
}


Measured memory_bytes: 35592
import functools

def get_mul_inverse(x: int, p: int) -> int:
    return iterative_square(x, p - 2, p)

def _iterative_square(x: int, n: int, p: int) -> int:
    if n <= 1:
        return x
    div, mod = divmod(n, 2)
    return (((iterative_square(x, div, p) ** 2) % p) * x ** mod) % p

def iterative_square(x: int, n: int, p: int) -> int:
    if n <= 0:
        return None

    return _iterative_square(x, n, p)

def factorial(a, b, p):
  x = 1

  x = functools.reduce(lambda x, y: (x * y) % p, range(a, b + 1), 1)
  return x

def com(n, r, p):
  fact_div_r = get_mul_inverse(factorial(1, r, p), p)

  _result = factorial(n - r + 1, n, p)
  result = (_result * fact_div_r) % p
  
  return result


n, a, b = [int(i) for i in input().split()]
p = 10**9 + 7


pow_2_n_1 = iterative_square(2, n, p) - 1

_result = pow_2_n_1 - com(n, a, p)

_result = _result - com(n, b, p)

result = _result % p
print(result)

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0) cout << 0 << endl;
  else cout << 1 << endl;
}


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

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

  vector<pair<int, int>> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i].first >> c[i].second;
  }

  bool flag = true;
  sort(c.begin(), c.end());
  for (int i = 0; i < n; i++) {
    if (c[i].second <= T) {
      cout << c[i].first << endl;
      flag = false;
      break;
    }
  }
  if (flag)
  cout << "TLE" << endl;



}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define pb(n) push_back(n)
#define endl '\n'
#define P(x)  cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c; bool flg;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN(s);
  sort(ALL(s));
  if (s[0]=='a' && s[1]=='b' && s[2]=='c') {
    OUT("Yes");
  } else {
    OUT("No");
  }
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    //nの読み込み
    int n;
    scanf("%d",&n);
    //配列aの読み込み
    int i;
    long long int a[n];
    for(i = 0 ; i < n ; i++){
        scanf("%ld",&a[i]);
    }
    //最大値と最小値を調べる
    long long int max,min;
    max = a[0];
    min = a[0];
    for(i = 0 ; i < n ; i++){
        if(a[i] > max){
            max = a[i];
        }
        if(a[i] < min){
            min = a[i];
        }
    }
    //表示
    printf("%ld\n",max - min);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define N 1001
 
int main(void){
        char T[N],P[N];
        int i,j;
        scanf("%s",T);
        scanf("%s",P);
 
        for(i=0;i<(int)strlen(T)-(int)strlen(P)+1;i++){
                for(j=0;j<strlen(P);j++){
                        if(T[i+j]!=P[j]) break;
                }
                if(j==strlen(P)) printf("%d\n",i);
        }
        return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    veci a(M), C(M);
    FORO(i, M) {
        cin >> a[i];
        int b; cin >> b;
        while(b--) {
            int c; cin >> c; c--;
            C[i] |= 1<<c;
        }
    }

    mati dp(M + 1, veci(1<<N, inf));
    dp[0][0] = 0;
    int ans = inf;
    FORO(i, M) {
        for(unsigned s = 0;s < (1<<N);s++) {
            if(dp[i][s] >= inf) continue;
            getMin(dp[i + 1][s], dp[i][s]);
            getMin(dp[i + 1][s | C[i]], dp[i][s] + a[i]);
        }
        getMin(ans, dp[i + 1][(1<<N) - 1]);
    }
    if(ans >= inf) ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19272
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    string S;
    long long ans = 0;
    cin >> N >> S;

    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'R')
        {
            ans += count(S.begin() + i + 1, S.end(), 'B') * count(S.begin() + i+1, S.end(), 'G');
        }
        else if (S[i] == 'B')
        {
            ans += count(S.begin() + i +1, S.end(), 'R') * count(S.begin() + i+1, S.end(), 'G');
        }
        else if (S[i] == 'G')
        {
            ans += count(S.begin() + i +1, S.end(), 'R') * count(S.begin() + i+1, S.end(), 'B');
        }
        int n = 1;
        while (i + n * 2 < N)
        {
            if (S[i] != S[i + n] and S[i] != S[i + n + n] and S[i + n] != S[i + n + n])
            {
                ans -= 1;
            }
            n += 1;
        }
    }
    cout << ans << endl;
}

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

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


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



int main(){
	int A,B;
	cin>>A>>B;
	int ans = 0;
	if(A>B){
		ans+=A;
		A--;
	}
	else{
		ans+=B;
		B--;
	}
	ans+=max(A,B);
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		int[] ax = new int[n];
		int num;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			ax[i] = Math.abs(x[i]);
		}
		int min = Integer.MAX_VALUE;
		for(int i = 0; i <= n - k; i++) {
			num = Math.abs(x[i] - x[i + k - 1]) + Math.min(ax[i], ax[i + k - 1]);
			if(min > num) {
				min = num;
			}
		}
		System.out.println(min);
	}

}

Measured memory_bytes: 60964
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdlib>

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char s[100000];
  cin >> s;
  int n = strlen(s);
  int result[n];
  int move[n];
  fill(result, result + n, 0);

  int cur_first = 0;
  for(int i = 1; i < n; i++) {
    if(s[i] != s[i - 1]) {
      for(int j = cur_first; j < i; j++) {
        if(s[i - 1] == 'L') {
          move[j] = cur_first;
        } else {
          move[j] = i;
        }
      }
      cur_first = i;
    }
  }
  for(int j = cur_first; j < n; j++) {
    move[j] = cur_first;
  }

  for(int i = 0; i < n; i++) {
    if(abs(i - move[i]) % 2 == 0) {
      result[move[i]] += 1;
    } else {
      result[move[i] - 1] += 1;
    }
  }

  for(int i = 0; i < n; i++) {
    cout << result[i] << " ";
  }

  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
bool edge[3030][3030]; 
ll a[3030][3030];
int n;
ll ans;
bool flag;
int main()
{
	cin>>n;
	REP(i,n)
		REP(j,n)
			cin>>a[i][j];
	REP(i,n)
		REP(j,n)
			REP(k,n)
			{
				if(i==j||i==k||j==k)continue;
				if(a[i][j]==a[i][k]+a[k][j])
                    edge[i][j]=1; 
                if(a[i][j]>a[i][k]+a[k][j])
                    flag=1;
			 } 
	if(flag){
		cout<<-1<<endl;
		return 0;
	}
	REP(i,n)
		REP(j,n)
			if(!edge[i][j])ans+=a[i][j];
	cout<<ans/2<<endl;		
	return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
long long MAX = 1e18;
int main()
{
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
	int n; cin >> n;
	long long ans = 1;
	
	vector<long long> v(n);
	for(int i=0 ; i < n ; i++){
		cin >> v[i];
		if(v[i] == 0 ) {
			cout<< 0 ; return 0;
		}
	}

	for(int i = 0 ; i < n ; i++){
		long long t = v[i];
		if( t <= MAX / ans) ans *= t;
		else{
			cout<< -1; return 0;	
		}	
	}    
	cout<<ans;

  return 0;
}


Measured memory_bytes: 3968