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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll N,M,L;
  cin>>N>>M>>L;
  vector<vector<ll>> g(N,vector<ll>(N,INF));
  rep(i,M){
    ll A,B,C;
    cin>>A>>B>>C;
    A--;
    B--;
    g[A][B] = C;
    g[B][A] = C;
  }
  rep(k,N){
    rep(i,N){
      rep(j,N) chmin(g[i][j],g[i][k]+g[k][j]);
    }
  }
  graph m(N);
  rep(i,N){
    rep(j,N){
      if(g[i][j]<=L) m[i].push_back(j);
    }
  }
  vector<vector<ll>> ans(N,vector<ll>(N,-1));
  rep(i,N){
    queue<ll> bfs;
    bfs.push(i);
    ans[i][i] = 0;
    while(!bfs.empty()){
      ll t = bfs.front();
      bfs.pop();
      for(auto nx:m[t]){
        if(ans[i][nx] != -1) continue;
        ans[i][nx] = ans[i][t] + 1;
        bfs.push(nx); 
      }
    }
  }
  ll Q;
  cin>>Q;
  rep(i,Q){
    ll s,t;
    cin>>s>>t;
    s--;
    t--;
    if(ans[s][t]==-1) cout<<ans[s][t]<<endl;
    else cout<<ans[s][t]-1<<endl;
  }
}

Measured memory_bytes: 6204
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author c0117321c5
 */
