akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 85
const int pax = 80 * 80;
int n, m, a[maxn][maxn], b[maxn][maxn], dp[maxn][maxn][maxn * maxn * 2], Ans = inf;
signed main() {
	n = read(), m = read();
	rep(i, 1, n) rep(j, 1, m) a[i][j] = read();
	rep(i, 1, n) rep(j, 1, m) b[i][j] = read();
	dp[1][1][pax - a[1][1] + b[1][1]] = dp[1][1][pax + a[1][1] - b[1][1]] = 1;
	rep(i, 1, n) {
		rep(j, 1, m) {
			rep(k, 0, pax * 2) {
				if(dp[i][j][k] == 0) continue;
				dp[i + 1][j][k + a[i + 1][j] - b[i + 1][j]] = 1;
				dp[i + 1][j][k - a[i + 1][j] + b[i + 1][j]] = 1;
				dp[i][j + 1][k + a[i][j + 1] - b[i][j + 1]] = 1;
				dp[i][j + 1][k - a[i][j + 1] + b[i][j + 1]] = 1;
			}
		}
	}
	rep(k, 0, pax * 2) if(dp[n][m][k] == 1) Ans = min(Ans, abs(k - pax));
	cout << Ans;
	return 0;
}

Measured memory_bytes: 778624
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int H;
    cin >> H;
    
    int Ans=0;
    int now=1;
    while(H>0){
        Ans+=now;
        H=H/2;
        now*=2;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
// 2014/04/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool is_hamming[1000001];

	for(int i=0; i<1000001; i++){
		is_hamming[i] = false;
	}

	for(int i=1; i<1000001; i*=2){
		for(int j=i; j<1000001; j*=3){
			for(int k=j; k<1000001; k*=5){
				is_hamming[k] = true;
			}
		}
	}

	int n_hamming[1000001];

	int cnt = 0;
	for(int i=0; i<1000001; i++){
		if(is_hamming[i]){
			cnt++;
		}
		n_hamming[i] = cnt;
	}

	while(true){
		int m;
		cin >> m;

		if(m==0)
			break;

		int n;
		cin >> n;

		cout << n_hamming[n]-n_hamming[m-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 6040
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long int> k(n);
    vector<long long int> num(n+1, 0);
    vector<long long int> combination(n+1);

    for(int i = 0; i < n; i++){
        cin >> k[i];
        num[k[i]]++;
    }

    //declaring combination set
    long long int total = 0;
    for(int i = 0; i < num.size(); i++){
        combination[i] = (num[i]*(num[i]-1))/2;
        total+=combination[i];
    }

    for(int i = 0; i < k.size(); i++){
        total -= (num[k[i]] - 1);
        cout << total << endl;
        total += (num[k[i]] - 1);
    }
/* 
*/
  
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int n;
char a[110],b[110];
int main()
{
    scanf("%d",&n);
    scanf("%s",a);
    scanf("%s",b);
    for(int i=0;i<n;i++)
    {
        printf("%c%c",a[i],b[i]);
    }
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int T[15];

int get(ll n)
{
    ll min = 12;
    REP(i, 24)
    {
        FOR(j, 24, i + 1)
        {
            if (((n >> i) & 1) == 0 || ((n >> j) & 1) == 0)
                continue;
            min = std::min(min, std::min(j - i, 24 + i - j));
        }
    }
    return min;
}

int solve(ll n = 0, int index = 0)
{
    if (index > 12)
        return get(n);

    if (T[index] == 0)
        return solve(n, index + 1);

    ll n0 = 1 << index;
    ll n1 = 1 << ((24 - index) % 24);
    if (T[index] == 2)
        return solve(n | n0 | n1, index + 1);
    return std::max(solve(n | n0, index + 1), solve(n | n1, index + 1));
}

int main()
{
    int N;
    cin >> N;
    T[0] = 1;
    REP(i, N)
    {
        int d;
        cin >> d;
        T[d]++;
    }

    bool isZero = false;
    REP(i, 13)
    {
        if (T[i] > 2)
            isZero = true;
    }
    if (T[0] > 1 || T[12] > 1)
        isZero = true;

    int ans = 0;
    if (!isZero)
    {
        ans = solve();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
using namespace std;

using cEdges=std::vector<std::vector<int>>;

void strongly_connected_components_helper1(int start,const cEdges& Edges,vector<bool>& Vertices,list<int>& SearchOrderList){
	Vertices[start]=true;

	for(const auto& val:Edges[start]){
		if(!Vertices[val]){
			strongly_connected_components_helper1(val,Edges,Vertices,SearchOrderList);
		}
	}

	SearchOrderList.push_front(start);
}

void strongly_connected_components_helper2(int start,const cEdges& tEdges,vector<bool>& tVertices,vector<int>& scc){
	tVertices[start]=true;
	scc.push_back(start);

	for(const auto& val:tEdges[start]){
		if(!tVertices[val]){
			strongly_connected_components_helper2(val,tEdges,tVertices,scc);
		}
	}
}

vector<vector<int>> strongly_connected_components(const cEdges& Edges){
	if(Edges.empty())return vector<vector<int>>();

	cEdges tEdges(Edges.size(),vector<int>());
	for(int i=0;i<Edges.size();++i){
		for(const auto& val:Edges[i]){
			tEdges[val].push_back(i);
		}
	}

	list<int> SearchOrderList;
	vector<bool> Vertices(Edges.size(),false);
	for(int i=0;i<Vertices.size();++i){
		if(!Vertices[i])strongly_connected_components_helper1(i,Edges,Vertices,SearchOrderList);
	}

	//for(auto& val:Vertices)val=false;
	for(int i=0;i<Vertices.size();++i){
		Vertices[i]=false;
	}
	vector<vector<int>> scc;
	for(const auto& val:SearchOrderList){
		if(!Vertices[val]){
			scc.emplace_back(vector<int>());
			strongly_connected_components_helper2(val,tEdges,Vertices,scc.back());
		}
	}

	return scc;
}


int main() {
	int N,M;
	cin>>N>>M;
	cEdges Edges(N);
	for(int i=0;i<M;++i){
		int u,v,w;
		cin>>u>>v;

		Edges[u].push_back(v);
	}

	auto ans=strongly_connected_components(Edges);

	vector<int> SCC_List(N,-1);
	for(int i=0;i<ans.size();++i){
		for(const auto& val:ans[i]){
			SCC_List[val]=i;
		}
	}
	
	cin>>M;
	for(int i=0;i<M;++i){
		int u,v;
		cin>>u>>v;

		if(SCC_List[u]==SCC_List[v])cout<<1<<"\n";
		else cout<<0<<"\n";
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 50 + 5;
const int maxm = 2500 + 10;
int a[maxn];
ll f[maxm << 1];
int main()
{
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		a[i] -= x;
	}
	f[maxm] = 1;
	for(int i = 1; i <= n; ++i)
		if(a[i] >= 0)
		{
			for(int j = (maxm << 1) - 1; j >= a[i]; --j)
				f[j] += f[j - a[i]];
		}
		else
		{
			for(int j = 0; j < (maxm << 1) + a[i]; ++j)
				f[j] += f[j - a[i]];
		}
	cout << f[maxm] - 1 << endl;
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define llong long long
#define mp make_pair
#define f first
#define s second

using namespace::std;

const int MAXN = 1e5 + 5;

int N;

vector<queue<int> > goals(MAXN);


int COMP = 1;
map<int, int> compress;

map<int, int> elements_a;


int union_count = 0;

struct DSU {
    vector<int> parent;
    vector<int> rank;

    DSU(int n)
    {
        parent.resize(n, 0);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
        rank.resize(n, 0);
    }

    int get_root(int cur)
    {
        /*if (cur == ROOT) {
            return ROOT;
        }*/
        if (parent[cur] == cur) {
            return cur;
        }
        return parent[cur] = get_root(parent[cur]);
    }

    void union_(int u, int v)
    {
        u = get_root(u);
        v = get_root(v);
        if (u == v) {
            return;
        }
        union_count++;
        if (rank[u] < rank[v]) {
            parent[u] = v;
        }
        else {
            parent[v] = u;
            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
};

DSU dsu(MAXN);


int main()
{
    ios::sync_with_stdio(false);
    ifstream fin("input.txt");
    cin >> N;

    vector<int> a(N), b(N);

    int tot = 0;

    int a_tot_cnt = 0;

    for (int i = 0; i < N; i++) {
        cin >> a[i];
        tot ^= a[i];
        elements_a[a[i]]++;

        if (compress.count(a[i]) == 0) {
            compress[a[i]] = COMP;
            COMP++;
        }
        a[i] = compress[a[i]];
    }
    elements_a[tot]++;

    if (compress.count(tot) == 0) {
        compress[tot] = COMP;
        COMP++;
    }
    tot = compress[tot];


    for (int i = 0; i < N; i++) {
        cin >> b[i];
        elements_a[b[i]]--;

        if (elements_a[b[i]] < 0) {
            cout << "-1";
            return 0;
        }

        if (compress.count(b[i]) == 0) {
            compress[b[i]] = COMP;
            COMP++;
        }
        b[i] = compress[b[i]];
    }

    bool tot_exist = -1;

    vector<int> go_to(N, -1);
    int cnt = 0;
    int singles = 0;

    vector<int> visited(MAXN, 0);

    bool statu = 1;

    for (int i = 0; i < N; i++) {
        if (a[i] == b[i]) {
            continue;
        }
        if (b[i] == tot) {
            tot_exist++;
        }
        dsu.union_(a[i], b[i]);
        visited[a[i]] = 1;
        visited[b[i]] = 1;
        statu = 0;
        cnt++;
    }

    if (statu) {
        cout << "0\n";
        return 0;
    }

    for (int i = 0; i < N; i++) {
        if (a[i] == b[i] && visited[a[i]] == 0) {
            singles++;
        }
    }

    //cout << tot_exist << "\n";
    int group_count = COMP - 1 - union_count - singles;
    //cout << cnt << " " << union_count <<  "\n";
    //cout << group_count << "\n";

    cout << cnt + group_count - 1;
}


Measured memory_bytes: 79232
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(tx, ty, w, h) (0 <= tx && tx <= w && 0 <= ty && ty <= h)

/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;

/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}

/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
vi arr;
void in(){
    cin >> n;
    rep(i,0,n) arr.push_back(input());
}

int dfs(int i, bool flag){

    if(i == n) return flag;

    if(arr[i] % 2 == 0) return dfs(i + 1, flag or false) * 2 + dfs(i + 1, true);
    else return dfs(i + 1, true) * 2 + dfs(i + 1, flag or false);

}

void solve(){
    print(dfs(0, false));
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int X,A;cin >> X >> A;
  if(X<A) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
//エラトステネスの篩
//素因数分解

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<list>

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


int main(){

    int mon_sat[300001];
    int prime[300001];
    REP(i,0,300001){
        mon_sat[i]=0;
        prime[i]=0;
    }

    //月曜土曜素数を1にする
    REP(i,1,300001){
        if(i%7==1||i%7==6){
            mon_sat[i]=1;
            prime[i]=1;
        }
    }

    //月曜土曜素数に1を立てた配列
    for(int i=2;i*i<=300000;i++){
        if(mon_sat[i]){
            for(int j=2*i;j<=300000;j+=i){
                prime[j]=0;
            }
        }
    }

	while(1){
        int num;
        list<int> anslist;
        cin >> num;
        if(num==1)break;

        int divisor[300001];
        REP(i,0,num+1){
            divisor[i]=0;
        }

        //numの約数に1を立てた配列
        for(int i=1;i*i<=num;i++){
            if(mon_sat[i]){
                if(num%i==0){
                    divisor[i]=1;
                    if((num/i) == i)continue;
                    divisor[num/i]=1;
                }
            }
        }

        //全ての月曜土曜素因数を列挙
        REP(i,2,num+1){
            if(prime[i] && divisor[i]) anslist.push_back(i);
        }
        
        cout << num << ":";
        
        for(auto x : anslist){
            cout << " " << x;
        }
        cout << endl;
       
    }
}



Measured memory_bytes: 6512
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<ll> a, v;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll tempv, tempa;
        cin >>tempv>>tempa;
        v.push_back(tempv);
        a.push_back(tempa);
    }
    ll nowa=a[0];
    ll nowv=v[0];
    ll sum=nowa+nowv;
    for(int i=1;i<n;i++){
        if(a[i]>=nowa&&v[i]>=nowv){
            nowa=a[i];
            nowv=v[i];
            sum=nowa+nowv;
        }
        else{
            ll b=max((nowa+a[i]-1)/a[i],(nowv+v[i]-1)/v[i]);
            nowa=a[i]*b;
            nowv=v[i]*b;
            sum=nowa+nowv;
        }
    }
    cout << sum << "\n";
}



Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var tmp = input.split("\n");
  var line0 = tmp[0].split(" ");
  //var line1 = tmp[1].split(" ");
  //var line2 = tmp[2].split(" ");
  //var line3 = tmp[3].split(" ");

  var n = Number(line0[0]);
  var ans = "hoge";

  //console.log(n +" "+ " " + " hoge ")

  var count = 0;
  for(var i=1; i<=n; i ){
    //console.log(tmp[i]);
    count++;
    i=tmp[i];
    //console.log( "i="+ i + ", count="+count);

    if(i==2) break;
    if(count == n) {
      count = -1;
      break;
    }

  }  
  console.log(count);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 18148
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;using vci=vector<int>;using vcl=vector<ll>;template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#define f first
#define s second
#define pb emplace_back
#define sz(a) ((int)a.size())
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
#define int ll

const int N=333;
int dp[N][N],suf[N][N];
int c[N][N];
int32_t main() {
    int n,k,m;
    cin>>n>>k>>m;
    for(int i=0;i<N;++i){
        c[i][0]=1;
        for(int j=1;j<=i;++j)c[i][j]=(c[i-1][j]+c[i-1][j-1])%m;
    }

    for(int top=0;top<=k;++top)dp[1][top]=1;
    for(int size=1;size<=n+1;++size){
        for(int top=k;top>=0;--top){
            for(int last=1;last<size;++last){
                dp[size][top]+=((suf[last][top+1]*dp[size-last][top])%m*c[size-2][last-1])%m;
            }
            dp[size][top]%=m;
            suf[size][top]=(suf[size][top+1]+dp[size][top])%m;
            dbg(size,top,dp[size][top],suf[size][top]);
        }
    }
    cout<<dp[n+1][0]<<'\n';

    return 0;
}


Measured memory_bytes: 2688
while True:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split(','))
        p = (x3 - x4) * (y1 - y3) + (y3 - y4) * (x3 - x1)
        q = (x3 - x4) * (y2 - y3) + (y3 - y4) * (x3 - x2)
        r = (x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3)
        s = (x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4)
        if p * q < 0 or r * s < 0:
            print("NO")
        else:
            print("YES")
    except EOFError: break

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

int main() {
    int x;
    cin >> x;
    if(x == 1) {
        cout << 1 << endl;
        return 0;
    }

    int m = 1;

    for(int i = 2; i <= sqrt(x) + 1; i++) {
        int j = 2;
        while(pow(i, j) <= x) {
            m = max((int)pow(i, j),m);
            j++;
        }
    }

    cout << m << endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int x;
    cin >> x;
    vector<bool> beki(10000);
    beki[1] = true;
    for(int i=2; i<=1000; i++){
        for(int j=2; pow(i,j) <= 1000; j++){
            beki[pow(i,j)] = true;
        }
    }
    for(int i=x; i>=0; i--){
        if(beki[i]){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}


void main() {
    LL n;
    R(n);
    LL sum=0;
    for ( LL i=1; i*i<=n; i++ ) {
        if ( n%i==0 ) {
            if ( n/i-1>i ) sum+=n/i-1;
        }
    }
    W(sum);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3828
#include<iostream>
#define N 10000
using namespace std;
int n,d[N],q,s,ans,f;

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>d[i];
  cin>>q;
  while(q--){
    cin>>s;
    f=0;
    for(int i=0;i<n;i++)
      if(d[i]==s)f=1;
    if(f)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

        int yoko = Integer.parseInt(scan.next());
		int a = Integer.parseInt(scan.next());

		int sum = 0;

		if(yoko - 2*a> 0) {
			sum = yoko - 2*a;
		}

		scan.close();
		System.out.println(sum);

	}

}



Measured memory_bytes: 23892
//
//  main.cpp
//  atCoder
//
//  Created by 佐々木勇星 on 2019/07/23.
//  Copyright © 2019 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <regex>


int main(void) {
    
    using namespace std;
    
    int A[4], l, i = 0;
    
    while(cin>>l){
        A[i] = l;
        //cout << A[i] << endl;
        i++;
        
    }
    
    if(A[0] != A[2]){
        cout << 1 << endl;;
    } else {
        cout << 0 << endl;;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    int slen = S.length();
    int tlen = T.length();
    VI accs(slen+1);
    VI acct(tlen+1);
    REP(i,slen){
        accs[i+1] = accs[i] + (S[i] == 'A' ? 1 : 2);
    }
    REP(i,tlen){
        acct[i+1] = acct[i] + (T[i] == 'A' ? 1 : 2);
    }

    int q; cin >> q;
    REP(i,q){
        int a,b,c,d; cin >> a >> b >> c >> d;
        if(((accs[b]- accs[a-1]) - (acct[d]-acct[c-1])) % 3 == 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

}


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

const int mod = 998244353;

const int max_N = 305;

using LL = long long;

int n, K, a[max_N];

LL dp[max_N][max_N][max_N];
// 前 i 个空隙, 共 j 个 1, 用了 k 步

char s[max_N];

int main() {
    scanf("%s", s);
    n = 1;
    for (int i = 0; i < max_N && s[i]; ++i) {
        if (s[i] == '0') {
            ++n;
        } else {
            ++a[n];
        }
    }
    for (int i = 2; i <= n; ++i) {
        a[i] += a[i - 1];
    }
    scanf("%d", &K);
    K = std::min(K, a[n]);
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = a[i - 1]; j <= a[n]; ++j) {
            for (int k = 0; k <= K; ++k) {
                // 不移动 i, 且从后往 i 移动 m 步
                for (int m = 0; j + a[i] - a[i - 1] + m <= a[n] && k + m <= K; ++m) {
                    int j1 = j + a[i] - a[i - 1] + m;
                    dp[i][j1][k + m] = (dp[i][j1][k + m] + dp[i - 1][j][k]) % mod;
                }
                // 移动 i, 且从 i 往前移动 m 步
                for (int m = a[i] - a[i - 1]; m && j + a[i] - a[i - 1] - m <= a[n]; --m) {
                    int j1 = j + a[i] - a[i - 1] - m;
                    dp[i][j1][k] = (dp[i][j1][k] + dp[i - 1][j][k]) % mod;
                }
            }
        }
    }
    /*
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= a[n]; ++j) {
            for (int k = 0; k <= K; ++k) {
                if (dp[i][j][k]) {
                    printf("dp[%d][%d][%d] = %lld\n", i, j, k, dp[i][j][k]);
                }
            }
        }
    }*/
    LL ans = 0;
    for (int k = 0; k <= K; ++k) {
        ans = (ans + dp[n][a[n]][k]) % mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 57276
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[20][20];
int main(){
	int n,m,x,mi=1000000000;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		for(int j=0;j<=m;j++) cin>>a[i][j];
	}
	for(int i=1;i<(1<<n);i++){
		int flag=0;
		for(int j=0;j<=m;j++) a[12][j]=0;
		for(int j=0;j<n;j++){
			if((i>>j)&1) {
				for(int k=0;k<=m;k++) a[12][k]+=a[j][k];
				
			}
		}
		for(int j=1;j<=m;j++) {
			if(a[12][j]<x) flag=1;
		}
		if(flag==0&&a[12][0]<mi) mi=a[12][0];
	}
	if(mi<1000000000)
	cout<<mi<<endl;
	else cout<<"-1"<<endl;
	return 0;
} 

Measured memory_bytes: 3632
#include<stdio.h>

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


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

using namespace std;

const int N = 1e5 + 5;

int n, m, dp[N], deg[N];
vector <int> g[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        ++deg[v];
    }

    vector <int> topo;
    queue <int> q;
    memset(dp, -0x3f, sizeof(dp));
    for (int i = 1; i <= n; i++) {
        if (!deg[i]) {
            dp[i] = 0;
            q.push(i);
        }
    }

    while (!q.empty()) {
        int u = q.front(); q.pop(); topo.push_back(u);
        for (auto v: g[u]) {
            if (--deg[v] == 0) q.push(v);
        }
    }

    for (auto i: topo) {
        for (auto j: g[i]) {
            dp[j] = max(dp[j], dp[i] + 1);
        }
    }

    cout << *max_element(dp + 1, dp + n + 1);
    return 0;
}


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

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

using namespace std;
using ll = long long;

ll solve(ll a, ll b, ll c);

int main(void){
    ll a, b, H, W;
    cin >> a >> b;
    H = min(a, b); W = max(a, b);
    ll ans = H; //答えは絶対Hよりも小さいやで、知っとるか????
    //3つの長方形に分けるということは、そのうち少なくとも1個は1つの列or1つの行を占拠する
    //で、これに関しても3つの要素(今回は長方形)を考えるのではなく、一つ固定して考えるという手法が役に立つ

    //行を占拠する場合
    rep(k, 2){
        for(int i = 1; i <= H-1; i++){
            ll kotei_area = i*W; //固定した長方形の面積
            ll rem_height = H-i;
            ll rem_big_area, rem_small_area;
            if((rem_height*W) % 2 == 0){ rem_big_area = rem_height*W/2; rem_small_area = rem_big_area;}
            else{
                //rem_heightの方が小さい
                ll mid_width = W / 2;
                rem_big_area = (W-mid_width)*rem_height;
                rem_small_area = rem_big_area - rem_height;
            }
            ll temp = solve(kotei_area, rem_big_area, rem_small_area);
            if(temp < ans) ans = temp; 
        }
        swap(H, W);
    }
    cout << ans << endl;
    return 0;
}

ll solve(ll a, ll b, ll c){
    return max(max(a, b), c) - min(min(a, b), c);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(i64, N);
    vector<pii> ps(N);

    i64 ans = 0;
    rep(i, 0, N) {
        VAR(int, a, b);
        ps[i] = pii(a, b);
        ans += -b;
    }

    sort(all(ps), [](auto a, auto b) {
        return a.first + a.second > b.first + b.second;
    });

    for (int i = 0; i < N; i += 2) {
        ans += ps[i].first + ps[i].second;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1792
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    B = [SI() for _ in range(n)]

    res = 0
    for i in range(n):
        is_good = 1
        for h in range(n):
            for w in range(h + 1, n):
                if B[h][(w + i) % n] != B[w][(h + i) % n]:
                    is_good = 0
                    break

            if not is_good:
                break

        if is_good:
            res += n

    return res


print(main())


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

typedef long long ll;
int dp[5001][51];
vector<int> bs;
int n, k;
int solve(int in, int inbox){
  if(in == bs.size())
    return 0;
  if(bs[in] == inbox)
    return 1e9;
  int& res = dp[in][inbox];
  if(res != -1)
    return res;

  res = 1e9;
  for(int i = 0;i < n;i++){
    res = min(res, (i == inbox ? 0 : 1) + solve(in + 1, i));
  }
  return res;
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n >> k;
  int a[n];
  int mn = 1e9;
  vector<pair<int, int>> v;
  for(int i = 0;i < n;i++){
    cin >> a[i], mn = min(mn, a[i]);
    v.push_back({a[i], i});
  }
  sort(v.begin(), v.end(), greater<>());
  int lst = -1;
  while(v.size()){
//    if(v.size() == 1)break;
    for(int i = 0;i < v.size();i++){
      if(v[i].second == lst && v.size() != 1)continue;
      bs.push_back(v[i].second);
      v[i].first--;
    }
    lst = bs.back();
    sort(v.begin(), v.end(), greater<>());
    while(v.back().first == 0)
      v.pop_back();
  }
//  for(auto el : bs)
//    cout << el << ' ';
  int res = 1e9;
  memset(dp, -1, sizeof(dp));
//    cout << solve(1, 1) << endl;
  for(int i = 0;i < n;i++){
    res = min(res, solve(0, i));
  }
//  cout << res << endl;
  if(res > k){
    cout << bs.size() << endl;
    for(int i = 0;i < bs.size();i++){
      cout << bs[i] + 1 << ' ';
    }
  }else{
//    assert(false);
    cout << "-1";
  }
  return 0;
}


Measured memory_bytes: 1408
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=readln.split.to!(long[]);

  import std.container;
  auto minHeap=new BinaryHeap!(Array!long, "a>b");
  long sum=0;
  foreach(i; 0..n){
    sum+=a[i];
    minHeap.insert(a[i]);
  }
  auto red=new long[](n+1);
  red[0]=sum;
  foreach(i; n..(n*2)){
    sum+=a[i];
    minHeap.insert(a[i]);
    sum-=minHeap.front;
    red[i-n+1]=sum;
    minHeap.removeFront;
  }
  auto maxHeap=new BinaryHeap!(Array!long, "a<b");
  sum=0;
  foreach(i; (n*2)..(n*3)){
    sum+=a[i];
    maxHeap.insert(a[i]);
  }
  auto blue=new long[](n+1);
  blue[n]=sum;
  foreach_reverse(i; n..(n*2)){
    sum+=a[i];
    maxHeap.insert(a[i]);
    sum-=maxHeap.front;
    blue[i-n]=sum;
    maxHeap.removeFront;
  }
  import std.range;
  long score=reduce!((r, i)=>max(r, red[i]-blue[i]))(-1000000000000000000, iota(0, (n+1)));
  writeln(score);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 17892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115
{
	class Program
	{
		static void Main(string[] args)
		{
			string D;
			string s;
			D = Console.ReadLine();

			if (D == "25")
			{
				s = "Christmas";
				Console.Write(s);
			}
			else if (D == "24")
			{
				s = "Christmas Eve";
				Console.Write(s);
			}
			else if (D == "23")
			{
				s = "Christmas Eve Eve";
				Console.Write(s);
			}
			else if (D == "22")
			{
				s = "Christmas Eve Eve Eve";
				Console.Write(s);
			}
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    long long int n;
    cin >> n;
    long long int maxg=1;
    for(long long int i=1;i*i<=n;i++){
        if(n%i == 0)maxg = i;
    }
    cout << maxg + n/maxg -2 <<endl;
}

Measured memory_bytes: 256
from bisect import bisect_left
from collections import defaultdict

N = int(input())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
pre_b = -1

dict_C = defaultdict(int)


for b in B:
    if b == pre_b:
        res += num_a * num_c
        continue
    num_a = bisect_left(A, b) # a < b となるAの要素数
    pre_num_c = bisect_left(C, b)
    num_c = N - pre_num_c # c > b となるAの要素数
    if pre_num_c != N and C[pre_num_c] == b:
        num_c = N - bisect_left(C, b+1)
    res += num_a * num_c
    pre_b = b
print(res)



Measured memory_bytes: 107108
n = int(input())
vs = list(sorted(map(int, input().split())))

numerator = vs[0] + vs[1]
for i in range(2, n):
    numerator += (2 ** (i - 1)) * vs[i]
denominator = 2 ** (n - 1)
print(1.0 * numerator / denominator)


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    vector<V>f(n,V(10));
    vector<V>p(n,V(11));
    rep(i,n){
        rep(j,10){
            cin>>f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin>>p[i][j];
        }
    }
    //bit全探索
    int ans=-INF;
    for(int bit=1;bit<(1<<10);bit++){
        int tmp=0;
        V myco(10);
        for(int i=0;i<10;i++){
            if(bit&(1<<i)){
                myco[i]=1;
            }
        }
        /*printf("myco=");
        rep(i,10)printf("%d",myco[i]);
        printf("\n");*/
        rep(i,n){
            int cnt=0;
            rep(j,10){
                if(myco[j]==1&&f[i][j]==1){
                    cnt++;
                }
            }
            //printf("cnt=%d\n",cnt);
            tmp+=p[i][cnt];
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}

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

int V, E, mat[15][15]={0}, m[1<<15][15]={0};
int INF =1e8 ;

int TSP(int x, int y){
	int i;
	if(m[x][y]>=0){
		return (m[x][y]);
	}
	if(x==(1<<V) -1 && y==0){
		return (m[x][y]= 0);
	}
	int min_path=INF;

	for(i=0; i<V; i++){
		if(!(x>>i & 1)){
			min_path=min(min_path, TSP(x | 1<<i, i) + mat[y][i]);
		}
	}


	return (m[x][y]=min_path);
}

int main(){
	int s, t, d, i, j;
	int out;

	cin>>V>>E; //getchar();
	for(i=0; i<V;i++){
		for(j=0; j<V; j++){
			mat[i][j]=INF;
		}
	}
	for(i=0; i<E; i++){
		cin>>s>>t>>d; //getchar();
		mat[s][t]=d;
	}

	memset(m, -1, sizeof(m));

	out=TSP(0,0);
	if(out == INF){
		cout<< -1 ;
	}else{
		cout<< out;
	}
    cout<<endl;
    //getchar();
    return 0;
}


Measured memory_bytes: 5036
K = str(input())
D = int(input())

N = len(K)

MOD = 10 ** 9 + 7

# if D == 1:
#     print (K)
#     exit()
# elif D == 2:
#     print (int(K) // 2)
#     exit()
# elif D == 5:
#     print (int(K) // 5)

dp0 = [[0] * D for _ in range(N + 1)]
dp1 = [0] * (N + 1)

for i in range(N):
    next_ = int(K[i])
    tmp = dp1[i]

    dp1[i + 1] = (tmp + next_) % D
    
    for j in range(next_):
        dp0[i + 1][(tmp + j) % D] += 1
    # print (dp0[i + 1])
    for j in range(D):
        for k in range(10):
            dp0[i + 1][(j + k) % D] += dp0[i][j]
    
    for j in range(D):
        dp0[i + 1][j] %= MOD


# for tmp in dp0:
#     print (tmp)

# print (dp1)


ans = dp0[N][0] - 1
if dp1[N] == 0:
    ans += 1

print (ans % MOD)

Measured memory_bytes: 52460
s = list(input())
n = len(s)
a = 0

for i in range(2**(n-1)):
  op = []
  tmp = ""
  for j in range(n-1):
    if (i >> j) & 1:
      op.append("+")
    else:
      op.append("")
  op.append("")
  
  for num, sbl in zip(s, op):
    tmp += num + sbl
  a += eval(tmp)

print(a)
  

Measured memory_bytes: 9080
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S[10010];
    rep(i, N) cin >> S[i];
    int ans = 0;
    int backA = 0, frontB = 0;
    int backAfrontB = 0;
    rep(i, N) {
        rep(j, S[i].length() - 1) {
            if(S[i][j] == 'A' && S[i][j + 1] == 'B') ans++;
        }
        if(S[i].back() == 'A') backA++;
        if(S[i].front() == 'B') frontB++;
        if(S[i].back() == 'A' && S[i].front() == 'B') backAfrontB++;
    }
    if(backA == frontB && backA == backAfrontB && backA > 0) ans--;
    cout << ans + min(backA, frontB) << endl;

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
using namespace std;
signed main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	while (a) {
		a /= b;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, K; cin >> N >> K;
    vl ds(K, 0); REP(i, K) cin >> ds[i];
    ll ret = 1e5+10;
    REP(i, 100100){
        ll aaaaa = i / 10000;
        ll aaaa = (i - aaaaa * 10000) / 1000;
        ll aaa = (i - aaaaa * 10000 - aaaa * 1000) / 100;
        ll aa = (i - aaaaa * 10000 - aaaa * 1000 - aaa * 100) / 10;
        ll a = (i - aaaaa * 10000 - aaaa * 1000 - aaa * 100 - aa * 10);
        bool ok = true;
        if(aaaaa != 0)
            ok = ok && find(ds.begin(), ds.end(), aaaaa) == ds.end();
        if(aaaaa != 0 || aaaa != 0)
            ok = ok && find(ds.begin(), ds.end(), aaaa) == ds.end();
        if(aaaaa != 0 || aaaa != 0 || aaa != 0)
            ok = ok && find(ds.begin(), ds.end(), aaa) == ds.end();
        if(aaaaa != 0 || aaaa != 0 || aaa != 0 || aa != 0)
            ok = ok && find(ds.begin(), ds.end(), aa) == ds.end();
        if(true)
            ok = ok && find(ds.begin(), ds.end(), a) == ds.end();
        if(ok && i >= N){
            ret = i; break;
        }
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  int n,k; //かっている数//最大100
  priority_queue<int> v;

  cin >> n >> k;



  // cout << abs(a - b) + abs(b - c) << endl;
  bool ans=false;

  if (n%k==0)ans=true;


  cout << (ans?0:1);
  return 0;
}


Measured memory_bytes: 256
//パスを伸ばす要領で, 両側dfs
#include <iostream>
#include <vector>
using namespace std;

int n, m;
vector<int> et[100000];
bool visited[100000] = {false};

void dfs(int v, vector<int> &path) {
	visited[v] = true;
	path.push_back(v);
	
	for (int i = 0; i < et[v].size(); i++) {
		if (!visited[et[v][i]]) {
			dfs(et[v][i], path);
			return;
		}
	}
}

int main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	vector<int> path[2];
	dfs(0, path[0]);
	dfs(0, path[1]);
	
	vector<int> ans;
	for (i = path[0].size() - 1; i >= 0; i--) ans.push_back(path[0][i]);
	for (i = 1; i < path[1].size(); i++) ans.push_back(path[1][i]);
	
	cout << ans.size() << endl;
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] + 1;
		if (i + 1 < ans.size()) cout << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 10296