akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int func(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}
int main(void){
  int c = 0, n, p[10] = {0};
  scanf("%d", &n);getchar();
  for(int i = 0; i < n; i++){
    scanf("%d", &p[i]);getchar();
  }
  qsort(p, n, sizeof(int), func);
  for(int i = 0; i < n; i++){
    if(i == n - 1){
      c += p[i] / 2;
    }else{
      c += p[i];
    }
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vvll pre(100001);

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll p(m), y(m);
    rep(i, m){
        cin >> p[i] >> y[i];
        pre[p[i]].emplace_back(y[i]);
    }
    rep(i, 100001){
        sort(ALL(pre[i]));
    }
    rep(i, m){
        ll in = lower_bound(ALL(pre[p[i]]), y[i])-pre[p[i]].begin()+1;
        cout << setfill('0') << right << setw(6) << p[i];
        cout << setfill('0') << right << setw(6) << in << endl;
    }
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    cin >> n;
    vector<vector<int>> a(2,vector<int>(n));
    rep(i,2) rep(j,n) cin >> a[i][j];

    int max_cnt = -(1<<29);
    rep(i,n)
    {
        int tmp_cnt = 0;
        rep(j,i+1) tmp_cnt += a[0][j];
        rep2(j,i,n) tmp_cnt += a[1][j];
        max_cnt = max(max_cnt,tmp_cnt);
    }
    cout << max_cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))

count = 0
for i in range(1,n-1):
    if (p[i-1]<p[i]<p[i+1]) or (p[i+1]<p[i]<p[i-1]):
        count += 1

print(str(count))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    ll N;
    cin >> N;
    map<string, ll> count;

    for(int i = 0; i < N; i++){
        string str;
        cin >> str;
        count[str]++;
    }

    ll maxv = 0;
    for(auto itr = count.begin(); itr != count.end(); itr++){
        maxv = max(maxv, itr->second);
    }
    
    for(auto itr = count.begin(); itr != count.end(); itr++){
        if(maxv == itr->second) cout << itr->first << endl;
    }



    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,K; cin >> N >> K;
    if((N-1)*(N-2)/2 < K){
        cout << -1 << endl;
        return 0;
    }

    vector<P> ans;
    REP(i,N-1) ans.emplace_back(1,i+2);
    int t = (N-1)*(N-2)/2;
    int u = 2,v = 3;
    while(t > K){
        ans.emplace_back(u,v);
        t--;
        v++;
        if(N < v){
            u++;
            v = u+1;
        }
    }
    cout << ans.size() << en;
    REP(i,ans.size()) cout << ans[i].first << " " << ans[i].second << en;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    vector<pair<int, int>> u(100100), v(100100);
    rep(i, 100100) {
        u[i] = make_pair(0, i);
        v[i] = make_pair(0, i);
    }
    rep(i, n) {
        if (i & 1) ++v[a[i]].first;
        else ++u[a[i]].first;
    }
    sort(u.rbegin(), u.rend());
    sort(v.rbegin(), v.rend());
    
    if (u[0].second != v[0].second) cout << n - u[0].first - v[0].first << endl;
    else cout << min(n - u[0].first - v[1].first, n - u[1].first - v[0].first) << endl;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 100
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return (1LL*a*b)%MOD;}
int fst_pow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=mul(res,a);
		a=mul(a,a),b>>=1;
	}
	return res;
}

int n,m;
int sx,sy;
char s[MAXN+5][MAXN+5];
short dp[MAXN+5][MAXN+5][MAXN+5][MAXN+5],a[MAXN+5][MAXN+5],b[MAXN+5][MAXN+5];
void upd(short &x,short y){x=max(x,y);}

