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

int n;
int node(int i, int j) {
	return (min(i, j) * n + max(i, j));
}
vector<int> adj[1000005];
vector<int> indegree(1000005, 0);
int main() {
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		int prev;
		cin >> prev;
		for(int j = 1; j < n-1; ++j) {
			int current;
			cin >> current;
			int fir = node(i, prev);
			int sec = node(i, current);
			// cout << "\n>" << fir << " " << sec << "\n";
			adj[fir].push_back(sec);
			++indegree[sec];
			prev = current;
		}
	}
	vector<int> current;
	for(int i = 1; i < n; ++i) {
		for(int j = i+1; j <= n; ++j) {
			if(indegree[node(i, j)] == 0)
				current.push_back(node(i, j));
		}	
	}
	int cnt = 0, day = 0;
	while(!current.empty()) {
		vector<int> other;
		++day;
		cnt += current.size();
		for(int i = 0; i < current.size(); ++i) {
			int chk = current[i];
			// cout << chk << " ";
			for(int j = 0; j < adj[chk].size(); ++j) {
				--indegree[adj[chk][j]];
				if(indegree[adj[chk][j]] == 0) {
					other.push_back(adj[chk][j]);
				}
			}
		}
		current = other;
		// cout << "\n";
	}
	if(cnt == (n*(n-1))/2) {
		cout << day;
	}
	else cout << -1;
	return 0;
}

