akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

class union_find
{
	int  _setnum;
	vector<int> par, nume;
public:
	union_find(){
	}
	
	union_find(int x){
		par.resize(x);
		nume.resize(x);
		init();
	}
	
	~union_find(){
		//
		
	}
	
	void clear(){
		_setnum = 0;
		par.clear();
		nume.clear();
	}
	
	void init(){
		_setnum = par.size();
		for(int i = 0; i < par.size(); i++){
			par[i] = i;
			nume[i] = 1;
		}
	}
	
	void resize(int x){
		
		par.resize(x);
		nume.resize(x);
		init();
	}

	int find(int x){
		return par[x] == x ? x : par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
	
		if(x == y)return;
		
		_setnum--;
		
		if(nume[x] > nume[y]) std::swap(x,y);
		
		par[x] = y;
		nume[y] += nume[x];
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	int numel(int x){
		return nume[find(x)];
	}
	
	int size(){
		return par.size();
	}
	
	int setnum(){
		return _setnum;
	}
};

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M, K;
	vector<vector<int>> F, B;
	union_find uf;
	
	cin>>N>>M>>K;
	
	F.resize(N);
	B.resize(N);
	uf.resize(N);
	
	for(int i = 0; i < M; i++){
		int A, B;
		
		cin>>A>>B;
		
		A--, B--;
		
		uf.unite(A, B);
		
		F[A].push_back(B);
		F[B].push_back(A);
	}
	
	for(int i = 0; i < K; i++){
		int C, D;
		
		cin>>C>>D;
		
		C--, D--;
		
		B[C].push_back(D);
		B[D].push_back(C);
	}
	
	for(int i = 0; i < N; i++){
		if(i) cout<<" ";
		
		int ans = uf.numel(i) - 1;
		
		for(int j = 0; j < F[i].size(); j++){
			if(uf.same(i, F[i][j])) ans--;
		}
		
		for(int j = 0; j < B[i].size(); j++){
			if(uf.same(i, B[i][j])) ans--;
		}
		
		
		cout<<ans;
	}
	
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 14580
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
		string S;
    	int R=0;
    	cin >> S;
    	
    	for (int i=0; i<S.size()/2; i++){
    		if (S.at(i) != S.at(S.size()-1-i)){
    			R++;
    		}
    	}
    	cout << R << endl;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n,u,v;
vector<int> ga[100100];
int cnt[100100];
vector<int> act;
int watershed=-1;
void dfs(int u,int p){
	cnt[u]=1;
	act.push_back(u);
	if(u==n){
		watershed=act[(act.size()+1)/2];
	}
	for(int i=0;i<ga[u].size();i++){
		int v=ga[u][i];
		if(v==p)
			continue;
		dfs(v,u);
		cnt[u]+=cnt[v];
	}
	act.pop_back();
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		ga[u].push_back(v);
		ga[v].push_back(u);
	}
	dfs(1,0);
	bool win=(cnt[watershed]*2<n);
	cout<<(win?"Fennec":"Snuke")<<endl;
	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int h, w;
  cin >> h >> w;
  char G[h][w];
  rep(i, h) rep(j, w) cin >> G[i][j];

  int cnt = 0;
  rep(i, h) rep(j, w) cnt += G[i][j] == '#';
  bool f = cnt == h + w - 1;

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

  // int x = 0;
  // int y = 0;
  // bool f = 1;
  // while (1) {
  //   if (G[y][x] != '#') {
  //     f = 0;
  //     break;
  //   }

  //   G[y][x] = '-';
  //   if (x == w - 1 && y == h - 1) break;

  //   rep(i, 2) {
  //     int ny = y + dy[i];
  //     int nx = x + dx[i];
  //     if (!(0 <= nx && nx < w && 0 <= ny && ny < h)) continue;
  //     if (G[ny][nx] == '#') {
  //       x = nx;
  //       y = ny;
  //       break;
  //     }
  //   }
  // }

  // rep(i, h) rep(j, w) if (G[i][j] == '#') f = 0;

