akhauriyash/Code-Regression huggingface dataset:
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
typedef pair<ll,ll> P;
struct Edge{ll from,to,dist;};
ll N; ll d[100000];
ll p[100000];
vector<Edge> G[100000];

void dijkstra(ll u){
    REP(i,N)d[i]=p[i]=INF;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push({0,u});
    d[u]=0;
    while(!que.empty()){
        auto r=que.top();que.pop();
        if(r.first>d[r.second])continue;//更新不可
        //d[r.second]=r.first;//更新

        for(Edge& e: G[r.second]){
            ll dist=d[r.second]+e.dist;
            if(dist>=d[e.to])continue;//更新不可
            d[e.to]=dist;//更新
            que.push({d[e.to],e.to});//更新
            p[e.to]=r.second;
        }
    }
}
//-----------------------------------------
int main(void){
    ll M;cin>>N>>M;
    REP(i,M){
        ll a,b;cin>>a>>b;a--;b--;
        G[a].push_back({a,b,1});
        G[b].push_back({b,a,1});
    }
    cout<<"Yes\n";
    dijkstra(0);
    REPS(i,N-1)cout<<p[i]+1<<"\n";
}

Measured memory_bytes: 23900
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int N,A,B;
  int sum1, sum2;
  scanf("%d %d %d\n",&N, &A, &B );

  sum1 =  N*A;
  sum2 = B;

  if(sum1 >= sum2){
    printf("%d\n",sum2 );
  } else{
    printf("%d\n",sum1 );
  }


  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=100010,mod=1000000007;