Measured memory_bytes: 43136
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll N;cin>>N;
    if(N<2){
        cout<<0<<endl;
    }
    else{
        map<ll,ll>SOIN;
        ll n=N;
        ll ans=0;
        for(ll i=2;i<=sqrt(N);i++){
            while(n%i==0){
                SOIN[i]++;
                n=n/i;
            }
        }
        if(n!=1){
            SOIN[n]=1;
        }
        for(auto p:SOIN){
            ll H=p.second;
            for(int i=1;i<=p.second;i++){
                H=H-i;
                if(H>=0){
                    ans++;
                }
                else{
                    break;
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <ctime>
#define rep(i,j,k) for(int i = j; i <= k; i++)
#define dow(i,j,k) for(int i = j; i >= k; i--)
#define ez(i,x) for(int i = h[x]; i; i = e[i].next)
#define fi first
#define se second
#define MS(x) memset(x, 0, sizeof(x))
using namespace std;


int main() {
    int n;
	ios::sync_with_stdio(0);
	cin >> n;
	map<int,int> m;
	long long sum = 0;
	rep(i,1,n) {
		int x;
		cin >> x;
		m[x]++;
		sum += x;
	}
	int q;
	cin >> q;
	while (q--) {
		int x, y;
		cin >> x >> y;
		sum = sum - 1ll * m[x] * x + m[x] * 1ll * y;
		m[y] += m[x];
		m[x] = 0;
		cout << sum << "\n";
	}
}

Measured memory_bytes: 8060
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;
}


void solve() {
    int n; cin >> n;
    map<ll,ll, greater<ll>> mp;
    rep(i, n) {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    int cnt = 0;
    ll ans = 1;
    for(auto p: mp){
        if(p.second >= 4 && cnt == 0) {
            ans = p.first * p.first;
            cnt = 2;
            break;
        } else if (p.second >= 2 && cnt == 1) {
            ans *= p.first;
            cnt++;
            break;
        } else if(p.second >= 2 && cnt == 0) {
            ans *= p.first;
            cnt++;
        }
    }
    if(cnt <= 1) cout << 0 << endl;
    else cout << ans << endl;
}

int main(void){
  solve();
  return 0; 
}


Measured memory_bytes: 9844
#include <algorithm>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;
#define X first
#define Y second

const ll MAX_N = 2e5 + 12;
ll n, ans, can;
pii Arr[MAX_N];
int A[MAX_N];
int B[MAX_N];
map <int, int> Map;
bool mark[MAX_N];

bool cmp (pii a, pii b) {
    return a.second < b.second;
}

void calc() {
    for (int i = 0; i < n; i++)
        Map[A[i]] = i;

    int d = 0, l = 1;
    mark[0] = true;
    while (!mark[Map[Arr[d].first]]) {
        mark[Map[Arr[d].first]] = true;
        d = Map[Arr[d].first];
        l++;
    }

    if (l != n)
        can = true;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> Arr[i].first;

    for (int i = 0; i < n; i++)
        cin >> Arr[i].second;

    sort(Arr, Arr + n, cmp);
    for (int i = 0; i < n; i++) {
        A[i] = Arr[i].first;
        B[i] = Arr[i].second;
    }

    can = false;
    sort(A, A + n);
    for (int i = 0; i + 1 < n; i++)
        if (A[i] == A[i + 1])
            can = true;

    if (!can)
        calc();

    for (int i = 0; i < n; i++)
        if (A[i] > Arr[i].second) {
            cout << "No\n";
            return 0;
        }

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

    for (int i = 1; i < n; i++)
        if (A[i] <= Arr[i - 1].second) {
            cout << "Yes\n";
            return 0;
        }

    cout << "No\n";
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iterator>
#include<algorithm>
using namespace std;

int main()
{
	long double a,b;
	cin>>a>>b;

	long double c = (a*b);
	//cout<<c<<endl;
	cout<<(long long)c<<endl;
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll>   vl;
#define f(i,n)  for(i=0;i<n;i++)
#define f1(i,n)  for(i=1;i<n;i++)
#define fr(i,n) for(i=n-1;i>=0;i--)
#define em emplace_back
#define mp make_pair
#define in insert
#define fi first
#define sc second
#define b begin
#define e end
#define er erase
#define l length
#define c clear
#define si size
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const double pi=3.141592653;
const ll infi=1000000001;
const ll MOD=1000000007;
const ll mod=998244353;
const string no="NO\n",yes="YES\n";

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

// void dfs(vl v[],ll node,ll hai[]){
//     hai[node]=1;
//     for(auto i:v[node]){
//         if(hai[i]==0){
//             dfs(v,i,hai);
//         }
//     }
// }

// ll con(vl v[],ll hai[],ll sz){
//     ll count=0;
//     for(int i=1;i<sz;i++){
//         if(hai[i]==0){
//             count++;
//             dfs(v,i,hai);
//         }
//     }
    // return count;
// }

// void gcde(int a,int b,int *x,int *y){
//     if(a==0){
//         *x=0;
//         *y=1;
//         return;
//     }    
//     int x1,y1;
//     gcde(b%a,a,&x1,&y1);
    
//     *x=y1-(b/a)*x1;
//     *y=x1;
// }


// ll recur(vl v,ll in,ll m,ll n){
//     if(in==-1)  return 1000000000001;
//     ll d,e,c;
//     d=max(m/v[in],n*v[in]);
//     c=recur(v,in-1,m/v[in],n*v[in]);
//     e=recur(v,in-1,m,n);
//     return min(c,min(e,d));
// }

// ll bexpo(ll a,ll p){
//     ll x=1;
//     while(p){
//     if(p&1){
//         x=(x*a)%mod;
//     }
//     a=(a*a)%mod;
//     p>>=1;
//     }
//     return x;
// }
// int dx[8]{-1,0,0,1,-1,-1,1,1};
// int dy[8]{0,-1,1,0,-1,1,-1,1};


int main() {
    fastio
    int t=1;
    // cin>>t;
    ll n,m,i,l,d,bank,s,k,j,x,y,ans,q;

    while(t--){ans=0;
        cin>>n;
        int a[n][2];
        f(i,n)  cin>>a[i][0]>>a[i][1];

        f(i,n-2){
            if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1]){
                ans=1;
                break;
            }
        }
        if(ans) cout<<"Yes";
        else cout<<"No";
    }
    
    
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,n;
  cin>>a>>b>>n;
  ll x = min(b-1, n);
  ll f = (a*x/b) - a * (x/b);
  cout<<f<<endl;
  return 0;
}


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

int main()
{
ll n ;
cin >> n ;
vector<ll> aa(n);
ll c=0;
rep(i, n){
  cin >> aa[i];
  if(i>1)c^=aa[i];
}
ll sum=aa[0]+aa[1]-c;
ll a=0,b=c;
if(sum<0){
  cout << -1 << endl;
  return 0;
}
rep(i,62){
  ll j=61-i;
  if(((a>>j)&1LL)==0 && ((b>>j)&1LL)==0 && sum>=2LL<<j){
    a+=1LL<<j;
    b+=1LL<<j;
    sum-=2LL<<j;
  }
}
if(sum!=0){
  cout << -1 << endl;
  return 0;
}
if(a>aa[0]){
  cout << -1 << endl;
  return 0;
}
rep(i,62){
  ll j=61-i;
  if((((a>>j)&1LL)^ ((b>>j)&1LL))==1 && aa[0]>=a+(1LL<<j)){
    a+=1LL<<j;
    b-=1LL<<j;
  }
}
if(a==0){
  cout << -1 << endl;
  return 0;
}
cout << aa[0]-a << endl;
return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define Mod 1000000007
#define Max 100001
#define vt vector<long long>

void func(){
    ll n;
    cin>>n;
    if(n>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}   
 
int main(){
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
 
// 
//int t;
//cin >> t;
//for(ll i=1; i<=t; i++)
//{
    
    func();
//    cout<<endl;
//cout<<func()<<endl;
 
//if(func())
//    cout<<"Yes"<< endl;
//else
//    cout <<"No"<<endl; 
//cout<<"Case"<<" "<<"#"<<i<<":"<<" "<<func()<<endl;
//}
return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>

using namespace std;
int v[102];
int main()
{
    int n, m;
    long long sum=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum+=v[i];
    }
    sort(v, v+n);
    if(v[n-m]<(double)sum/(4*m)){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	vector<int> v;

	cin >> n;

	v.resize(n);

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

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

	double sum = (double)v[0];
	for(int i = 1; i < n; ++i)
	{
		sum = (sum + (double)v[i]) / 2.0;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define P tuple<ll, ll, ll>

using namespace std;
ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}
ll gcd(ll a, ll b){
  if (a < b){
    swap(a, b);
  }
  while (b != 0){
    ll t = a;
    a = b;
    b = t % b;
  }
  return a;
}

ll sign(ll a){
  if (a > 0)
    return 1;
  else if (a < 0)
    return -1;
  
  return 0;
}

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  map<P, ll> m;
  ll azero = 0, bzero = 0;
  ll zero = 0;
  
  for (int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
    if (sign(a[i]) * sign(b[i]) > 0){
      ll g = gcd(a[i], b[i]);
      m[P(1, abs(a[i]/g), abs(b[i]/g))]++;
    }
    else if (sign(a[i]) * sign(b[i]) < 0){
      ll g = gcd(a[i], b[i]);
      m[P(-1, abs(a[i]/g), abs(b[i]/g))]++;
    }
    else if (a[i] == 0 && b[i] == 0)
      zero++;
    else if (a[i] == 0)
      azero++;
    else
      bzero++;
  }


  map<P, ll> checked;

  vector<ll> preans(0);
  preans.emplace_back((power(2, azero) + power(2, bzero) - 1 + MOD) % MOD);
  for (pair<tuple<ll, ll, ll>, ll> T : m){
    P t = T.first;
    if (checked[t] == 1)
      continue;
    ll s = get<0>(t);
    ll A = get<1>(t);
    ll B = get<2>(t);
    checked[t] = 1;
    checked[P(s*(-1), B, A)] = 1;
    ll add = (power(2, m[t]) + power(2, m[P(s*(-1), B, A)]) - 1 + MOD) % MOD;
    preans.emplace_back(add);
  }

  ll ans = 1;
  for (int i = 0; i < preans.size(); i++){
    ans = (ans * preans[i]) % MOD;
  }
  ans--; // 空を除く
  ans = (ans + zero + MOD) % MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70392
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int A,B,C;
int L[8];

int main(){
    cin>>N>>A>>B>>C;
    rep(i,N) cin>>L[i];

    int ans=1001001001;
    for(int i=0;i<(1<<(2*N));i++){
        int res=0;
        int abc[3]={0,0,0};
        rep(j,N){
            int t=(i>>(2*j))%4;
            if(t!=3){
                abc[t]+=L[j];
                if(abc[t]!=L[j]) res+=10;
            }
        }
        
        if(abc[0]!=0 && abc[1]!=0 && abc[2]!=0){
            res+=abs(A-abc[0]);
            res+=abs(B-abc[1]);
            res+=abs(C-abc[2]);
            ans=min(ans,res);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
lines = [input().split() for i in range(3)]
 
num = int(input())
bs = []
for i in range(num):
  bs.append(input())
 
hits = []
for i in bs:
  for row_index in range(len(lines)):
    for col_index in range(len(lines[row_index])):
      if lines[row_index][col_index] == i:
        hits.append((row_index,col_index))
row_hits = [0,0,0]
col_hits = [0,0,0]
stride_hits = [0,0]
 
for hit in hits:
  r = hit[0]
  c = hit[1]
  row_hits[r]+=1
  col_hits[c]+=1
  if r == c:
    stride_hits[0]+=1
  if (r,c) == (0,2) or (r,c) == (1,1) or (r,c) == (2,0) :
    stride_hits[1]+=1
 
if max(row_hits)>= 3 or max(col_hits)>=3 or max(stride_hits)>= 3:
  print ('Yes')
else:
  print ('No')
  

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


//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;

	//typedef tree<
			//int,
			//null_type,
			//less<int>,
			//rb_tree_tag,
			//tree_order_statistics_node_update>
	//ordered_set;
	

//#define REP(i,m) for(int i=0;i<(m);++i)
//struct dsu{
	//static const int MAXN=105;
	//int par[MAXN];
	//int size[MAXN];
	//void init(){
		//memset(par,-1,sizeof(par));
		//REP(i,MAXN) size[i]=1;
	//}
	//int root(int a){
		//if(par[a]==-1) return a;
		//return par[a]=root(par[a]);
	//}
	//void unite(int a,int b){
		//a=root(a);b=root(b);
		//if(a==b) return;
		//if(size[a]<size[b]) swap(a,b);
 
		//par[b]=a;
		//size[a]+=size[b];
	//}
	//bool same(int a,int b){
		//return root(a)==root(b);
	//}
//};	

#define ll long long 

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	ll n;cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+= (i+1)*(n-i);
	}
	for(int i=0;i<n-1;i++){
		ll a,b;cin>>a>>b;
		ans-= (min(a,b)*(n-max(a,b) +1));
	}
	cout<<ans<<endl;
	return 0;
	
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<cstdio>
#include<stdio.h>
using namespace std;
typedef long long ll;

const int mod = 1e9+7;

int main(){
	ios::sync_with_stdio(false);
	int n,sum = 0,maxnum = 0,curnum;
	cin >> n; 	
	for(int i = 0; i< n; ++i){
		cin >> curnum;
		maxnum = curnum > maxnum ? curnum:maxnum;
		sum += curnum;
	}
	if(sum-maxnum > maxnum)printf("Yes");
	else printf("No");
	
	return 0;
} 

Measured memory_bytes: 3244
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




const ll table_size = 100005;
ll fact[table_size], finv[table_size], inv[table_size];

void make_table(ll mod) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < table_size; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll nPr(ll n, ll r, ll mod){
    return fact[n] * finv[n - r] % mod;
}

ll POW(ll n, ll m, ll p){
    ll res = 1, x = n;
    for(ll i = m; i > 0; i >>= 1){
        if(i & 1){
            res *= x;
            res %= p;
        }
        x *= x;
        x %= p;
    }
    return res;
}

ll Fermat(ll a, ll x, ll p){
    return POW(a, p - 1 - x, p);
}


int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    
    make_table(MOD);
    
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1));
    for(ll i = 0; i <= b; i++){
        dp[i][0] = 1;
    }
    for(ll i = a; i <= b; i++){
        for(ll j = 0; j <= n; j++){
            dp[i][j] = dp[i - 1][j];
            for(ll k = c; k <= d && j - i * k >= 0; k++){
                dp[i][j] += ((dp[i - 1][j - i * k] * nPr(n - j + i * k, i * k, MOD) % MOD)
                            * Fermat((POW(fact[i], k, MOD) * fact[k]) % MOD, 1, MOD)) % MOD;
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[b][n] << endl;
}


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

int N;
int d[100000];

int abc(int k) {
  return distance(d, lower_bound(d, d+N, k));
}

signed main() {
  cin >> N;
  for(int i=0; i<N; i++) cin >> d[i];
  sort(d, d+N);
  int ans = 0;
  for(int k=d[0]; k<=d[N-1]; k++) {
    int c = abc(k);
    if(abc(k) == N/2) ans++;
  }
  cout << ans << endl;
}


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


int main()
{
	int K,N;
	cin>>K>>N;
	vector<ll> A(N);
	rep(i,N)
	{
		cin>>A[i];
	}
	ll mx=0;
	rep(i,N-1)
	{
		mx=max(mx,A[i+1]-A[i]);
	}
	mx=max(mx,K-A[N-1]+A[0]);
	ll sum=K;
	cout<<sum-mx<<endl;
	return 0;
}


Measured memory_bytes: 4828
#include <iostream>

int main() {
    int n;
    std::cin >> n;

    int cnt = 0, next = 1;
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        if (a == next) {
            ++next;
        } else {
            ++cnt;
        }
    }

    std::cout << (cnt == n ? -1 : cnt) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
using pll = pair<long,long>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

map<ll,ll> m;
const int MOD=1e9+7;

void primeFac(ll n) {
  for(ll i=2;i*i<=n;i++) {
    ll index=0;
    while(n%i==0) {
      n/=i;
      index++;
    }
    m[i]+=index;
  }
  if(n!=1) m[n]++;
}

int main() {
  ll n;
  cin>>n;
  ll ans=1;
  for(int i=2;i<=n;i++) {
    primeFac(i);
  }
  for(auto x:m) {
    ans*=(x.second+1)%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
str1 = input().split()
str2 = input().split()

m1 = str1[0]
d1 = str1[1]
m2 = str2[0]
d2 = str2[1]

 
if m1 == m2:
    return_value = '0'
else:
    return_value = '1'
    
print(return_value)

Measured memory_bytes: 3060
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const int mod = ((int)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
// function
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}

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


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

 public static void main(String[] args) {
     
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int R = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc.
    
    double cf = 2*3.14*R;
    System.out.println(cf);
  }
  
}

Measured memory_bytes: 36012
#include <iostream>
#define US unsigned short

using namespace std;

int main(int argc, char const *argv[])
{
    US A, B;
    cin >> A >> B;

    if (A < (B << 1))
        cout << 0 << endl;
    else
        cout << A - (B << 1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] card = new int[n];
        int[] alice = new int[n];
        int[] bob = new int[n];
        for(int i = 0; i < n; i++){
            card[i] = sc.nextInt();
        }
        Arrays.sort(card);
        if(card.length % 2 == 0){
            for(int i = 0; i < n; i++){
                if(i % 2 == 1){
                    alice[i] = card[i];
                }else{
                    bob[i] = card[i];
                }
            }
        }else{
            for(int i = 0; i < n; i++){
                if(i % 2 == 1){
                    bob[i] = card[i];
                }else{
                    alice[i] = card[i];
                }
            }
        }
        int cnt_a = 0;
        int cnt_b = 0;
        for(int a : alice){
            cnt_a += a;
        }
        for(int b : bob){
            cnt_b += b;
        }
        System.out.println(cnt_a - cnt_b);
    }
}


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

using namespace std;

int main () {

    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    vector<int> times;
    
    times.push_back(A); 
    times.push_back(B); 
    times.push_back(C); 
    times.push_back(D); 
    times.push_back(E);

    sort(times.begin(), times.end());
    int res = 0;
    vector<int> xs;
    for (size_t i = 0; i < times.size(); ++i) {

        res += times[i];
        // cout << "res = " << res << endl;
        int count = res;
        while(count % 10 != 0) {
            count += 1;
            xs.push_back(res - count);
        }
        res = count;
    }
    // cout << res + xs.back() << endl;
    int mn = 0;
    for (auto p : xs)
        if (p < mn)
            mn = p;
    // cout << mn << endl;
    cout << res + mn << endl;
    return 0;

}


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

struct LazySegmentTree {
    int size;
    vector<int> node, lazy;
    const int I = (unsigned int) (1 << 31) - 1;

    LazySegmentTree(int n) {
        size = 1;
        while (size < n) size <<= 1;
        node.resize(2 * size, I);
        lazy.resize(2 * size, -1);
    }

    void eval(int k) {
        if (lazy[k] == -1) return;
        node[k] = lazy[k];
        if (k < size) lazy[2 * k] = lazy[2 * k + 1] = lazy[k];
        lazy[k] = -1;
    }

    void update(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;
        eval(k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] = x;
            eval(k);
        } else {
            int m = (l + r) / 2;
            update(a, b, x, 2 * k, l, m);
            update(a, b, x, 2 * k + 1, m, r);
            node[k] = min(node[2 * k], node[2 * k + 1]);
        }
    }

    int query(int a, int b, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;

        eval(k);
        if (r <= a || b <= l) return I;
        if (a <= l && r <= b) return node[k];
        int m = (l + r) / 2;
        return min(query(a, b, 2 * k, l, m), query(a, b, 2 * k + 1, m, r));
    }
};

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

    int n, q;
    cin >> n >> q;
    LazySegmentTree st(n);
    for (int j = 0; j < q; j++) {
        int type;
        cin >> type;
        if (type == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            st.update(s, t + 1, x);
        } else {
            int s, t;
            cin >> s >> t;
            cout << st.query(s, t + 1) << '\n';
        }
    }
}


Measured memory_bytes: 4864
#include<stdio.h>
#include<string.h>
char card_name[52];
int card_no[52] = {0};
int s[13] = {0};
int h[13] = {0};
int c[13] = {0};
int d[13] = {0};
int main(){
int n,count=0;
int no_s=0,no_h=0,no_c=0,no_d=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%s",&card_name[i]);
    scanf("%d",&card_no[i]);
}

for(int i=0;i<n;i++){
    if(card_name[i]=='S'){
        s[no_s] = card_no[i];
        no_s++;
    }
    else   if(card_name[i]=='H'){
        h[no_h] = card_no[i];
        no_h++;
    }
    else   if(card_name[i]=='C'){
        c[no_c] = card_no[i];
        no_c++;
    }
    else   if(card_name[i]=='D'){
        d[no_d] = card_no[i];
        no_d++;
    }
}
for(int i=1;i<=13;i++){
for(int j=0;j<13;j++){
    if(i==s[j]){
        count++;
    }

}
 if(count==0){
        printf("S %d\n",i);
    }
else count = 0;
    }

    for(int i=1;i<=13;i++){
for(int j=0;j<13;j++){
    if(i==h[j]){
        count++;
    }

}
 if(count==0){
        printf("H %d\n",i);
    }
else count = 0;
    }

for(int i=1;i<=13;i++){
for(int j=0;j<13;j++){
    if(i==c[j]){
        count++;
    }

}
 if(count==0){
        printf("C %d\n",i);
    }
else count = 0;
    }

for(int i=1;i<=13;i++){
for(int j=0;j<13;j++){
    if(i==d[j]){
        count++;
    }

}
 if(count==0){
        printf("D %d\n",i);
    }
else count = 0;
    }

return 0;
}




Measured memory_bytes: 2088
from collections import Counter
def main():
    n = int(input())
    l1 = []
    for _ in range(n):
        l1.append(input())
    l1c = Counter(l1)
    l1c2 = [c for c in l1c if l1c[c]%2 != 0]
    print(len(l1c2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 19708
#include<stdio.h>
int M=(1<<31)-1;
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,B=200,i,q,x,y,a[100010],b[1010],min;
  scanf("%d %d",&n,&m);
  for(i=0;i<100010;i++)a[i]=M;
  for(i=0;i<1010;i++)b[i]=M;
  while(m--){
    scanf("%d %d %d",&q,&x,&y);
    if(q){
      min=M;
      while(x<y+1){
	if(x%B==0&&x+B<=y+1){
	  min=MIN(min,b[x/B]);
	  x+=B;
	}
	else min=MIN(min,a[x++]);
      }
      printf("%d\n",min);
    }
    else{
      a[x]=y;
      b[x/B]=M;
      for(i=x-x%B;i<MIN(n,x-x%B+B);i++)b[x/B]=MIN(b[x/B],a[i]);
    }
    //for(i=0;i<n;i++)printf("%d ",a[i]);printf("\n");
    //for(i=0;i<=x/B;i++)printf("%d ",b[i]);printf("\n");
  }
  return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=51;

ll A[MAX];
ll P[MAX];

void Do(){
  A[0]=1;P[0]=1;
  for(int i=1;i<MAX;i++){
    A[i]=A[i-1]*2+3;
    P[i]=P[i-1]*2+1;
  }
  return;
}

void bfs(ll N,ll &X,ll &ans){
  //cout<<ans<<endl;
  if(A[N]/2<X){
    ans+=P[N-1];
    ans++;
    X=X-A[N]/2;
  }
  if(A[N]/2==X){
    ans+=P[N-1];
    X=0;
  }
  if(A[N]/2>X&&X!=0){
    N--;
    X--;
    //cout<<N<<" "<<X<<" "<<ans<<endl;
    bfs(N,X,ans);
  }
  if(X==0){
    //cout<<N<<" "ans<<endl;
    return;
  }
  
}
  

int main() {
  Do();
  ll N,X;
  cin>>N>>X;
  if(A[N]==X){
    X--;
  }
  ll ans=0;
  bfs(N,X,ans);
  cout<<ans<<endl;
  //cout<<P[2];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
int a,b,c;
int i[1000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int i[100000];
  int ans=0;
  lol sum=0;
  cin >>a;
  for(int n=0;n<a;n++) cin >>i[n],sum+=i[n];
  cin >>a;
  for(int n=0;n<a;n++){
      cin >>b>>c;
      b--;
      cout <<sum-i[b]+c<<'\n';
  }
  return (0);
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    vector<ll> a(m),p(n);
    rep(i,m){
        cin >> a[i];
        a[i]--;
        p[a[i]]=1;
    }
    ll sum1=0,sum2=0;
    for(ll i=0;i<=x-1;i++){
        sum1+=p[i];
    }
    for(ll i=x;i<=n-1;i++){
        sum2+=p[i];
    }
    ll ans=min(sum1,sum2);
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, d;
 
  // 変数aで入力を受け取る
  cin >> n >>  d;
  int num = (n /  (d * 2 + 1));
  if((n %  (d * 2 + 1)) !=  0) {
    num++;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include<stdio.h>  
int main(){
	int a,b,c,t,d;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)
	t=a;
	else 
	t=b;
	if(c%t==0)
    d=c/t;
    else 
    d=c/t+1;
    printf("%d\n",d);
}

Measured memory_bytes: 128
#include <string>
#include <iostream>
using namespace std;
int main()
{  int a,b,c,n;
   cin >> n;
   for(int i=0;i<n;i++){
   cin >> a >> b >> c;
   if((c*c)==(a*a)+(b*b)){
   cout << "YES" << endl;}
   else if((c*c)==(a*a)+(b*b)){
   cout << "YES" << endl;}
   else if((a*a)==(c*c)+(b*b)){
   cout << "YES" << endl;}
   else if((b*b)==(a*a)+(c*c)){
   cout << "YES" << endl;}
   else {
   cout << "NO" << endl;}
   
    }
   
    return 0;
}

Measured memory_bytes: 1156
S = list(input())

totals = [[]] * len(S)
def rec(S, num, totals):
    totals[num] = [int(''.join(S[:num+1]))]
    for idx in range(num):
        for item in totals[idx]:
            totals[num].append( item + int(''.join(S[idx+1:num+1])) )
    return totals

sl = len(S)
num = 1
totals[0].append( int(S[0]) )
while num < sl:
    totals = rec(S, num, totals)
    num += 1

print( sum(totals[-1]) )

Measured memory_bytes: 3316
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
typedef long long int ll;
typedef pair<ll, ll> p;

string maxx(string x, string y) {
	return max(x, y);
}

int main() {
	int n;
	cin >> n;
	vector<string> b;
	vector<double> a;
	rep(i, n) {
		double aa;
		string bb;
		cin >> aa >> bb;
		a.push_back(aa);
		b.push_back(bb);
	}
	double ans=0;
	rep(i, n) {
		if (b[i] == "JPY") {
			ans += a[i];
		}
		else {
			ans += (a[i] * 380000);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
ABCD = list(input())

a, b, c, d = int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[3])

if a+b+c+d == 7:
    print('{0}+{1}+{2}+{3}=7'.format(a, b, c, d))
elif a+b+c-d == 7:
    print('{0}+{1}+{2}-{3}=7'.format(a, b, c, d))
elif a+b-c+d == 7:
    print('{0}+{1}-{2}+{3}=7'.format(a, b, c, d))
elif a-b+c+d == 7:
    print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))
elif a-b-c+d == 7:
    print('{0}-{1}-{2}+{3}=7'.format(a, b, c, d))
elif a+b-c-d == 7:
    print('{0}+{1}-{2}-{3}=7'.format(a, b, c, d))
elif a-b+c-d == 7:
    print('{0}-{1}+{2}-{3}=7'.format(a, b, c, d))
elif a-b-c-d == 7:
    print('{0}-{1}-{2}-{3}=7'.format(a, b, c, d))

Measured memory_bytes: 9204
import java.util.Scanner;
public class Main {
	//?????°
	public static int x;
	//????????????
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		System.out.println(x*x*x);
	}
	public static void main(String[] args) {
		solve();
	}

}

Measured memory_bytes: 25988
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
S = set(map(int,input().split()))
for i in range(300):
    y = x-i
    if not y in S:
        print(y)
        break
    z = x+i
    if not z in S:
        print(z)
        break

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

struct Edge{
  int from;
  int to;
  long cost;
};

void dfs(vector<vector<Edge>> &Graph, int v, stack<int> &stk, vector<bool> &seen, vector<bool> &finish, bool &c){
  if(c) return;
  seen.at(v) = true;
  stk.push(v);
  for(Edge ed : Graph.at(v)){
    int nv = ed.to;
    if(seen.at(nv) && !finish.at(nv)){
      c = true;
      return;
    }
    if(finish.at(nv)) continue;
    dfs(Graph,nv,stk,seen,finish,c);
  }
  if(c) return;
  finish.at(v) = true;
  stk.pop();
}

long circuit(vector<vector<Edge>> &Graph, int s){
  stack<int> stk;
  vector<bool> seen(Graph.size(), false);
  vector<bool> finish(Graph.size(), false);
  bool c = false;
  dfs(Graph,s,stk,seen,finish,c);
  if(c) return stk.size();
  else return 0;
}


int main(){
  int n;
  cin >> n;
  vl a(n),b(n);
  vector<pll> data(n);
  rep(i,n) cin >> data.at(i).second;
  rep(i,n) cin >> data.at(i).first;
  sort(all(data));
  rep(i,n) {
    a.at(i) = data.at(i).second;
    b.at(i) = data.at(i).first;
  }
  sort(all(a));
  rep(i,n){
    if(a.at(i) > b.at(i)){
      NO;
      return 0;
    }
  }
  rep(i,n){
    if(a.at(i) == data.at(i).second){
      YES;
      return 0;
    }
  }
  if(n != unique(all(a)) - a.begin()){
    YES;
    return 0;
  }
  rep(i,n-1){
    if(a.at(i+1) <= b.at(i)){
      YES;
      return 0;
    }
  }
  map<long,int> mp;
  rep(i,n) mp[a.at(i)] = i;
  vector<vector<Edge>> Graph(n);
  rep(i,n){
    int to = mp.at(data.at(i).second);
    Graph.at(i).push_back(Edge{i,to,1});
  }
  if(circuit(Graph,0) == n) NO;
  else YES;
}

Measured memory_bytes: 24832
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
c = Counter(a)
if len(c)>2 or a[0]+1<a[-1]: print("No")
elif len(c)==1:
	if a[0]+1==n or n>=2*a[0]: print("Yes")
	else: print("No")
else:
	x,y = c[a[-1]],c[a[0]]
	if y+1<=a[-1]<=x//2+y: print("Yes")
	else: print("No")

Measured memory_bytes: 18656
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int dp[301][301],f[301][301];
string ch(string s,string t){
    memset(dp,0,sizeof(dp));
    memset(f,0,sizeof(f));
    s="@"+s,t="@"+t;
    int m=s.size(),n=t.size();
    for(int i=1;i<m;i++)
     for(int j=1;j<n;j++){
      if(s[i]==t[j]){
        dp[i][j]=dp[i-1][j-1]+1;
        f[i][j]=3;
      }
      else{
        if(dp[i-1][j]<dp[i][j-1]){
          dp[i][j]=dp[i][j-1];
          f[i][j]=2;
        }
        else{
          dp[i][j]=dp[i-1][j];
          f[i][j]=1;
        }
      }
    }
    int idx=dp[m-1][n-1];
    string ans;
    for(int i=m-1,j=n-1;i>0&&j>0&&idx;){
      if(f[i][j]==1)i--;
      else if(f[i][j]==2)j--;
      else i--,j--,idx--,ans+=s[i+1];
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
main(){
  string s;
  while(cin>>s,s!="#END"){
    string ans;
    for(int i=1;i<s.size();i++){
      string s1=s.substr(0,i);
      string s2=s.substr(i);
      string s3=ch(s1,s2);
      if(ans.size()<s3.size())ans=s3;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3920
import scala.io.StdIn.readInt
  
object Main extends App {
  val (x,minv) = (readInt, readInt)

  val m = (1 until x).foldLeft((minv,Int.MinValue)) { (x, _) =>
      val r = readInt
      (r.min(x._1), (r-x._1).max(x._2))
    }._2
  println(m)

}


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

const int maxn=2010;
const int maxm=maxn*maxn;
int n;
int a[maxn];
int sum;

bitset<maxm> dp[2];

int main(){

	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]), sum+=a[i];
	sum=(sum+1)/2;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		int ii=i&1;
		dp[ii]=dp[ii^1];
		dp[ii]|=dp[ii^1]<<a[i];
	}
	for(int i=sum;i<=sum*2;i++) if(dp[n&1][i]){ printf("%d\n", i); return 0; }
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9223372036854775807;
ll dp[1<<22];
int a[22][22];

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){  //　<-　注意
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<(1<<22);i++) dp[i]=0;
    dp[0]=1;
    for(int s=0;s<(1<<n);s++){
        int i=__builtin_popcount(s);
        for(int j=0;j<n;j++){
            if(a[i][j] && 1&(s>>j)){
                dp[s]+=dp[s^(1<<j)];
                dp[s]%=MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,m;cin>>n>>m;
	if(n>m) swap(n,m);
	if(n==1){
		if(m==1){
			cout<<1;
		}
		else {
			cout<<m-2;
		}
		return 0;
	}
	else {
		cout<<n*m-2*(n+m)+4;
	}
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(n)]

a.sort(reverse=True)
b.sort()
idxb = list()
for i in range(n):
    idx = -1
    maxy = -1
    for j in range(n):
        if not j in idxb:
            if a[j][0] < b[i][0] and maxy < a[j][1] < b[i][1] :
                maxy = a[j][1]
                idx = j
    if idx != -1:
        idxb.append(idx)

print(len(idxb))





Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmax(a,b) a=max(a,b);
#define chmin(a,b) a=min(a,b);
#define N 5010
ll f[N][N],n,a,b,p[N];
int main(){
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)cin>>p[i];
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)f[i][j]=1e17;
    f[0][0]=0;
    for(int i=0;i<n;i++){
	for(int j=0;j<=n;j++){
	    if(j<p[i]){
		chmin(f[i+1][p[i]],f[i][j]);
		chmin(f[i+1][j],f[i][j]+a);
	    }
	    else chmin(f[i+1][j],f[i][j]+b);
	}
    }
    ll ans=1e17;
    for(int i=0;i<=n;i++)chmin(ans,f[n][i]);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 196352
package main

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

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, _ := strconv.Atoi(nextStr(s))
	return n
}

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	var N, D int
	N = nextInt(s)
	D = nextInt(s)
	var ans = 0
	for i := 0; i < N; i++ {
		var x, y int
		x = nextInt(s)
		y = nextInt(s)
		if x*x+y*y <= D*D {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,mod=1000000007,a=0,b=0,r=0;
    cin>>n>>k;
    for(long long i=0;i<k;i++)
    {
        r+=n-i-i;
        ///r%=mod;
    }
    long long ans=0;
    for(long long i=k;i<=n+1;i++)
    {
        ///cout<<r<<' '<<ans<<endl;
        ans+=r+1;
        ans%=mod;
        r+=n-i-i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3592
from sys import stdin

s, t = stdin.read().split()
s = list(s)

possible_indexes = []
for i in range(len(s) - len(t) + 1):
    substring = s[i: i+len(t)]
    for j in range(len(t)):
        if substring[j] == t[j] or substring[j] == '?': continue
        else: break
    else:
        possible_indexes.append(i)

if not possible_indexes: print('UNRESTORABLE'); exit()

ma = max(possible_indexes)
for j in range(len(t)):
    s[ma+j] = t[j]

s = ''.join(s)

s = s.replace('?', 'a')
print(s)

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

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) cin >> v[i];

  
  int ans = 10000;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 3; j++) {
      ans = min(ans, v[i] + v[j]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *find(struct Node *,int);
void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);

struct Node *root,*NIL;

int main(){
  int n,i,x;
  char com[10];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,"find")==0){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

struct Node *find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Measured memory_bytes: 19364
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    
    int N;
    cin >> N;
    int ans = 0;
    long long int x = 1;
    while(x < N){
        x *= 3;
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

long long int x;


int main(){
    cin >> x;

    long long int a, b;
    

    for(long long int a = -120;a<=120;a++){
        for(long long int b = -120;b<=120;b++){
            if((a*a*a*a*a) - (b*b*b*b*b) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e17 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

struct UnionFind {
	int N;
	vector<int> siz;
	vector<int> par;
	vector<int> Rank;
	UnionFind(int n) : siz(n, 1), par(n), Rank(n, 0) {
		N = n;
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (Rank[x] < Rank[y]) {
			par[x] = y;
			siz[x] += siz[y];
			siz[y] = siz[x];
		}
		else {
			siz[y] += siz[x];
			siz[x] = siz[y];
			par[y] = x;
			if (Rank[x] == Rank[y]) Rank[x]++;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
};
void solve() {
	int N, M; cin >> N >> M;
	UnionFind uf(N);
	REP(i, M) {
		int a, b; cin >> a >> b;
		a--, b--;
		uf.unite(a, b);
	}
	int ans = 0;
	REP(i, N) {
		chmax(ans, uf.siz[uf.find(i)]);
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 7908