public class Main{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int sum = 0;
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        for (int i = 0; i <= 2; i++) {
            if (S.charAt(i)==T.charAt(i)) {
                sum++;
            }
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

//unionFind
class unionFind {
private:
	int* p;   //親配列のポインタ
	int* rank;
	int N;   //要素数
	int* check;   //同値な要素の数
public:
	unionFind(int);   //コンストラクタ
	int parent(int);   //親要素を返す
	void unit(int, int);   //2要素をつなぐ
	int operator[](int);   //parentの省略形
	~unionFind();
	int size(int n);   //頂点nと同値な要素数を返す
};

unionFind::unionFind(int n) {
	N = n;
	p = new int[N];
	rank = new int[N];
	for (int i = 0; i < N; i++) {
		p[i] = i;
		rank[i] = 0;
	}
	check = new int[N];
	for (int n = 0; n < N; n++)check[n] = 1;
	return;
}

int unionFind::parent(int n) {
	if (n < 0 || n >= N)return -1;
	if (p[n] == n)return n;   //自分が一番上の親
	return p[n] = parent(p[n]);   //つなぎ直しと上にたどる操作
}

int unionFind::operator[](int n) {
	return parent(n);
}

void unionFind::unit(int x, int y) {
	x = parent(x), y = parent(y);
	if (x == y)return;   //根が同じだから何もせずに帰る
	int sum = check[x] + check[y];
	if (rank[x] < rank[y])p[x] = y;
	else {
		p[y] = x;
		if (rank[x] == rank[y])rank[x]++;
	}
	check[x] = sum;
	check[y] = sum;
	return;
}

unionFind::~unionFind() {
	delete(p);
	delete(rank);
	delete(check);
	return;
}

int unionFind::size(int n) {
	return check[parent(n)];
}

ll N, M;
vector<pll> A;   //中身、添え字

int main() {
	cin >> N >> M;
	A.resize(N);
	for (ll n = 0; n < N; n++) {
		cin >> A[n].first;
		A[n].second = n;
	}
	unionFind UF(N);
	for (ll m = 0; m < M; m++) {
		ll x, y;
		cin >> x >> y;
		UF.unit(x, y);
	}
	vector<pll> mincheck(N,pll(1e9+1,-1));
	for (ll n = 0; n < N; n++) {
		ll p = UF[n];
		if (mincheck[p].first >= A[n].first) {
			mincheck[p] = A[n];
		}
	}
	ll ans = 0;
	ll root = 0;
	for (ll n = 0; n < N; n++) {
		if (mincheck[n].first != 1e9 + 1) {
			ans += mincheck[n].first;
			A[mincheck[n].second].first = 1e9 + 1;
		}
		else root++;
	}
	root = N - root;
	if (2 * root - 2 > N) {
		cout << "Impossible" << endl;
		return 0;
	}
	else if (root == 1) {
		cout << 0 << endl;
		return 0;
	}
	sort(A.begin(), A.end(), [](pll a, pll b) {
		return a.first < b.first;
	});
	for (ll n = 0; n < root-2; n++) {
		ans += A[n].first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using ipair = pair<int,int>;

int main(){
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double PI = 3.141592653589;

    double move_z = 30*H + M/2;
    double move_h = M*6;
    while(move_z>=360) move_z -=360;
    double rad = abs(move_z-move_h)*PI/180;
    double ans = A*A+B*B-2*A*B*cos(rad);
    cout << std::setprecision(12) << sqrt(ans) << endl;


}

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

int main() {
	int R, G;
	cin >> R >> G;
	cout << R + (G - R) * 2;
	return 0;
}
// 次のコンテストをSとして、(R+S)/2=Gである
// 変形するとR+S=2G S=2G - R

Measured memory_bytes: 256
N = int(input())
ans = [0] * (N + 1)
m = int(N**0.5)
for x in range(1, m + 1):
    for y in range(1, m + 1):
        for z in range(1, m + 1):
            n = x * x + y * y + z * z + x * y + y * z + z * x
            if n <= N:
                ans[n] += 1
for i in range(1, N + 1):
    print(ans[i])


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int bounce, max;
    
    cin >> bounce >> max;
    
    int distance[bounce];
    for(int i = 0; i < bounce; i++) cin >> distance[i];
    int total = 0;
    int cnt = 1;
    
    for(int i = 0; i < bounce; i++){
        if(total + distance[i] <= max){
            total += distance[i];
            cnt++;
        }
        else break;
    }
    
    printf("%d", cnt);
    
	return 0;
}


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

int main(){
    int n, k;
    std::cin >> n >> k;
    std::vector<bool> bad(10, false);
    for(int i = 0; i < k; i++){
        int tmp;
        std::cin >> tmp;
        bad[tmp] = true;
    }

    int minGood = 9, nonzerominGood = 9, maxGood = 0;
    for(int i = 0; i < 10; i++){
        if(!bad[i]){
            minGood = std::min(minGood, i);
            nonzerominGood = std::max(1, minGood);
            maxGood = std::max(maxGood, i);
        }
    }

    int keta = 0;
    int tmp = n;
    int base = 1;
    int maxGoodVal = 0;
    std::vector<int> ketaVal;
    while(tmp > 0){
        keta++;
        maxGoodVal += maxGood * base;
        ketaVal.push_back(tmp % 10);
        tmp /= 10;
        base *= 10;
    }

    int pay = 0;

    // nと同じ桁で実現できるか？
    if(maxGoodVal >= n){
        // 上位の桁から順に決める
        base /= 10;
        while(keta > 0){
            int now = ketaVal[keta - 1] % 10;
            int i;
            for(i = now; i < 10; i++){
                if(!bad[i]) break;
            }

            if(i == 10 || pay >= n){
                pay += minGood * base;
            }else{
                pay += i * base;
            }

            base /= 10;
            keta--;
        }
    }else{
        pay += nonzerominGood * base;
        base /= 10;

        while(keta > 0){
            pay += minGood * base;
            base /= 10;
            keta--;
        }
    }

    std::cout << pay << std::endl;

    return 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n; cin >> n;
    int a; cin >> a;
    cout << n*n - a << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#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;
typedef pair<dd,dd> d_d;
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);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////

int main(){fastio
    ll n,m;cin>>n>>m;
    ll dp[m+1][n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][1][1]=1;
    rep(i,0,m-1){
        rep(j,0,n){
            rep(k,0,n){
                if(k+1<=n)Add(dp[i+1][j][k+1],dp[i][j][k]*(n-k));
                Add(dp[i+1][j][k],dp[i][j][k]*(k-j));
                Add(dp[i+1][k][k],dp[i][j][k]*j);
            }
        }
    }
    cout<<mod(dp[m][n][n])<<endl;
    
    return 0;
}


Measured memory_bytes: 213248
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int, int> P;
const int MAX_N = 100010;

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

	int n, r, l;
	cin >> n >> r >> l;

	int score[MAX_N] = {};
	int time_[MAX_N] = {};
	int id = 0;
	int top = 0;
	int now = 0;
	int timemax = 0;
	int tmid = 0;
	for(int i = 0; i < r; ++i){
		int d, t, x;
		cin >> d >> t >> x;
		--d;
		time_[id] += t - now;
		if(timemax < time_[id] || (timemax == time_[id] && id < tmid)){
			timemax = time_[id];
			tmid = id;
		}
		now = t;
		score[d] += x;
		if(id == d){
			top += x;
		}
		if(x < 0 && id == d){
			for(int j = 0; j < n; ++j){
				if(top < score[j] || (top == score[j] && j < id)){
					top = score[j];
					id = j;
				}
			}
		}
		if(x > 0 && id != d){
			if(top < score[d] || (top == score[d] && d < id)){
				top = score[d];
				id = d;
			}
		}
	}
	time_[id] += l - now;

	if(timemax < time_[id] || (timemax == time_[id] && id < tmid)){
		timemax = time_[id];
		tmid = id;
	}

	cout << tmid + 1 << endl;

	return 0;
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
priority_queue<double,vector<double>,greater<double>> pq;
for (int i = 0;i < N;i++) {
    double a;
    cin >> a;
    pq.push(a);
}
double ans = 0;
while (!pq.empty()) {
    double b,c;
    b = pq.top();
    pq.pop();
    if (pq.empty()) break;
    c = pq.top();
    pq.pop();
    ans = (b+c)/2;
    pq.push(ans);
}

cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
N = int(input())
cnt,lcnt = 0,0

for i in range(1,N+1,2):
	for j in range(1,i+1):
		if i%j == 0:
			cnt += 1
			if cnt == 8:
				lcnt += 1
				cnt = 0
	cnt = 0
print(lcnt)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
//g++ -std=c++11
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define ii pair <int, int>
#define vii vector <ii> ;
#define INF 1e9+1
typedef long long ll;
#define MOD 1000000007;

int main() {

    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    string s;
    cin >> s;
    
    if(s.size() <= n) {
        cout << s;
    }
    else {
        for (int i=0; i<n; i++) {
            cout << s[i];
        }
        cout << "...";
    }
    
    
    cout << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
const int maxn=50+10;
ll dp[maxn][maxn*maxn],sum[maxn];
int a[maxn];
int main(){
	int N,A;
	scanf("%d%d",&N,&A);
	dp[0][0]=1;
	for(int i=1;i<=N;i++){
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
		
	for(int i=1;i<=N;i++)
		for(int j=i;j>=1;j--){
			for(int k=sum[i];k>=1;k--){
				/*if(i==2 && j==2 && k==7)
					cout<<endl;*/
				if(k>=a[i])
					dp[j][k]+=dp[j-1][k-a[i]];
				//cout<<i<<' '<<j<<' '<<k<<':'<<dp[j][k]<<endl;
			}
		}
			
	ll ans=0;
	for(int i=1;i<=N;i++)
		ans+=dp[i][i*A];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4420
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 100000

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

    if ((7 == X) || (5 == X) || (3 == X)){
        cout << "YES" << "\n";
    }
    else{
        cout << "NO" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-3;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define CHECK cout<<"arrived"<<endl

ll N; vec d;
const int K=100;
ll x[K];

void keta(ll a, ll MID){
    if(!a) return;
    if(x[a]>MID) {
        x[a]=1;
        x[a-1]++;
        keta(a-1,MID);
    }
    return;
}
ll Solve(){
    bool UP=true;
    rep(i,N-1) if(d[i+1]<=d[i]) UP=false;
    if(UP) return 1;
    rep(i,N) if(d[i]>K-30) d[i]=K;
    ll NG=1, OK=N;
    while(OK>NG+1){
        ll MID=(NG+OK)/2;
        rep(i,K) {
            if(i<d[0]) x[i]=1;
            else x[i]=0;
        }
        REP(i,1,N){
            if(d[i]>d[i-1]) REP(j,d[i-1],d[i]) x[j]=1;
            else{
                if(d[i]<d[i-1]) REP(j,d[i],d[i-1]) x[j]=0;
                x[d[i]-1]++;
                keta(d[i]-1,MID);
            }
            /*if(MID==2 && i>=187731-K && i<187735){
                cout<<d[i]<<';';
                rep(i,K) cout<<x[i];
                cout<<endl;
            }*/
        }
        /*cout<<MID<<';';
        rep(i,K) cout<<x[i];
        cout<<endl;*/
        if(x[0]>MID) NG=MID;
        else OK=MID;
    }
    return OK;

}

void input(){
    cin>>N;
    rep(i,N){
        ll x; cin>>x;
        d.pb(x);
    }
}
int main(){
    /*N=199999;
    rep(i,187731) d.pb(187731-i);
    rep(i,N-187731) d.pb(187731-i);*/
    input();
    cout<<Solve()<<endl;
    

}

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    if(N%2 ==1){
        cout << "No" << endl;
        return 0;
    }
    for(int i =0; i < N/2; i++){
        if(s[i] != s[i + N/2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Author : Vidish Joshi
*/

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

//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#define ll long long int
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define FOR1(i, m, n) for(i=m; i<n; i++)
#define FOR2(i, n, m) for(i=n-1; i>=m; i--)
#define re(v) ll v; cin>>v
#define mod 1000000007
#define mod2 998244353
#define mp make_pair
#define pb push_back
#define fill(a) memset(a, 0, sizeof(a))
#define start ll t; cin>>t; while(t--)
#define start1 ll t = 1; while(t--)
#define F first
#define S second
#define br "\n"

void solve(){
    int n, k; cin>>n>>k;
    int a[n+k+1];

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

    int dp[n+k+1];
    for(int i=n; i<n+k+1; i++) dp[i] = -1e4, a[i] = -1e4;
    for(int i=0; i<n; i++) dp[i] = INT_MAX;

    dp[n-1] = 0;
    for(int i=n-2; i>=0; i--){
        for(int j=1; j<=k&&i+j<n; j++) dp[i] = min(dp[i], abs(a[i] - a[i+j]) + dp[i+j]);
    }


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

    // cout<<br;
    cout<<dp[0]<<br;

}

int main(){
    FIO;
    start1{
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int r; cin >> r;
    cout << r * r * 3 << endl;


    return 0;
}

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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  int M = 10000000;
  for (int bit = 0; bit < (1<<n); bit++) {
    vector<int> b(n, 0);
    for (int i = 0; i < n; i++) {
      if (bit & (1<<i)) {
        b[i] = 1;
      }
    }
    vector<int> abi(m, 0);
    int mon = 0;
    for (int i = 0; i < n; i++) {
      if (b[i] == 1) {
        mon += c[i];
        for (int j = 0; j < m; j++) {
          abi[j] += a[i][j];
        }
      }
    }
    bool f = 1;
    for (int i = 0; i < m; i++) {
      if (abi[i] < x) {
        f = 0;
        break;
      }
    }
    if (f) M = min(M, mon);
  }
  if (M == 10000000) cout << -1 <<endl;
  else cout << M <<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin >> c;
  a = "ABC";
  b = "ARC";
  if(c == a) {
    cout << b << endl;
  }
  if(c == b) {
    cout << a << endl;
  }
}


Measured memory_bytes: 3636
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(l[k - 1])

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    vector<int> v1;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        v1.push_back(a);
    }
    sort(v1.begin(),v1.end());
    a=0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(k=j+1;k<n;k++){
                if(v1[i]==v1[j] || v1[j]==v1[k])continue;
                if(v1[i]+v1[j]>v1[k])a++;
            }
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

signed main()
{
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);

  int A = a * b;
  int B = c * d;

  if( A >= B ) printf("%d\n",A);
  else printf("%d\n",B);

  return 0;


}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
bool pal(string s){
	for(int i = 0; i < s.size() / 2; i++){
		if(s[i] != s[s.size() - i - 1]) return false;
	}
	return true;
}
int main(){
	string s;
	cin >> s;
	int n = s.size();
	string f = s.substr(0, (n - 1) / 2);
	string sec = s.substr(((n + 3) / 2 - 1), n - ((n + 3) / 2 - 1));
//	cout << f << " " << sec << endl;
	if(pal(s) && pal(f) && pal(sec)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
        t: [Usize1; d],
    };
    let mut last = vec![0; 26];
    let mut score = 0;
    for (i, &t_i) in t.iter().enumerate() {
        let d_i = i as i64 + 1;
        last[t_i] = d_i;
        score += s[i][t_i];
        for i in 0..26 {
            score -= c[i] * (d_i - last[i]);
        }
        println!("{}", score);
    }
}


Measured memory_bytes: 2312
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == s[i+1])
		{
			cout << "Bad" << endl;
			return;
		}
	}
	cout << "Good" << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


Measured memory_bytes: 256
N,M = [int(i) for i in input().split()]
li = [0]*N
for i in range(N):
    li[i] = [int(j) for j in input().split()]
li.sort()
ans = 0
for i in range(N):
    if M - li[i][1] > 0:
        M -= li[i][1]
        ans += li[i][0]*li[i][1]
    else:
        ans += li[i][0]*M
        print(ans)
        exit()

Measured memory_bytes: 21616
from collections import Counter
 
n = int(input())
s = input()
try:
  x, y, z = Counter(s).values()
  print(x * y * z - sum(s[i] != s[(i + j) // 2] != s[j] != s[i]
                        for i in range(n) for j in range(i + 2, n, 2)))
except ValueError:
  print(0)


Measured memory_bytes: 9408
#include <iostream>
using namespace std;
int main(){
    int a,b,c,r[100];
    cin>>a>>b>>c;
    for(int i=0;i<b;i++){
        r[i]=a*(i+1)%b;
    }
    for(int i=0;i<b;i++){
        if(r[i]==c){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}

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

int main(){
  int i, n, j ,ice[10], k;
  while(scanf("%d", &n) && n){
    memset(ice, 0, sizeof(ice));
    for(i = 0; i < n; ++i){
      scanf("%d", &k);
      ice[k]++;
    }

    for(i = 0; i < 10; ++i){
      if(ice[i] == 0) putchar('-');
      for(j = 0; j < ice[i]; ++j) putchar('*');
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 588
#include <iostream>
const int MAXN=100;
const int MAXK=100;
int A[MAXN][MAXK];//お菓子を持っているかフラグ

using namespace std;
int main() {
    int N,K;
    cin>>N>>K;
    int d[K];//iのお菓子を持っている人数
    int count =0;
    for(int i =0;i<K;i++)
    {
      cin>>d[i];
      //cout<<d[i]<<endl;
      for(int t=0;t<d[i];t++)
      {
        int num=0;
        cin>>num;
        //cout<<num-1<<endl;
        A[num-1][i]=1;
      }
    }
    for(int t=0;t<N;t++)
      {
        bool flg =true;
        for(int i =0;i<K;i++)
    	{
          //cout<<i+1<<"種類目のお菓子"<<endl;
          //cout<<t+1<<"人目:"<<A[i][t]<<endl;      
          if(A[t][i]==1)flg=false;      
        }
        if(flg)count++;
      }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(void)
{
   int n, i, a[100], s;
   s=1;
   scanf("%d",&n);

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

   for(i=0;i<n-1;i++){
        if (a[i]<=a[i+1]) s=s+1;
        else if (a[i]>a[i+1]) a[i+1]=a[i];
   }
   printf("%d\n",s);
   return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
const int MAXN=100005;

LL a[65],bin[65],temp;
void add(LL u)
{	
	for(int i=62;i>=0;i--)
	{
		if(!(temp&bin[i])&&(u&bin[i]))
		{
			if(!a[i]){a[i]=u;return ;}
			else u^=a[i];
		}
	}
	for(int i=62;i>=0;i--)
	{
		if((temp&bin[i])&&(u&bin[i]))
		{
			if(!a[i]){a[i]=u;return ;}
			else u^=a[i];
		}
	}
}
int n;
bool vis[65];
LL b[MAXN];
int main()
{
//	freopen("a.in","r",stdin);
	bin[0]=1;for(int i=1;i<65;i++)bin[i]=bin[i-1]<<1;
	n=read();
	for(int i=1;i<=n;i++)
	{
		b[i]=read();temp^=b[i];
//		add(x);
	}
	for(int i=1;i<=n;i++)add(b[i]);
	LL x1=0;
	for(int i=62;i>=0;i--)
	{
		if(!(temp&bin[i]))
		{
			if(x1&bin[i])continue;
			x1^=a[i];
		}
	} 
	for(int i=62;i>=0;i--)
	{
		if(temp&bin[i])
		{
			x1=min(x1,x1^a[i]);
		}
	}
	pr2(x1+(temp^x1));
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int a, b;
	while(cin >> a, a){
		vector<int> n(a);
		int suma = 0, sumb = 0;
		rep(i, a-1){cin >> n[i]; suma += n[i];}
		n[a-1] = 360-suma;
		cin >> b;
		vector<int> m(b);
		rep(i, b-1){cin >> m[i]; sumb += m[i];}
		m[b-1] = 360-sumb;

		double p=0., q = 0.;
		rep(i, a) p += sin(n[i] * M_PI / 180);
		rep(i, b) q += sin(m[i] * M_PI / 180);


		if(abs(p-q) < eps) cout << 0 << endl;
		else if(p > q) cout << 1 << endl;
		else cout << 2 << endl;
	}
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#include <map>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<int,int>;
const ll M = 1e9+7, mx = 1000000;
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; void chmax(ll& x, ll y) {if (x<y) x=y;}; void chmin(ll& x, ll y) {if (x>y) x=y;};

int main() {
  int n; cin>>n;
  int an = 360;
  for(int i=1;i<=360;i++) {
    if (n*i%360==0) an=min(an,i);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
using namespace std;
int n = 10000000;
int kansuu(int num,int nokori,int kaisuu)
{
	int a, b, c, d;
	if (nokori==0)
	{
		n = min(n, kaisuu);
		return 0;
	}
	if (num==0)
	{
		a = 1;
		while (a*9<=nokori)
		{
			a *= 9;
		}
		if (nokori-a<=5)
		{
			n = min(n, kaisuu+1+nokori-a);
			return 0;
		}
		kansuu(0, nokori - a, kaisuu + 1);
		kansuu(1, nokori - a, kaisuu + 1);
	}
	else if (num == 1)
	{
		a = 1;
		while (a * 6 <= nokori)
		{
			a *= 6;
		}
		if (nokori - a <= 5)
		{
			n = min(n, kaisuu + 1 + nokori - a);
			return 0;
		}
		kansuu(0, nokori - a, kaisuu + 1);
		kansuu(1, nokori - a, kaisuu + 1);
	}
	return 0;



}


int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];

	cin >> a;
	//while (a != 0)
	//{
	//	b = 1;
	//	while (b * 6 <= a)
	//	{
	//		b *= 6;
	//	}
	//	c = 1;
	//	while (c * 9 <= a)
	//	{
	//		c *= 9;
	//	}
	//	d = max(b, c);
	//	a -= d;
	//	cout << a << endl;

	//	ans++;
	//}
	

	kansuu(0, a,0);
	kansuu(1, a, 0);
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, temp, count;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			uint64 t = mask;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			while (~map[t].first) {
				--t;
			}
			while (++t <= (mask >> 1)) {
				mkey = map[t];
				map[t].first = ~static_cast<std::uint_fast64_t>(0);
				temp = mask&hash64(mkey.first);
				while (~map[temp].first) {
					temp = mask&(temp + 1);
				}
				map[temp] = mkey;
			}
			for (t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<std::uint_fast64_t>(0);
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

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

	hashmap64<uint32> map(1);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";

	
	return 0;
}

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

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>> a(H+2, vector<char>(W+2));

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>a[i][j];
        }
    }

    for(int i=0;i<H+2;i++){
        a[i][0] = '#';
        a[i][W+1] = '#';
    }
    for(int i=0;i<W+2;i++){
        a[0][i] = '#';
        a[H+1][i] = '#';
    }

    for(int i=0;i<=H+1;i++){
        for(int j=0;j<=W+1;j++){
            cout<<a[i][j];
        }
        cout<<"\n";
    }
 return 0;
}

Measured memory_bytes: 256
// AOJ 0599: IOI Manju
// 2017.12.5 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int p[10002], c[502], e[502], s[10002];
int dp[10002];

char buf[20], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	bp++;
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int m, n, i, j, ii, ans;

	fgets(bp=buf, 20, stdin);
	m = getint(), n = getint();
	for (i = 0; i < m; i++) fgets(bp=buf, 20, stdin), p[i] = getint();
	for (i = 0; i < n; i++) {
		fgets(bp=buf, 20, stdin);
		c[i] = getint(), e[i] = getint();
	}

	qsort(p, m, sizeof(int), cmp);
	for (s[0] = 0, i = 0; i < m; i++) s[i+1] = s[i] + p[i];

	memset(dp, 0x55, sizeof(dp));
	dp[0] = 0;
	for (i = 0; i < n; i++) for (j = m; j >= 0; j--) {
		ii = 0; if (j > c[i]) ii = j - c[i];
		if (dp[j] > dp[ii] + e[i]) dp[j] = dp[ii] + e[i];
	}

	ans = 0;
	for (i = 0; i <= m; i++) if (ans < s[i] - dp[i]) ans = s[i] - dp[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1988
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
class LargeNumber {
private:
	bool is_prime[1000000 + 13];// Up to 3e5 + 1
	vector<long long> Prime_table;
public:
	vector<long long> Eratosthenes(const long long N = 1000007) { // return primes up to N
		for (int i = 0; i <= N; i++)
		{
			is_prime[i] = true;
		}
		for (int i = 2; i <= N; i++)
		{
			if (is_prime[i])
			{
				for (int j = 2 * i; j <= N; j += i)
				{
					is_prime[j] = false;
				}
				Prime_table.emplace_back(i);
			}
		}
		return Prime_table;
	}

	template<typename T>
	map<T, T> Factorization(T N) const {
		map<T, T> mp;
		if (N == 1) {
			return mp;
		}

		for (int i = 0; i < Prime_table.size(); i++) {
			while (N % Prime_table[i] == 0) {
				mp[Prime_table[i]]++;
				N /= Prime_table[i];
			}
		}

		if (N > 1) mp[N]++;

		return mp;
	}


	bool isPrime(long long x) {
		if (x == 0 || x == 1) {
			return false;
		}
		return is_prime[x];
	}
};

int main() {
	ll N; cin >> N;
	LargeNumber lg; lg.Eratosthenes();

	map<ll, ll> mp = lg.Factorization(N);

	ll cnt = 0;
	for (auto iter = mp.begin(); iter != mp.end(); iter++) {
		ll val = iter->second;
		ll temp = 0;
		while (temp * (temp + 1) / 2 < val) {
			temp++;
		}

		if (temp * (temp + 1)  / 2> val) {
			cnt += temp - 1;
		}
		else {
			cnt += temp;
		}
	}

	cout << cnt << endl;
	sysp;
}

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

#define int long long
#define itn __int32_t
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<(T)>())
#define REVERCE(x) reverce(ALL(x))

itn main() {
	ios::sync_with_stdio(false);

	int n, m;

	cin >> n >> m;

	vector<int> box(n, 100000000);

	struct key {
		itn plice;
		itn kindValue;
		itn kind;
	};

	vector<key> keys(m);
	int kind_part;

	for (int i = 0; i < keys.size(); i++) {
		cin >> keys[i].plice >> keys[i].kindValue;
		for (int j = 0; j < keys[i].kindValue; j++) {
			cin >> kind_part;
			keys[i].kind |= 1 << (kind_part - 1);
		}
	}

	vector<vector<itn>> dp(m + 1);

	REP(i, dp.size()) {
		dp[i].resize(pow(2, n), pow(2, 30));
	}

	dp[0][0] = 0;

	REP2(i, 1, dp.size()) {
		REP(j, dp[i].size())dp[i][j] = dp[i - 1][j];
		REP(j, dp[i].size()) {
			dp[i][j | keys[i - 1].kind] = min(dp[i - 1][j] + keys[i - 1].plice, dp[i][j | keys[i - 1].kind]);
		}
	}

	if (dp[m][pow(2, n) - 1] == pow(2, 30)) {
		cout << -1;
	}
	else {
		cout << dp[m][pow(2, n) - 1];
	}

	return 0;
}

Measured memory_bytes: 16384
#include <iostream>
#include <map>
typedef long long ll;

using namespace std;

const int mod = 1e9 + 7;
ll N;
map <ll,ll> M;


ll solve (ll n) {
  if(M[n]) return M[n];

  return M[n] = ((solve(n/2) + solve((n-1)/2)) % mod + solve((n-2)/2))%  mod;
}

int main() {
  cin >> N;
  M[0] = 1;
  M[1] = 2;
  cout << solve(N)<<endl;
  return 0;
}

  
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 200005
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define MAXN 100005
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
vector<int> v[105];
int match[105];
int vis[105];
bool dfs(int a){
	for(auto it:v[a]){
		if(!vis[it]){
			vis[it]=1;
			if(match[it]==-1||dfs(match[it])){
				match[it]=a;
				return true;
			}
		}
	}
	return false;
}
int max_match(int n){
	int cnt=0;
	MEMS(match);
	for(int i=0;i<n;i++){
		MEM(vis);
		if(dfs(i))
			cnt++;
	}
	return cnt;
}
int main(){
	int n;
	scanf("%d",&n);
	pii r[105],b[105];
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		r[i]=mp(x,y);
	}
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		b[i]=mp(x,y);
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			if(r[i].x<b[j].x&&r[i].y<b[j].y)
				v[i].pb(j);
		}
	printf("%d\n",max_match(n));
}
/*
BC
ACC
AABC
CC
ABC
AACC*/

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() 
{
	int x, h;
	double S;
	while (1) {
		cin >> x;
		cin >> h;
		if (x == 0 && h == 0) {
			break;
		}
		S = x * x + 4 * 0.5 * x * sqrt(x * 0.5 * x * 0.5 + h * h);
		cout << fixed << setprecision(6) << S << endl;
	}
	return 0;
}


Measured memory_bytes: 3284
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 100010;
const int MAXK = 20;

int n, x;
int a[MAXN];

int main()
{
	
	int x, a;
	cin >> x >> a;
	puts(x < a ? "0" : "10");
	
	return 0;
}


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

int n,ans;
char s[100100];
int main()
{
	scanf("%s",s); ans=n=strlen(s);
	for (int i=1;i<n;i++)
		if (s[i]!=s[i-1])
			ans=min(ans,max(i,n-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9 + 7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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

using pll = pair<long long, long long>;

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

	ll N;
	cin >> N;

	vector<ll> vA(N, 0);
	rep(i, N) cin >> vA[i];

	ll total = 0;
	rep(i, N) total += vA[i];

	ll total2 = 0;
	rep(i, N) {
		total2 += vA[i];
		if (total2 * 2 >= total) {
			break;
		}
	}

	ll total3 = 0;
	for (int i = N-1; i >=0; --i) {
		total3 += vA[i];
		if (total3 * 2 >= total) {
			break;
		}
	}
	ll ans = min((total2 * 2 - total), (total3 * 2 - total));
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void) {
	int N, a, b;
	int num, i;

	scanf("%d", &N);

	if (N % 2 == 0) {
		num = N / 2 - 1;
	}
	else {
		num = (N - 1) / 2;
	}
	printf("%d", num);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=200005;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch&15);ch=getchar();}
	return x*f;
}

int n,m,num[N];set<int> a;

int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++) num[i]=1;
	a.insert(1);
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		num[x]--;num[y]++;
		if(a.find(x)!=a.end())//找得到
		{
			a.insert(y);
			if(!num[x]) a.erase(x); 
		} 
			
	}
	printf("%d\n",a.size());
}

Measured memory_bytes: 5376
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>
#define ti3 tuple<ll,ll,ll>

vector<int> g[100001];

int dfs(int p)
{
    if(g[p].size() == 0)
    {
        return 0;
    }
    
    vector<pii> c;
    for(auto e : g[p])
    {
        c.push_back(make_pair(dfs(e) + 1, e));
    }
    sort(c.begin(), c.end(), std::greater<pii>());
    auto m = c[0].first;
    //for(auto e: c)
    {
        //cout << "parent: " << p << ", child depth:" << e.first << "," << e.second << endl;
    }
    for(int i = 1;i < c.size();i++)
    {
        m = max(m, c[i].first + i);
    }
    return m;
}

int main()
{
    ll n;
    cin >> n;
    
    for(int i = 2;i <= n;i++)
    {
        ll a;
        cin >> a;
        g[a].push_back(i);
    }
    ll r = dfs(1);
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 13568
from itertools import accumulate

n = int(input())
W = list(map(int, input().split()))
WR = W[::-1]
ans = 10 ** 20
SW = list(accumulate([0] + W))
SWR = list(accumulate([0] + WR))
for i in range(1, n):
    j = n - i
    temp = abs(SW[i] - SWR[j])
    ans = min(ans, temp)
print(ans)


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

int n;
map<string, int> results;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    results[s]++;
  }
  
  string keys[4] = {"AC", "WA", "TLE", "RE"};
  
  for (int i = 0; i < 4; i++) {
   cout << keys[i] << " x " << results[keys[i]] << "\n"; 
  }

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

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


Measured memory_bytes: 256