  cout << (f ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,p;
    scanf("%d%d",&a,&p);
    int sum=a*3+p;
    printf("%d\n",sum/2);
}


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

int main(){
  int K;
  string S;
  cin>>K>>S;
  for(int i=0;i<S.size() && i<K;i++)
    cout<<S[i];
  if(S.size()>K)
    cout<<"...";
  cout<<endl;
}


Measured memory_bytes: 3628
h, w = gets.split.map(&:to_i)
alphabes_memo = Hash.new(0)
h.times do
  gets.chomp.each_char { |c| alphabes_memo[c] += 1 }
end
same_places_memo = Hash.new(0)

# 元の場所、x軸線対称、y軸線対称、点対称が何ヶ所存在するか
def same_places (h, w, r, c)
  [[r, c], [h - 1 - r, c], [r, w - 1 - c], [h - 1 - r, w - 1 - c]].uniq.size
end

h.times do |r|
  w.times do |c|
    same_places_memo[same_places(h, w, r, c)] += 1
  end
end

mod_memo = Hash.new(0)

# 4 で割った余りがあればメモ
alphabes_memo.values.each do |v|
  mod = v % 4
  if mod == 1
    mod_memo[1] += 1
  elsif mod == 2
    mod_memo[2] += 2
  elsif mod == 3
    mod_memo[1] += 1
    mod_memo[2] += 2
  end
end

mod_memo[1] -= same_places_memo[1]
mod_memo[2] -= same_places_memo[2]

if mod_memo[1] <= 0 && mod_memo[1] + mod_memo[2] <= 0
  puts "Yes"
else
  puts "No"
end


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    rep1(i,n) {
        int m = i*1.08;
        if(m==n) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << ":(" << '\n';
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/

using namespace std;
typedef long long int ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	vector<int> count(101,0);
	int n,k,d,t;
	cin>>n>>k;
	while(k--){
		cin>>d;
		while(d--){
			cin>>t;
			count[t]++;
		}
	}
	t=0;
	for(int i=1;i<=n;i++){
		if(count[i]==0){
			t++;
		}
	}
	cout<<t;


}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    // long long N, K;
    // cin >> N >> K;
    // long long tmpmax = N;
    // long long tmpmin = K-1;
    // double ans = 0;
    // if(N > K){
    //     ans += N - (K-1);
    // }
    // long long time = 1;
    // while(true){
    //     if(tmpmin == 0){
    //         break;
    //     }
    //     tmpmax = min(tmpmin, N);
    //     tmpmin = (K-1) / pow(2, time);
    //     if(tmpmax > tmpmin){
    //         ans += (tmpmax - tmpmin)/pow(2.0, time);
    //         //cout << tmpmin << endl;
    //     }
    //     time++;
    //     if(tmpmin == 0){
    //         break;
    //     }
    // }
    // ans /= N;
    // printf("%.10f\n", ans);
    // return 0;
int a,b;scanf("%d%d",&a,&b);
double ret=0;
for(int i=1;i<=a;i++){
double tmp=1.0/a;
int now=i;
while(now<b){
now*=2;
tmp/=2;
}
ret+=tmp;
}
printf("%.12f\n",ret);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t a, b;
    cin >> a >> b;

