akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S,T;
	while(cin>>S>>T) {
		vector<string> c;
		REP(i, S.size()-T.size()+1) {
			bool ok = 1;
			string s(S);
			REP(j, T.size()) {
				if(!(s[i+j]==T[j] || s[i+j]=='?')) ok=0;
				s[i+j] = T[j];
			}
			REP(j, s.size()) if(s[j]=='?') s[j] = 'a';
			if(ok) c.PB(s);
		}
		sort(ALL(c));
		if(c.size()==0) c.PB("UNRESTORABLE");
		cout<<c[0]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{
    ll N, M;
    cin >> N >> M;
    vector<int> A(N);
    float all_vote = 0;
    rep(i, N) {
        cin >> A[i];
        all_vote += A[i];
    }
    sort(A.rbegin(), A.rend());
    if (A[M-1] >= (all_vote / (4 * M))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

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

    const char *x = s.c_str();
    int l = s.length();
    bool ok = false;
    for(int i=0;i<l;i++) {
        if(x[i] == 'h') {
            if(x[i+1] == 'i'){
                ok = true;
            } else {
                ok = false;
                break;
            }
        } else if(x[i] == 'i') {
            if(i>0 && x[i-1] == 'h'){
                ok = true;
            } else {
                ok = false;
                break;
            }
        }
    }

    if(ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
# a,b = map(int, input().split())
s = input()
c = s.count("R")

if c == 1:
    print(c)
elif c == 2:
    if s[0] == s[1]:
        print(c)
    elif s[1] == s[2]:
        print(c)
    else:
        print(1)
elif c == 3:
    print(3)
elif c == 0:
    print(0)

Measured memory_bytes: 9112
#include <iostream>

using namespace std;

int main() {
    int *a = new int[5], ans = 0, tmp = 10;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        ans += a[i]-a[i]%10;
        if (a[i] % 10) {
            ans += 10;
            tmp = min(tmp, a[i] % 10);
        }
    }
    ans -= 10-tmp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF=1e9;

int main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  int yum;
  priority_queue<int> p,q,r;
  rep(i,a) {cin >>yum;    p.push(yum);}
  rep(i,b) {cin >>yum;    q.push(yum);}
  rep(i,c) {cin >>yum;    r.push(yum);}
  

  rep(i,x){ r.push(p.top()); p.pop();}
  rep(i,y){ r.push(q.top()); q.pop();}
  

  ll ans=0.0;
  rep(i,x+y){
    ans+=r.top();
    r.pop();
  }
  
  cout<<ans<<endl;
}

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

int main()
{
    double r;
    cin >> r;
    double ans = 2*r*3.1415;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*int V;
vector<edge> G[MAX_V];
int d[MAX_V]:
void dijkstra(int s) {
priority_queue<P, vector<P>, greater<P>> q;
fill(d, d + V, INF);


}*/


ll fact[100001];

int main(void) {
	fact[0] = 1;
	REP(i, 100000) fact[i + 1] = mmul(fact[i], i + 1);
	int n, k, a, b;
	cin >> n >> k;

	vector<vector<int>> v(n + 1);
	vector<int> cnt(n + 1, 0);
	vector<bool> visited(n + 1, false);
	queue<int> q;

	REP(i, n - 1) {
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	q.push(1);
	visited[1] = true;
	while (!q.empty()) {
		int vert = q.front();
		q.pop();
		for (auto neigh : v[vert]) {
			if (!visited[neigh]) {
				visited[neigh] = true;
				cnt[vert]++;
				q.push(neigh);
			}
		}
	}

	ll res = k;
	if (k - 1 < cnt[1]) {
		cout << "0";
		return 0;
	}
	res = mmul(res, fact[k - 1]);
	res = mdiv(res, fact[k - 1 - cnt[1]]);
	FOR(i, 2, n + 1) {
		if (cnt[i] > 0) {
			if (k - 2 < cnt[i]) {
				cout << "0";
				return 0;
			}
			res = mmul(res, fact[k - 2]);
			res = mdiv(res, fact[k - 2 - cnt[i]]);
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 7672
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include <cstdlib>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)

int main() {
	int H,W,D;
	cin>>H>>W>>D;
	int A[H+1][W+1];
	int x[H*W+1],y[H*W+1];
	rep(i,H) {
		rep(j,W) {
			cin>>A[i][j];
		x[A[i][j]]=i;
		y[A[i][j]]=j;}
	
	}
	int Q;
	cin>>Q;
	int L[Q],R[Q];
	rep(i,Q) cin>>L[i]>>R[i];
	int S[H*W+D];
	rep(i,H*W+D) S[i] = 0;
	rep(i,H*W-D){
		S[i+D] = S[i] + abs(x[i+D]-x[i])+ abs(y[i+D]-y[i]);
	}
	rep(i,Q){
		cout<<S[R[i]]-S[L[i]]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,x; cin>>n>>x;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    rep(i,n){
        x-=p[i];
    }
    sort(btoe(p));
    int ans=n;
    if(x!=0){
        ans+=(x/p[0]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
import collections

n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))

c1 = collections.Counter(lm)
c2 = collections.Counter(ln)

for i in c1.keys():
    if c2[i] < c1[i]:
        print("NO")
        exit()

print("YES")

Measured memory_bytes: 57056
#include <iostream>
#include <vector>

void solve(int N, std::vector<long> H) 
{
  for (int i = N-2; i >=0; i--)
  {
    if(H[i+1] - H[i] >= 0)
    {
      continue;
    }
    else if(H[i+1] - H[i] == -1)
    {
      H[i] -= 1;
    }
    else
    {
      std::cout << "No" << std::endl;
      return;
    }
    
    
  }
  std::cout << "Yes" << std::endl;
  
}

int main(void) 
{
  int N;
  std::cin >> N;
  std::vector<long> H(N);
  for(auto i0 = 0; i0 < N; ++i0)
  {
    std::cin >> H[i0];
  }
  solve(N,H);
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int x,y,z;
  cin >> x >> y >>z;
  int count = 0;

  while(true){
    if(x < y * count + z * (count+1)){
      count--;
      break;
    }
    count++;
  }
  
  cout << count;
  return 0;
}

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


int main(){
	int h,n;
	cin >> h >> n;
  	for(int i=0;i<n;i++){
    	int x;
      cin >> x;
      h-=x;
    }
  if(h>0) cout << "No" << endl;
   else cout << "Yes";
return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k,ans=-INF; cin>>n>>k;
    vector<ll> a(n,0),sum(n+1,0),psum(n+1,0);
    rep(i,n) cin>>a[i];
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
        psum[i+1]=psum[i];
        if(a[i]>0) psum[i+1]+=a[i];
    }
    for(int i=0;i<n-k+1;i++){
        ll d=sum[i+k]-sum[i],cnt;
        cnt=psum[i]+psum[n]-psum[i+k];
        ans=max(ans,max(cnt,cnt+d));
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N= 51;
const int M= 101;

int dp[N][N][M];

void solve() {
        int n, k; cin >> n>> k;

        memset(dp, -1, sizeof(dp));
        vector<int> v(n);
        for (auto& i: v) cin >> i;

        function<int(int, int, int)> calc= [&](int i, int j, int cnt)->int {
                if (cnt< 0) return -1e18;
                if (cnt== 0) return 0;
                if (i> j) return 0;

                int &ret= dp[i][j][cnt];
                if (ret!= -1) return ret;
                ret= 0;

                ret= max(ret, calc(i+ 1, j, cnt- 1)+ v[i]);
                ret= max(ret, calc(i+ 1, j, cnt- 2));
                ret= max(ret, calc(i, j- 1, cnt- 1)+ v[j]);
                ret= max(ret, calc(i, j- 1, cnt- 2));
                return ret;
        };

        cout << calc(0, n- 1, k)<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b, c; cin >> a >> b >> c;
    cout << min({a+b, b+c, c+a}) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7716
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n,m;cin>>n>>m;
    int a[m],b[m];
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    vector<vector<int>> v(n);
    vector<bool> check(n);
    vector<int> dis(n);
    vector<int> ans;
    int len=INF;
    //省く辺
    for(int ed=0;ed<m;ed++){
        rep(i,n){
            v[i].clear();
            dis[i]=0;
            check[i]=false;
        }
        rep(i,m){
            if(ed==i) continue;
            v[a[i]].push_back(b[i]);
        }
        queue<int> q;
        q.push(b[ed]);
        check[b[ed]]=true;
        vector<int> prev(n,-1);
        while(!q.empty()){
           int x=q.front();
           q.pop();
           for(auto y:v[x])if(!check[y]){
               check[y]=true;
               dis[y]=dis[x]+1;
               prev[y]=x;
               q.push(y);
           }
        }
        if(!check[a[ed]]) continue;

        if(chmin(len,dis[a[ed]]+1)){
            ans.clear();
            int x=a[ed];
            ans.push_back(x);
            while(x!=b[ed]){
                x=prev[x];
                ans.push_back(x);
            }
        }
    }
    if(ans.empty()){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans.size()<<endl;
    for(auto x:ans){
        cout<<x+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, d, e, f, y;
	cin >> a >> b >> c >> d >> e >> f;
	y = (a * 1) + (b * 5) + (c*10) + (d*50) + (e*100) + (f * 500);
	if (y >= 1000)
	{
		cout << 1 << endl;
	}
	else
		cout << 0 << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

//最小公倍数, 複数の時はlcm(a,lcm(b,c))みたいな感じで
template <class T>
T lcm(T a,T b){
	return a*(b/gcd(a,b));
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll l=lcm(c,d);
	auto solve=[&](ll x){
		return x+1-(x/c+x/d-x/l);
	};
	cout<<solve(b)-solve(a-1)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

char S[30];
int c[30]={0};
int main()
{
	scanf("%s",S);
	for(int i=0;S[i];i++)
	{
		if(c[S[i]-'a']>0)
		{
			puts("no");
			return 0;
		}
		c[S[i]-'a']++;
	}
	puts("yes");
	return 0;
}


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

const int N = 1e5+5;
int n,a[N],pre[N],suf[N];

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

    cin >> n;
    for(int i=1;i<=n;i++)cin >> a[i];
    for(int i=1;i<=n;i++)pre[i] = __gcd(pre[i-1],a[i]);
    for(int i=n;i>=1;i--)suf[i] = __gcd(suf[i+1],a[i]);
    int ans = -1;
    for(int i=1;i<=n;i++){
        ans = max(ans, __gcd(pre[i-1], suf[i+1]));
    }

    cout << ans << "\n";



    return 0;
}


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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;

int fac[100005];

int power(int a, int b){
    if (b == 0) return 1;
    int tmp = power(a, b/2);
    tmp = (tmp * tmp) % mod;
    if (b % 2) tmp = (a * tmp) % mod;
    return tmp;
}

int C(int n, int k){
    return (fac[n] * power(((fac[k] * (fac[n - k])) % mod), mod - 2)) % mod;
}


integer main() {
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    int ar[n];
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++){
        fac[i] = (i * fac[i-1]) % mod;
    }

    for (int i = 0; i < n; i++){
        cin >> ar[i];
    }
    sort(ar, ar+n);
    int ans = 0;
    for (int i = n-1; i >= k-1; i--){
        ans = (ans + ((ar[i] * C(i, k-1)) % mod)) % mod;
    }
    for (int i = 0; i <= n-k; i++){
        ans = (ans - ((ar[i] * C(n-i-1, k-1)) % mod) + mod) % mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=2e5+5;
int n,in[N],out[N],dep[N],p[N];
vector<int>adj[N],col[N];

int cnt=0;
void dfs(int u)
{
    in[u]=++cnt;
    for(auto&v:adj[u])
    {
        if(v==p[u]) continue;
        dep[v]=dep[u]+1;
        p[v]=u;
        dfs(v);
    }
    out[u]=cnt;
}

int ST[4*N],lazy[4*N];
void dolazy(int id,int l,int r)
{
    if (lazy[id]==-1) return;
    ST[id]=(r-l+1)*lazy[id];
    if (l!=r)
    {
        lazy[id*2]=lazy[id];
        lazy[id*2+1]=lazy[id];
    }
    lazy[id]=-1;
}

void Update(int id,int l,int r,int L,int R,int val)
{
    dolazy(id,l,r);
    if (r<L||R<l) return;
    if (L<=l&&r<=R)
    {
        ST[id]=(r-l+1)*val;
        if (l!=r)
        {
            int mid=(l+r)/2;
            lazy[id*2]=val;
            lazy[id*2+1]=val;
        }
        return;
    }
    int mid=(l+r)/2;
    Update(id*2,l,mid,L,R,val);
    Update(id*2+1,mid+1,r,L,R,val);
    ST[id]=ST[id*2]+ST[id*2+1];
}

int get (int id,int l,int r,int L,int R)
{
    dolazy(id,l,r);
    if (r<L||R<l) return 0;
    if (L<=l&&r<=R) return ST[id];
    int mid=(l+r)/2;
    return get (id*2,l,mid,L,R)+get (id*2+1,mid+1,r,L,R);
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(lazy,-1,sizeof lazy);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        col[x].push_back(i);
    }
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1);
    for(int i=1;i<=n;i++)
    {
        int res=0;
        vector<pii>order;
        for(auto&y:col[i]) order.push_back(mp(-dep[y],y));
        sort(order.begin(),order.end());
        Update(1,1,n,1,n,1);
        int tmp=n;
        for(auto&y:order)
        {
            int u=y.se;
            int total=0;
            for(auto&v:adj[u])
            {
                if(v==p[u]) continue;
                int cur=get(1,1,n,in[v],out[v]);
                res+=cur*total;
                total+=cur;
            }
            int sz=get(1,1,n,in[u],out[u]);
            res+=sz*(tmp-sz+1);
            tmp-=sz;
            Update(1,1,n,in[u],out[u],0);
        }
        cout<<res<<'\n';
    }
}


Measured memory_bytes: 49520
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	char c; cin >> c;
	if (c != 'a' &&c != 'i' &&c != 'u' &&c != 'e' &&c != 'o') {
		cout << "consonant" << endl;
		return 0;
	}
	cout << "vowel" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	long long t;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	t=a-b;
	if(t>1000000000000000000)
	{
		printf("Unfair");
	}
	else
	{
		if(k%2!=0)
		{
			t*=-1;
		}
		printf("%lld",t);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
const int N = 1e5;
VI e[N];
int reach[N][2];
 
void dfs(int now, int d){
	reach[now][d] = 1;
	for (int next : e[now]){
		if (reach[next][d^1]) continue;
		dfs(next, d^1);
	}
}
 
int main() {
	int n, m;
	cin >> n >> m;
	while (m--){
		int a, b;
		scanf("%d %d", &a, &b);
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
 
	dfs(0, 0);
 
	int even = 0, odd = 0;
	REP(i,n){
		even += reach[i][0];
		odd += reach[i][1];
	}
 
	ll ans = 0;
	REP(i,n){
		if (reach[i][0] && reach[i][1]){
			ans += (n - e[i].size() - 1);
		}else if (reach[i][0]){
			ans += (odd - e[i].size());
		}else{
			ans += (even - e[i].size());
		}
		// cout << ans << endl;
	}
 
	cout << ans/2 << endl;
    
    return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x[200000],n;
	cin>>n;
	for(int i=0;i<n;i++)x[i]=0;
	for(int i=1;i<n;i++){
		int a;
		cin>>a;
		--a;
		x[a]++;
	}
	for(int i=0;i<n;i++)
		cout<<x[i]<<endl;
	return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/

const ll MOD = 1e18 + 7;
ll poww(ll b, ll p)
{
    if (p == 0)
        return 1;

    ll sq = poww(b, p / 2);

    sq = (sq * sq) % MOD;

    if (p % 2 == 1)
    {
        sq = (sq * b) % MOD;
    }

    return sq;
}

void solve()
{
    ll n;
    cin >> n;
    for (ll i = -1000; i <= 1000; i++)
    {
        for (ll j = -1000; j <= 1000; j++)
        {
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if (a - b == n)
            {
                cout << i << " " << j << endl;
                return;
            }
        }
    }
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a == b {
		fmt.Println("a == b")
	} else if a < b {
		fmt.Println("a < b")
	} else {
		fmt.Println("a > b")
	}
}


Measured memory_bytes: 1132
#include <iostream>
#include <string>
using namespace std;
int main() {
	int cnt = 0;
	string S;
	cin >> S;
	for (int i = 0; i < 3; i++)
	{
		if (S[i] == 'o') {
			cnt++;
		}
	}

	cout << 700 + cnt * 100 << endl;

	return 0;
}

Measured memory_bytes: 256
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def MS(): return map(str, input().split())


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True


def main():
    N = I()
    s = [None] * N
    m = {}

    for i in range(N):
        s[i] = S()
        m[s[i]] = 0

    for i in range(N):
        m[s[i]] += 1

    arr = []
    for (key, v) in m.items():
        arr.append((v, key))

    arr.sort(reverse=True)

    m = arr[0][0]
    ans = []
    for i in range(len(arr)):
        if m == arr[i][0]:
            ans.append(arr[i][1])

    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


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

int main()
{
	long long num=0;
	int x,y;
	cin>>x>>y;
	if(x==3) num+=100000;
	if(x==2) num+=200000;
	if(x==1) num+=300000;
	if(y==3) num+=100000;
	if(y==2) num+=200000;
	else if(y==1) num+=300000;
	if(x==1 && y==1) num+=400000;
	cout<<num;
	
	return 0;
} 

Measured memory_bytes: 256
I = lambda s:map(int, s)

p = int(input().split()[1])
s = input()
if 10 % p == 0:
  r = sum(i for i, x in enumerate(I(s), 1) if x % p == 0)
else:
  d = {0 : 1}
  t, y = 0, 1
  for i, x in enumerate(I(reversed(s)), 1):
    t = (t + x * y) % p
    d[t] = d.get(t, 0) + 1
    y = y * 10 % p;
  r = sum(i * (i - 1) // 2 for i in d.values())
print(r)


Measured memory_bytes: 4072
from itertools import accumulate


def solve(string):
    n, m, k, *ab = map(int, string.split())
    a, b = [0] + ab[:n], [0] + ab[n:]
    a, b = list(accumulate(a)), list(accumulate(b))
    i, j = n, 0
    while a[i] > k:
        i -= 1
    while j <= m and a[i] + b[j] <= k:
        j += 1
    ans = i + j - 1
    for i in range(i, -1, -1):
        while j <= m and a[i] + b[j] <= k:
            j += 1
        ans = max(ans, i + j - 1)
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 59392
N, X = map(int, input().split())

layer = [1]
num_of_P = [1]
result = 0

for _ in range(N-1):
    layer.append(layer[-1] * 2 + 3)
    num_of_P.append(num_of_P[-1] * 2 + 1)

layer.append(layer[-1] * 2 + 3)

while num_of_P:
    if layer[-1] // 2 + 1 > X:
        X -= 1
    else:
        X -= layer[-1] // 2 + 1
        result += num_of_P[-1] + 1

    del layer[-1]
    del num_of_P[-1]

print(result if X < 1 else result+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n, cnt=0;
    string s;
    cin >> n >> s;
    for(int i=0; i<=n-3; i++){
        if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') cnt++;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
n = int(input())
l = [0, 9, 909, 90909]
if len(str(n)) % 2 == 1:
    print(l[len(str(n)) // 2] + n - 10 ** (len(str(n)) - 1) + 1)
else:
    print(l[len(str(n)) // 2])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  vector<ll>vec(a+1);
  ll b=0;
  for(ll i=0;i<a;i++){
    ll c;
    cin>>c;
    if(c>a){
      b+=1;
    }
    else{
      vec.at(c)+=1;
    }
  }
  
  for(ll i=1;i<a+1;i++){
    if(vec.at(i)>i){
      b+=vec.at(i)-i;
    }
    else if(vec.at(i)<i){
      b+=vec.at(i);
    }
  }
  cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>

int main(){
    
    
    long long num[100000];
    long long c;
    scanf("%lld", &c);
    for(long long i=0;i <c;i++){
        scanf("%lld", &num[i]); 
    }
    for(long long i=0;i < c;i++){
        if(num[i] == 0){ 
            printf("0\n");
            return 0;
        }
    }
    long long int sum = 1;
    for(int i=0;i<c;i++){
        if(num[i] <= 1000000000000000000/sum){
            sum *= num[i];
        }else{
            printf("-1\n");
               return 0;
        }        
    }    printf("%lld\n", sum);
        return 0;    
}

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

int main(){
	int W,H,x,y,r;
	
	cin >> W >> H >> x >> y >> r;
	if(x+r<=W && x-r>=0 && y-r>=0 && y+r<=H){
	cout << "Yes" << "\n";
	}else{
	cout << "No" << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 1128
#include <stdio.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
typedef struct{
	int top;
	char str[101];
}Stack;
Stack s;
void push(char a){
	s.str[s.top++]=a;
	return;
}
char pop(){
	return s.str[--s.top];
}

int main(void)
{
	int n,i,t=0;
	s.top=0;
	char str[101],c;
	scanf("%d",&n);
	scanf("%s",str);
	FOR(i,0,n){
		if(str[i]=='(') push(str[i]);
		else{
			if(s.top==0) t++;
			else pop();
		}
	}
	FOR(i,0,t) putchar('(');
	printf("%s",str);
	FOR(i,0,s.top) putchar(')');
	puts("");
	return 0;
}


Measured memory_bytes: 128
open System.Collections.Generic

let inline Σ n = n*(n+1L) / 2L
let inline sort (s:string) = new string (s.ToCharArray() |> Array.sort)
let inline sum (xs:Dictionary<string, int64>) =
    let mutable total = 0L
    for x in xs do
        let N = x.Value
        total <- total + Σ(N-1L)
    total
let inline load n =
    let xs = Dictionary<string, int64>()
    for _ in 0..n-1 do
        let s = stdin.ReadLine() |> sort
        if (xs.ContainsKey s) then
            xs.[s] <- xs.[s] + 1L
        else
            xs.Add (s, 1L)
    xs

let N = stdin.ReadLine() |> int
let xs = load N
printfn "%d" (sum xs)

Measured memory_bytes: 33352
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[200010], F[200010];
int main()
{
	int N;
	ll K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> F[i];
	sort(A, A + N);
	sort(F, F + N, greater<ll>());
	ll ok = INF;
	ll ng = -1;
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		ll sum = 0;
		for (int i = 0; i < N; i++) {
			ll time = A[i] * F[i];
			sum += max(0ll, (time - mid + F[i] - 1) / F[i]);
		}
		if (sum <= K) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}


Measured memory_bytes: 6752
/*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
#define INF 10000
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/
int Field[10][10];

/*****その他関数置き場*****/
int djikstra(int start,int townnum){
	int sum=0;
	int town;
	int *dis;
	bool *used;
	dis = new int [townnum];
	used = new bool [townnum];
	for(int i=0;i<townnum;i++){
		dis[i] = INF;
		used[i] = 0;
	}
	dis[start] = 0;
	while(true){
		town = -1;
		for(int i=0;i<townnum;i++){
			if(!used[i] && (town == -1 || dis[town] > dis[i])){
				town = i;
			}
		}
		if(town == -1)	break;
		used[town] = true;
		for(int i=0;i<townnum;i++){
			if(dis[i] > dis[town] + Field[town][i]){
				dis[i] = dis[town] + Field[town][i];
			}
		}
	}
	for(int i=0;i<townnum;i++){
		if(dis[i] != INF)	sum += dis[i];
	}
	delete used;
	delete dis;
	return sum;
}
/*****main関数*****/
int main(){
	/*****変数置き場*****/
	int appear[10];
	int townnum;
	int n;
	int from,to,cost;
	int now_cost;
	int min_cost;
	int min_town;
	/*****処理部*****/
	while(1){
		for(int i=0;i<10;i++){
			appear[i] = 0;
			for(int j=0;j<10;j++){
				Field[i][j] = INF;
			}
		}
		townnum = 0;
		
		min_cost = INF;
		min_town = INF;
		cin >> n;
		if(n==0)	break;
		for(int i=0;i<n;i++){
			cin >> from >> to >> cost;
			Field[from][to] = cost;Field[to][from] = cost;
			Field[from][from] = 0;Field[to][to] = 0;
			if(!appear[from]){
				appear[from] = 1;
				townnum++;
				//cout << townnum << endl;
			}
			if(!appear[to]){
				appear[to] = 1;
				townnum++;
				//cout << townnum << endl;
			}
		}
		//cout << "djikstra begin..." << endl;
		for(int start=0;start<townnum;start++){
			//cout << start << " " << townnum << endl;
			now_cost = djikstra(start,townnum);
			if(now_cost < min_cost){
				min_cost = now_cost;
				min_town = start;
			}
		}
		cout << min_town << " " << min_cost << endl;
	}
	/*****処理終了後*****/
	return 0;
}

Measured memory_bytes: 1192
def calc(x, y):
    x1 = x - 1
    x2 = x - 1
    x3 = x - 1
    x4 = x
    x5 = x
    x6 = x + 1
    x7 = x + 1
    x8 = x + 1
    y1 = y - 1
    y2 = y
    y3 = y + 1
    y4 = y - 1
    y5 = y + 1
    y6 = y - 1
    y7 = y
    y8 = y + 1
    return x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))
ans = []
for i in range(h * w):
    y = i % w
    x = i // w
    x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8 = calc(x, y)
    s_list = [[x1, y1], [x2, y2], [x3, y3], [x4, y4],
              [x5, y5], [x6, y6], [x7, y7], [x8, y8]]
    if s[x][y] == ".":
        c = 0
        for xx, yy in s_list:
            if ((xx >= 0) & (yy >= 0)) & ((xx < h) & (yy < w)):
                if s[xx][yy] == "#":
                    c += 1
        ans.append(str(c))
    else:
        ans.append("#")
sss = ""
for i, anss in enumerate(ans):
    if (i % w) == w - 1:
        sss += anss + "\n"
    else:
        sss += anss
print(sss[:-1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[100009][4],dp[100009][4],k;
int main(){
    cin >> n;
    for(int i=1; i<=n; i++){
    	cin >> a[i][1] >> a[i][2] >> a[i][3];
    }
    for(int i=1; i<=n; i++){
    	dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]);
    	dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]);
    	dp[i][3]=a[i][3]+max(dp[i-1][1],dp[i-1][2]);
    }//ashsijk
    cout << max(max(dp[n][1],dp[n][2]),dp[n][3]) << endl;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> length(N);
    for(int i=0; i<N; i++){
        cin >> length.at(i);
    }
    int M=0;
    for(int j=0; j<N; j++){
        if(M<length.at(j)){
            M=length.at(j);
        }
    }
    int sum=0;
    for(int k=0; k<N; k++){
        sum+=length.at(k);
    }

    sum-=M;

    if(sum > M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  sort(ALL(A));
  ll ans=0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      for(int k=j+1;k<n;k++)
	if(A[i]+A[j]>A[k])ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int maze[2010][2010][2];
int n, k;
int findans(int x, int y) {
  int blk1 = maze[2*k-1][k+y][1] + maze[k+x][2*k-1][1] - maze[x+k][y+k][1]
    - (maze[2*k-1][y][1] - maze[k+x][y][1])
    - (maze[x][2*k-1][1] - maze[x][k+y][1])
    - maze[k+x][k+y][1] 
    + maze[x][k+y][1] + maze[k+x][y][1]
    - 2 * maze[x][y][1];
  int blk2 = maze[2*k-1][2*k-1][1] - blk1;
  int wht2 = maze[2*k-1][k+y][0] + maze[k+x][2*k-1][0] - maze[x+k][y+k][0]
    - (maze[2*k-1][y][0] - maze[k+x][y][0])
    - (maze[x][2*k-1][0] - maze[x][k+y][0])
    - maze[k+x][k+y][0] 
    + maze[x][k+y][0] + maze[k+x][y][0]
    - 2 * maze[x][y][0];
  int wht1 = maze[2*k-1][2*k-1][0] - wht2;
  return max(blk1 + wht1, blk2 + wht2);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    maze[x%(2*k)][y%(2*k)][(c=='W'?0:1)]++;
  }

  for (int i = 0; i < 2 * k; i++) {
    for (int j = 1; j < 2 * k; j++) {
      maze[i][j][0] += maze[i][j-1][0];
      maze[i][j][1] += maze[i][j-1][1];
    }
  }

  for (int i = 1; i < 2 * k; i++) {
    for (int j = 0; j < 2 * k; j++) {
      maze[i][j][0] += maze[i-1][j][0];
      maze[i][j][1] += maze[i-1][j][1];
    }
  }
  /*
  for (int i = 0; i < 2 * k; i++) {
    for (int j = 0; j < 2 * k; j++) {
      cout << maze[i][j][0] << " ";
    }
    cout << endl;
  }
  */
  int ans = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      ans = max(ans, findans(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

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

  if (A+B>C+D) {
    cout << "Left" << endl;
  } else if (A+B==C+D) {
    cout << "Balanced" << endl;
  } else if (A+B<C+D) {
    cout << "Right" << endl;
  }
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

struct edge { int to, cost; };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'R') cnt++;
	}
	cout << (cnt > n-cnt ? "Yes" : "No") << endl; 
	return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, a, b;
	scanf("%d", &n);
	a = n % 1000;
	b = n - (n % 10);
	if (a % 111 == 0 || b % 111 == 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
ll L , n;
ll a[200005];
ll p[200005];
ll s[200005];
ll solve()
{
        ll ans = 0;
        for(ll i=1;i<=n;i++) p[i] = a[i] + p[i-1];
        for(ll i=n;i>=0;i--) s[i] = s[i+1] + a[i];
        for(ll i=1;i <= n; i++) {
                ll ret = 0;
                ll len = n - i;
                ll tails = (len + 1)/2;
                tails = n - tails + 1;
                ret = len*L;
                if(len%2 == 1) {

                        ret += 2*(p[tails-1] - p[i-1]);
                        ret -= 2*(s[tails]) - a[tails];
                }else {
                        ret += 2*(p[tails-1] - p[i-1]) - a[tails-1];
                        ret -= 2*(s[tails]);
                }
                ans = max(ans, ret);

        }
        return ans;
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cin >> L >> n;
        for(ll i=1;i<=n;i++) cin >> a[i];
        ll ans = solve();
        for(ll i=1;i<=n;i++) a[i] = L - a[i];
        sort(a+1, a+n+1);
        ans = max(ans , solve());
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 4992
ans = []
for i in range(4):
    for j in range(13):
        ans.append("SHCD"[i] + " " + str(j + 1))

n = int(input())
for i in range(n):
    a = input()
    ans.remove(a)

if len(ans) > 0:
    print("\n".join(ans))


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;


int main(){
   int N,M;cin>>N>>M;
   vector<int>H(N);
   int ans=0;
   //cout<<123<<endl;
   for(int i=0;i<N;i++)cin>>H[i];
   Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    //cout<<123<<endl;
    seen.assign(N, false);
    for(int i=0;i<N;i++){
        for(auto next_v : G[i]){
            //cout<<i<<" "<<next_v<<endl;
            if(H[next_v]>=H[i])seen[i]=true;
        }
                
        if(seen[i]==false) ans+=1;
    }
    
   
    cout<<ans<<endl;



}

Measured memory_bytes: 8804
#include<stdio.h>
int main(){
	int N;
	long long int result = 0;
	scanf("%d", &N);
	for(int i = 1 ; i <= N ; i++){
		if(i % 3!=0 && i % 5 !=0){
			result += i;
		}
	}
	if(result > 266666333332){
		printf("266666333332");
	}else{
		printf("%lld", result);
	}

	return 0;
}

Measured memory_bytes: 1712
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int sum = accumulate(a.begin(), a.end(), 0);
    int ans = -1;
    int minDiff = INT_MAX;
    for(int i=0; i<n; ++i){
        int diff = abs(sum - a[i] * n);
        if(diff < minDiff){
            ans = i;
            minDiff = diff;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764