akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > A(m);
    rep(i, m) {
        cin >> A[i].first >> A[i].second;
    }
    vi vec(n);
    rep(i, n) {
        vec[i] = i+1;
    }
    int C=0;
    do {
        if(vec[0] != 1) continue;
        bool able = true;
        rep(i, n-1){
            bool OK = false;
            rep(j, m) {
                if(A[j] == make_pair(vec[i], vec[i+1]) || A[j] == make_pair(vec[i+1], vec[i])) {
                    OK = true;
                    break;
                }
            }
            if(!OK) {
                able = false;
                break;
            }
        }
        if(able) {
            ++C;
        }
    } while(next_permutation(vec.begin(), vec.end()));
    cout << C << endl;
}

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

int main()
{
	int n;
	long long k;
	scanf("%d%lld", &n, &k);
	std::vector<long long> a(n), value_delta(64);
	for (auto &e : a)
		scanf("%lld", &e);
	long long x{}, value{};
	for (int digit_i{}; digit_i <= 40; digit_i++)
	{
		int count{};
		for (int j{}; j < n; j++)
			count += a[j] >> digit_i & 1;
		if (n - count > count)
		{
			x += 1LL << digit_i;
			value += (long long)(n - count) << digit_i;
			value_delta[digit_i] = (long long)(n - 2 * count) << digit_i;
		}
		else
			value += (long long)count << digit_i;
	}
	int digit{50};
	for (; digit >= 0 && (~k >> digit & 1); digit--)
	{
		x &= ~(1LL << digit);
		value -= value_delta[digit];
	}
	long long best_value{};
	for (int digit_i{digit}; x > k; digit_i--)
	{
		if (~x >> digit_i & 1) continue;
		if (k >> digit_i & 1)
			best_value = std::max(best_value, value - value_delta[digit_i]);
		else if (~k >> digit_i & 1)
		{
			x &= ~(1LL << digit_i);
			value -= value_delta[digit_i];
		}
	}
	printf("%lld\n", std::max(value, best_value));

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

double const INF = 1e18;
struct range { 
  double ma, mi;
  range(): ma(-INF), mi(INF) {}
  range(double hi, double lo): ma(hi), mi(lo) {}
  void update(double v) {
    ma = std::max(ma, v);
    mi = std::min(mi, v);
  }
void print() const { std::cout << "[" << mi << ", " << ma << "]\n"; }
};

void add_time(std::vector<double>& ts, range r[3]) {
  auto add_one = [&](std::vector<double>& t, double v)->void { if(v >= 0 && v <= 2e8) t.push_back(v); };
  //up to stop;
  add_one(ts, r[1].ma - r[2].ma);
  add_one(ts, r[1].ma - r[2].mi);
  add_one(ts, r[1].mi - r[2].ma);
  add_one(ts, r[1].mi - r[2].mi);
  //down to stop;
  add_one(ts, r[0].ma - r[1].ma);
  add_one(ts, r[0].ma - r[1].mi);
  add_one(ts, r[0].mi - r[1].ma);
  add_one(ts, r[0].mi - r[1].mi);
  // up to down
  add_one(ts, (r[0].ma - r[2].ma)*0.5);
  add_one(ts, (r[0].ma - r[2].mi)*0.5);
  add_one(ts, (r[0].mi - r[2].ma)*0.5);
  add_one(ts, (r[0].mi - r[2].mi)*0.5);
}

double calc(double t, range r[3]) {
  double ma = r[1].ma, mi = r[1].mi;
  ma = std::max(ma, r[0].ma - t);
  ma = std::max(ma, r[2].ma + t);
  mi = std::min(mi, r[0].mi - t);
  mi = std::min(mi, r[2].mi + t);
  return ma - mi;
}

int main() {
  std::cout << std::setprecision(10) << std::fixed;
  int N; std::cin >> N;
  range x[3], y[3]; // 0:dec, 1:stop, 2:inc
  for(int i = 0; i < N; ++i) {
    double xx, yy; char d; std::cin >> xx >> yy >> d;
    switch(d) {
    case 'R': x[2].update(xx); y[1].update(yy); break;
    case 'L': x[0].update(xx); y[1].update(yy); break;
    case 'U': x[1].update(xx); y[2].update(yy); break;
    case 'D': x[1].update(xx); y[0].update(yy); break;
    }
  }
  std::vector<double> ts(1,0);
  add_time(ts, x);
  add_time(ts, y);
  std::sort(ts.begin(), ts.end());
  ts.erase(std::unique(ts.begin(), ts.end()), ts.end());
  double ans = INF;
  for(double t: ts) ans = std::min(ans, calc(t, x)*calc(t, y));
  fin(ans);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

ll g[200000], ig[200000];

bool istrue(int perm[], int n){
    map <int,int> mm;
    for(int i=1;i<=n;i++){
        mm[i+perm[i]]++;
        if(mm[i+perm[i]]>1) return 0;
    }

    map <int,int> mm2;
    for(int i=1;i<=n;i++){
        mm2[i-perm[i]]++;
        if(mm2[i-perm[i]]>1) return 0;
    }

    return 1;
}

void findall(vector<string> &ans, string ptup, int left, int right, int n){
    
    if(ptup.size()==2*n){
        ans.push_back(ptup);
        // cout<<"yo";
        return;
    }
    if(left){
        ptup+='(';
        findall(ans,ptup,left-1,right,n);
        ptup.pop_back();
    }
    if(left!=right and right){
        ptup+=')';
        findall(ans,ptup,left,right-1,n);
        ptup.pop_back();        
    }
    
}


void solve()
{   

    int x;
    cin>>x;

    if(x>=30) cout<<"Yes\n";
    else cout<<"No";



}

int main() {

    g[1] = 1;
    ig[1] = 1;
    for (ll i = 2; i < 100000; ++i) {
        g[i] = 1 + g[i - g[g[i - 1]]];
        ig[i] = ig[i - 1] + i * g[i];
    }


    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 5408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  bool fin = false;
  
  for (int i = 1; i <= b; i++) {
    if (a*i%b == c) {
      cout << "YES";
      fin = true;
      break;
    }
  }
  
  if(!fin)
    cout << "NO";
      
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
const ll INF = (int)1e18;

int main() {
  int n, m;
  ll l;
  cin >> n >> m >> l;

  vector< vector<ll> > dist(n, vector<ll>(n, INF));
  for (int i = 0; i < n; ++i) dist[i][i] = 0;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }

  for (int k = 0; k < n; ++k) 
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
	dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  vector< vector<ll> > dist2(n, vector<ll>(n, INF));
  for (int i = 0; i < n; ++i) dist2[i][i] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (dist[i][j] <= l) dist2[i][j] = 1;
    }
  }

  for (int k = 0; k < n; ++k) 
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
	dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);

  int q;
  cin >> q;
  vector<ll> ans;
  while (q--) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    ans.push_back(dist2[s][t] == INF? -1: dist2[s][t] - 1);
  }
  for (ll a: ans) {
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 2808
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char A[110000];
char B[110000];
char C[110000];
char D[110000];
long long U[110000];
long long S[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	scanf("%s%s%s%s",A,B,C,D);
	int cnt=0;
	for(int i=0;i<a;i++)cnt+=A[i]-'0';
	for(int i=0;i<a;i++)cnt+=B[i]-'0';
	for(int i=0;i<b;i++)cnt+=C[i]-'0';
	for(int i=0;i<b;i++)cnt+=D[i]-'0';
	if(cnt==0){
		printf("1\n");return 0;
	}
	long long ret=0;
	init_C(410000);
	for(int w=0;w<2;w++){
		int l=0;
		int r=0;
		int uc=0;
		int dc=0;
		for(int i=0;i<b;i++){
			uc+=C[i]-'0';
			dc+=D[i]-'0';
		}
		for(int i=0;i<110000;i++)U[i]=S[i]=0;
		for(int i=0;i<a;i++){
			U[i]=Comb(l+r+uc-1,l+r);
			if(l+r==0)U[i]=1;
			if(A[i]=='1')l++;
			if(B[i]=='1')r++;
		}
		l=0;
		r=0;
		for(int i=0;i<a;i++){
			S[i]=Comb(l+r+dc-1,l+r);
			if(l+r==0)S[i]=1;
			if(A[a-1-i]=='1')l++;
			if(B[a-1-i]=='1')r++;
		}
		// for(int i=0;i<a;i++)printf("%d: %lld %lld\n",i,U[i],S[i]);
		long long ks=0;
		for(int i=0;i<a;i++){
			if(A[i]=='1'||B[i]=='1')ks=(ks+U[i])%mod;
			if(A[i]=='1'&&B[i]=='1')ks=ks*2%mod;
			if(A[i]=='1'||B[i]=='1')ret=(ret+ks*S[a-i-1])%mod;
			// printf("%d: %lld %lld\n",i,ks,S[a-i-1]);
		}
		swap(a,b);
		swap(A,C);
		swap(B,D);
	}
	printf("%lld\n",ret);
}



Measured memory_bytes: 18560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc058.contest.atcoder.jp/tasks/arc058_c>
 問題文============================================================
 日本の誇る美しいリズムとして、五七五というものがあります。
 いろはちゃんは、数列から五七五を探すことにしました。でもこれは簡単だったので、XYZを探すことにしました。
 
 長さ N の、それぞれの値が 1~10 の数列 a0,a1,…,aN−1 を考えます。
 このような数列は全部で 10^N 通りありますが、そのうちXYZを含むものは何通りでしょう？
 
 ただし、XYZを含むとは以下のように定義されます。
 
 ax+ax+1+…+ay−1=X
 ay+ay+1+…+az−1=Y
 az+az+1+…+aw−1=Z
 
 を満たす 0≦x<y<z<w≦N が存在する。
 
 なお、答えは非常に大きくなることがあるので、答えは 10^9+7 で割ったあまりを出力してください。
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

#define MAX_N 45
#define MAX_S 18
ll dp[MAX_N][1<<MAX_S];
ll solve(){
    ll res = 0;
    ll N,X,Y,Z; cin >> N >> X >> Y >> Z;
    dp[0][0] = 1;
    ll base = (1<<(X+Y+Z-1))|(1<<(Y+Z-1))|(1<<(Z-1));
    for(int i = 0; i < N;i++){
        for(int j = 0; j < (1<<MAX_S);j++){
            for(int k = 1; k <=10; k++){
                ll next = (j<<k)|(1<<(k-1)); next = next&((1<<MAX_S)-1);
                if((next&base)!=base){
                    (dp[i+1][next] += dp[i][j])%=MOD;
                }
            }
        }
    }
    ll Sum = 0;
    for(int i = 0; i < (1<<MAX_S);i++) (Sum += dp[N][i])%=MOD;
    res = (powmod(10, N) - Sum + MOD*2)%MOD;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

const int N=105;
const int INF=1e7;
int n,m,f[N][N],u[N*N],v[N*N],c[N*N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			f[i][j]=INF;
	for(int i=0;i<n;++i)
		f[i][i]=0;
	for(int i=0;i<m;++i){
		cin>>u[i]>>v[i]>>c[i];
		--u[i],--v[i];
		f[u[i]][v[i]]=min(f[u[i]][v[i]],c[i]);
		f[v[i]][u[i]]=min(f[v[i]][u[i]],c[i]);
	}
	for(int k=0;k<n;++k)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	int res=m;
	for(int i=0;i<m;++i){
		bool ok=false;
		for(int j=0;j<n;++j)
			if(f[j][u[i]]+c[i]==f[j][v[i]]) ok=true;
		if(ok) --res;
	}
	cout<<res<<'\n';
}




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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int ord[310][310];
bool deleated[310];

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

  int N, M;
  cin >> N >> M;

  rep(i, N){
    rep(j, M){
      cin >> ord[i][j];
      ord[i][j]--;
    }
  }

  int ans = N+1;
  rep(m, M){

    vector<int> cnt_suki(M);
    rep(i, M){
      cnt_suki[i] = 0;
    }

    rep(i, N){
      rep(j, M){
        if(!deleated[ord[i][j]]){
          cnt_suki[ord[i][j]]++;
          break;
        }
      }
    }

    int max_sanka = 0;
    int tmp_sport;
    rep(i, M){
      if(chmax(max_sanka, cnt_suki[i])){
        tmp_sport = i;
      }
    }
    deleated[tmp_sport] = true;

    chmin(ans, max_sanka);
    
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define AC ios::sync_with_stdio(false);cin.tie(0);
#define ll long long


int main()
{
    AC
    ll n, m, count=0;
    cin>>n>>m;
    ll a[m];
    for(int i=0; i<m; i++)
    {
        cin>>a[i];
        count +=a[i];
    }
    n = n-count;
    if(n>=0) cout<<n;
    else cout<<"-1";

}

Measured memory_bytes: 3680
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <climits>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
//const int mod=1e9+7;
//const ll inf = (ll)1e16 + 7;
const int N=1e5+7;

int main(){
    fast;
    int k,s,ans=0;
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y<=k and s-x-y>=0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if (A + B >= C) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 20820
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;

bool check(int p) {
    if (p < 0 || p >= n) return false;
    else return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    V<int> p(n * n, -1);
    for (int i = 0; i < n * n; i++) {
        cin >> p[i];
        p[i]--;
    }

    V< V<int> > dist(n, V<int>(n));
    V< V<bool> > used(n, V<bool>(n, false));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) dist[i][j] = min({i, j, n - i - 1, n - j - 1});
    }

    V<int> dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
    int ans = 0;
    for (int i = 0; i < n * n; i++) {
        int x = p[i] / n, y = p[i] % n;
        ans += dist[x][y];
        used[x][y] = true;

        queue< P<int, int> > que;
        que.push( make_pair(x, y) );

        while (!que.empty()) {
            P<int, int> q = que.front(); que.pop();
            int tx = q.first, ty = q.second;
            for (int di = 0; di < 4; di++) {
                int nx = tx + dx[di], ny = ty + dy[di];
                if (!check(nx) || !check(ny)) continue;
                if (used[tx][ty] && dist[nx][ny] > dist[tx][ty]) {
                    dist[nx][ny] = dist[tx][ty];
                    que.push( make_pair(nx, ny) );
                } else if (!used[tx][ty] && dist[nx][ny] > dist[tx][ty] + 1) {
                    dist[nx][ny] = dist[tx][ty] + 1;
                    que.push( make_pair(nx, ny) );
                }
            }
        }
        // cout << x << ' ' << y << '\n';
        // for (int j = 0; j < n; j++) DEBUG_VLL(dist[j])
        // cout << '\n';
    }
    cout << ans << '\n';
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
ll gcd(ll a, ll b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    ll ans = 0;
    ans += b - (b / c) - (b / d) + (b / (c * d / gcd(c, d)));
    ans -= a - (a / c) - (a / d) + (a / (c * d / gcd(c, d)));

    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            double m = double.Parse(x[0].ToString() + x[1].ToString());
            Console.WriteLine(Math.Ceiling(Math.Sqrt(m)) - Math.Sqrt(m) == 0 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11220
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

int n, a[5],b;

int main()
{
	b=7;
	scanf("%1d%1d%1d%1d",&a[1],&a[2],&a[3],&a[4]);
	if(a[1] + a[2] +a[3] +a[4] == b)
		printf("%d+%d+%d+%d=7",a[1],a[2],a[3],a[4]);
	else if(a[1] - a[2] +a[3] +a[4] == b)
		printf("%d-%d+%d+%d=7",a[1],a[2],a[3],a[4]); 
	else if(a[1] + a[2] -a[3] +a[4] == b)
		printf("%d+%d-%d+%d=7",a[1],a[2],a[3],a[4]); 
	else if(a[1] + a[2] +a[3] -a[4] == b)
		printf("%d+%d+%d-%d=7",a[1],a[2],a[3],a[4]); 
	else if(a[1] - a[2] -a[3] +a[4] == b)
		printf("%d-%d-%d+%d=7",a[1],a[2],a[3],a[4]); 
	else if(a[1] - a[2] +a[3] -a[4] == b)
		printf("%d-%d+%d-%d=7",a[1],a[2],a[3],a[4]); 
	else if(a[1] + a[2] -a[3] -a[4] == b)
		printf("%d+%d-%d-%d=7",a[1],a[2],a[3],a[4]); 
	else if(a[1] - a[2] -a[3] -a[4] == b)
		printf("%d-%d-%d-%d=7",a[1],a[2],a[3],a[4]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 10005
#define int long long
#define T int t;cin>>t;while(t--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<x = <<x<<n;
#define set_dp(dp) memset(dp,-1,sizeof(dp))
using namespace std;


signed main(){
	ios_base::sync_with_stdio(false);	
	cin.tie(0);
	cout.tie(0);
 	int n,Q;
 	cin>>n>>Q;
 	map<int,vector<int>> m;
 	int *ans = new int[n+1];
 	int *final =new int[n+1];
 	for(int i=0;i<=n;i++){
 		// parent[i] = i;
 		ans[i] = 0;
 		final[i] = 0;
 	}
 	int p,c;
 	for(int i=0;i<n-1;i++){
 		cin>>p>>c;
 		m[p].push_back(c);
 	}
 	for(int i=0;i<Q;i++){
 		cin>>p>>c;
 		ans[p] += c;
 	}
 	// for(int i=1;i<=n;i++){
 	// 	cout<<solve(parent,ans,i,0ll)<<" ";
 	// }

 	queue<int> q;
 	q.push(1);
 	// q.push(-1);
 	int k;
 	while(!q.empty()){
 		int top = q.front();
 		q.pop();
 		k = ans[top];
 		for(auto i:m[top]){
 			q.push(i);
 			ans[i] += k;
 		}
 		final[top] = ans[top];
 	}
 	for(int i=1;i<=n;i++)cout<<final[i]<<" ";
	return 0;
}



Measured memory_bytes: 27392
#include <iostream>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;
int main() {
    ll i, j, k, n, h;
    cin >> n >> k;
    ll a[n];
    for (i = 0; i < n; i++){
        cin >> a[i];
    }
    ll dp[n + 1][k + 1]; // n番目まででのk個の分配の仕方
    ll sum[k + 1] = {};  // 直前の累積和
    for(i = 0; i <= k;i++)sum[i] = 1;
    for(i = 1; i <= n; i++) {
        for(j = 0; j <= k; j++) {
            if(j > a[i - 1])
                dp[i][j] = (sum[j] - sum[j - a[i - 1] - 1] + MOD) % MOD;
            else
                dp[i][j] = sum[j];
        }
        sum[0] = 1;
        for(j = 1; j <= k;j++){
            sum[j] = dp[i][j] + sum[j - 1];
            sum[j] %= MOD;
        }
    }

    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 79744
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //入力
            int n = int.Parse(Console.ReadLine());

            //h/aであまりが生じないならそのまま、それ以外は1回足す
            
            Console.WriteLine((n + 1) /2);
            
            
        }
    }

Measured memory_bytes: 13140
//Created by Aminul on 9/26/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int k = in.nextInt();
        for (int i = 0; i < k; i++) {
            pw.print("ACL");
        }
        pw.println();

        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

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

using namespace std;
#define int long long
#define all(a) (a).begin(), (a).end()
#define ms(a,v) memset(a, v, sizeof(a))
#define sz(v) ((int)(v).size())
#define mp make_pair
#define pb push_back
#define prev biiiiirl_sai_de_casa_comi_pra_caralho
#define next trapezio_descendente
#define index eh_ele_que_nos_vai_buscar
#define left aqui_eh_37_anos_porra
#define R32 ({int32_t x; scanf("%d", &x); x;})
#define RL ({long long x; scanf("%lld", &x); x;})
#define RC ({char x; scanf(" %c", &x); x;})
#define RI RL
#define ff first
#define ss second
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;

int mod(int x, int MOD){
    x %= MOD;
    if(x < 0) x += MOD;
    return x;
}

struct Ant {
    int coord, direction, idx;
    bool operator<(const Ant & rhs) const {
        return coord < rhs.coord;
    }
};

const int N = 1e6;
int ans[N];

int32_t main(){
    int n = RI;
    int L = RI;
    int t = RI;
    vector<Ant> v, v2;

    int tot_speed = 0;

    for(int i = 0; i < n; i++){
        int x = RI;
        int w = RI == 1 ? 1 : -1;
        v.pb({x, w, i});
        v2.pb({mod(x + w*t, L), w, i});
        tot_speed += w*t;
    }

    sort(all(v));
    sort(all(v2));

    tot_speed = mod(tot_speed, n*L);
    int tot_offset = 0;

    for(int i = 0; i < n; i++){
        tot_offset += v2[i].coord - v[i].coord;
        tot_offset = mod(tot_offset, n*L);
    }

    assert(mod(tot_speed - tot_offset, L) == 0);
    int ozin = (tot_speed - tot_offset) / L;

    for(int i = 0; i < n; i++){
        int r = mod(i+ozin, n);
        ans[v[i].idx] = v2[r].coord;
    }

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


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

int main() {
    int X; cin >> X;
    int k = 1;
    if (X == 1) cout << 1 << endl;
    else {
        for (int i = 2; i < X; i++) {
            for (int j = 2; pow(i, j) <= X; j++) {
                int l = pow(i, j);
                k = max(k, l);
            }
        }
        cout << k << endl;
    }
}


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

int main()
{
    int m, f, r;
    cin >> m >> f >> r;

    while(m + f + r != -3)
    {
        if(m * f < 0) cout << "F" << endl;
        else if(m + f >= 80) cout << "A" << endl;
        else if(m + f >= 65) cout << "B" << endl;
        else if(m + f >= 50) cout << "C" << endl;
        else if(m + f >=  30 && r >= 50) cout << "C" << endl;
        else if(m + f >= 30) cout << "D" << endl;
        else cout << "F" << endl;

        cin >> m >> f >> r;
    }

return 0;
}


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

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

#define INF 1e9


int main(){ 
  string S;
  cin >> S;
  map<char, int> mp;
  mp['N'] = 0, mp['W'] = 0, mp['S'] = 0, mp['E'] = 0;
  REP(i, S.size()){
    mp[S[i]]++;
  }
  if((mp['N'] != 0 && mp['S'] == 0) || (mp['S'] != 0 && mp['N']==0) || (mp['W'] != 0 && mp['E'] == 0) || (mp['E'] != 0 && mp['W']==0)){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
temp = 0

print(" ".join(map(str,A)))
for i in range(1,n):
    temp = A[i]
    j = i -1
    while j >=0 and A[j] > temp :
        A[j+1]=A[j]
        j-=1
    A[j+1] = temp
    print(" ".join(map(str,A)))

Measured memory_bytes: 7660
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
else:
    D.sort()

    D_num = []
    count = 1
    for i in range(N):
        if i == N-1 or D[i] != D[i+1]:
            D_num.append([D[i],count])
            count = 1
        else:
            count += 1

    D_max = D[N-1]

    if D_num[0][1] != 1:
        print(0)
    elif len(D_num) != D_max+1:
        print(0)
    else:
        result = 1
        for i in range(1,D_max+1):
            result = result * D_num[i-1][1] ** D_num[i][1]
            result = result % 998244353

        print(result)


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

int main(){
int c[]={1,5,10,50,100,500};
int n=0,m;
for(int i=0;i<6;++i){
cin>>m;
n+=m*c[i];
if(n>=1000){
cout<<1<<endl;
return 0;
  }
}
cout<<0<<endl;
return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[19], B[19];
int dp[1 << 18][18];
int keisan(int b, bool bp, int k) {
	if (b && dp[b][k] != -1) return dp[b][k];
	if (b == (1 << N) - 1) return 0;

	int k2 = (bp ^ (k & 1)) ? A[k] : B[k];
	int saishou = 2e9;
	int num2 = 0;
	rep(i, N) {
		if (!(b >> i & 1)) {
			if ((bp ^ i) & 1) {
				if (B[i] >= k2) {
					chmin(saishou, keisan(b ^ (1 << i), !bp, i) + num2);
				}
			}
			else {
				if (A[i] >= k2) {
					chmin(saishou, keisan(b ^ (1 << i), !bp, i) + num2);
				}
			}
			num2++;
		}
	}
	return dp[b][k] = saishou;
}

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


	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, 1 << N) rep(j, 18) dp[i][j] = -1;

	int kotae = keisan(0, 0, 18);
	if (kotae > 1e9) co(-1);
	else co(kotae);

	Would you please return 0;
}

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

using namespace std;

#define ll long long

signed main(){
    int count[9];
    for (int i = 0;i < 9;++i)
        count[i] = 0;
    int n;
    cin >> n;
    for (int i = 0;i < n;++i){
        int a;
        cin >> a;
        ++count[min(a / 400,8)];
    }
    int ans_min = 0;
    for (int i = 0;i < 8;++i)
        if (count[i])
            ++ans_min;
    if (ans_min == 0){
        cout << "1 " << count[8] << endl;
        return 0;
    }
    cout << ans_min << " " << (ans_min + count[8]) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    ll n; cin >> n;
    Vl a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];
    ll j = 0;
    rep(i, 0, n){
        if(a[i] > a[j]) j = i;
    }
    cout << a[j] + b[j] << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll sum = min(k,a);
    k-=min(a,k);
    k-=min(b,k);
    sum-=min(k,c);
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
   string s,t;
   cin>>s>>t;
   vector<int> alpha[26];
   for(int i=0;i<s.length();i++)
   	alpha[s[i]-'a'].push_back(i);
   	int pos=-2,cnt=0;
   	for(int j=0;j<t.length();j++)
   {
   	std::vector<int>::iterator cpos;
	   cpos=std::lower_bound(alpha[t[j]-'a'].begin(), alpha[t[j]-'a'].end(),pos+1);
	   if(cpos==alpha[t[j]-'a'].end())
	   {
	   	if(alpha[t[j]-'a'].size()==0)
	   	{cout<<-1;
	   	return 0;
		}
		else
		{pos=alpha[t[j]-'a'][0];
		++cnt;
		}
		}
		else
		pos=*cpos; 
   }
   cout<<cnt*s.length()+pos+1;
    return 0;
}

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

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    long long a, b;
    cin >> a >> b;
    long long c = gcd(a, b);
    int ans = 1;
    for (long long i = 2; i*i <= c; ++i) {
        if (c%i == 0) {
            ans++;
            while(c%i==0) c /= i;
        }
    }
    if (c != 1) ans++;
    cout << ans << endl;
    return 0;
}

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

struct Edge {
  int to, w;
  Edge(int t, int w) :to(t), w(w) {}
};

struct Graph {
  int N, M;
  vector<vector<Edge>> edges;
  vector<bool> change, isUse, ans;

  Graph(int N, int M) :N(N), M(M), edges(N), change(N), isUse(N, false), ans(M, false) {}

  void addEdge(int a, int b, int w) { 
    edges[a].emplace_back(b, w);
    edges[b].emplace_back(a, w);
  }

  bool calc(int n) {
    if (isUse[n]) return false;
    isUse[n] = true;
    bool res = change[n];
    for (Edge x : edges[n]) {
      if (isUse[x.to]) continue;
      ans[x.w] = calc(x.to);
      res ^= ans[x.w];
    }
    return res;
  }
};

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(N);
  int now = 0;

  Graph G(N + 1, M);

  vector<pair<int, int>> P(N); rep(i, N) cin >> P[i].first >> P[i].second;
  sort(P.begin(), P.end());
  rep(i, N) {
    A[i] = P[i].first;
    G.change[i] = (now != P[i].second);
    now = P[i].second;
  }
  G.change[N] = now;

  rep(i, M) {
    int L, R; cin >> L >> R;
    int x = lower_bound(A.begin(), A.end(), L) - A.begin();
    int y = upper_bound(A.begin(), A.end(), R) - A.begin();
    if (x == y) continue;
    G.addEdge(x, y, i);
  }

  rep(i, N + 1) {
    if (G.calc(i)) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << count(G.ans.begin(), G.ans.end(), true) << endl;
  rep(i, M) {
    if (G.ans[i]) cout << i + 1 << " ";
  }
  cout << endl;
}

Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

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

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

bool isInteger(double d){
	return ceil(d) == floor(d);
}

int main(){
	int n,d;cin>>n>>d;
	VVI x(n,VI(d));
	rep(i,n){
		rep(j,d){
			cin>>x.at(i).at(j);
		}
	}
	int ans=0;
	rep(i,n){
		for(int j=i+1;j<n;j++){
			double dist=0;
			rep(k,d){
				dist+=(double)pow((double)x.at(i).at(k)-(double)x.at(j).at(k),2);
			}
			dist=(double)sqrt(dist);
			if(isInteger(dist))ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;


public class Test
{
	public static void Main()
	{
		// your code goes here
		int A=int.Parse(Console.ReadLine());
		int B=int.Parse(Console.ReadLine());		
		int h=int.Parse(Console.ReadLine());
        int M;
        
        M = ((A+B)*h)/2;
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 2648
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

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

def main():
	n = int(rl())
	x = pow(10, n, MOD) - 2*pow(9, n, MOD) + pow(8, n, MOD)
	print(x % MOD)
	stdout.close()

if __name__ == "__main__":
	main()

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

bool compare_by_first(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) return a.first < b.first;
    else return a.second < b.second;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        AB[i] = make_pair(a, b);
    }

    sort(AB.begin(), AB.end(), compare_by_first);

    ll cnt = 0;
    ll cost = 0;
    int j=0;
    while(cnt < M) {
    rep(i, AB[j].second) {
        cnt++;
        cost += AB[j].first;
        if(cnt >= M) break;
    }
    j++;   
    }

    cout << cost << endl;
    return 0;
}

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

#define df(b, e) ((b) > (e))
#define fore(i, b, e) for(auto i = (b) - df(b, e); i != e - df(b, e); i += 1 - 2 * df(b, e))
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define pb push_back

typedef long long lli;
typedef long double ld;
typedef pair<int, int> ii;

template <class T>
struct rge { T b, e; };

template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}

template <class T> auto dud(T *x) -> decltype(cerr << *x, 0);
template <class T> char dud(...);

struct debug {
#ifdef LOCAL
  ~debug() { cout << endl; }

  template <class T>
  typename enable_if<sizeof dud<T>(0) != 1, debug &>::type operator << (T i) {
    cout << boolalpha << i;
    return *this;
  }

  template <class T>
  typename enable_if<sizeof dud<T>(0) == 1, debug &>::type operator << (T i) {
    return *this << range(begin(i), end(i));
  }

  template <class A, class B>
  debug & operator << (pair<A, B> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }

  template <class T>
  debug & operator << (rge<T> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
      *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
#else
  template <class T> 
  debug & operator << (const T&) {
    return *this; 
  }
#endif
};

#define deb(...) " " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " "

const int N = 101;
const int D = 80;

bitset<N> isp;
vector<int> primes;
map<lli, int> mem[N][D]; // won't work :'(
int n;

vector< pair<lli, int> > factorialFactors(int n) {
  vector< pair<lli, int> > fac;
  for (lli p: primes) {
    if (n < p)
      break;
    lli mul = 1LL, k = 0;
    while (mul <= n / p) {
      mul *= p;
      k += n / mul;
    }
    fac.pb({p, k});
  }
  return fac;
}

int inline dp(int i, int divs, lli num, vector< pair<lli, int> > &fac) {
  if (divs % 2 == 0)
    return 0;
  if (i == sz(fac))
    return 0;
  if (divs == 75)
    return 1;
  if (mem[i][divs].count(num))
    return mem[i][divs][num];
  int ans = 0;
  lli mul = 1LL;
  fore (k, 0, fac[i].s + 1) {
    if (divs * (k + 1) > 75)
      break;
    ans += dp(i + 1, divs * (k + 1), num * mul, fac);
    mul *= fac[i].f;
  }
  return mem[i][divs][num] = ans;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  isp.set();
  isp[0] = isp[1] = 0;
  fore (i, 2, N) if (isp[i]) {
    primes.pb(i);
    if (1LL * i * i < N)
      for (int j = i * i; j < N; j += i)
        isp[j] = 0;
  }
  cin >> n;
  auto fac = factorialFactors(n);
  debug() << deb(fac);
  cout << dp(0, 1LL, 1LL, fac) << '\n';
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<cmath>

using namespace std;
int main(){

	int N, M, C;
	cin >> N >> M >> C;
	vector<int>B(M);

	for (int i = 0; i < B.size(); i++)
		cin >> B[i];

	int ans = 0;
	for (int i = 0; i < N; i++){
		int tmp, now = C;
		for (int j = 0; j < M; j++){
			cin >> tmp;
			now += B[j] * tmp;
		}
		if (now > 0) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
 
int main(){
  int N, A, B, C, D;
  std::string S;
  std::cin >> N >> A >> B >> C >> D;
  std::cin >> S;
//  for(int i=B; i<D; ++i){  
  int maxstone=0;
  for(int i=B; i<D; ++i){
    if( S[i] == '#') {
      maxstone++;
    }
    else {
      maxstone=0;
    }
    if (maxstone >=2) {std::cout << "No" << std::endl; return 0;}
  }
  maxstone=0;
  for(int i=A; i<C; ++i){
    if( S[i] == '#') {
      maxstone++;
    }
    else {
      maxstone=0;
    }
    if (maxstone >=2) {std::cout << "No" << std::endl; return 0;}
  }
  int maxdot=0, tmpdot=0;
  if( C > D ) {
    for (int i=B-2; i<D+1; ++i){
      if( S[i] == '.') {
        tmpdot++;
      }
      else {
        tmpdot=0;
      }
      if( maxdot < tmpdot ) maxdot = tmpdot;
    }
    if (maxdot <= 2) {std::cout << "No" << std::endl; return 0;}
  }
  std::cout << "Yes" <<std::endl;
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define rep(i,a,b)  for (int i = a; i < b; ++i)
#define rrep(i,z,a) for (int i = z; i >= a; --i)
#define rep0(n)     for(int i = 0 ; i < n; ++i )
#define rep1(n)     for(int i = 1 ; i <= n; ++i )
#define pb          push_back
#define sd(x)       scanf("%d",&x)
#define tc          int test;cin>>test; while(test--)
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define mp          make_pair
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl        "\n"
#define spc         " "
#define mem0(a)     memset(a,0,sizeof(a))
#define extime      cout << endl << endl << "____"<<(float)clock() / CLOCKS_PER_SEC << "s____";
#define maxn        998244353
#define mod         1000000007
//#define ll          long long int
//typedef vector<ll>  vll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
void OJ()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int solve()
{
  int d, t, s;
  cin >> d >> t >> s;
  if (s * t >= d)cout << "Yes";
  else cout << "No";
  return 0;
}
signed main()
{
  OJ();
  IOS
  //tc
  solve();
  //extime
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
vector<int>edge[100010];
int x,y,n,m,q,u,d,c;
int color[100010],maxu[100010],U[100010],D[100010],C[100010];
void dfs(int u,int d,int c)
{
 if(color[u]==0)color[u]=c;
 if(d==0)return;
 if(maxu[u]>=d)return;
 maxu[u]=d; 
 for(int i=0;i<edge[u].size();i++)
  {int to=edge[u][i];
   dfs(to,d-1,c);
  }
}
int main()
{
    scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	 {scanf("%d%d",&x,&y);
	  edge[x].push_back(y);
	  edge[y].push_back(x);
	 }
	scanf("%d",&q);
	for(int i=1;i<=q;i++)scanf("%d%d%d",&U[i],&D[i],&C[i]);	
	for(int i=q;i>=1;i--)dfs(U[i],D[i],C[i]);
	for(int i=1;i<=n;i++)printf("%d\n",color[i]);
	return 0;
} 

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

int main() {
int N,S;
cin >>N;
S=0;
rep(i,8){
  int t = 1;
  rep(j,i){
  t*=10;
  }
  S+=(N%(10*t)-N%t)/t;

}
if(N%S == 0){
  cout<<"Yes"<<endl;
}
else{
  cout<<"No"<<endl;
}
  
  


}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std; 
int main(){
  long long int x, d, a, b,y, k,temp,ans,p,q; 
  cin>>x>>k>>d; 
  temp=abs(x);
  b=temp/d;
  if((temp/d)>=k){
      x=temp-(k*d);
    cout<<x;
    return 0;
  }
    y=temp-(b*d);
  ans=abs(y);
  k=k-b; 
  if(k%2==0){
    cout<<ans; 
  }
  else{
    cout<<(d-ans);
  }
  return 0;
}

Measured memory_bytes: 3576
h,w = map(int,input().split())
a=["" for _ in range(h)]
for i in range(h):
    a[i]=list(input())
for i in range(h):
    key=0
    for j in range(w):
        if a[i][j]=="#":
            key=1
    if key==0:
        for j in range(w):
            a[i][j]=""
for i in range(w):
    key=0
    for j in range(h):
        if a[j][i]=="#":
            key=1
    if key==0:
        for j in range(h):
            a[j][i]=""
for i in range(h):
    if a[i]!=["" for _ in range(w)]:
        print(''.join(a[i]))


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  string A;
  cin >> A;
  ll cnt = 0;
  rep(i,0,3){
    if (A[i] == '1')
    {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,X=get_i
x=get_i
x.push(X)
x.sort!
diff=array(N)
N.times do|i|
    diff[i]=x[i+1]-x[i]
end
puts diff.inject(0){|res,x| res.gcd(x)}

Measured memory_bytes: 10632
let () = Scanf.scanf "%d %d\n" @@ fun n t ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let maximum = Array.make n as_.(n - 1) in
  for i = n - 2 downto 0 do
    maximum.(i) <- max as_.(i) maximum.(i + 1)
  done;
  Array.mapi (fun i a -> maximum.(i) - a) as_
  |> Array.fold_left (fun (maximum, c) d ->
      max d maximum,
        match compare d maximum with
        | -1 -> c
        | 0 ->  1 + c
        | 1 ->  1) (min_int, 0)
  |> snd
  |> Printf.printf "%d\n"

Measured memory_bytes: 6272