    for (auto i : irange(0L, b + 1)) {
        if (i * (a - 1) + 1 >= b) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
def examA():
    A, B, C, K = LI()
    if K%2==0:
        ans = A-B
    else:
        ans = B-A
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 2019;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 200000 + 5;
const long long int MINN = 2e5 + 5;
const long long int inf = 1e6;

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

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 10050;
const int MAXN = 105;
int binsearch(int lo, int hi){
	while(lo<hi){
		int mid=(lo+hi)/2;
		if((mid))   // check(mid)
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=((res*x)%MOD);

      y/=2;
      x=((x*x)%MOD);
    }
    return res%MOD;
}

map<int,int> m;
int main(){
    FAST
    string s;
    cin>>s;
    for(int i=0;i<2019;i++) m[i]=0;
    int rem=0;
    m[0]=1;
    int digits=0;
    for(int i=s.length()-1;i>=0;i--){
        int cur = (int)(s[i]-'0');
        int temp= power(10,digits)%2019;
        rem = (rem + ((temp)*(cur)))%2019;
        m[rem]++;
        digits++;
    }
    ll ans =0;
    for(int i=0;i<2019;i++){
        ans += (m[i]*(m[i]-1))/2;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int a[maxn],o[maxn],e[maxn];
int main(){
	int n,max1=0,max2=0,t1,t2;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i%2)o[a[i]]++;//2 4 6
		else e[a[i]]++;
	}
	vector<int>v1,v2;
	for(int i=1;i<maxn;i++){
		if(o[i]){
			v1.push_back(o[i]);
			if(max1<o[i]){
				max1=o[i];
				t1=i;
			}
		}
		if(e[i]){
			v2.push_back(e[i]);
			if(max2<e[i]){
				max2=e[i];
				t2=i;
			}
		}
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	int l1=v1.size(),l2=v2.size(),k1=n/2,k2=n/2;
	if(n%2)k1+=1;
	if(t1!=t2)cout<<k1-v1[l1-1]+k2-v2[l2-1];
	else if(l1==1&&l2==1)cout<<(v1[0]<v2[0]?v1[0]:v2[0]);
	else if((k1-v1[l1-2]+k2-v2[l2-1])<(k2-v2[l2-2]+k1-v1[l1-1]))cout<<k1-v1[l1-2]+k2-v2[l2-1];
	else if((k1-v1[l1-2]+k2-v2[l2-1])>(k2-v2[l2-2]+k1-v1[l1-1]))cout<<k2-v2[l2-2]+k1-v1[l1-1];
	else cout<<k1-v1[l1-2]+k2-v2[l2-1];
}

Measured memory_bytes: 2044
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int main() {
  ll n, k;
  cin>>n>>k;
  string s;
  cin>>s;
  if(k>600000){
    if(n%2==0){
      string ans;
      rep(i,0,s.sz){
        if(i%2==0)ans+="B";
        else ans += "A";
      }
      cout << ans << endl;
      return 0;
    }
    else{
      string ans;
      rep(i,0,s.sz){
        if(i%2==0)ans+="A";
        else ans += "B";
      }
      if(k%2==0){
        ans[0]='B';
      }
      cout << ans << endl;
      return 0;
    }
  }
  int index = 0;
  int c = 0;
  rep(i,0,k){
    if(c==0){
      if(s[index]=='A'){
        s[index]='B';
      }
      else{
        index++;
        index%=n;
        c=1-c;
        s[(index+n-1)%n] = 'B';
      }
    }
    else{
      if(s[index]=='B'){
        s[index]='A';
      }
      else{
        index++;
        index%=n;
        c=1-c;
        s[(index+n-1)%n] = 'A';
      }
    }
  }
  string ans;
  rep(i,0,n){
    if(c==0){
      ans += s[(index+i)%n];
    }
    else{
      if(s[(index+i)%n]=='A'){
        ans += "B";
      }
      else{
        ans += "A";
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 904
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;
int n,k,h[N],f[N];

int32_t main()
{
	fast;

	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>h[i];

	for(int i=1;i<=n;i++)
		f[i] = N*N*N;

	f[1] = 0;
	for(int i=2;i<=n;i++)
	{
		int j = max(i-k,1LL);
		for(;j<i;j++)
			f[i] = min(f[i],(llabs(h[i]-h[j])+f[j]));
	}

	cout<<f[n];

	return 0;
}

Measured memory_bytes: 5120
a, b, k = map(int, input().split())
s = set()
if b - a == 0:
    print(a)
elif b - a + 1 <= k:
    print(*range(a, b + 1), sep="\n")
else:
    for i in range(k):
        s.add(a + i)
        s.add(b - i)
    s = sorted(s)
    print(*s, sep="\n")


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

bool compare(pair<string,int> a,pair<string,int> b)
{
    if(a.first==b.first)
        return a.second>b.second;
    else
        return (a.first<b.first);
}
int main()
{
    int n;
    cin>>n;
    map<int,int>mm;
    pair<string,int> p[n];
    for (int i = 0; i < n; ++i) {
        cin>>p[i].first>>p[i].second;
        mm[p[i].second]=i+1;
    }
    sort(p,p+n,compare);

    for (int i = 0; i < n; ++i) {
//        cout<<p[i].first<<" "<<p[i].second<<endl;
cout<<mm[p[i].second]<<endl;
    }
}

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

int main() {
  int n;
  long long int l, r, sum = 0;
  vector<pair<long long int, long long int>> seats;
  bool taken[100001];
  for (long long int i=0; i<=100000; i++) taken[i] = false;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> l >> r;
    seats.push_back(make_pair(l,r));
  }
  for (auto i : seats) {
    for (long long int j=i.first; j<=i.second; j++) {
      taken[j]=true;
    }
  }
  for (long long int i=0; i<=100000; i++) if (taken[i]) sum++;
  cout << sum;
  return 0;
}

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

int main() {
	int x[5], ans;
	for (int i = 0; i < 5; i++){
		cin >> x[i];
		if(x[i] == 0){
			ans = i + 1;
		}
	}
	cout << ans;
	return 0;
}

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

const int MAXN = 1005;
const int MOD = 1e9+7;

int n, m, dp[MAXN][MAXN];
char arr[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> arr[i][j];
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i) dp[i][j] += dp[i-1][j];
            if (j) dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
            if (arr[i][j] == '#') dp[i][j] = 0;
        }
    }
    cout << dp[n-1][m-1] << "\n";
    return 0;
}


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

int main(){
	string x;
	while (cin >> x){
		if (x == (string)"0") break;
		long s = 0;
		for (long i = 0; i < x.size(); i++) s += (char)x[i] - (long)'0';
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >>n;
	int sum=0;
	for(int i=1;i<=n;i++){
		if(i%2==1)sum++;
	}
	double num;
	num=sum*1.0/n*1.0;
	printf("%.10lf",num);
}

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

int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  vector<vector<int>> ans(H + 2, vector<int>(W + 2, 0));
  rep(i, H)
  {
    rep(j, W)
    {
      cin >> S[i][j];
    }
  }

  rep(i, H)
  {
    rep(j, W)
    {
      if (S[i][j] == '#')
      {
        int h = i + 1;
        int w = j + 1;
        ans[h - 1][w - 1]++;
        ans[h - 1][w]++;
        ans[h - 1][w + 1]++;
        ans[h][w - 1]++;
        ans[h][w + 1]++;
        ans[h + 1][w - 1]++;
        ans[h + 1][w]++;
        ans[h + 1][w + 1]++;
      }
    }
  }
  rep(i, H)
  {
    rep(j, W)
    {
      if (S[i][j] == '#')
        cout << '#';
      else
        cout << ans[i + 1][j + 1];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
class UnionFind
  attr :union_count

  def initialize()
    @table = Hash.new { |_hash, key| key }
    @rank = Hash.new { 0 }
    @union_count = 0
  end

  def find(elt)
    if @table[elt].eql? elt
      elt
    else
      @table[elt] = find(@table[elt])
    end
  end
 
  def union(node1, node2)
    root1 = find(node1)
    root2 = find(node2)

    if @rank[root1] < @rank[root2]
      @table[root1] = root2
    elsif @rank[root1] > @rank[root2]
      @table[root2] = root1
    elsif root1 != root2
      @table[root2] = root1
      @rank[root1] += 1
    else
      return
    end
    @union_count += 1
  end

end

n, m = gets.split.map(&:to_i)

uf = UnionFind.new

m.times do
  x, y, z = gets.split.map(&:to_i)
  uf.union(x, y)
end

puts n - uf.union_count


Measured memory_bytes: 10364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace B
{
	class Program
	{
		static void Main(string[] args)
		{
            int n = Int32.Parse(Console.ReadLine().ToString());
            String a = Console.ReadLine().ToString();
            String b = Console.ReadLine().ToString();
            String c = Console.ReadLine().ToString();
            
            int count = 0;
            
            for(int i = 0; i<n;i++){
			
            	int diff = 0;
            	var wordList = new List<String>();
            
            	wordList.Add(a.Substring(i,1));

				if(wordList.Contains(b.Substring(i,1))==false){
					wordList.Add(b.Substring(i,1));
				}
				
				
				if(wordList.Contains(c.Substring(i,1))==false){
					wordList.Add(c.Substring(i,1));
				}
				
				count += wordList.Count -1;
				
			}
			
			Console.WriteLine(count);
			
		}
            

	}
}

Measured memory_bytes: 13152
using System;


namespace ConsoleApplication38
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String[] ss = Console.ReadLine().Split(' ');
                int m = int.Parse(ss[0]);
                int f = int.Parse(ss[1]);
                int r = int.Parse(ss[2]);
                //?????????????????????
                if(m == -1 && f == -1 && r == -1)
                {
                    break;
                }

                if (m + f < 30 || m == -1 || f == -1)
                {
                    Console.WriteLine("F");
                }
                else if(m + f >= 80)
                {
                    Console.WriteLine("A");
                }
                else if(m + f >= 65 && m + f < 80)
                {
                    Console.WriteLine("B");
                }
                else if(m + f >= 50 && m + f < 65 || r >= 50)
                {
                    Console.WriteLine("C");
                }
                else
                {
                    Console.WriteLine("D");
                }
            }
        }
    }
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	cin>>n;
	vector<vector<int>> x(n,vector<int>(3,0));
	rep(i,n)rep(j,3)cin>>x[i][j];

	vector<vector<int>> dp(n, vector<int>(3,0));
	rep(i,3)dp[0][i] = x[0][i];
	repi(i,1,n){
		rep(j,3){
			rep(k,3){
				if(j==k)continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k]+x[i][j]);
			}
		}
	}
	cout<<*max_element(all(dp[n-1]))<<endl;
	return 0;
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int m = in.nextInt();
		String[] grid = getStringArr(in, n);
		long r = solve(n, m, grid);
		System.out.println(r);
		in.close();
	}

	static long mod = 1000000007;

	private static long solve(int n, int m, String[] grid) {
		long[][] state = new long[n + 1][m + 1];
		state[0][1] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (grid[i - 1].charAt(j - 1) == '.') {
					state[i][j] = (state[i - 1][j] + state[i][j - 1]) % mod;
				}
			}
		}
		return state[n][m];
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 39688
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF INT_MAX/2
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
template<typename T> pair<vector<T>,int> getAuto() {int N; cin >> N; pair<vector<T>, int> rt;rt.first.resize(N);rt.second = N;REP(i, N) cin >> rt.first[i];return rt;}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

