akhauriyash/Code-Regression huggingface dataset:
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 100, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    cin>>n;
    v32 ans(10010,0);
    forsn(t1,2,151){
        forsn(t2,2,151){
            forsn(t3,2,151){
                int val=t1*t1 + t2*t2 + t3*t3;
                val/=2;
                // if(val==12) debug_out(t1,t2,t3);
                int mx=max({t1,t2,t3});
                if(t1+t2+t3 - 2*mx < 2) continue;
                if(val <=10005 && (t1+t2+t3)%2==0) ans[val]++; 
            }
        }
    }
    // dbg(ans[7]);
    forsn(i,1,n+1){
        cout<<ans[i]<<ln;
    }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int check(string s) {
int flag  = 0;
if(s[0] == '1') {
for (int i = 1; i < s.length(); i++) if (s[i] != '0') return 0;
return 1;
}
return 0;
}
int main() {
string s;
cin>>s;
if (check(s)) {
cout<<10<<endl;
} else {
int ans = 0;
for (int i = 0; i < s.length(); i++) ans += s[i]-'0';
cout<<ans<<endl;
}
return 0;
}

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

using namespace std;

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

int main() {
	int n, ans = 0;
	string ser;
	cin >> n >> ser;

	while (n--) {
		string str;
		cin >> str;

		bool f = false;
		for (int i = 1; i * (ser.size() - 1) < str.size(); ++i) {
			for (int j = 0; j + i * (ser.size() - 1) < str.size(); ++j) {
				int k = 0;
				for (k = 0; k < ser.size() && ser[k] == str[j + i * k]; ++k);
				if (k == ser.size()) f = true;
			}
		}
		
		if (f) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>

int main() {
    int x{}, y{}, a{}, b{};
    std::cin >> x >> y >> a >> b; 
    std::cout << static_cast<double>(x) * static_cast<double>(y) / 2.0 << ' ' << (a + a == x && b + b == y ? 1 : 0) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int n, x, t;
    std::scanf("%d %d %d", &n, &x, &t);

    int cnt = 0;
    while (n > 0) {
        n -= x;
        cnt += t;
    }

    std::printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define N 1000005
typedef long long int ll;
// int n,m;
// vector<int> adj[mx];

//---dfs--
// bool visited[mx];
// vector<int> val(n,0);

// void dfs(int s, int & cnt_vert, int & cnt_edge){
// 	assert(!visited[s]);
// 	visited[s]=true;
// 	++cnt_vert;
// 	cnt_edge+=adj[s].size();
// 	for(int b:adj[s]){
// 		if(!visited[b]){
// 			dfs(b,cnt_vert,cnt_edge);
// 		}
// 	}
// }
//---dfs---

//---primes---
// vector<bool> prime(N,true);
// int spf[N];

// void calc(){
// 	for(int i=2;i<1e4;i++){
// 		if(!prime[i]) continue;
// 		spf[i]=i;
// 		for(int j=i*i;j<N;j+=i){
// 			prime[j]=false;
// 			spf[j]=i;
// 		}
// 	}
// 	for(int i=2;i<N;i++){
// 		if(!spf[i]) spf[i]=i;
// 	}
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int t=1;
	//cin>>t;
	while(t--){
		string s,t;
		cin>>s>>t;
		int count=0;
		for(int i=0;i<(int)s.size();i++){
			if(s[i]!=t[i]) count++;
		}
		cout<<count<<"\n";
	}
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const int HW = 100;
    const char W = '.';
    const char B = '#';
    int a, b;
    cin >> a >> b;
    vector<string> ss;
    REP(i,HW) {
        if (i < HW /2) ss.emplace_back(string(HW,B));
        else ss.emplace_back(string(HW,W));
    }

    int x = 0, y = 0;
    int i = a-1;
    while(i > 0) {
        ss[y][x] = W;
        x += 2;
        if (x >= HW) {
            y += 2;
            x = 0;
        }
        i--;
    }

    x = 0, y = HW-1;
    i = b-1;
    while(i > 0) {
        ss[y][x] = B;
        x += 2;
        if (x >= HW) {
            y -= 2;
            x = 0;
        }
        i--;
    }

    cout << HW << " " << HW << '\n';
    REP(i,HW) cout << ss[i] << '\n';

    return 0;
}

Measured memory_bytes: 256
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)# util functions
else
  # debug
  $debugFlag = ( ARGV[0] != nil )
  p "==== DEBUG MODE ====" if $debugFlag

  def pd(str)
    p str if $debugFlag
  end

  def printd(str)
    print str if $debugFlag
  end

  # input
  inputs = []
  lc = 0
  nn = 0
  as = []
  bef = 0
  end_flag = false
  while l = $stdin.gets do
    if lc == 0
      nn = l.chomp.split(" ").map(&:to_i)[0]
    else
      xx = l.chomp.split(" ").map(&:to_i)[0]
      if xx - bef == 1 and bef != 0
        end_flag = true
        break
      end
      as << xx
      bef = xx
    end
    lc += 1
  end

  if end_flag
    puts 0
    exit
  end

  # input check
  if $debugFlag
    p "--- INPUT (begin) ---"
    inputs.each do |l_i|
      p l_i
    end
    p "--- INPUT (end) ---"
    print "\n"
  end

  # body
  if $debugFlag
    p nn
    p as
  end

  as << (nn + 1)

  lst = []
  tmp = 0
  as.length.times do |i|
    if i == 0
      lst << as[i] - 1
    else
      lst << as[i] - tmp - 2
    end
    tmp = as[i]
  end

  pd lst

  $memo = {}
  def calc(n)
    return 1 if n <= 1
    return $memo[n] if $memo[n]

    $memo[n] = calc(n-1) + calc(n-2)
    return $memo[n]
  end

  combs = 1
  lst.each do |l_i|
    combs *= calc(l_i)
  end

  puts (combs % 1000000007)
end


Measured memory_bytes: 454068
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int a, b;
	cin >> a >> b;
	a += b;
	a %= 24;
	cout << a << endl;

	return 0;

}


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

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