int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='E')sx=i,sy=j;
			a[i][j]=a[i][j-1]+(s[i][j]=='o');
			b[i][j]=b[i-1][j]+(s[i][j]=='o');
		}
	}
	int L=sy-1,U=sx-1,R=m-sy,D=n-sx;
	for(int u=0;u<=U;u++)
		for(int d=0;d<=D;d++)
			for(int l=0;l<=L;l++)
				for(int r=0;r<=R;r++){
					int pl=max(sy-l,r+1),pr=min(sy+r,m-l);
					if(pl<=pr){
						upd(dp[u+1][d][l][r],dp[u][d][l][r]+((sx-u-1>=d+1)?a[sx-u-1][pr]-a[sx-u-1][pl-1]:0));
						upd(dp[u][d+1][l][r],dp[u][d][l][r]+((sx+d+1<=n-u)?a[sx+d+1][pr]-a[sx+d+1][pl-1]:0));
					}
					pl=max(sx-u,d+1),pr=min(sx+d,n-u);
					if(pl<=pr){
						upd(dp[u][d][l+1][r],dp[u][d][l][r]+((sy-l-1>=r+1)?b[pr][sy-l-1]-b[pl-1][sy-l-1]:0));
						upd(dp[u][d][l][r+1],dp[u][d][l][r]+((sy+r+1<=m-l)?b[pr][sy+r+1]-b[pl-1][sy+r+1]:0));
					}
				}
	printf("%d\n",dp[U][D][L][R]);
}

Measured memory_bytes: 46080
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>

using namespace std;

const int nax = 1e6 + 5;
int g[nax];

int cnt[nax];


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    for(int i=1;i<nax;i++) g[i] = i;
    for(int i=2;i<nax;i++)
    {
        for(int j=i;j<nax;j+=i)
        {
            if(g[j] == j) g[j] = i;
        }
    }
    int n; cin>>n;
    int ful;
    for(int i=1;i<=n;i++)
    {
        int x; cin>>x;
        if(i == 1) ful = x;
        else ful = __gcd(ful,x);
        int last = -1;
        while(x > 1)
        {
            int akt = g[x];
            x /= akt;
            if(akt != last)
            {
                cnt[akt]++;
            }
            last = akt;
        }
    }
    int ok = 0;
    for(int i=1;i<nax;i++)
    {
        if(cnt[i] > 1) ok++;
    }
    if(ok == 0)
    {
        cout<<"pairwise coprime";
    }
    else if(ful == 1)
    {
        cout<<"setwise coprime";
    }
    else cout<<"not coprime";
    return 0;
}


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

int main() {
  int h,a;
  cin >> h >> a;
  int c=h/a;
  int d=h%a;
  if (d==0) {
  cout << c << endl;
  }
  else {
    cout << c+1 << endl;
  }
}


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

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

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int dr[] = {1, -1, 0, 0};
int dc[] = {0, 0, 1, -1};

int bfs(vector<string>& map, PII start, PII goal) {
    int res = 0;
    VVI costs(map.size(), VI(map[0].size(), -1));
    costs[start.first][start.second] = 0;
    queue<PII> q;
    q.push(start);
    int cost = 0;
    while (!q.empty()) {
        PII p = q.front(); q.pop();
        if (p == goal) {
            cost = costs[p.first][p.second];
            break;
        }
        for (int i = 0; i < 4; i++) {
            int nr = p.first + dr[i];
            int nc = p.second + dc[i];
            if (nr >= 0 && nr < map.size() && nc >= 0 && nc < map[nr].size()
                    && map[nr][nc] != 'X' && costs[nr][nc] == -1) {
                costs[nr][nc] = costs[p.first][p.second] + 1;
                q.push(PII(nr, nc));
            }
        }
    }
    /*
    REP(i, costs.size()) {
        REP(j, costs[i].size()) {
            if (
            cerr << (costs[i][j] == -1 ? '?' : costs[i][j]) << " "; 
        }
        cerr << endl;
    }
    */
    return cost;
}

int getCost(vector<string>& map, int next) {
    char from = 'S';
    if (next > 1) from = char(next - 1 + '0');
    char to = char(next + '0');

    PII start, goal;
    for (int i = 0; i < map.size(); i++) {
        for(int j = 0; j < map[i].size(); j++) {
            if (map[i][j] == from) start = PII(i, j);
            if (map[i][j] == to) goal = PII(i, j);
        }
    }
    return bfs(map, start, goal);
}