int main() {
	ll X;
	cin >> X;
	ll ans = 0;
	ll maxrange = 0;
	while (maxrange<X)
	{
		ans++;
		maxrange += ans;
	}
	out(ans);
}



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

typedef long long ll;

using namespace std;

int n, k;
ll a[555], ans;

priority_queue <ll, vector<ll>, greater<ll> > q;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 0; i <= min (n, k); i++)
    {
        for(int j = 0; i + j <= min(n, k); j++)
    	{
        	for(int s = 1; s <= i; s++)
        	    q.push(a[s]);
        	for(int s = n; s >= n - j + 1; s--)
        	    q.push(a[s]);
        	int step = i + j;
        	while(!q.empty() && step < k && q.top() < 0)
	        {
    	        q.pop();
        	    step++;
	        }
    	    ll now = 0;
        	while(!q.empty())
	        {
    	        now += q.top();
        	    q.pop();
        	}
        	ans = max(ans, now);
    	}
    }
    cout << ans << endl;
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int a, b; cin >> a >> b;
    FOR(i, 1, 1250) {
        if (i * 8 / 100 == a && i * 10 / 100 == b)
            return cout << i << endl, 0;
    }
    cout << -1 << endl;
}

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


void solve(std::string S){
    int ans = 700;
    int counter = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') {
            counter++;
        }
    }
    cout << ans + counter * 100 << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d,s,f;
    cin>>a;
    b=a%10;
    c=a/100;
    d=a/10;
    s=d%10;
    f=b*100+s*10+c;
    if(f==a)
    cout<<"Yes";
    else cout<<"No";
    
}


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