int main() {
  ll n,d;
  cin >> n >> d;
  int m=0;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    if(d*d >=x*x+y*y){
      m++;
    }
  }
  cout << m << endl;
 
  return 0;

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define Mod 1000000007
using namespace std;
long long n,a,b;
long long quick_pow(long long n,long long p,long long k) {
	if(p==0) return 1;
	long long ans=quick_pow(n,p/2,k);
	ans=ans*ans%k;
	if(p&1) ans=ans*n%k;
	return ans;
}
long long exgcd(long long a,long long b,long long &x,long long &y) {
	if(!b) {
		x=1,y=0;
		return a;
	}
	long long d=exgcd(b,a%b,x,y);
	long long z=x;x=y;y=z-y*(a/b);
	return d;
}
int main() {
	cin>>n>>a>>b;
	long long ans=quick_pow(2,n,Mod)-1;
	long long m1=1,m2=1;
	long long x,y;
	for(int i=1;i<=a;i++) {
		m1=m1*(n-i+1)%Mod;
		exgcd(i,Mod,x,y);
		m1=m1*x%Mod;
	}
	for(int i=1;i<=b;i++) {
		m2=m2*(n-i+1)%Mod;
		exgcd(i,Mod,x,y);
		m2=m2*x%Mod;
	}
	cout<<((ans-m1-m2)%Mod+Mod)%Mod;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

/********************/
vector<ll> make_four(ll n) {
	vector<ll> a(8);
	ll x = n;
	for (ll i = 0; i < 8; i++) {
		a[i] = x % 4;
		x /= 4;
	}
	return a;
}
int main() {
	ll n, a, b, c; cin >> n >> a >> b >> c;
	vector<ll> l(n); rep(n) cin >> l[i];
	ll ans = INF;
	for (ll i = 0; i < qp(4,n); i++) {
		ll res;
		auto s = make_four(i);
		ll k1=0, k2=0, k3=0;
		ll l1=0, l2=0, l3=0;
		for (ll j = 0; j < n; j++) {
			if (s[j] == 0) {
				k1++, l1 += l[j];
			}
			else if (s[j] == 1) {
				k2++, l2 += l[j];
			}
			else if(s[j] == 2) {
				k3++, l3 += l[j];
			}
		}
		if(k1 == 0 || k2 == 0||k3 == 0)continue;
		if (k1 <= 1) k1 = 0; else k1 = (k1 - 1) * 10;
		if (k2 <= 1) k2 = 0; else k2 = (k2 - 1) * 10;
		if (k3 <= 1) k3 = 0; else k3 = (k3 - 1) * 10;
		res = k1 + k2 + k3 + abs(a - l1) + abs(b - l2) + abs(c - l3);
		mins(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    int n,i,max,min;
    scanf("%d",&n);
    int hairetu[n];
    for(i=0;i<n;i++){
        scanf("%d",&hairetu[i]);
    }
    max=hairetu[0];
    min=hairetu[0];
    for(i=0;i<n;i++){
        if(hairetu[i]>max)
            max=hairetu[i];
        if(hairetu[i]<min)
            min=hairetu[i];
    }
    max=max-min;
    
    printf("%d\n",max);
    
    
}



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

const int DIM = 1e5 + 5;

int arr[DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    int cnt = 0;
    for( int i = 1; i <= m; i ++ ) {
        cin >> arr[i];
        cnt += arr[i] % 2;
    }
    
    if( cnt > 2 )
        cout << "Impossible\n";
    else
    if( n == 1 )
        cout << "1\n1\n1\n";
    else
    if( m == 1 )
        cout << arr[1] << "\n" << "2\n" << arr[1] - 1 << " 1\n";
    else {
        int p = 0;
        for( int i = 1; i <= m; i ++ )
            if( arr[i] % 2 == 1 )
                swap( arr[i], arr[++ p] );
        swap( arr[2], arr[m] );
        
        for( int i = 1; i <= m; i ++ )
            cout << arr[i] << " ";
        cout << "\n" << m - ( arr[1] == 1 ) << "\n";
        
        if( arr[1] != 1 )
            cout << arr[1] - 1 << " ";
        
        for( int i = 2; i <= m - 1; i ++ )
            cout << arr[i] << " ";
        cout << arr[m] + 1 << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, i;
	ll k;
	cin >> n >> k;
	
	int arr[n + 1];
	foe(i, 1, n)
	cin >> arr[i];
	
	bool vis[n + 1];
	memset(vis, false, sizeof vis);
	vector <int> v;
	int x = 1;
	bool ok = 0;
	while(!vis[x]) {
		v.pb(x);
		vis[x] = 1;
		x = arr[x];
		if(x == arr[x]) ok = 1;
	}
	if(ok) {
		if(k >= v.size()) cout << v.back();	
		else cout << v[k];
	}
	else {
		vector <int> rep;
		int ind = -1;
		for(int i = v.size() - 1; i >= 0; i--) {
			rep.pb(v[i]);
			if(v[i] == x) {
				ind = i;
				break;
			}
		}
		reverse(all(rep));
		if(k >= ind) {
			k -= ind;
			cout << rep[k % (int)rep.size()];
		}
		else 
		cout << v[k];
	}
}


Measured memory_bytes: 6500
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int t[55]; string s[55];
signed main() {
	int n; cin >> n ;
	rep(i, n)cin >> s[i] >> t[i];
	string x; cin >> x;
	int cnt = 0;
	int flg = 0;
	rep(i, n) {
		if (flg)cnt += t[i];
		if (x == s[i])flg++;
	}
	cout << cnt << endl;
}


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

int a, b;
int main()
{
	scanf("%d %d", &a, &b);

	if(a>=13) printf("%d\n", b);
	else if(a>=6 && a<=12) printf("%d\n", b/2);
	else printf("0\n");
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

map<ll, int> fctm( ll x ){
	map<ll, int> fmp;
	for( ;x>=4 && x%2==0; x/=2)  fmp[2]++;
	for(ll d=3, q=x/d; q>=d ; q=x/d){if(x%d==0) fmp[d]++, x=q; else d +=2;}
	if(x!=1) fmp[x]++;
	return fmp;
}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll  n;
	cin >>n;
	
	auto sb = fctm(n);
	//for(auto x :sb) cerr<<x.first<<":"<<x.second<<", "; dbg();
	VL bb(63);
	bb[0]=0;
	rep(i,  62) bb[i+1]= bb[i] + i+1;
	//for(auto x :bb) cerr<<x<<" "; dbg();
	ll ans = 0;
	for(auto x: sb){
		int cc = x.second;
		rep(j, 60) if(bb[j]<= cc && cc<bb[j+1]){
			ans += j; break;
		}
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 3660
// 2020-06-27 15:10:39
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct RangedFenwickTree {
  int N;
  vll bit1, bit2;
  void init(int n) {
    N = n;
    bit1.assign(n+2, 0);
    bit2.assign(n+2, 0);
  }
  void add(vll& bit, int i, ll a) {
    assert(i > 0);
    while(i <= N) {
      bit[i] += a;
      i += (i & -i);
    }
  }
  void range_add(int l, int r, ll a) {
    add(bit1, l, a);
    add(bit2, l, -a*(l-1));
    add(bit1, r+1, -a);
    add(bit2, r+1, a*r);
  }
  ll query(vll& bit, int i) {
    ll res = 0;
    while(i > 0) {
      res += bit[i];
      i -= (i & -i);
    }
    return res;
  }
  ll sum(int i) {
    return query(bit1, i) * i + query(bit2, i);
  }
};

int n, c[200020];
vector<ll> ans;
vector<int> G[200020];
RangedFenwickTree bit;
ll calc(ll a) {
  return a + (a * (a - 1) / 2);
}
void dfs(int u, int p) {
  int init, cur;
  init = cur = bit.sum(c[u]) - bit.sum(c[u]-1);
  for(const int v : G[u]) if(p != v) {
    dfs(v, u);
    int now = bit.sum(c[u]) - bit.sum(c[u]-1);
    ans[c[u]] -= calc(now - cur);
    cur = now;
  }
  bit.range_add(1, n, 1);
  bit.range_add(c[u], c[u], init - cur - 1);
}
void answer() {
  cin >> n;
  bit.init(n);
  ans.assign(n+10, calc(n));
  rep(i, n) cin >> c[i];
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  dfs(0, -1);
  REPC(i, 1, n) {
    ans[i] -= calc(bit.sum(i) - bit.sum(i-1));
  }
  REPC(i, 1, n) cout << ans[i] << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 35028
#include <bits/stdc++.h>
using namespace std;
vector <int> v1, v2;
int main()
{
int a;
v1.push_back(5);
v1.push_back(5);
v1.push_back(7);
for(int i=0; i<3; i++) {
cin>>a; v2.push_back(a);
}
sort(v2.begin(), v2.end() );
if(v1==v2) puts("YES");
else puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n, k; cin >> n >> k;
    ll ans = 0;
    if(k%2!=0){
        ans = pow(n/k,3);
        cout << ans << endl;
    }else{
        ans = pow((n+k/2)/k,3)+pow(n/k,3);
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


void solve() {
    int x;
    cin >> x;
    int ans = 1;
    for (int i = 2; i <= 100; ++i) {
        int tmp = i;
        for (int j = 2; j < 10; ++j) {
            tmp *= i;
            if(tmp <= x){
                ans = max(ans, tmp);
            }else{
                break;
            }
        }
    }
    cout << ans << "\n";
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

class town {
public:
  i64 x;
  i64 y;
  friend std::istream& operator>>(std::istream& is, town& self) {
    return is >> self.x >> self.y;
  }
};

constexpr double distance(const town& i, const town& j) {
  return std::sqrt((i.x - j.x) * (i.x - j.x) + (i.y - j.y) * (i.y - j.y));
}

constexpr i64 fact(const i64& n) {
  return n == 0 ? 1 : n * fact(n - 1);
}

int main() {
  i64 N;
  std::cin >> N;
  std::vector<town> towns;
  tools::read(towns, N);

  std::vector<i64> indices(N);
  std::iota(indices.begin(), indices.end(), 0);
  double answer = 0.0;
  do {
    for (auto it = ++indices.begin(), prev_it = indices.begin(); it != indices.end(); prev_it = it, ++it) {
      answer += distance(towns[*prev_it], towns[*it]);
    }
  } while (std::next_permutation(indices.begin(), indices.end()));
  answer /= fact(N);

  std::cout << std::fixed << std::setprecision(10) << answer << std::endl;
  return 0;
}

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

int main(){
  int N,sum=0;
  cin >> N;
  vector<int> a(N),b(N);
  for(int i=0;i<N;i++)cin >> a.at(i) >> b.at(i);
  for(int i=0;i<N;i++)sum += b.at(i)-a.at(i)+1;
  cout << sum << "\n";
  return 0;
}


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

using namespace std;

const int INFTY = 1e9;
const int HMAX = 100;
const int WMAX = 100;

char grid[HMAX][WMAX];
int dist[HMAX][WMAX];
int di[] = {0,0,1,-1};
int dj[] = {1,-1,0,0};

int H,W;

int bfs(int sx, int sy, int gx, int gy){
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            dist[i][j] = INFTY;
        }
    }

    dist[sx][sy] = 1;
    queue<pair<int,int> > Q;
    Q.push(make_pair(sx,sy));

    while(!Q.empty()){
        auto p = Q.front(); Q.pop();
        int x = p.first;
        int y = p.second;
        for(int i=0;i<4;i++){
            int nx = x + di[i];
            int ny = y + dj[i];
            if(nx < 1 || nx > H || ny < 1 || ny > W) continue;
            if(nx == gx && ny == gy) return dist[x][y] + 1;
            if(dist[nx][ny] == INFTY && grid[nx][ny] == '.'){
                dist[nx][ny] = dist[x][y] + 1;
                Q.push(make_pair(nx,ny));
            }
        }
    }
    return -1;
}

int main(){
    cin >> H >> W;
    int count = 0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> grid[i][j];
            if(grid[i][j] == '.') count++;
        }
    }

    int ans = bfs(1,1, H,W);

    if(ans == -1){
        cout << -1 << endl;
    }else{
        cout << count - ans << endl;
    }
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}


int main(){
	int n;cin>>n;
	vector<P>v;
	rep(i,n){
		int x,y;scanf("%d%d",&x,&y);
		v.push_back(P(x,y));
	}
	auto p=smallest_enclosing_disc(v);
	printf("%.12lf\n",p.rad);
}

Measured memory_bytes: 256
H,W = map(int,input().split())
sharp = '#'*(W+2)
S = []
for i in range(H):
  S.append(input())
for i in range(H+2):
  if i == 0 or i == H+1:
    print(sharp)
  else:
    print('#'+S[i-1]+'#')

Measured memory_bytes: 38256
x,k,d = map(int,input().split())
if x>0:      
    a = x//d
    if k < a:
        b = x - k*d
        print(abs(b))
    else:
        if (k-a)%2==0:
            kouho1 = x - a*d
            print(abs(kouho1))
        else:
            kouho2 = x - (a+1)*d
            print(abs(kouho2))
else:
    x = x*(-1)
    a = x//d
    if k < a:
        b = x - k*d
        print(abs(b))
    else:
        if (k-a)%2==0:
            kouho1 = x - a*d
            print(abs(kouho1))
        else:
            kouho2 = x - (a+1)*d
            print(abs(kouho2))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
  int A,P,pi;
  cin >> A >> P;
  pi = ((3 * A) + P) / 2; 
  cout << pi << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,m;
	cin>>n;
	vector<int>A(n);
	vector<int>B(n);
	vector<int>C(n+1);
	bool p=0;
	for(int i=0;i<n;i++){
	 	cin>>A[i];
	 	C[A[i]]++;
	}
	for(int i=0;i<n;i++) {
		cin>>B[i];
		C[B[i]]++;
		if(C[B[i]]>n) p=1;
	}
	if(p){
		cout<<"No";
		return;
	}
	cout<<"Yes \n";
	int i=n-1;
	int j=n-2;
	while(j>=0){
		while(i>=0 && A[i]!=B[i]) i--;
		if(i<=j) j=i-1;
		while(j>=0 && (B[i]==B[j] or A[j]==A[i])) j--;
		if(j<0) break;
		swap(B[i],B[j]);
		j--;
	}
	// for(i=0;i<n;i++) cout<<B[i]<<" ";
	i=0;
	j=1;
	while(j<n){
		while(i<n && A[i]!=B[i]) i++;
		if(i>=j) j=i+1;
		while(j<n  && (B[i]==B[j] or A[j]==A[i])) j++;
		if(j==n) break;
		swap(B[i],B[j]);
		j++;
	}
	//cout<<"\n";
	for(i=0;i<n;i++) cout<<B[i]<<" ";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();

}

Measured memory_bytes: 5576
#include <iostream>

int
main(int argc, char** argv) {
    std::string S;
    std::cin >> S;

    int ans = 0;
    const char* wp = S.c_str();
    for (int i = 1; i < S.length(); i++) {
        if (*(wp + i - 1) == *(wp + i)) {
            ans = 1;
            break;
        }
    }

    std::printf("%s\n", ans == 0 ? "Good" : "Bad");
    return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=2010;
const int inf=2147483647;
const int mod=998244353;
void upd(int&x,int y){x+=y;if(x>=mod)x-=mod;}
char s[Maxn];int n;
int C[Maxn][Maxn],f[Maxn][Maxn];
void pre()
{
	C[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
		C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	pre();
	int s1=0,s0=0;f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		int t=s[i]-'0';
		s1+=t;//1的个数
		s0+=2-t;
		for(int j=0;j<=min(s1,i);j++)
		{
			if(j)upd(f[i][j],f[i-1][j-1]);
			if(i-j<=s0)upd(f[i][j],f[i-1][j]);
//			printf("%d %d %d\n",i,j,f[i][j]);
		}
	}
	int ans=0;
	for(int i=0;i<=min(s1,n);i++)upd(ans,(LL)f[n][i]*C[n][s1-i]%mod);
	printf("%d",ans);
}


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

int main(){
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int k;
  cin >> k;
  
  cout << v[k-1] << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<numeric>
#include<bits/stdc++.h>

#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define REP(i,n) FOR(i,0,n)
#define endl "\n"

#define INF 9e18
#define ll long long int
const double PI  =3.141592653589793238463;
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int r;
	
	cin >> r;
	
	cout << 2*PI*r << endl;
	
	return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> a(n),b(m);
    for(int &i: a)cin >> i;
    for(int &i: b)cin >> i;
    int lo = 0, hi = n+m, ans = 0;
    while(lo <= hi){
        int sum = 0,mid = lo + hi >> 1;
        int i = min(mid,n)-1, j = mid - min(mid,n) - 1;
        for(int k = 0; k <= i; ++k)sum+=a[k];
        for(int k = 0; k <= j; ++k)sum+=b[k];
        bool pos = sum <= k;
        while(i >= 0 && j+1 < m && !pos){
            sum-=(a[i--]-b[++j]);
            pos = (sum <= k);
        }
        if(pos)ans=mid,lo=mid+1;
        else hi = mid-1;
    }
    return cout << ans << "\n",0;
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;

   vector<short> space(1e6 + 5);
   vector<long int> v(n);

   for(long int i = 0; i < n; i++)
      cin>>v[i];

   sort(v.begin(),v.end());
   long int ans = 0;

   for(long int i = 0; i < n; i++){
      long int ele = v[i];

      if(space[ele] == 1){
        ans--;
        space[ele] = 2;
        continue;
      }

      if(space[ele] == 2)
        continue;

      space[ele] = 1;
        ans++;
      
      for(long int k = 2 * ele; k <= space.size(); k += ele)
        space[k] = 2;
   }



   cout<<ans;

   return 0;
}

Measured memory_bytes: 6624
c = [list(map(int, input().split())) for _ in range(3)]
 
for i in range(2):
  for j in range(2):
    if c[i][j] - c[i][j+1] == c[i+1][j] - c[i+1][j+1]:
      pass
    else:
      print('No')
      exit()
      
print('Yes')

Measured memory_bytes: 3060
/* CODE BY NITIN 
	ON 5 April 2020--------------
	*/
	
	#include <bits/stdc++.h>
	//#include<boost/multiprecision/cpp_int.hpp>
	#define mod 1000000007
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
	#define REP(i, n) for (int i = 0; i < (n); i++)
	#define REPN(i, n) for (int i = 1; i <=(n); i++)
	#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
	#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
	#define T(a) ll a;  cin >> a;
	#define TT(t) T(t); while (t--)
	#define pb push_back
	#define mp make_pair
	 #define ll long long int
	using namespace std;


	void solve()
	{
	
	

		T(r)
		cout<<2*3.14*r<<endl;

				
		
	}
	int main()
	{
		
		
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
		solve();
		return 0;
		
	}

Measured memory_bytes: 3820
#include <stdio.h>
#define MAX 100000

typedef struct{
    char suit;
    int value;
}Card;

Card L[MAX/2+2],R[MAX/2+2];

void merge(Card*,int,int,int,int);
void mergeSort(Card*,int,int,int);
int partition(Card*,int,int,int);
void quickSort(Card*,int,int,int);

int main(){
    int n,i,value;
    Card A[MAX],B[MAX];
    char suit;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf(" %c%d",&suit,&value);
        
        A[i].suit=suit;
        B[i].suit=suit;
        A[i].value=value;
        B[i].value=value;
    }

    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);

    for(i=0;i<n;i++){
        if(A[i].suit!=B[i].suit){
            printf("Not stable\n");
            break;
        }
        if(i==n-1) printf("Stable\n");
    }

    for(i=0;i<n;i++){
        printf("%c %d\n",B[i].suit,B[i].value);
    }

    return 0;
}

void merge(Card *A,int n,int left,int mid,int right){
    int i,j,k;
    int n1=mid-left;
    int n2=right-mid;

    for(i=0;i<n1;i++){
        L[i]=A[left+i];
    }

    for(i=0;i<n2;i++){
        R[i]=A[mid+i];
    }

    L[n1].value=1000000001;
    R[n2].value=1000000001;
        
    i=0;
    j=0;

    for(k=left;k<right;k++){
        if(L[i].value <= R[j].value) A[k]=L[i++];
        else A[k]=R[j++];
    }

}

void mergeSort(Card *A,int n,int left,int right){
    int mid;

    if(left+1<right){
        mid=(left+right)/2;

        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }

}

int partition(Card *A,int n,int p,int r){
    int i,j;
    Card tmp,x;

    x=A[r];
    i=p-1;

    for(j=p;j<r;j++){
        if(A[j].value<=x.value){
            i++;
            tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
        }
    }

    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;

    return i+1;
}

void quickSort(Card *A,int n,int p,int r){
    int q;

    if(p<r){
        q=partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }

}


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

a=gets.to_i
b=gets.to_i
arr=array(3,1)
arr[a-1]=arr[b-1]=0
ans=0
arr.each do|num|
  unless num.zero?
    break
  end
  ans+=1
end
puts ans+1



Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
    int i,j,n,x[2001],y[2001];
    long int r,fact=1;
    double d=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x[i]>>y[i];
        fact=fact*(i+1);
    }
    r=fact/n;
    for(i=0;i<n;i++){
        for(j=i;j<n;j++){
            d=2*r*(sqrt(((x[i]-x[j])*(x[i]-x[j])) + ((y[i]-y[j])*(y[i]-y[j]))))+d;
        }
    }
    cout<<setprecision(10)<<d/fact;
    return 0;
}

Measured memory_bytes: 256
def up(x,y):
    if(y-1<0):return 0
    if a[y-1][x]=="#":return 1
    else:return 0
def down(x,y):
    if(y+1>h-1):return 0
    if a[y+1][x]=="#":return 1
    else:return 0
def right(x,y):
    if(x+1>w-1):return 0
    if a[y][x+1]=="#":return 1
    else:return 0
def left(x,y):
    if(x-1<0):return 0
    if a[y][x-1]=="#":return 1
    else:return 0

def upleft(x,y):
    if(y-1<0):return 0
    if(x-1<0):return 0
    if a[y-1][x-1]=="#":return 1
    else:return 0
def downleft(x,y):
    if(x-1<0):return 0
    if(y+1>h-1):return 0
    if a[y+1][x-1]=="#":return 1
    else:return 0
def upright(x,y):
    if(y-1<0):return 0
    if(x+1>w-1):return 0
    if a[y-1][x+1]=="#":return 1
    else:return 0
def downright(x,y):
    if(y+1>h-1):return 0
    if(x+1>w-1):return 0
    if a[y+1][x+1]=="#":return 1
    else:return 0

h,w=map(int,input().split())
a=[[i for i in input()] for j in range(h)]

for y in range(h):
    for x in range(w):
        if a[y][x]!="#":
            p=up(x,y)+down(x,y)+left(x,y)+right(x,y)+upright(x,y)+downright(x,y)+upleft(x,y)+downleft(x,y)
            print(p,end="")
        else:print("#",end="")
    print()

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

int main(){
    int n;
    cin >> n;
    int a[n-1], b[n-1];
    vector<int> p[n];
    rep(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        p[b[i]].push_back(a[i]);
        p[a[i]].push_back(b[i]);
    }
    ll c[n];
    rep(i,n) cin >> c[i];
    sort(c,c+n,greater<ll>());
    queue<int> que;
    vector<bool> used(n,false);
    ll ans[n] = {};
    que.push(0);
    ans[0] = c[0]; used[0] = true;
    int num = 1;
    while(!que.empty()){
        int q = que.front();
        que.pop();
        rep(i,p[q].size()){
            if(!used[p[q][i]]){
                ans[p[q][i]] = c[num++];
                used[p[q][i]] = true;
                que.push(p[q][i]);
            }
        }
    }
    ll s = 0;
    rep(i,n-1) s += min(ans[a[i]],ans[b[i]]);
    cout << s << endl;
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
int main()
{
    scanf("%d%d",&n,&k);
    if(k==1) printf("0\n"); else printf("%d\n",n-k);
    return 0;
}



Measured memory_bytes: 256
S = input()
li = []
for s in S:
    li.append(int(s))

count = 0
first = li[0]
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] != first:
            count += 1
    else:
        if li[i] == first:
            count += 1

count2 = 1
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] == first:
            count2 += 1
    else:
        if li[i] != first:
            count2 += 1

print(min(count, count2))


Measured memory_bytes: 4084
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s;
    cin>>s;
    ll ans=1;
    ll len=1;
    for(int i=1;i<s.length();i++)
    {
        if(len==2)
        {
            len=1;
            ans++;
        }
        else
        {
            if(i==s.length()-1)
            {
                if(s[i]==s[i-1])
                    continue;
                else
                    ans++;
            }
            else
            {
                if(s[i]==s[i-1])
                {
                    len=2;
                    i++;
                    ans++;
                }
                else
                {
                    len=1;
                    ans++;
                }
            }
        }
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string s;
    cin >> s;
    int cnt = 0;
    forn(i, sz(s) / 2) {
        if (s[i] != s[sz(s) - i - 1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
int a[10];
bool ans;
void dfs(int i,int r,int l){
	if(i==10)ans=1;
	if(a[i]<r&&a[i]<l)return;
	if(ans)return;
	if(r<a[i])dfs(i+1,a[i],l);
	if(l<a[i])dfs(i+1,r,a[i]);

}
int main(){
	int t;
	cin>>t;
	while(t--){
		ans=0;
		for(int i=0;i<10;i++)cin>>a[i];
		dfs(0,0,0);
		if(ans)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 1152
#Input
s = input()
n = len(s)
#Process
#Progress1
o1 = True
for i in range(n):
    if(i != int(n/2) + 1):
        #print(s[i],s[n - i - 1])
        o1 = o1 and s[i] == s[n - i -1]

#Progress2
o2 = True
n2 = int((n - 1) / 2)
for i in range(n2):
    #print(s[i],s[n2 - i - 1])
    o2 = o2 and s[i] == s[n2 - i -1]
    
#Progress3
o3 = True
n3 = int((n + 3) / 2)
for i in range(n - n3):
    #print(s[i + n3 -1],s[n - i -1])
    o3 = o3 and s[i + n3 -1] == s[n - i -1]


#EndProgress
if(o1 and o2 and o3): 
    Ans = "Yes"
else:
    Ans = "No"

#Output
print(Ans)

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

int main()
{
    ll A; cin >> A;
    long double B; cin >> B;
    ll ans = (A * B * 100.0) + 0.4;
    cout << ans / 100 << endl;


}


Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vp = vector<Pii>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

  int n, l;
  cin >> n >> l;
  int miabs = inf;
  int miabs_a;
  int sum = 0;
  rep(i, n) {
    int a = l + i;
    sum += a;
    if (miabs > abs(a)) {
      miabs = abs(a);
      miabs_a = a;
    }
    // output(a, sum, miabs, miabs_a);
  }
  cout << sum - miabs_a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> L(N, 0);
	rep (i, N){
		cin >> L[i];
	} // end rep
	
	sort(ALL(L));

	int sum = accumulate(ALL(L), 0);
	sum -= L[N-1];
	cout <<  (sum > L[N-1] ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t

int main() {
	int m, d;
	cin >> m >> d;
	int ans = 0;
	ff(i, 4, m + 1) {
		ff(j, 22, d + 1) {
			if (j % 10 < 2) {
				continue;
			}
			if ((j / 10) * (j % 10) == i) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256