int solve(vector<string>& map, int N) {
    int cost = 0;
    for (int i = 1; i <= N; i++) {
        cost += getCost(map, i);
    }
    return cost;
}

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<string> map;
    for (int i = 0; i < H; i++) {
        string s; cin >> s;
        map.push_back(s);
    }
    int answer = solve(map, N);
    cout << answer << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		boolean bl = true;
		int a=0,b=0;

		while(bl){
			a = stdIn.nextInt();
			b = stdIn.nextInt();

			if((1 <= a) && (a <= Math.pow(10, 9)) && (1 <= b) && (b <= Math.pow(10, 9)) ){
				break;
			}
		}

		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;

		System.out.printf("%d %d %.6f", d,r,f);
	}
}

Measured memory_bytes: 26380
#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>;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> st;
    rep(i,k) {
        if (a+i <= b) st.insert(a+i);
    }
    rep(i,k) {
        if (b-i >= a) st.insert(b-i);
    }
    for (auto itr = st.begin(); itr != st.end(); itr++) {
        cout << *itr << endl;
    }
}

Measured memory_bytes: 256
def p_d():
    from fractions import gcd
    n, m = map(int, input().split())
    *A, = map(lambda x: int(x) // 2, input().split())

    c = 0
    for a in A:
        if c == 0:
            while a & 1 == 0:
                c += 1
                a >>= 1
        else:
            ne = 0
            while a & 1 == 0:
                ne += 1
                a >>= 1
            if c != ne:
                print(0)
                exit()

    lcm = A[0]
    for i in range(1, n):
        lcm = lcm * A[i] // gcd(lcm, A[i])
    print((m // lcm + 1) // 2)
    
p_d()

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

int main() {
  int N,K;
  cin>>N>>K;
  int n=1;
  for(int i=0;i<N;i++){
    if(n*2<n+K){
    n*=2;
    }
    else{
      n+=K;
    }
  }
  cout<<n<<endl;
}


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

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	
	if (a == 0 && b == 0)
	{
		cout << a << " " << b;
		return 0;
	}
	else if (a + b <= k)
	{
		cout << 0 << " " << 0;
		return 0;
	}
	
	if (a <= k)
	{
		b = (b + a) - k;
		a = 0;
	}
	else {
		a -= k;
	}
	
	
	cout << a << " " << b;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  ll N, K; cin >> N >> K;
  vector < pair<ll, int> > DT(N);
  
  for (int i = 0; i < N; i++){
    int T, D; cin >> T >> D; T--;
    DT[i] = make_pair(D, T);
  }
  sort(DT.begin(), DT.end(), greater< pair<ll, int> > ());

  vector <int> cnt(N);
  ll ans = 0, X = 0;
  priority_queue < pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > que;

  for (int i = 0; i < K; i++){
    que.push(DT[i]);
    ans += DT[i].first;
    if (cnt[DT[i].second] == 0) X++;
    cnt[DT[i].second]++;
  }
  ans += X * X;

  ll now = ans;
  for (int i = K; i < N; i++){
    if (cnt[DT[i].second] == 0){
      while (!que.empty()){
        pair <ll, int> P = que.top(); que.pop();

        if (cnt[P.second] > 1){
          now += DT[i].first - P.first;
          now += (X + 1) * (X + 1) - X * X;
          X++; cnt[P.second]--;
          cnt[DT[i].second]++;
          break;
        }
      }
      ans = max(now, ans);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll pri = 1000000007;
typedef pair<int, int>P;
int main(){
    ll N, ans = 1;
    cin>>N;
    vector<P>vec;
    for(int i=0;i<N;i++){
        int tmp;
        cin>>tmp;
        vec.push_back(P(tmp, 0));
    }
    for(int i=0;i<N;i++){
        int tmp;
        cin>>tmp;
        vec.push_back(P(tmp, 1));
    }
    sort(vec.begin(), vec.end());
    int lst[2] = {0, 0};
    for(int i=0;i<vec.size();i++){
        if(vec[i].second){
            if(lst[0]>0){
                lst[0]--;
            }
            else{
                lst[1]++;
                ans = ans * lst[1] % pri;
            }
        }
        else{
            if(lst[1]>0){
                lst[1]--;
            }
            else{
                lst[0]++;
                ans = ans * lst[0]%pri;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
let prim a n =
  let reached_p = Array.make n false in
  let d = Array.make n max_int in
  d.(0) <- 0;
  let from = Array.make n (-1) in
  let rec doit () =
    let u =
      Array.fold_left (fun (j, m, u) p ->
        if not p && d.(j) < m then (j + 1, d.(j), j) else (j + 1, m, u))
        (0, max_int, (-1)) reached_p
      |> (fun (_, _, u) -> u) in
    if u = (-1) then ()
    else begin
      reached_p.(u) <- true;
      Array.iteri (fun j p ->
        if a.(u).(j) <> (-1) && not p && a.(u).(j) < d.(j) then begin
          d.(j) <- a.(u).(j);
          from.(j) <- u;
        end) reached_p;
      doit ()
    end in
  doit ();
  Array.fold_left (fun (j, sum) i ->
    (j + 1, if i = (-1) then sum else sum + a.(i).(j)))
    (0, 0) from
  |> snd

let () =
  let n = read_int () in
  let a = Array.make_matrix n n 0 in
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      a.(i).(j) <- Scanf.scanf " %d" (fun i -> i)
    done
  done;
  prim a n |> Printf.printf "%d\n"

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const long long mod = 1000000007;
const long long INF = mod*mod;

ll dp[3001][3001];
int solve()
{
	string s,t;
	cin>>s>>t;
	rep(i,3001){
		dp[0][i] = 0;
		dp[i][0] = 0;
	}
	rep_a(i,1,s.length()+1)
	{
		rep_a(j,1,t.length()+1)
		{
			if(s[i-1] == t[j-1])
			{
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else
			{
				dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
			}
		}
	}

	int index = dp[s.length()][t.length()]; 
    char lcs[index+1]; 
    lcs[index] = '\0'; 
    int i = s.length();int j = t.length(); 
    while (i > 0 && j > 0) 
    {  
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1];  
          i--; j--; index--; 
      } 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
 
	return 0;
}
int main()
{
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
	#endif */

	return 0;
} 

Measured memory_bytes: 70656
// D - Triangles
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define all(x) (x).begin(),(x).end()

int solve(int N, vi &L){
	sort(all(L));
	int ans = 0;
	irp(hi, N-1, 0){
		irp(mid, hi-1, -1){
			auto ite = lower_bound(all(L), L[hi] + L[mid]);
			int d = distance(ite, L.end());
			ans += (N - 1 - hi) - d;
		}
	}
	return ans;
}

int main(){
	int N; cin>>N;
	vi L(N);
	rp(i, 0, N) cin>>L[i];
	cout<< solve(N, L) <<endl;
}

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

#define FOR(i,a,b) for(ll i=a; i<b; i++)
#define IN(a) cin>>a
#define OUT(a) cout<<a<<endl

int main(){
  long long int n,d; IN(n); IN(d);
  long long int count = 0;
  FOR(i,0,n){
    long long int x,y;
    cin >> x >> y;
    if(x*x+y*y<=d*d){
      count++;
    }
  }
  OUT(count);
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdlib>

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

	long long n;
	std::cin >> n;

	long long t[2] = {0,0} , x[2] = {0,0} , y[2] = {0,0} ;
	std::cin >> t[0] >> x[0] >> y[0];
  
	for (int i = 1; i <= n; ++i) {
		std::cin >> t[1] >> x[1] >> y[1];

		long long ts = abs(t[1] - t[0]);
        long long ds = abs(x[1] - x[0]) + abs(y[1] - y[0]);
		if (ts < ds || (ts % 2) != (ds % 2)) {
			std::cout << "No";
			return 0;
		}
		t[0] = t[1];
		x[0] = x[1];
		y[0] = y[1];
	}
	std::cout << "Yes";

	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	string t[4] = { "dream","dreamer","erase","eraser" };
	for (int i = 0;i < 4;i++)reverse(t[i].begin(), t[i].end());
	reverse(s.begin(), s.end());
	int now = 0;
	int flag = 0;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 4;j++) {
			if (now == n-1) {
				break;
				flag = 1;
			}
			if (s.substr(now, t[j].size()) == t[j])now += t[j].size();
		}
		if (flag)break;
	}
	if (now == n)cout << "YES" << endl;
	else cout << "NO" << endl;
}
//Tの末尾に dream dreamer erase eraser のいずれかを追加する。

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    int n = (int)s.size();

    ll r = 0;
    int a = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == 'A') {
            a++;
        } else if (s[i] == 'B' && s[i + 1] == 'C') {
            r += a;
            i++;
        } else {
            a = 0;
        }
    }

    cout << r << endl;

    //貪欲に処理していい気がする でもO(N^2)かかるのでそこだけか？
    //ABCACCBABCBCAABCB
    //BCAACCBBCBCBCAAAB
    //全てのABCを検出し（ABC同士の範囲が被ることはない）、その直前がAか直後がBCのとき連鎖する
    //ACB BAC CBA などの逆順は連鎖しない
    //AC が存在したらそこが変化することはない そこで切断して独立に考えていい
    //BAはBBCAに変化してもそこまで CBはBCABになるかも
    //BCというパーツが沈んでいく
    //AABC BCA 
    //AABC ABCA
    //   A BCA BC

    return 0;
}

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

using namespace std;

void execute()
{
	int N;
	int a0 = 0, b0 = 0, c0 = 0;
	int a1, b1, c1;
	int diff;
	bool ans = true;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a1 >> b1 >> c1;
		if (ans)
		{
			diff = a1 - a0 - abs(b1 - b0) - abs(c1 - c0);
			if (diff < 0 || diff % 2 == 1)
				ans = false;

			a0 = a1;
			b0 = b1;
			c0 = c1;
		}
	}

	cout << (ans ? "Yes" : "No");
}

int main()
{
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
using ll = long long;
typedef pair<int, int> Pair;

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

  vector<int> h(N);
  rep(i, N) cin >> h[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (h[i] >= K) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int N;

int main() {
	cin >> N;
	if (N / 100000 == 1) {
		cout << 90909;
	}
	else if (N / 10000 >= 1) {
		cout << 909 + N - 9999;
	}
	else if (N / 1000 >= 1) {
		cout << 909;
	}
	else if (N / 100 >= 1) {
		cout << 9 + N - 99;
	}
	else if (N / 10 >= 1) {
		cout << 9;
	}
	else {
		cout << N;
	}
	return 0;
}


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


using namespace std;


int main (int argc, char const* argv[]){
    int n;
    map<string, int> words;
    string sentence, word;
    int max=0, min = 0;
    string maxFreq, maxWord; //最多頻度単語, 最長単語
    
    //文章取得
    getline(cin,sentence);
    stringstream ss(sentence);
    
    while(getline(ss,word,' ')){
        //words内にwordが既に存在するならインクリメント
        if(words.find(word) != words.end()) {
            words[word] += 1;
        }
        //words内にwordがまだ存在しない場合に新たに挿入する
        else{
            words.insert(map<string, int>::value_type(word,1));
        }
    }
    
    
    //最多出現頻度の単語を探す
    map<string, int>::iterator it = words.begin();
    while(it != words.end()){
        if(max < (*it).second){
            max = (*it).second;
            maxFreq = (*it).first;
        }
        if(min < (*it).first.size()){
            min = (*it).first.size();
            maxWord = (*it).first;
        } 
        it++;
    }
    
    
    
    //最多頻度単語と最長単語の出力
    cout <<  maxFreq << " " << maxWord <<  endl;
    
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;
char str[MAXN];
int alp[27];
long long ans;
int main()
{
    scanf("%s",str+1);
    int n=strlen(str+1);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=25;j++)
        {
            if(j==(str[i]-'a'))
            {
                continue;
            }
            else
            {
                ans+=alp[j];
            }
        }
        alp[str[i]-'a']++;
    }
    printf("%lld\n",ans+1);
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    forn(i, 0, n) cin >> a[i];
    sort(all(a));
    ll x = 0, y = 0;
    while (n >= 2) {
        if (a[n - 2] == a[n - 1]) {
            x = a[n - 1];
            n -= 2;
            break;
        }
        --n;
    }
    while (n >= 2) {
        if (a[n - 2] == a[n - 1]) {
            y = a[n - 1];
            n -= 2;
            break;
        }
        --n;
    }
    cout << x * y << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cout << #x << " = " << (x) << "\n"
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int n;

void solve() {
	double now = n / 2.0;
	while ( fabs( sq( now ) * now - n ) >= 0.00001 * n ) {
		now -= ( sq( now ) * now - n ) / ( 3 * sq( now ) );
	}
	printf( "%f\n", now );
}

int main() {
#ifdef WIN32
	printf( "Debug Mode\n" );
#endif
	while ( ~scanf( "%d", &n ) && ~n ) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1216
#分岐は後で処理すれば良い
#それぞれ0,nに近づくのが最適
from heapq import heappush,heappop
inf=10**10
n=int(input())
l=[[] for i in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l[a].append(b)
  l[b].append(a)
def dijkstra(s):
  q=[(0,s)]
  dist=[inf]*(n+1)
  dist[s]=0
  while q:
    c,v=heappop(q)
    if dist[v]<c:
      continue
    for i in l[v]:
      t=i
      cost=1
      if dist[v]+cost<dist[t]:
        dist[t]=dist[v]+cost
        heappush(q,[dist[t],t])
  return dist
d1=dijkstra(1)
d2=dijkstra(n)
countp=0
counts=0
for i in range(1,n+1):
  if d1[i]>d2[i]:
    counts+=1
  else:
    countp+=1
if countp>counts:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 29076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;
long long INF = 1LL << 60;
int main() {
	int N;
	cin >> N;
	vector<int> A(N), order(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		order[A[i] - 1] = i + 1;
	}
	for (int i = 0; i < N; i++) cout << order[i] << " ";
	return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
int solve(int a[],int dp[],int n){
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++){
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  
  }
  return dp[n-1];
}
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[n]={0};
  cout<<solve(a,dp,n);

  return 0;
}


Measured memory_bytes: 4332
q=int(input())
lr=[tuple(map(int,input().split())) for _ in range(q)]

n=10**5
ansl=[]
sieve=[1]*(n+1)
sieve[0],sieve[1]=0,0
for i in range(2,n):
  if sieve[i]:
    sieve[2*i::i]=[0 for _ in range(2*i,n+1,i)]
ans=[0]*(n+1)
for i in range(3,n):
  if sieve[i]==1 and sieve[(i+1)//2]==1:
    ans[i]=ans[i-1]+1
  else:
    ans[i]=ans[i-1]

for e in lr:
  print(ans[e[1]]-ans[e[0]-1])


Measured memory_bytes: 24680
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    if(a < b) swap(a, b);

    if((a-b)%2==0) {
        cout << (a-b)/2 << endl;
    } else {
        int l, r;
        l = min((b-1)+(a-b)/2+1, a-1);
        r = min((n-a)+(a-b)/2+1, n-b);

        cout << min(l, r) << endl;        
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)

int main(){
	int n,t,dp[2][5010];
	rep(i,2)rep(j,5010)dp[i][j] = 1000000000;
	dp[0][1] = 0;
	cin >> n;
	
	rep(i,n-1){
		cin >> t;
		for(int j=n/2;j>0;j--){
			dp[1][j] = min ( dp[0][j] + t , dp[1][j] );
			dp[0][j] = min ( dp[0][j-1] , dp[1][j-1] + t );
		}
	}
	
	cout << min ( dp[0][n/2] , dp[1][n/2] ) << endl;
}

Measured memory_bytes: 1200
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m, k, ans[333][333], C = 1;
	memset(ans, 0, sizeof ans);
	cin >> n >> m >> k;
	char row[333];
	for(int i = 0; i < n; i++) {
		int sm = 0;
		for(int j = 0; j < m; j++) {
			cin >> row[j];
			sm += row[j]=='#';
		}
		if(sm) {
			int x = 0;
			for(int j = 0; j < m; j++) {
				ans[i][j] = C+x;
				if(row[j]=='#') x=min(x+1, sm-1);
			}
			C+=sm;
		}
	}
	for(int j = 0; j < m; j++)
		for(int i = n; i--;)
			if(!ans[i][j])
				ans[i][j] = ans[i+1][j];
	for(int j = 0; j < m; j++)
		for(int i = 1; i<n;i++)
			if(!ans[i][j])
				ans[i][j] = ans[i-1][j];
	for(int i = 0; i < n; i++, cout << "\n")
		for(int j = 0; j < m; j++)
			cout << ans[i][j] << " ";
}


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

int main() {
	int H, W;
	int a = 1;
	while (a == 1) {
		cin >> H >> W;
		if (!(H == 0 && W == 0)) {
			for (int i = 1; i <= H; i++) {
				if (i == 1 || i == H) {
					for (int j = 1; j <= W; j++) {
						cout << "#" << flush;
					}
					cout << endl;
				}
				else if (!(i == 1 || i == H)) {
					for (int j = 1; j <= W; j++) {
						if (j == 1 || j == W) {
							cout << "#" << flush;
						}
						else if (!(j == 1 || j == W)) {
							cout << "." << flush;
						}
					}
					cout << endl;
				}
			}
			cout << endl;
		}
		else if (H == 0 && W == 0) {
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 2960
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const int MN = 100010;

int n;
int a[MN];
int ft[2 * MN];

int h(int x) { return x + MN; }

void update(int pos, int by) {
    while (pos < 2 * MN) ft[pos] += by, pos |= pos + 1;
}

int query(int pos) {
    int res = 0;
    while (pos >= 0) res += ft[pos], pos = (pos & (pos + 1)) - 1;
    return res;
}

int can(int x) {
    long long cnt = 0;
    memset(ft, 0, sizeof ft);
    update(h(0), 1);
    for (int i = 1, sum = 0; i <= n; i++) {
        sum += (a[i - 1] > x ? 1 : -1);
        cnt += i - query(h(sum));
        update(h(sum), 1);
    }
    return cnt >= ((1LL * n * (n + 1)) / 2) / 2 + 1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	cin >> n;
	for (int i = 0; i < n; i++)
        cin >> a[i];
    int lo = 0, hi = 1e9;
    while (hi - lo > 1) {
        int mi = (hi + lo) / 2;
        if (can(mi)) hi = mi;
        else lo = mi;
    }
    cout << hi << endl;
	return 0;
}


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N;
    cin >> N;
    cout << (N-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        s = 0
        for k in range(d):
            s += (x[i][k] - x[j][k])**2
        if math.sqrt(s) % 1 == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(void)
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if ((0 > (x - r)) || (w < (x + r)) ||
        (0 > (y - r)) || (h < (y + r)))
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    long long H, W;
    cin >> H >> W;
    vector<vector<int>> vec(H, vector<int>(W));
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++)
        {
            if (s[j] == '#')
            {
                vec[i][j] = -1;
            }
        }
    }
    int dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
    int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (vec[i][j] == -1)
            {
                continue;
            }
            for (int k = 0; k < 8; k++)
            {
                int nowy = i + dy[k];
                int nowx = j + dx[k];
                if (nowy >= 0 && nowy < H && nowx >= 0 && nowx < W && vec[nowy][nowx] == -1)
                {
                    vec[i][j]++;
                }
            }
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (vec[i][j] == -1)
            {
                cout << '#';
            }
            else
            {
                cout << vec[i][j];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E15;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

dd PI=acos(-1);
 
int main(){fastio
    //cout<<atan(1.0)<<endl;
    ll aa,bb,xx;cin>>aa>>bb>>xx;
    dd a,b,x;a=aa;b=bb;x=xx;
    dd ans=(dd)180/PI;
    dd theta;
    if(2*xx==aa*aa*bb){
        theta=atan(b/a);
        ans*=theta;
    }else if(2*x>a*a*b){
        dd y=2*x/a/a-b;
        theta=atan((b-y)/a);
        ans*=theta;
    }else{
        dd z=2*x/a/b;
        theta=atan(z/b);
        ans*=theta;
        ans=90.0-ans;
    }
    cout<<setprecision(15)<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
nums = gets.split("").map(&:to_i)
 
 
["+", "-"].repeated_permutation(nums.size - 1) do |a|
    ans = 0
    4.times do |i|
        if i == 0
            ans = nums[i]
        else
            if a[i - 1] == "+"
                ans += nums[i]
            else
                ans -= nums[i]
            end
        end
        if i==3 && ans == 7
          puts "#{nums[0]}#{a[0]}#{nums[1]}#{a[1]}#{nums[2]}#{a[2]}#{nums[3]}=7"
          exit 0
        end
    end
end

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

int main(void){
    using namespace std;
    int n,a,b=0;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>a;
        if(a!=i) b++;
        if(b>2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint N;
  cin >> N;
  lint A[N];
  rep(i,N) cin >> A[i];
  lint L=0,R=0;
  lint Xor=A[0],Sum=A[0],ans=1;
  while(R!=N){
    while(Xor==Sum){
      R++;
      if(R==N) break;
      Xor=Xor^A[R];
      Sum+=A[R];
      if(Xor==Sum) ans+=R-L+1;
    }
    if(R==N){
      while(Xor!=Sum){
      L++;
      Xor=Xor^A[L-1];
      Sum-=A[L-1];
      if(Xor==Sum) ans+=R-L+1;
      }
      break;
    }
    while(Xor!=Sum){
      L++;
      Xor=Xor^A[L-1];
      Sum-=A[L-1];
      if(Xor==Sum) ans+=R-L+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
from collections import deque
a,b,c,d,e,f = map(int,input().split())

def judgement(x,y):
    flag = True
    if 100*y > e*x:
        flag = False
    if x+y > f:
        flag = False
    return flag


q = deque([(100*a, 0)])
used = set()
used.add((100*a, 0))
if 100*b <= f:
    q.append((100*b, 0))
    used.add((100*b, 0))
ans = (100*a,0)
per = 0
while q:
    tar = q.popleft()
    step = [(tar[0]+100*a, tar[1]), (tar[0]+100*b, tar[1]),
            (tar[0], tar[1]+c), (tar[0], tar[1]+d)]
    for i in step:
        if i not in used:
            used.add(i)
            if judgement(i[0], i[1]):
                q.append(i)
                if per*i[0] < i[1]:
                    per = i[1]/i[0]
                    ans = i
print(ans[0]+ans[1], ans[1])







Measured memory_bytes: 41456
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N, K = LI()
    A_li = LI()
    最上位桁 = len(bin(K))-3
    x = ''

    one_to_zero = False
    # K の上から見ていく。
    for i in range(最上位桁, -1, -1):
        # その桁で多いのは 1 か 0 か？
        counter = {0: 0, 1: 0}
        for a in A_li:
            if a & (1<<i):
                counter[1] += 1
            else:
                counter[0] += 1
        if counter[0] > counter[1]:
            # 0 が多いとき: 1を入れたい。
            # K が 1 なら、1 を入れられる。
            if K & (1<<i):
                x += '1'
            # K が 0 なら、事前に 1 を 0 にしていたら 1 を入れられる。
            elif one_to_zero:
                x += '1'
            # それ以外なら 0 を入れるしかない。
            else:
                x += '0'
        else:
            # 1 が多いとき: 0 を入れたい。
            # 0 はいつでも入れられるが、Kが1だったら one_to_zero を True にしてやる。
            x += '0'
            if K & (1<<i):
                one_to_zero = True

    x = int(x, 2)
    if K == 0: x = 0

    ans = 0
    for a in A_li:
        ans += a ^ x
    print(ans)

main()

Measured memory_bytes: 14748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_155
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var dict = new Dictionary<string, int>();
            int cnt = 0;
            for(int i = 0; i < n; i++)
            {
                string s = Read();
                if (dict.ContainsKey(s))
                {
                    dict[s]++;
                }
                else
                {
                    dict.Add(s, 1);
                }
                cnt = Max(cnt, dict[s]);
            }
            List<string> res = new List<string>();
            foreach(string key in dict.Keys)
            {
                if (dict[key] == cnt)
                {
                    res.Add(key);
                }
            }
            res.Sort(StringComparer.Ordinal);
            for(int i = 0; i < res.Count; i++)
            {
                WriteLine(res[i]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 40796