int main(){
    using namespace std;
    unsigned long N, D, A;
    cin >> N >> D >> A;
    priority_queue<pair<unsigned long, unsigned long>> pq;
    vector<pair<unsigned long, unsigned long>> enemies(N);
    for(auto& i : enemies){
        cin >> i.first >> i.second;
        (i.first *= 2) += 10000000000;
        (i.second += A - 1) /= A;
    }
    sort(enemies.begin(), enemies.end(), greater<>());
    unsigned long ans{0}, now{0};
    for(const auto& i : enemies){
        while(!pq.empty() && pq.top().first > i.first && (now -= pq.top().second) | 1)pq.pop();
        auto k = i.second - min(i.second, now);
        if(k)pq.emplace(i.first - D * 4 - 1, i.second - now);
        ans += k;
        now += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5492
using System;
using System.Linq;

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var a = Console.ReadLine();

            if(a == "ABC") {
                Console.Write("ARC");
            }else if(a == "ARC") {
                Console.Write("ABC");
            }
        }
    }
}

Measured memory_bytes: 25792
N = int(input())
a = [0] * 10050
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            x = i**2+j**2+k**2+i*j+j*k+k*i 
            if x <= N:
                a[x] += 1
            
for i in range(N):
    print(a[i+1])

Measured memory_bytes: 9260
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;
using PII = pair<int, int>;

