akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

typedef vector<int> vec;
typedef vector<vec> mat;
int n, l;
string s;
bool is_num(char t) {
	if ('0' <= t && t <= '9')return true;
	return false;
}
bool is_alf(char t) {
	if ('A' <= t && t <= 'Z')return true;
	return false;
}

int nex[100][100];
void mtmul(mat &A, mat &B) {
	rep(i, n) {
		rep(j, n) {
			int z = B[i][j];
			int x = z / n, y = z % n;
			nex[i][j] = A[x][y];
		}
	}
	rep(i, n) {
		rep(j, n) {
			A[i][j] = nex[i][j];
		}
	}
}
void repet(mat &A,int k) {
	mat ret(n);
	rep(i, n) {
		ret[i].resize(n);
		rep(j, n) {
			ret[i][j] = i * n + j;
		}
	}
	while (k) {
		if (k % 2) {
			mtmul(ret, A);
		}
		k >>= 1;
		mtmul(A, A);
	}
	A = ret;
}
void solve() {
	cin >> n >> l;
	cin >> s;
	mat E(n);
	rep(i, n) {
		E[i].resize(n);
		rep(j, n) {
			E[i][j] = i * n + j;
		}
	}
	stack<mat> st;
	mat cur = E;
	rep(i, l) {
		if (s[i] == '(') {
			st.push(cur); cur = E;
		}
		else if (is_alf(s[i])) {
			char memo = s[i];
			i++;
			int le = i;
			while (i + 1 < l&&is_num(s[i + 1]))i++;
			string t = s.substr(le, i - le + 1);
			int z = stoi(t) - 1;
			if (memo == 'L') {
				int u = cur[z][0];
				rep(j, n-1) {
					cur[z][j] = cur[z][j + 1];
				}
				cur[z][n - 1] = u;
			}
			else if (memo == 'R') {
				int u = cur[z][n - 1];
				for (int j = n - 1; j > 0; j--) {
					cur[z][j] = cur[z][j - 1];
				}
				cur[z][0] = u;
			}
			else if (memo == 'U') {
				int u = cur[0][z];
				rep(j, n - 1) {
					cur[j][z] = cur[j + 1][z];
				}
				cur[n - 1][z] = u;
			}
			else {
				int u = cur[n - 1][z];
				for (int j = n - 1; j > 0; j--) {
					cur[j][z] = cur[j - 1][z];
				}
				cur[0][z] = u;
			}
		}
		else if (s[i] == ')') {
			i++;
			int le = i;
			while (i + 1 < l&&is_num(s[i + 1]))i++;
			string t = s.substr(le, i - le + 1);
			int z = stoi(t);
			repet(cur,z);
			mat m = st.top(); st.pop();
			mtmul(m, cur);
			cur = m;
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (j > 0)cout << " ";
			cout << cur[i][j] + 1;
		}
		cout << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 17348
def solve(n, k):
    MOD = 998244353

    if n > k:
        return 0
    if n == 1:
        return pow(2, k - 1, MOD)

    invs = [1] * (k + 1)
    pf, kf = 1, 1
    for m in range(2, k + 1):
        pf = kf
        kf *= m
        kf %= MOD
        invs[m] = pow(kf, MOD - 2, MOD)

    ans = 0
    if k & 1 == 0:
        r = k >> 1
        s = k - n + 1
        ans = pf * (invs[r] * invs[r - 1] - invs[s] * invs[k - s - 1]) % MOD

    for r in range(k // 2 + 1, k + 1):
        if r * 2 >= n + k:
            ans += kf * invs[r] * invs[k - r]
        else:
            s = r * 2 - n + 1
            ans += kf * (invs[r] * invs[k - r] - invs[s] * invs[k - s])
        ans %= MOD
    return ans


print(solve(*map(int, input().split())))


Measured memory_bytes: 44908
#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 , a , b ;
cin >> n >> a >> b ;
ans+=n/(a+b) *a;
if(n%(a+b)>a)ans+=a;
else ans+=n%(a+b);
cout << ans << endl;
return 0;
}

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

using namespace std;

typedef long long LL;

int n,sum,ans,a[200005],b[200005],c[200005],d[200005],l,r;

int findl(int x)
{
	int l=1,r=n,mid,ans=-1;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (d[mid]>=x)
		{
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	return ans;
}
int findr(int x)
{
	int l=1,r=n,mid,ans=-1;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (d[mid]<=x)
		{
			ans=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=1;i<=n;++i) scanf("%d",&b[i]);
	for (int z=0;z<=28;++z)
	{
		int now=1<<z;
		now*=2;
		for (int i=1;i<=n;++i) c[i]=a[i]%now;
		for (int i=1;i<=n;++i) d[i]=b[i]%now;
		now/=2;
		sort(c+1,c+n+1);
		sort(d+1,d+n+1);
		ans=0;
		for (int i=1;i<=n;++i)
		{
			//B<=c[i]+d[i]<2B
			//3B<=c[i]+d[i]<4B
			l=findl(now-c[i]);
			r=findr(2*now-c[i]-1);
			if (l!=-1&&r!=-1) ans^=(r-l+1)&1;
			l=findl(3*now-c[i]);
			r=findr(4*now-c[i]-1);
			if (l!=-1&&r!=-1) ans^=(r-l+1)&1;
		}
		if (ans&1) sum^=now;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; ll k; cin>>n>>k; ll k1=k;
	int dk[40];
	int d0;
	for(int i=0; i<40; i++){
		dk[i]=(k&1);
		k>>=1;
		if(k==0){
			d0=i;
			break;
		}
	}
	ll a[100001];
	ll ct[40]={};
	ll s=0;
	for(int i=0; i<n; i++){
		cin>>a[i]; s+=(a[i]^k1);
	}
	if(k1==0){
		cout<<s<<endl;
		return 0;
	}
	for(int d=0; d<40; d++){
		for(int i=0; i<n; i++){
			if(a[i]&(1ll<<d)) ct[d]++;
		}
	}
	ll ans2=0;
	for(int i=d0+1; i<40; i++){
		ans2+=ct[i]*(1ll<<i);
	}
	ll ans=s;
	ll ans0=ans2;
	for(int i=d0; i>=0; i--){
		if(dk[i]){
			ll ans1=ans0;
			ans1+=ct[i]*(1ll<<i);
			for(int j=i-1; j>=0; j--){
				ans1+=max((ll)n-ct[j], ct[j])*(1ll<<j);
			}
			ans=max(ans, ans1);
		}
		if(dk[i]) ans0+=((ll)n-ct[i])*(1ll<<i);
		else ans0+=ct[i]*(1ll<<i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main (void) {
    int n;
    int nx = 0;
    int ny = 0;
    int nt = 0;
 
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        int x;
        int y;
        cin >> t >> x >> y;
        int diff = (t - nt) - (abs(x - nx) + abs(y - ny));
        if (diff < 0 || diff % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
        nt = t;
        nx = x;
        ny = y;
    }
 
    cout << "Yes" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, Y;
	cin >> N >> Y;

	bool f = false;

	for (int i = 0; i <= Y / 10000; i++) {
		for (int j = 0; j <= Y / 5000; j++) {
			if (i + j > N) break;

			int k = N - i - j;
			if (i + j + k == N) {
				int sum = 10000 * i + 5000 * j + 1000 * k;
				if (sum == Y) {
					cout << i << ' ' << j << ' ' << k << endl;
					return 0;
				}
			}
		}
	}

	cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

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

int main(){
	int k;
  	cin>>k;
  	int sum = 0;
  	for(int i=1;i<=k;i++){
    	for(int j=1;j<=k;j++){
        	for(int l=1;l<=k;l++){
            	sum+=__gcd(__gcd(i,j),l);
            }
        }
    }
  	cout<<sum;
  	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int ab, bc, ca;
    std::cin >> ab >> bc >> ca;

    std::cout << ab * bc / 2 << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, a, b, c, d; string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--; b--; c--; d--;
  auto can_go = [&] (int from, int to) {
    for (int i = from; i < to; ) {
      if (s[i + 1] == '.') {
        i++;
      } else {
        if (s[i + 2] == '.') {
          i += 2;
        } else {
          return false;
        }
      }
    }
    return true;
  };
  auto has_good_pos = [&] (int from, int to) {
    for (; from <= to; from++) {
      if (s[from - 1] == '.' && s[from] == '.' && s[from + 1] == '.') return true;
    }
    return false;
  };
  cout << (
    can_go(a, c) && can_go(b, d) &&
    (c < d || has_good_pos(b, d))
    ? "Yes" : "No"
    ) << endl;
  return 0;
}


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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
//#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  998244353;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}


int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n;
    cin>>n;
    ll a[100005] = {0};
    ll b[100005] = {0};
    ll c[100005] = {0};
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i]>>b[i]>>c[i];
    }

    ll dp[100005][3] = {0};
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];

    for(int i=2;i<=n;i++)
    {
    	dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
    	dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
    	dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c[i];
    }

    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << "\n";
	return 0;
}

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


struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main(){
    int N;
    double K;
    cin >>N>>K;
    double ans = 0;
    reps(i,1,N+1){
    double c;
    if(K<i){
        c = 1;
    }
    else{
        double a = log2 (K/double(i));
    int b = ceil(a);
    c = 1/(pow(2,b)); 
    }
    
    ans += (c/double(N));
   
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) cout << 1 << endl;
  else if (a == b || b == c || c == a) cout << 2 << endl;
  else cout << 3 << endl;
}

Measured memory_bytes: 256
import sys
N, = map(int, input().split())
X = list(map(int, input().split()))
S = X[0]+X[1]
T = 0
for i in range(2, N):
    T ^= X[i]
if S<T or (S-T)%2:
    print(-1)
    sys.exit()

D = (S-T)//2
if D&T:
    print(-1)
    sys.exit()

M = T.bit_length()+1
if D > X[0]:
    print(-1)
    sys.exit()

Y = D
for i in range(M, -1, -1):
    if T & (1<<i) and (1<<i)|Y <= X[0]:
        Y |= 1<<i

if Y == 0:
    print(-1)
else:
    print(X[0]-Y)


Measured memory_bytes: 62180
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    string s;
    cin >> s;

    int cnt = 0;
    for(int i = 1; i < s.size(); i++){
        if(s[i-1] != s[i]) cnt++; 
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll ans=0;
    rep(k,30){
      ll t=pow(2,k);
      ll cnt=0;
      vector<int> a2(a),b2(b);
      rep(i,n){
        a2[i]=a[i]%(2*t);
        b2[i]=b[i]%(2*t);
      }
      sort(begin(b2),end(b2));
      //cout<<' '<<k<<' '<<t<<endl;
      //cout_vec(b2);
      rep(i,n){
        cnt+=lower_bound(begin(b2),end(b2),2*t-a2[i])-lower_bound(begin(b2),end(b2),t-a2[i]);
        //cout<<i<<' '<<cnt<<' '<<lower_bound(begin(b2),end(b2),2*t-a2[i])-begin(b2)<<' '<<lower_bound(begin(b2),end(b2),t-a2[i])-begin(b2)<<' ';
        //cout<<i<<' '<<2*t-a[i]<<endl;
        cnt+=lower_bound(begin(b2),end(b2),4*t-a2[i])-lower_bound(begin(b2),end(b2),3*t-a2[i]);
        //cout<<cnt<<endl;
      }
      //cout<<k<<' '<<cnt<<endl;
      if(cnt%2==1) ans+=t;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3456
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> dts(n);
    for(int i = 0; i < n; i++){
        int t, d;
        cin >> t >> d;
        dts[i] = {d, t};
    }
    sort(dts.rbegin(), dts.rend());
    unordered_set<int> eaten;
    ll acc = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    for(int i = 0; i < k; i++){
        acc += dts[i].first;
        if(eaten.count(dts[i].second)){
            pq.push(dts[i].first);
        }else{
            eaten.insert(dts[i].second);
        }
    }
    ll ans = acc + eaten.size() * eaten.size();
    for(int i = k; i < n; i++){
        if(pq.empty()){ break; }
        printde(eaten);
        int t = dts[i].second;
        if(!eaten.count(t)){
            eaten.insert(t);
            acc -= pq.top(); pq.pop();
            acc += dts[i].first;
            ll cand = acc + ll(eaten.size() * eaten.size());
            printde(ans, cand);
            ans = max(ans, cand);
        }
    }
    cout << ans << '\n';
}


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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    double inv_sum = 0;
    for(int i = 0; i < N; i++)
    {
        inv_sum += 1.0 / A[i];
    }
    printf("%.6f\n", 1 / inv_sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
#define int ll
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e18;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 100000+1;

int32_t main()
{ 

  IOS 
    int n,m,x;
    cin>>n>>m>>x;
    int c[n];
    int a[n][m];
    for(int i = 0;i<n;i++){
      cin>>c[i];
      for(int j = 0;j<m;j++)
        cin>>a[i][j];
    }
    int ans = 1e17;
    for(int mask = 0;mask<(1<<n);mask++){
      int sum[m] = {0};
      int cost =0;
      for(int i =0;i<n;i++){
        if(((mask>>i)&1))
        {
          for(int j = 0;j<m;j++)
            sum[j]+=a[i][j];
          cost+=c[i];
        }
      }
      bool check = true;
      for(int i = 0;i<m;i++){
        check&=(sum[i]>=x);
      }
      if(check)
        {
          ans = min(ans,cost);
        }
    }
    if(ans>=1e15){
      cout<<-1<<endl;
    }
    else{
      cout<<ans<<endl;
    }

  

  




}


Measured memory_bytes: 3652
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int []d = new int [N];
      	for(int i=0; i<N; i++){
        	d[i] = sc.nextInt();
        }
      	int wa = 0;
      	for(int i=0; i<N; i++){
        	for(int j=0; j<N; j++){
            	if(i!=j)wa+=d[i]*d[j];
            }
        }
      	System.out.println(wa/2);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
string str;
int n;
int t[12],cnt;
int main(){
  while(cin>>n&&n){
    cin>>str;
    cnt=1;
    for(int i=0;i<11;i++)t[i]=0;
    for(int i=0;i<(int)str.length();i++){
      if(str[i]=='M'){
	t[cnt]++;
      }else if(str[i]=='S'){
	t[0]+=t[cnt]+1;
	t[cnt]=0;
      }else{
	t[cnt]+=t[0]+1;
	t[0]=0;
      }
      cnt++;
      if(cnt>n)cnt=1;
    }//for

    sort(t+1,t+n+1);

    for(int i=1;i<=n;i++){
      cout<<t[i]<<' ';
    }
    cout<<t[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#       )                         .MMdMMM;                    .M#(,dM]                        .:
#       )                        .M@d@d#Mb                    dMGMM(MN                        .:
#       )                        dM1MCdbMM_                  .M@MSN;dM-                       .:
#       )                       .M#(#?d#(Mb.. ...............JMIMIMLdM]                       .:
#       )                      ..M#?NHM# ?MMMMMMMMMH"""""""HMM@(Nad#(Mb                       .:
#       )                  .(MMMMH=..-(Jg[   `               daggmp  MNm,                     .:
#       )                ..MMY`     !qN;                       (J     ?MMN,                   .:
#       )               (MMD`       .MM@                      .MM{      .WMN,                 .:
#       )              dM@`         dMM%                      .MM}        (MMm                .:
#       )             .M#`          dMN!                      .MM}        ~(MMr               .:
#       )            .MM:           dM#                       .MM}        ..JM#               .:
#       )      ``    .M@            dMF                       .MM}        .~(M#   `  .        .:
#       )      ?MMMMMMMNgJ,         .7`                        T"!       .JJjMNgNNMMMB^       .:
#       )            dMr ?Mm,                                            7YYMM#!`             .:
#       )            dMb   ?`                  .,   ` ..                 ~.(MM%               .:
#       )         ..JgMMNNN)                  .Mn.(Mm-JM{               dHHMMNag.,            .:
#       )         ("!  ?MN,..,                (NM@"`~OMM}             ..~-(M@` _?"M[          .:
#       )               ,MMM#_                .M#    .M#`           .~.~JMMMNg-..             .:
#       )           ..gMB"?TMMNJ..              `     _`         .~~.(JdM#^  _"TMMNgJ-,       .:
#       )        .gMB=`      _7WMMNaJ...                 ....__-(JJgMMMM^          ?T"^       .:
#       )           ............  ?TWMMMMNNNNgggggggggggggNNMMMMMMBY7`...                     .:
#       )           WMMMMMMMMMMMMMNgJ,   (dMMMM#"TYYYYYYMMMMMMMNgMMMMMMMMMMMNNgJ-,            .:
#       )            -?TMNmuuuuUWMMMMMMNNMM@g@MMmJ--_(JMMg@g@@gMMMMMMWUXXXUWMMMMMMNe.         .:

import sys
import bisect
input = sys.stdin.readline

a,b,q = map(int,input().split())
s = []
t = []
for i in range(a):
    S = int(input())
    s.append(S)
for i in range(b):
    T = int(input())
    t.append(T)
s.sort()
t.sort()

def f(x):
    if 0<=x and a-1>= x:
        return True
    return False
def g(x):
    if 0<=x and b-1>= x:
        return True
    return False
for i in range(q):
    x = int(input())
    p = bisect.bisect_left(s,x)
    m = bisect.bisect_left(t,x)
    
    res = []
    if f(p) and g(m):
        res.append(max(t[m],s[p])-x)
    if f(p) and g(m-1):
        res.append(min(s[p]-x,x-t[m-1])+s[p]-t[m-1])
    if f(p-1) and g(m):
        res.append(t[m]-s[p-1]+min(t[m]-x,x-s[p-1]))
    if f(p-1) and g(m-1):
        res.append(x-min(t[m-1],s[p-1]))
    print(min(res))

Measured memory_bytes: 12212
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M,X = map(int, readline().split())
data = np.array(read().split(), np.int64)

data = data.reshape(N,-1)
C = data[:,0]
A = data[:,1:]

cost = np.zeros(1<<N, np.int64)
ability = np.zeros((1<<N, M), np.int64)
for i in range(N):
    cost[1<<i:1<<(i+1)] = cost[:1<<i] + C[i]
    ability[1<<i:1<<(i+1)] = ability[:1<<i] + A[i]

ok = np.all(ability >= X, axis=1)

x = cost[ok]
answer = -1 if len(x) == 0 else x.min()
print(answer)

Measured memory_bytes: 27612
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int A,B,C,D,E,F;
	cin >>A>>B>>C>>D>>E>>F;
	
	vector<int> mizu(3010,-1);
	mizu[0]= 0;
	A *= 100;
	B *= 100;
	const int W_MAX = 3000;
	for(int i=0;i<=W_MAX;++i){
		if( mizu[i] >= 0 ){
			if( i+A <= W_MAX ){
				mizu[i+A] = 0;
			}
			if( i+B <= W_MAX ){
				mizu[i+B] = 0;
			}
		}
	}
	vector<int> syu(3010,-1);
	syu[0] = 0;
	for(int i=0;i<=W_MAX;++i){
		if( syu[i] >= 0 ){
			if( i + C <= W_MAX ){
				syu[i+C] = 0;
			}
			if( i+D <= W_MAX ){
				syu[i+D] = 0;
			}
		}
	}
	vector<int> mizuR,syuR;
	for(int i=0;i<=W_MAX;++i){
		if( mizu[i] >= 0 ){
			mizuR.push_back( i );
		}
		if( syu[i] >= 0 ){
			syuR.push_back( i );
		}
	}
	
	int size = mizuR.size();
	vector<int>::iterator itr;
	int ansMiz = 0;
	int ansSyu = 0;
	for(int i=0;i<size;++i){
		int nowMiz = mizuR[i];
		int weiMAX = F-nowMiz;//重さの最大値
		if( weiMAX < 0 ){
			break;
		}
		int syuMAX = (nowMiz/100)*E;//砂糖の最大値
		int res = min(weiMAX,syuMAX);
		itr = lower_bound( syuR.begin(), syuR.end(), res);
		if( itr == syuR.end() ){
			--itr;
		}
		while( res < (*itr)){
			--itr;
		}
		int mount = *itr;//砂糖をいれる最大量
		//iにmountいれる
		if( ansMiz == 0 && ansSyu == 0 ){
			ansMiz = nowMiz;
			ansSyu = mount;
		}else if( ansSyu*(nowMiz+mount) < mount*(ansMiz+ansSyu) ){
			ansMiz = nowMiz;
			ansSyu = mount;
		}
	}
	cout << ansMiz+ansSyu << " " << ansSyu << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

bool Judge_Leap_Year( int x )
{
    bool j = false;
    if( x % 4 == 0 )
        j = true;
    if( x % 100 == 0 )
        j = false;
    if( x % 400 == 0 )
        j = true;
    return j;
}

int main()
{
    int a, b, cnt = 0;
    while( cin >> a >> b )
    {
        if( a == 0 && b == 0 )
            break;
        if( cnt != 0 )          //最初の一回を除いて、空行を出力。
            cout << endl;       //嫌がらせ。
        cnt++;
        bool j = false;
        for( int i = a; i <= b; i++ )
        {
            if( Judge_Leap_Year(i) == true )
            {
                j = true;
                cout << i << endl;
            }
        }
        if( j == false )
            cout <<"NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

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


ll dp[100010];

int main() {

    int n;
    cin >> n;

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

    for (int i = 0; i < 100010; i++) {
        dp[i] = INF;
    }
    
    dp[0] = 0;
    /*
    dp[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    */

   for (int i = 1; i < n; i++) {
       chmin(dp[i], dp[i-1] + abs(h[i-1] - h[i]));
       if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i-2] - h[i]));
   }

    cout << dp[n-1] << endl;

    return 0;
    
    

}

Measured memory_bytes: 1408
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input()) - 1])

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

int main()
{
    std::string s;
    std::cin >> s;
    int n[4];
    char op[3] = "+-";
    int opi[] = {1, -1};
    for (int i = 0; i < 4; i++) {
        n[i] = s[i] - '0';
    }

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                if (n[0] + n[1]*opi[i] + n[2]*opi[j] + n[3]*opi[k] == 7) {
                    std::cout << n[0] << op[i] << n[1] << op[j] << n[2] << op[k] << n[3] << "=7" << std::endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(5010), Mod(1e9 + 7);
struct edge { int next, to; } e[N << 1];
int head[N], e_num, f[N][N], g[N], size[N], n;
inline void add_edge(int from, int to)
{
	e[++e_num] = (edge) {head[from], to};
	head[from] = e_num;
}

void dfs(int x, int fa)
{
	static int tmp[N];
	size[x] = 1; int *fx = f[x]; fx[1] = 1;
	for (int i = head[x]; i; i = e[i].next)
	{
		int to = e[i].to; if (to == fa) continue;
		dfs(to, x);
		for (int j = 0; j <= size[x]; j++)
			for (int k = 0; k <= size[to]; k++)
				tmp[j + k] = (tmp[j + k] + 1ll * fx[j] * f[to][k]) % Mod;
		size[x] += size[to], std::copy(tmp + 1, tmp + size[x] + 1, fx + 1);
		std::fill(tmp + 1, tmp + size[x] + 1, 0);
	}
	fx[0] = 0;
	for (int i = 1; i <= size[x]; i++)
		fx[0] = (fx[0] - 1ll * fx[i] * g[i] % Mod + Mod) % Mod;
}

int main()
{
	n = read(), g[0] = 1;
	for (int i = 1, a, b; i < n; i++)
		a = read(), b = read(), add_edge(a, b), add_edge(b, a);
	for (int i = 2; i <= n; i += 2) g[i] = 1ll * g[i - 2] * (i - 1) % Mod;
	dfs(1, 1); printf("%d\n", Mod - f[1][0]);
	return 0;
}
//

Measured memory_bytes: 97280
n = int(input())

f = []
for i in range(n):
    f.append(list(map(int, input().split())))

p = []
for i in range(n):
    p.append(list(map(int, input().split())))

# bit全探索
ans = -10**10

for i in range(1, 2**10):
    l = [0 for _ in range(10)]
    for j in range(10):
        if i & 2 ** j > 0:
            l[j] = 1
    score = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if f[j][k] == l[k] == 1:
                count += 1
        score += p[j][count]
    ans = max(ans, score)
print(ans)

Measured memory_bytes: 3064
// B - ss
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string S; cin>>S;
	int N = S.size();
	rp(d, 1, N-1){//number of del char
		int n = N - d;
		if(n%2) continue; //n: odd
		int len = n/2;//len: half length
		int f;
		for(f=0; f<len; ++f) if(S[f] != S[len + f]) break;//fore half != back half -> break
		if(f >= len){
			cout<< n <<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, x, t;

int main(){
    multiset<int> p;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        p.insert(x);
    }

    for(auto it = p.begin(); it != p.end(); ++it){
        if(it != --p.end()){
            t = t + *it;
        } else{
            t = t + (*it/2);
        }
    }

    cout << t;


}

Measured memory_bytes: 256
def ch(data):
    data.sort()
    if max(data.count(i) for i in range(1, 10)) > 4:
        return False
    if len(data) == 2 and data[0] == data[1]:
        return True
    for i in range(1, 10):
        if data.count(i) >= 3:
            tmp = data[:]
            for _ in range(3):
                tmp.remove(i)
            if ch(tmp):
                return True
    for i in range(7):
        if i + 1 in data and i + 2 in data and i + 3 in data:
            tmp = data[:]
            for j in range(3):
                tmp.remove(i + j + 1)
            if ch(tmp):
                return True
    return False

while True:
    try:
        data = list(map(int, input()))
        if not len(data):
            break
    except:
        break
    res = []
    for i in range(1, 10):
        if ch(data + [i]):
            res.append(i)
    print(*res if len(res) else [0])

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

int main(){
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;

    for(int i = 0;i < s.size();i++){
        if(i != a){
            if(!('0' <= s[i] && s[i] <= '9')){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	float c;
	if(b==100)c=1000*a+b;
	else	if(b>9) c=100*a+b;
		else c=10*a+b;
		int d=c/sqrt(c);
	if(d==sqrt(c))
		printf("Yes\n");
	else printf("No\n");
}

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

int dp[31];

int main(){
  dp[0] = 1;
  for(int i=0;i<30;i++){
    for(int j=1;j<=3;j++){
      if(i+j<=30)dp[i+j] += dp[i];
    }
  }

  int n;
  while(cin >> n, n){
    cout << ((dp[n]+9)/10+364)/365 << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
int n,k,d,a[101]={},i,j,s,r=0;
int main(){
    scanf("%d%d",&n,&k);
    for(i=0;i<k;i++){
        scanf("%d",&d);
        for(j=0;j<d;j++){
            scanf("%d",&s);
            a[s]++;
        }
    }
    for(i=1;i<=n;i++)if(a[i]==0)r++;
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll n,m;
cin>>n>>m;
ll p[m+1];
string s[m+1];
ll c1=0,c2=0;
ll corr[n];
ll w[n];
bool vis[n];
 for(int i = 1; i <= n; i++) {
        w[i] = 0;
        corr[i]=0;
        vis[i]=false;
    }
 
for(int i=0;i<m;i++){
    cin>>p[i]>>s[i];
    if(vis[p[i]]) continue;
    if(s[i]=="AC"){
        vis[p[i]]=true;
       c1++;
        c2+=w[p[i]];
      
    }
    else if(s[i]=="WA"){
        w[p[i]]++;
        //cout<<w[p[i]]<<endl;
    }
}
    
cout<<c1<<" "<<c2<<endl;
 
}

Measured memory_bytes: 8192
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
//#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
       int a,b,c,d;
       cin>>a>>b>>c>>d;
       int x=(a+d-1)/d;
       int y=(c+b-1)/b;
       if(x>=y)
       cout<<"Yes";
       else
       cout<<"No";
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3648
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var map = new char[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++) map[i, j] = s[j];
        }
        var s12 = Console.ReadLine().Trim() + Console.ReadLine().Trim();
        var dm = getDM(map, s12, h, w);
        Console.WriteLine(dm );
    }
    static int getDM(char[,] map, string s12, int h, int w)
    {
        var dm = 0; var count = 0;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
            {
                if (i < h - 1 && j < w - 1)
                    if (s12[0] == map[i, j] &&
                       s12[1] == map[i, j + 1] &&
                       s12[2] == map[i + 1, j] &&
                       s12[3] == map[i + 1, j + 1]) count++;
                var cj = checkJOI(map, s12, h, w, i, j, 'J');
                var jo = checkJOI(map, s12, h, w, i, j, 'O');
                var ji = checkJOI(map, s12, h, w, i, j, 'I');
                var tm = Max(cj, Max(jo, ji));
                dm = Max(dm, tm);
            }
        return dm + count;
    }
    static int checkJOI(char[,] map, string s12, int h, int w, int x, int y, char cc)
    {
        var ans = 0;
        if (x - 1 >= 0 && y - 1 >= 0)
        {
            var org = "" + map[x - 1, y - 1] + map[x - 1, y] + map[x, y - 1] + map[x, y];
            var cj = "" + map[x - 1, y - 1] + map[x - 1, y] + map[x, y - 1] + cc;
            if (cj == s12 && org != s12) ans++;
            if (cj != s12 && org == s12) ans--;
        }
        if (x - 1 >= 0 && y + 1 < w)
        {
            var org = "" + map[x - 1, y] + map[x - 1, y + 1] + map[x, y] + map[x, y + 1];
            var cj = "" + map[x - 1, y] + map[x - 1, y + 1] + cc + map[x, y + 1];
            if (cj == s12 && org != s12) ans++;
            if (cj != s12 && org == s12) ans--;
        }
        if (x + 1 < h && y - 1 >= 0)
        {
            var org = "" + map[x, y - 1] + map[x, y] + map[x + 1, y - 1] + map[x + 1, y];
            var cj = "" + map[x, y - 1] + cc + map[x + 1, y - 1] + map[x + 1, y];
            if (cj == s12 && org != s12) ans++;
            if (cj != s12 && org == s12) ans--;
        }
        if (x + 1 < h && y + 1 < w)
        {
            var org = "" + map[x, y] + map[x, y + 1] + map[x + 1, y] + map[x + 1, y + 1];
            var cj = "" + cc + map[x, y + 1] + map[x + 1, y] + map[x + 1, y + 1];
            if (cj == s12 && org != s12) ans++;
            if (cj != s12 && org == s12) ans--;
        }
        return ans;
    }
}



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

using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b>> c >> d;
	
	int ans = max(a, b)-min(c, d);
	int freq[101] = {0};
	
	for(int i = a; i < b; i ++)
		freq[i] ++;
		
	for(int j = c; j < d; j++)
		freq[j]++;
		
	int count = 0;
	for(int i = 0; i <= 100; i++){
		if(freq[i] > 1)
			count ++;
	}
	cout << count << endl;
	return 0;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int H, W, K;
    std::cin >> H >> W >> K;
    std::vector<string> C(H);
    REP(i, H) {
        std::cin >> C[i];
    }

    int ans = 0;
    for(int wi = 0; wi < (1 << W); wi++) {
        for(int hi = 0; hi < (1 << H); hi++) {
            int cnt = 0;
            REP(i, W) {
                if(wi & (1 << i)) {
                    REP(j, H) {
                        if(hi & (1 << j)) {
                            if(C[j][i] == '#') cnt++;
                        }
                    }
                }
            }
            if(cnt == K) ans++;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3592
n = int(input())
numsA = list(map(int, input().split()))
q = int(input())
numsB = list(map(int, input().split()))
count = 0

# for i in range(n):
#     for j in range(q):
#         if numsB[j] == numsA[i]:
#             count += 1
#             break

for i in range(q):
    for j in range(n):
        if numsB[i] == numsA[j]:
            count += 1
            break

print(count)



Measured memory_bytes: 6324
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

	long maxh = -1;
	long i_maxh = 0;
	long x[100]={0}, y[100]={0}, h[100]={0};
	long i;
	for(i=0; i<n; i++) {
		scanf("%ld %ld %ld", &(x[i]), &(y[i]), &(h[i]));
		if (maxh < h[i]) {
			maxh = h[i];
			i_maxh = i;
		}
	}

	long xx, yy;
	for(xx=0; xx<=100; xx++) {
		for(yy=0; yy<=100; yy++) {
			long hh = abs(x[i_maxh] - xx) + abs(y[i_maxh] - yy) + h[i_maxh]; 
			for(i=0; i<n; i++) {
				long value = hh - abs(x[i] - xx) - abs(y[i] - yy);
				if ( value < 0 ) {
					value = 0;
				}
				if( value != h[i] ) {
					break;
				}
			}
			if(i==n) {
				printf("%d %d %d\n", xx, yy, hh);
				return 0;
			}
		}
	}

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	string s ; cin >> s ;
	string t = s ;
	reverse(all(t)) ;
	string u,v,w,x ;
	for(int i=0;i<s.size()/2;i++) u += s.at(i) ;
	v = u ;
	reverse(all(v)) ;
	for(int i=s.size()/2+1;i<s.size();i++) w += s.at(i) ;
	x = w ;
	reverse(all(x)) ;
	cout << (s==t&&u==v&&w==x?"Yes":"No") << endl ;
}




Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,p;
  vector<int>prime;
  cin >> n >> p;
  if(n==1)cout<<p<<endl;
  else if(n==2){
    int ans = 1;
    for(long i=2;i<=sqrt(p);i++){
      if(p%(i*i)==0)ans=i;
    }
    cout<<ans<<endl;
  }else{
    int ans = 1;
    for(int i=2;i<=p;i++){
      long tmp = 1;
      bool chk=true;
      for(int j=0;j<n;j++){
        tmp*=i;
        if(tmp>p){
          chk=false;
          break;
        }
      }
      if(chk){
        if(p%tmp==0)ans=i;
      }else break;
    }
    cout<<ans<<endl;
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}


int main(){
  int n;
  cin >>n ;
  
  int h[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int dp[n+10];//n+9番目までのcostの最小値
  dp[1] = abs( h[0] ,h[1] );
  dp[0] = 0;
  for(int i=0; i<= n;i ++){
    dp[i+2] = min(dp[i] + abs(h[i],h[i+2]) , dp[i+1] + abs( h[i+2] , h[i+1])  );
    
  }
  
  cout <<dp[n-1] <<endl;
}

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

namespace ABC084C {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] C = new int[N - 1];
            int[] S = new int[N - 1];
            int[] F = new int[N - 1];
            for (int i = 0; i < N - 1; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                C[i] = input[0];
                S[i] = input[1];
                F[i] = input[2];
            }
            for (int i = 0; i < N; i++) {
                int time = 0;
                int start = 0;
                for (int j = 0; j < (N - i - 1); j++) {
                    if (S[i + j] >= time) {
                        start = S[i + j];
                    } else {
                        start = S[i + j] + ((time - S[i + j] + F[i + j] - 1) / F[i + j]) * F[i + j];
                    }
                    time = start + C[i + j];
                }
                Console.WriteLine(time);
            }
        }
    }
}

Measured memory_bytes: 13396
package main

import (
	"fmt"
	"strconv"
	"strings"
)

var (
	n, c int
	max  = 9
	set  = []string{"7", "5", "3"}
)

func search(s string) {
	i, _ := strconv.Atoi(s)
	skip := i > n
	for _, r := range set {
		skip = skip || !strings.Contains(s, r)
		if len(s) < max {
			search(s + r)
		}
	}
	if !skip {
		c++
	}
}

func main() {
	fmt.Scan(&n)
	search("")
	fmt.Println(c)
}

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

int main(){
  int n;
  cin >> n;
  int A[n];

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

  for (int i=n-1; i >=0; i--){
    if(i==0){
      cout << A[i];
    }
    else{
    cout << A[i] << " ";
    }
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 3080