int n,m;
int x[N],y[N],cnt;
struct pt
{
	int x,y;
	bool operator < (const pt a)const
	{
		return x<a.x || (x==a.x && y<a.y);
	}
}b[N];
long long s[N<<2];
int lowbit(int k)
{
	return k&-k;
}
void add(int k,long long x)
{
	for(int i=k;i<=n*3;i+=lowbit(i))
		(s[i]+=x)%=mod;
}
long long query(int k)
{
	long long res=0;
	for(int i=k;i;i-=lowbit(i))
		(res+=s[i])%=mod;
	return res;
}
long long f[N];
int h[N<<1];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&y[i]);
	int fi=1;
	while(x[fi]<=y[1] && fi<=n)fi++;
	for(int i=1;i<m;i++)
	{
		while(x[fi]==y[i] && fi<=n)fi++;
		while(x[fi]<y[i+1] && fi<=n)
		{
			b[++cnt].x=x[fi]-y[i];
			b[cnt].y=y[i+1]-x[fi];
			fi++;
		}
	}
	int tot=0;
	sort(b+1,b+cnt+1);
	for(int i=1;i<=cnt;i++)
		h[++tot]=b[i].x,h[++tot]=b[i].y;
	sort(h+1,h+tot+1);
	tot=unique(h+1,h+tot+1)-h-1;
	for(int i=1;i<=cnt;i++)
		b[i].x=lower_bound(h+1,h+tot+1,b[i].x)-h,b[i].y=lower_bound(h+1,h+tot+1,b[i].y)-h;
	long long ans=1;
	for(int i=1;i<=cnt;)
	{
		int j=i;
		for(;j<=cnt && b[i].x==b[j].x;j++)
			f[j]=(1+query(b[j].y-1))%mod;
		j=i;
		for(;j<=cnt && b[i].x==b[j].x;j++)
			if(b[j].y!=b[j-1].y || b[j].x!=b[j-1].x)
				add(b[j].y,f[j]),(ans+=f[j])%=mod;
		i=j;
    }
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 6528
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
inline void solve(void){
  int N;in(N);
  vector<pair<long,long>>A(N);
  vector<long>B(N);
  rep(i,N){
    long X,L;in(X,L);
    A[i]=mp(X+L,X-L);
  }
  sort(all(A));
  long ans=0,t=LONG_MIN;
  rep(i,N){
    if(t<=A[i].sd){
      ans++;
      t=A[i].ft;
    }
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

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

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    rep(i, s.size()) {
        cout << "x";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
import sys

N, K = map(int,input().split())
D = list(map(str, input().split()))

D_ava = list(map(str,[i for i in range(1,10) if i not in D]))
for s in range(N, 10**5+1):
	ss = list(set(str(s)))
	cond = True
	for sss in ss:
		if sss in D:
			cond = False
			break
	if cond == True:
		print(s)
		sys.exit()
	else:
		continue

Measured memory_bytes: 3064
import heapq
n, m = map(int, input().split())
tmp = [[] for _ in range(m)]
for j in range(n):
    a, b = list(map(int, input().split()))
    if a-1 < m:
        tmp[a-1].append(-b) #heapqはMin Heapのみ

ans = 0
heap = []
for i in range(m):
    for b in tmp[i]:
        heapq.heappush(heap, b)
    if len(heap) > 0:
        ans -= heapq.heappop(heap)
print(ans)        

Measured memory_bytes: 23752
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;
int n;
int sx[10];
int sy[10];

const int dx[12] = {-1,0,1,2,2,2,1,0,-1,-2,-2,-2};
const int dy[12] = {-2,-2,-2,-1,0,1,2,2,2,1,0,-1};

const int dx2[9] = {-1,-1,-1,0,0,0,1,1,1};
const int dy2[9] = {-1,0,1,-1,0,1,-1,0,1};

bool solve(int x, int y, int m) {
  if (m == n) return true;
  // REP(i,m)
  //   cout << " ";
  // cout << x << ", " << y << endl;
  
  REP(i,12) {
    int xx = x + dx[i];
    int yy = y + dy[i];

    bool f = false;
    REP(j,9) {
      int sxx = sx[m] + dx2[j];
      int syy = sy[m] + dy2[j];

      if (xx == sxx && yy == syy) {
        f = true;
        break;
      }
    }
    if (f && solve(xx, yy, m+1))
        return true;
  }
  return false;
}

int main() {
  int x, y;
  while(cin >> x >> y, x||y) {
    cin >> n;
    REP(i,n) {
      cin >> sx[i] >> sy[i];
    }
    if (solve(x,y,0)) 
      cout<< "OK" << endl;
    else
      cout << "NA" << endl; 
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define lli long long unsigned int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

lli start(lli now,lli pos,vector<lli> *c,vector<lli> *s,vector <lli> *f){
	if(now <= s->at(pos))return s->at(pos);
	if((now % f->at(pos))==0)return now;
	return now/f->at(pos)*f->at(pos)+f->at(pos);
}

int main(){

	lli n;
	vector<lli> c,s,f;
	cin>>n;
	for(lli i=0;i<n-1;i++){
		lli tmpC,tmpS,tmpF;
		cin>>tmpC>>tmpS>>tmpF;
		c.push_back(tmpC);
		s.push_back(tmpS);
		f.push_back(tmpF);
	}

	for(lli i=0;i<n;i++){
		lli ans = 0;
		for(lli j=i;j<n-1;j++){
			ans = start(ans,j,&c,&s,&f);
			ans += c[j];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }









const int MAX = 3000010;
const int M = 1000000007;

vector<ll> fac(MAX); //n!(mod M)
vector<ll> ifac(MAX); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll COMinit(){
  //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<MAX; i++){
    fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
    ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  return 0;
}

ll COM(ll a, ll b){ //aCbをmod計算
  if(a == 0 && b == 0)return 1;
  if(a < b || a < 0)return 0;
  ll tmp = ifac[a-b]* ifac[b] % M;
  return tmp * fac[a] % M;
}

int main(){
  COMinit();
  int x,y;
  cin >> x >> y;
  if((x+y)%3){
    cout << 0 << endl;
    return 0;
  }
  int n = (x+y)/3;
  x-=n;y-=n;
  if(x<0||y<0){
    cout << 0 << endl;
    return 0;
  }
  cout << COM(x+y,y) << endl;
  return 0;
}










Measured memory_bytes: 47104
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
using Pc=pair<char,char>;
ll dp[300][200000];
int main() {
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int main(void){
	long n=nextplong();
	if(n==2){
		puts("1");
		return 0;
	}
	long ans=0;
	{
		long m=sqrt(n-1);
		for(int i=2; i<=m; i++){
			if((n-1)%i==0){ans+=2; /*printf("%d ", i);*/}
		}
		if(m*m==n-1) ans--;
		ans++; //n-1
		//putchar(10);
	}{
		long m=sqrt(n);
		for(int i=2; i<=m; i++){
			if(n%i==0){
			long s=n;
			while(s%i==0) s/=i;
			if(s%i==1){ans++; /*printf("%d ", i);*/}
			s=n;
			long j=n/i;
			if(j==i) continue;
			while(s%j==0) s/=j;
			if(s%j==1){ans++; /*printf("%ld ", j);*/}
			}
		}
		ans++; //n
		//putchar(10);
	}
	printf("%ld\n", ans);
}


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

int main(){
  int n,k;
  cin >> n >> k;
  int t = 0;
  for (int i=0;i<n;i++){
    int x;
    cin >> x;
    int a = x * 2;
    int b = abs(k-x) * 2;
    t += min(a,b);
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
int fa[N];
vector<int> edges[N];
int dep[N], dp[N];
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int ans(0);
    for(int i(1); i <= n; i++) {
        scanf("%d", &fa[i]);
        if(i == 1) {
            ans += fa[1] != 1;
            fa[1] = 0;
        }else {
            edges[fa[i]].push_back(i);
        }
    }
    dep[1] = 0;
    dp[1] = 0;
    vector<pair<int, int> > q;
    q.push_back(make_pair(1, 0));
    while(!q.empty()) {
        int v(q.back().first), p(q.back().second++);
        if(p < (int)edges[v].size()) {
            int y(edges[v][p]);
            dep[y] = dep[v] + 1;
            dp[y] = 0;
            q.push_back(make_pair(y, 0));
        }else {
            if(dp[v] == k - 1 && dep[v] >= 2) {
                ans++;
            }else {
                dp[fa[v]] = max(dp[fa[v]], dp[v] + 1);
            }
            q.pop_back();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8312
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    vector<int> a(5);
    REP(i, 5) cin >> a[i];
    int k;
    cin >> k;
    SORT(a);

    if (a[4] - a[0] > k) {
        cout << ":(" << endl;
        return 0;
    }

    cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}

	SORT(a);
	reverse(a.begin(), a.end());

	int A = 0, B = 0;

	REP(i, n) {
		if (i % 2 == 0) {
			A += a[i];
		}
		else {
			B += a[i];
		}
	}

	ANS(A - B);


	return 0;
}



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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e5 + 5;

vector<vi> adj;

bool isVisited[maxn];

set<int> kolUnik, rowUnik;
ii a[maxn];

void dfs(int node) {
	isVisited[node] = true;
	rowUnik.insert(a[node].first); kolUnik.insert(a[node].second);
	int i,j;
	for(i=0;i<adj[node].size();i++){
		int v = adj[node][i];
		if(!isVisited[v]){
			dfs(v);
		}
	}
}

int main(){
	int n,i,j;
	scanf("%d",&n);
	
	vector<vi> row, col;
	map<ii, int> mapper;
	row.assign(maxn, vi()); col.assign(maxn, vi());
	for(i=0;i<n;i++){
		scanf("%d %d",&a[i].first, &a[i].second);
		mapper[a[i]] = i;
		row[a[i].first].pb(a[i].second);
		col[a[i].second].pb(a[i].first);
	}
	if(n < 3){printf("0\n");}
	else{
		memset(isVisited, false, sizeof isVisited);
		adj.assign(maxn, vi());
		for(i=1;i<maxn;i++){
			for(j=0;j<(int)row[i].size()-1;j++){
				int kol = row[i][j];
				ii koor = ii(i,kol);
				int idx1 = mapper[koor];
				int kol2 = row[i][j+1];
				ii koor2 = ii(i, kol2);
				int idx2 = mapper[koor2];
				adj[idx1].pb(idx2); adj[idx2].pb(idx1);
			}
		}

		for(i=1;i<maxn;i++){
			for(j=0;j<(int)col[i].size()-1;j++){
				int row = col[i][j];
				ii koor = ii(row,i);
				int idx1 = mapper[koor];
				int row2 = col[i][j+1];
				ii koor2 = ii(row2, i);
				int idx2 = mapper[koor2];
				adj[idx1].pb(idx2); adj[idx2].pb(idx1);
			}
		}

		//iterasi semua row

		ll ans = 0;
		set<int>::iterator it;
		for(i=0;i<n;i++){
			if(!isVisited[i]){
				// printf("visit node %d\n",i);
				kolUnik.clear(); rowUnik.clear();
				dfs(i);
				int ukuranKol = kolUnik.size();
				for(it=rowUnik.begin(); it!=rowUnik.end();it++){
					int ukuranRow = row[*it].size();
					// printf("ukuranKol: %d ukuranRow: %d\n",ukuranKol, ukuranRow);
					ans += (ukuranKol - ukuranRow);
					// printf("ans jd: %lld\n",ans);

				}
			}
		}

		// ll ans = 0;
		// for(i=1;i<maxn;i++){
		// 	for(i=0)
		// }
		// for(i=1;i<maxn;i++){
		// 	if(col[i].size())
		// 		ans += (tot - col[i].size());
		// }
		printf("%lld\n",ans);

	}
	return 0;
};

Measured memory_bytes: 28416
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>

#define rep(n) for(int i = 0; i < n; i++)

using namespace std;

int main () {
  int N; cin >> N;
  vector <int> a;

  rep(N) {
    int b; cin >> b;
    a.push_back(b);
  }

auto max = *max_element(a.begin(), a.end());
auto min = *min_element(a.begin(), a.end());

cout << max - min << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int p[100];
char s[100][11];
int cmp(const void *a, const void *b) {
	int c = *(int*)a, d = *(int*)b, m = strcmp(s[c], s[d]);
	return m ? m : p[d] - p[c];
}
int main() {
	int n, o[100], i;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%s %d", s[i], &p[i]);
		o[i] = i;
	}
	qsort(o, n, sizeof(int), cmp);
	for(i = 0; i < n; i++) {
		printf("%d\n", o[i] + 1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
void solve(std::string S){
    bool s1 = S[0] == 'R';
    bool s2 = S[1] == 'R';
    bool s3 = S[2] == 'R';
    if( s1 && s2 && s3){
      cout << 3 << endl;
    } else if(s2 && (s1 || s3)){
      cout << 2 << endl;
    } else {
      cout << (int) (s1 || s2 || s3) << endl;
    }
}
 
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;





int main() {

    int n, m;
    cin >> n;
    vector <string> s(n);
    rep(i,n) cin >> s[i];
    cin >> m;
    vector <string> t(m);
    rep(i,m) cin >> t[i];

    int ans = 0;
    rep(i,n) {
        int tmp = 0;
        rep(j, n) {
            if (s[i] == s[j]) ++tmp;
        }
        rep(j,m) {
            if (s[i] == t[j]) --tmp;
        }
        ans = max(ans, tmp);
    }


    out(ans);

    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 256
//in the name of ALLAH
#include<bits/stdc++.h>
#define pi 3.141592653589793238
using namespace std;
typedef long long ll;
int main()
{
  int r;
  cin>>r;
  double a=2*pi*r;
  cout<<fixed<<setprecision(20)<<a<<endl;

}



Measured memory_bytes: 3788
P,M,A,I=input,max,int,-10**9
n,a=A(P()),list(map(A,P().split()))
x,y,z=0,I,I
for i,L in enumerate(a):
 if i%2:z=M(y,z);y+=L
 else:y=M(x,y);x+=L;z+=L
print(M(y,z)if n%2else M(x,y))

Measured memory_bytes: 31624
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A = [a - i for i, a in enumerate(A, start=1)]
    A.sort()

    b = A[(N + 1) // 2 - 1]
    ans = sum(map(lambda x: abs(x - b), A))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 30916
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
// from:
// https://atcoder.jp/contests/abc130/submissions/5990273

#[fastout]
fn main() {
    input! {
        n:usize,
        xyd:[(f64,f64,char);n]
    }
    let mut xd = D::new();
    let mut yd = D::new();
    for &(x, y, d) in xyd.iter() {
        // x,y どちらも速度を +1 する
        match d {
            'L' => {
                xd.add(x, 0);
                yd.add(y, 1);
            }
            'R' => {
                xd.add(x, 2);
                yd.add(y, 1);
            }
            'U' => {
                xd.add(x, 1);
                yd.add(y, 2);
            }
            _ => {
                xd.add(x, 1);
                yd.add(y, 0);
            }
        }
    }
    // 交差する時間リスト
    let mut ts = vec![0f64];
    for &t in xd.events().iter().chain(yd.events().iter()) {
        ts.push(t);
    }
    let mut ans = 1e18;
    for t in ts {
        let now = xd.get(t) * yd.get(t);
        if ans > now {
            ans = now;
        }
    }
    println!("{}", ans);
}

struct D {
    l: Vec<f64>,
    r: Vec<f64>,
}
impl D {
    fn new() -> D {
        D {
            l: vec![INF; 3], //速度が3通り(0,1,2)
            r: vec![-INF; 3],
        }
    }
    fn add(&mut self, x: f64, v: usize) {
        // 向きごとに最大・最小を格納
        if self.l[v] > x {
            self.l[v] = x;
        }
        if self.r[v] < x {
            self.r[v] = x;
        }
    }
    fn get(&mut self, t: f64) -> f64 {
        // 時刻が与えられたときに幅を出力
        let mut nl = INF;
        let mut nr = -INF;
        for i in 0..3 {
            if nl > self.l[i] + i as f64 * t {
                nl = self.l[i] + i as f64 * t;
            }
            if nr < self.r[i] + i as f64 * t {
                nr = self.r[i] + i as f64 * t;
            }
        }
        nr - nl
    }
    fn events(&mut self) -> Vec<f64> {
        // 交差する時間リストを出力
        let mut ts = Vec::new();
        for i in 0..3 {
            for j in 0..i {
                // 座標の差/相対速度
                let mut t = (self.l[j] - self.l[i]) / (i - j) as f64;
                if t > 0f64 {
                    ts.push(t);
                }
                let mut t = (self.r[j] - self.r[i]) / (i - j) as f64;
                if t > 0f64 {
                    ts.push(t);
                }
            }
        }
        ts
    }
}
const INF: f64 = 1e11;


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

//----------------------------------------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e4 + 1;//                                                             |
//----------------------------------------------------------------------------------




//main func
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;cin>>t;
    vl v(t);
    ii m;
    ll sum=0;
    for(auto &i:v) {cin>>i;m[i]++;sum+=i;}
    ll q;cin>>q;
    while(q--){
        ll x,y;cin>>x>>y;
        sum-=m[x]*x;
        sum+=m[x]*y;
        m[y]+=m[x];
        m[x]=0;
        cout<<sum<<"\n";
    }
    
    
	return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  int res = 0;
  if (Y >= 1000*N && Y <= 10000*N) {
    for (int i = 0; i <= Y / 10000; i++) {
      for (int j = 0; j <= N; j++) {
        for (int k = (Y % 5000) / 1000; k <= N; k += 5) {
          if (i + j + k == N && 10000*i + 5000*j + 1000*k == Y) {
            cout << i << " " << j << " " << k << endl;
            res++;
            return 0;
          }
        }
      }
    }
  }
  if (res == 0) cout << "-1 -1 -1" <<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: int, x: "List[int]"):
    dp = [[0] * 2501 for _ in range(N + 1)]
    dp[0][0] = 1
    for i in range(N):
        for s in range(2500, -1, -1):
            for j in range(N):
                if dp[j][s] > 0:
                    dp[j + 1][s + x[i]] += dp[j][s]
    ret = 0
    for i in range(1, N + 1):
        for j in range(2501):
            if j % i == 0 and j // i == A:
                ret += dp[i][j]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40304
for i in range(1000):
    
    a, b, c = input().split()
    
    if b == '?': break
    
    a = int(a)
    c = int(c)
    
    if b == '+': print(a + c)
    if b == '-': print(a - c)
    if b == '*': print(a * c)
    if b == '/': print(a // c)







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

int main() 
{ 
    int n,x,y;
    cin >> n >> x >> y;
    int dis[2001][2001];

    unordered_map<int,int>ans;
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; ++j) {
            if (i == j) dis[i][j] = 0;
            else {
                dis[i][j] = min(abs(i - j), 
                            min(abs(i - x) + 1 + abs(j - y), 
                            abs(i - y)+ 1 + abs(j - x)));
            }
           
            ans[dis[i][j]]++;
        }
    }

    for(int k = 1; k <= n - 1; ++k) {
        cout << ans[k] << endl;
    }
    

	return 0; 
} 



Measured memory_bytes: 15872
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;
typedef long long ll;

int main() {
	ll n, ans = 0;
	cin >> n;
	vector<ll>p(n + 1);
	for (ll i = 1;i <= n;i++) {
		cin >> p[i];
	}
	ll tmp = 0;
	for (ll i = 1;i <= n;i++) {
		if (i == 1||i==n) {
			if (p[1] == 1) {
				tmp = p[1];
				p[1] = p[2];
				p[2] = tmp;
				ans++;
			}
			else {
				if (p[n] == n) {
					tmp = p[n];
					p[n] = p[n - 1];
					p[n - 1] = tmp;
					ans++;
				}
			}
		}
		else {
			if (p[i] == i) {
				if (p[i - 1] == i - 1) {
					tmp = p[i];
					p[i] = p[i - 1];
					p[i - 1] = tmp;
					ans++;
				}
				else {
					if (p[i + 1] == i + 1) {
						tmp = p[i];
						p[i] = p[i + 1];
						p[i + 1] = tmp;
						ans++;
					}
					else {
						tmp = p[i];
						p[i] = p[i - 1];
						p[i - 1] = tmp;
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

//AOJ Depth First Search
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B&lang=ja
using Graph = vector<vector<int>>;
vector<bool> seen;
vector<int> first_order;
vector<int> last_order;

void dfs(const Graph &G,int v,int& first_ptr){
    seen[v] = true;

    first_order[v] = first_ptr++;
    for(auto next_v: G[v]){
        if(seen[next_v]) continue;
        dfs(G,next_v,first_ptr);
    }
    last_order[v] = first_ptr++;
}
int main() {
    int v;
    cin >> v ;
    Graph G(v);

    rep(i,v){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int vi;
            cin >> vi;
            G[u-1].push_back(vi-1);
        }
    }

    seen.assign(v,false);
    first_order.resize(v);
    last_order.resize(v);
    int first_ptr = 1;
    rep(vi,v){
        if(seen[vi])continue;
        dfs(G, vi, first_ptr);
    }
    rep(i,v){
        cout << i+1 << " " << first_order[i] << " " << last_order[i] << endl;
    }
}


Measured memory_bytes: 3156
#include <iostream>
#include <climits>

using namespace std;

int *A;
int N;
int SwapNum;
int Count;

void BubbleSort()
{
  bool flag = true;
  int i = 0;
  SwapNum = 0;

  do
  {

    flag = false;
    for(int j = N - 1; j >= i + 1; --j)
    {
      if(A[j] < A[j-1])
      {
	int tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;

	flag = true;
	++SwapNum;
      }

    }

    ++i;


  }while(flag);

  return;
}

void SelectionSort()
{

  SwapNum = 0;
  for(int i = 0; i < N; ++i)
  {
    int mini = i;
    bool flag = false;

    for(int j = i; j < N; ++j)
    {
      if(A[j] < A[mini])
      {
	mini = j; 
	flag = true;	
      }
    }

    if(flag)
    {
      int tmp = A[i];
      A[i] = A[mini];
      A[mini] = tmp;

      ++SwapNum; 
    }
  }

  return;

}

void InsertionSort(int g)
{

  for(int i = g; i < N; ++i)
  {
    int v = A[i];
    int j = i - g;

    while( j >= 0 && A[j] > v)
    {
      A[j + g] = A[j];
      j = j - g;
      ++Count;
    }
    A[j + g] = v;
  }

  return;
}

void ShellSort()
{

  Count = 0;

  int m = 0;
  int s = 1;

  while(N / s > 0)
  {
    s *= 2;
    ++m;
  }

  int G[N];

  for(int i = 0, s = 1; i < m; ++i, s *= 2)
    G[i] = N / s; 

  for(int i = 0; i < m; ++i)
    InsertionSort(G[i]);

  cout << m << endl;

  for(int i = 0; i < m; ++i) 
    cout << (i != 0 ? " " : "") << G[i];
  cout << endl;

  cout << Count << endl;

  for(int i = 0; i < N; ++i)
    cout << A[i] << endl;

  return;
}

int main()
{
  cin >> N;

  A = new int[N];

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

  //BubbleSort();
  //SelectionSort();
  ShellSort();

  /*
  cout << A[0];
  for(int i = 1; i < N; ++i)
    cout << " " << A[i];

  cout << endl;
  cout << SwapNum << endl;
  */
  delete [] A;


}


Measured memory_bytes: 6712
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		int [] l = new int[N];
		int max = 1, sum = 0, count = 0,maxIndex = -1;
		for(int i = 0; i < l.length; i++) {
			l[i] = sc.nextInt();
		}
		for(int i = 0; i < K; i++) {
			for(int j = 0; j < l.length; j++) {
				if(l[j] > max) {
					max = l[j];
					maxIndex = j;
				}
			}
			sum += max;
			l[maxIndex] = -1;
			max = 1;
			count++;
		}
		System.out.println(sum);
	}

}


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

/******************************
 * Minesweeper
 *****************************/

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S.at(i);
  }
  vector<string> res = S;
  for (int ih = 0; ih < H; ih++) {
    for (int iw = 0; iw < W; iw++) {
      char t = S.at(ih).at(iw);
      if (t == '#')  {
        continue;
      }
      int count = 0;
      for (int iih = -1; iih <=1; iih++) {
        for (int iiw = -1; iiw <= 1; iiw++) {
          int th = ih + iih;
          int tw = iw + iiw;
          if (0 <= th && th < H && 0 <= tw && tw < W) {
            if (S.at(th).at(tw) == '#') {
              count++;
            }
          }
        }
      }
      string tmp = to_string(count);
      res.at(ih).at(iw) = (char)*tmp.c_str();
    }
  }

  // 出力
  for (int i = 0; i < H; i++) {
    cout << res.at(i) << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ll a, b; cin >> a >> b;
  auto ans = boost::integer::lcm(a, b);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string S;
	cin >> S;
	int res = 0;
	for (int i = 0; i <= (int)S.size() - 3; i++) {
		if (S.substr(i, 3) == "ABC") {
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split()) 

alist=[]

for i in range(n):
    a, b = map(int, input().split()) 
    alist.append([a,b])

alist=sorted(alist)
#print(alist)

eternal=1
now=0
hoshu=0

koholist=[]
for i in range(m):
    j=i+1
    switch=1
    while switch==1 and eternal==1:
        if alist[now][0]<=j:
            heapq.heappush(koholist, -alist[now][1])
            if now>=n-1:
                switch=0
                eternal=0
            else:
                now+=1
        else:
            switch=0
    if len(koholist)>0:
        saidai=heapq.heappop(koholist)
        #print(saidai)
        hoshu+=saidai

print(-hoshu)

Measured memory_bytes: 24192
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(int, const char**)
{
    int n;
    cin >> n;
    for(int i = 10000; i >= 0; i -= 1000)
    {
        if(i - n < 0)
        {
            cout << i - n + 1000 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main()
{
    int H,W;
    cin>>H>>W;
    char a[H][W];
    char b[H][W];
    for (int i=0;i<H;i++)
        for (int j=0;j<W;j++)
        {
             cin>>a[i][j];
            b[i][j]=a[i][j];
        }
        for (int i=0;i<H;i++)
            for (int j=0;j<W;j++)
        {
            if (b[i][j]=='#')
                ;
            else {
                 int sum=0;
            if (i-1>=0&&j-1>=0&&b[i-1][j-1]=='#')
                sum++;
            if (i-1>=0&&b[i-1][j]=='#')
                sum++;
            if (i-1>=0&&j+1<W&&b[i-1][j+1]=='#')
                sum++;
            if (j-1>=0&&b[i][j-1]=='#')
                sum++;
            if (j+1<W&&b[i][j+1]=='#')
                sum++;
            if (i+1<H&&j-1>=0&&b[i+1][j-1]=='#')
                sum++;
            if (i+1<H&&b[i+1][j]=='#')
                sum++;
            if (i+1<H&&j+1<W&&b[i+1][j+1]=='#')
                sum++;
            a[i][j]=sum+'0';
            }
        }
        for (int i=0;i<H;i++)
        {
            for (int j=0;j<W;j++)
            cout<<a[i][j];
            cout<<endl;
        }
    return 0;
}


Measured memory_bytes: 256
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,i,a[131072],r=1,c=1;
    scanf("%d",&n);
    for(i = 0;i < n;i++){scanf("%d",&a[i]);}
    qsort(a,n,sizeof(int),sortfncsj);
    for(i=1;i<n;i++){
        if(a[i] == a[i-1]){
            c++;
            if(c%2){r++;}else{r--;}
        }
        else{c=1;r++;}
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 1020
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val numList = readLine()!!.split(" ").map { it.toLong() }
    val ans = numList.map { getDivCount(it) }.sum()
    println(ans)
}

val dic = mutableMapOf<Long, Int>()
fun getDivCount(num:Long):Int {
    if(num % 2 != 0L) {
        return 0
    }
    dic[num]?.let { return it }
    dic[num] = getDivCount(num/2) + 1
    return dic[num]!!
}


Measured memory_bytes: 49804
def main(A,B,C,K):
    ans=False
    while K >= 0:
        if A < B:
            if B < C:
                ans=True
                return ans
            else:
                C = C * 2
        else:
            B = B * 2
        K=K-1
    return ans
A,B,C=map(int, input().split())
K=int(input())
ans=main(A,B,C,K)
print('Yes' if ans else 'No')

Measured memory_bytes: 9036
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

char tmp[100];
string s;

int read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  return true;
}

void solve() {
  for (int i = 0; i < 4; i++) {
    printf("%c", s[i]);
  }
  printf(" ");
  for (int i = 4; i < sz(s); i++) {
    printf("%c", s[i]);
  }
  printf("\n");
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int A, B, C; cin >> A >> B >> C;
    if((A >= C && C >= B) || (A <= C && C <= B)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

int dp[5010][5010];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, L; cin >> N >> L;
  VI x(N), a(N);
  REP(i,N) cin >> x[i];
  REP(i,N) cin >> a[i];

  for(int d=0;d<L;++d)
	dp[0][d] = 1 + (a[0] == 0? 0: d/a[0]);
  for(int i=1;i<N;++i){
	int dx = x[i] - x[i-1] - 1;
	if(a[i] == 0){
	  for(int j=0;j<L;++j)
		dp[i][j] = dp[i-1][dx];
	  continue;
	}
	for(int j=0;j<a[i];++j)
	  dp[i][j] = dp[i-1][dx];
	for(int j=a[i];j<L;++j){
	  dp[i][j] = (int)((LL)dp[i][j-a[i]] + (LL)dp[i-1][dx+j/a[i]*a[i]]) % MOD;
	}
  }
  
  cout << dp[N-1][L-x[N-1]-1] << endl;
  /*
  REP(i,N){
	REP(j,L) cout << dp[i][j] << " ";
	cout << endl;
  }
  */
  return 0;
}

Measured memory_bytes: 99088