int main() {
	int n, a, b;
	cin >> n;

	vector<PII> jobs(n);
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		jobs[i] = make_pair(b, a);
	}
	sort(jobs.begin(), jobs.end());

	long long t = 0;
	for (auto p: jobs) {
		t += p.second;
		if (t > p.first) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int t[]=new int[N];
		int sum=0;
		for(int i=0;i<N;i++) {
			t[i]=sc.nextInt();
			sum+=t[i];
		}
		int M=sc.nextInt();
		int ans[]=new int[M];
		for(int i=0;i<M;i++) {
			int p=sc.nextInt();
			int x=sc.nextInt();
			ans[i]=sum-(t[p-1]-x);
		}
		for(int i:ans) {
			p(i);
		}
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 22736
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, K;
    cin >> N >> K;
    ll A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    bool bit[30];
    for (int i = 0; i < 30; i++) {
        if ((K & (1 << i)) > 0) {
            bit[i] = true;
        } else {
            bit[i] = false;
        }
    }
    ll sum[30];
    fill(sum, sum + 30, 0);
    for (int i = 29; i >= 0; i--) {
        if (bit[i] || i == 0) {
            for (int j = 0; j < N; j++) {
                bool ok = true;
                for (int k = 29; k > i; k--) {
                    if (!bit[k] && ((A[j] & (1 << k)) > 0)) {
                        ok = false;
                    }
                }
                if (i != 0) {
                    if ((A[j] & (1 << i)) > 0) {
                        ok = false;
                    }
                } else {
                    if (!bit[0] && (A[j] % 2 == 1)) {
                        ok = false;
                    }
                }
                if (ok) {
                    sum[i] += B[j];
                    //cout << i << " " << j << endl;
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 30; i++) {
        ans = max(ans, sum[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string number;
    cin >> number;
    string ans = number.at(0) == number.at(2) ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int x;
cin>>x;
if(x>=400&&x<=599)
cout<<8;
else if(x>=600&&x<=799)
cout<<7;
else if(x>=800&&x<=999)
cout<<6;
else if(x>=1000&&x<=1199)
cout<<5;
else if(x>=1200&&x<=1399)
cout<<4;
else if(x>=1400&&x<=1599)
cout<<3;
else if(x>=1600&&x<=1799)
cout<<2;
else 
cout<<1;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	static String matrix[][];
	static int dist[][];
	static boolean used[][];

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

	static int w;
	static int h;

	static int min = Integer.MAX_VALUE;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		h = Integer.parseInt(str[0]);
		w = Integer.parseInt(str[1]);

		matrix = new String[h][w];
		dist = new int[h][w];
		used = new boolean[h][w];

		int whiteSize = 0;

		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
				dist[i][j] = Integer.MAX_VALUE;
				used[i][j] = false;

				if (matrix[i][j].equals("."))
					whiteSize++;
			}
		}
		bfs(0, 0);
		if (dist[h - 1][w - 1] == Integer.MAX_VALUE)
			System.out.println(-1);
		else
			System.out.println(whiteSize - (dist[h - 1][w - 1] + 1));
	}

	static void bfs(int x, int y) {
		Queue<Integer> queueX = new ArrayDeque<>();
		Queue<Integer> queueY = new ArrayDeque<>();

		dist[y][x] = 0;
		used[y][x] = true;

		queueX.add(x);
		queueY.add(y);

		while (!queueX.isEmpty() && !queueY.isEmpty()) {
			int sx = queueX.poll();
			int sy = queueY.poll();

			for (int i = 0; i < 4; i++) {
				int nx = sx + dx[i];
				int ny = sy + dy[i];
				if (nx >= 0 && nx < w && ny >= 0 && ny < h) {
					if (matrix[ny][nx].equals(".") && !used[ny][nx]) {
						dist[ny][nx] = dist[sy][sx] + 1;
						used[ny][nx] = true;
						queueX.add(nx);
						queueY.add(ny);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 22868
#include <stdio.h>
#include <math.h>

int main(void){
	int x, h;
	while(1) {
		scanf("%d %d", &x, &h);
		if(x==0 && h==0) break;
		
		double area = x*x;
		double rect = sqrt(h*h+x*x/4.0);
		area += (double)x*rect*2.0;
		
		printf("%lf\n", area);
	}

	return 0;
}

Measured memory_bytes: 632
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 1000005
#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()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct BIT
{
	int bit[SIZE];
	int n;
	
	void add(int k,int x){//(k番目にxを足す)
		while(k<=n){
			bit[k]+=x;
			k=k+(k&-k);//一番右端
		}
	}

	int sum(int k){//kまでの和
		int ret=0;
		while(k>0){
			ret+=bit[k];
			k=k-(k&-k);//一番左端
		}
		return ret;
	}

	int sum(int a,int b){//a~bの和
		return sum(b)-sum(a-1);
	}

};

BIT bit;


int main(){
	int N,M;
	cin>>N>>M;
	vector<pii> data;
	for(int i=0;i<N;i++){
		int l,r;
		cin>>l>>r;
		data.pb(mp(r-l+1,l));
	}
	sort(data.begin(),data.end());
	int now=0;
	bit.n = M+2;
	
	for(int d=1;d<=M;d++){
		int ans=0;
		while(now<N&&data[now].first<d){
			int l=data[now].second,r=l+data[now].first-1;
			//cout<<l<<" "<<r<<endl;
			bit.add(l,1);
			bit.add(r+1,-1);
			/*for(int i=1;i<=M+1;i++){
				cout<<bit.sum(i)-bit.sum(i-1)<<" ";
			}
			cout<<endl;*/
			now++;
		}
		for(int i=1;i*d<=M;i++){
			ans+=bit.sum(i*d);
		}
		ans+=N-now;
		cout<<ans<<endl;
		//" "<<N-now<<endl;
	}
}

Measured memory_bytes: 6512
#include<stdio.h>
#define MAX 100005
#define NIL -1
  
struct Node{
    int p, l, r;
};
struct Node T[MAX];
int dep=1,m;
 
main(){
  int i, j, d, v, c, l, n,tmp;
      
    scanf("%d", &n);
      
    for ( i = 0; i < n; i++ ) {
        T[i].p = T[i].l = T[i].r = NIL;
    }
      
    for (i = 0; i < n; i++){
        scanf("%d %d", &v, &d);
        for ( j = 0; j < d; j++ ){
      m=d;
            scanf("%d", &c);
              
            if(j==0){
                T[c].p=v;
                T[v].l=c;
        tmp=c;
            }
            else{
                T[c].p=v;
                T[tmp].r=c;
        tmp=c;
            }
              
        }
    }
      
    for ( i = 0; i < n; i++ ) print(i);
    return 0;
}
 
 
int depth(int u){
  if(T[u].p == NIL)return 0;
  if(T[T[u].p].p != NIL){
     dep++;
    depth(T[u].p);
  }
  return dep;
}
  
  
void print(int u){
  int i;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  dep=1;
  printf("depth = %d, ",depth(u));
   
   if(T[u].p == NIL){
     printf("root, [");
     if(T[u].l != NIL){
      printf("%d",T[u].l);
      while( T[T[u].l].r!=NIL){
     printf(", %d", T[T[u].l].r);
     T[u].l=T[T[u].l].r;
      }
     }
      printf("]\n");
   }//Endroot
  
   else if(T[u].p != NIL && T[u].l != NIL){
      printf("internal node, [%d",T[u].l);
      while( T[T[u].l].r!=NIL){
     printf(", %d", T[T[u].l].r);
     T[u].l=T[T[u].l].r;
       }
      printf("]\n");
   }//Endroot
  
   else if(T[u].l == NIL){
  printf("leaf, []\n");
   }//Endleaf
  
}

Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, temp, count;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			uint64 t = mask;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			while (~map[t].first) {
				--t;
			}
			while (++t <= (mask >> 1)) {
				mkey = map[t];
				map[t].first = ~static_cast<std::uint_fast64_t>(0);
				temp = mask&hash64(mkey.first);
				while (~map[temp].first) {
					temp = mask&(temp + 1);
				}
				map[temp] = mkey;
			}
			for (t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<std::uint_fast64_t>(0);
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

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

	hashmap64<uint32> map(200001);
	uint32 n;
	scanf("%u", &n);
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		scanf("%lld", &a);
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	printf("%u\n", ans);
	return 0;
}

Measured memory_bytes: 10844