akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int n,k;
vector<int> d;
vector<vector<int>> a;

void input()
{
    cin>>n>>k;
    d.resize(k);
    a.resize(k,vector<int>());
    for(int i =0;i<k;i++){
        cin>>d[i];
        a[i].resize(d[i]);
        for(int j=0;j<d[i];j++){
            cin>>a[i][j];
        }
    }
}
void solve()
{
    int ans=0;
    for(int i=1;i<=n;i++){
        bool have = false;
        for(auto v: a){
            for(auto p:v){
                if(p == i){
                    have = true;
                }
            }
        }
        if(!have){
            ans++;
    }
    }
    cout<<ans<<endl;
    }
int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin >> n;
  double f[n],ans;
  ans=0;
  string s[n];
  for(int i=0;i<n;++i)
  {
  cin >> f[i] >> s[i];
  if(s[i]=="JPY") ans=ans+f[i];
  else ans=ans+f[i]*380000;
  }
  cout << ans;
return 0;}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll K;
  const ll N = 50;
  cin >> K;
  cout << N << endl;
  VLL ans(N,0);
  rep(i,N) ans[i] = 49 + K/50;

  rep(i,K%N){
    ans[i] += N+1;
    rep(j,N) ans[j]--;
  }

  rep(i,N) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[128];
	int count = 0;
	
	while (scanf("%s", str) != EOF){
		int i;
		int len;
		
		for (i = 0, len = strlen(str); i < len / 2; i++){
			if (str[i] != str[len - i - 1]){
				break;
			}
		}
		if (i == len / 2){
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110000
using namespace std;
typedef long long ll;

int main() {
	int i, j, k;
	int A, P, ans;
	cin >> A >> P;
	P += A * 3;
	ans =  P / 2;
	cout << ans << endl;
	return 0;
}

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

const int INF = 1e8;

int H, W;

ll dist[1010][1010];

char maze[1010][1010];


void bfs() {
    // cout << sy << " " << sx << endl;

    queue<P> q;

    rep(i, H)rep(j, W) {
        if (maze[i][j] == '.') continue;
        dist[i][j] = 0;
        q.push(P(i, j));
    }

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

    while (!q.empty()) {
        P p = q.front(); q.pop();
        // if (p.first == gy && p.second == gx) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.second + dx[i], ny = p.first + dy[i];
            if (0 <= ny && ny < H && 0 <= nx && nx < W && maze[ny][nx] != '#' && dist[ny][nx] == INF) {
                    // cout << ny << " " << nx << endl;
                    q.push(P(ny, nx));
                    dist[ny][nx] = dist[p.first][p.second] + 1;
            }
        }
    }
}

int main() {
    cin >> H >> W;

    rep(i, H)rep(j, W) cin >> maze[i][j];

    // # 開始から最大の距離 の中で一番小さい値
    rep(i2, H)rep(j2, W) dist[i2][j2] = INF;


    bfs();

    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 20004
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int H,W;

bool input() {
  cin >>H >>W;
  if (H == 0 && W == 0) return false;
  return true;
}

void solve() {
  rep(i, H){
    rep(j, W){
      if (i == 0 || i == H-1){
        cout <<"#";
      }else if (j == 0 || j == W-1){
        cout <<"#";
      }else{
        cout <<".";
      }
    }
    cout <<endl;
  }
  cout <<endl;
}

int main() {
  while (input()){
    solve();
  }
}



Measured memory_bytes: 3020
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	fmt.Println(len(strconv.FormatInt(int64(n), k)))
}


Measured memory_bytes: 1772
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.snd", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		int a,b,n;

		stringstream ss(str);
		ss >> a >> b >> n;
		if (a % b == 0){
			cout << '0' << endl;
			continue;
		} // end if

		while (a > b){
			a -= b;
		} // end if	

		vector <int> res;
		int sum = 0;
		int i;
		
		for (i = 0; i < n; ++i){
			int c = (10*a)/b;
			int d = (10*a % b);
			a = d;
			sum += c;
		} // end for
		cout << sum << endl;

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
//A
int main() {
	// your code goes here
	int n; double a;
	cin >> n; a=n;
	if(n%2==0) cout << "0.5" << endl;
	else printf("%.10lf\n",(a+1)/(2*a));
 	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<int>B(N-1);
  vector<int>A(N,999999);
  for(int i=0;i<=N-2;i++){
  
    cin>>B[i];
  }
  for(int i=0;i<=N-2;i++){
  
    if(A[i+1]>B[i])A[i+1]=B[i];
    if(A[i]>B[i])A[i]=B[i];
  }
  int ans=0;
  for(int i=0;i<=N-1;i++){
  
    ans+=A[i];
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3544
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1),i=new(n(2))(r.readFileSync("/dev/stdin","utf8").split(/\s+/g));n(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3);t.exports=class{constructor(t){this.inp=new r(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}add(t){this.inp.enq(t)}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,e,n){"use strict";t.exports=function(t){var e=[t.in(),t.in(),t.in()];e.sort(function(t,e){return t-e}),console.log(e[0]+e[1])}}]);

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<strinx>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  vi v(3);
  int n;
  rep(i,3)cin>>v[i];
  cin>>n;
  sort(v.begin(),v.end());
  rep(i,n)v[2] *= 2;
  cout<<v[0]+v[1]+v[2]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long a){
    cout << a + a*a+a*a*a<<endl;
}   
int main(){
    long long a;
    scanf("%lld",&a);
    solve(a);
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include<algorithm>

using namespace std;

int main(void){
    long n,k;
    cin >> n >> k;
    long ans = k;
    for(int i = 0;i < n - 1;i++){
          ans *= (k - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int read() {
	int f = 1, x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -f;
		ch = getchar();
	} while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return f * x;
}
const int N = 400010;
int n, a[N], dp[N], b[N], wk[N], cnt;
vector <int> g[N]; 
multiset <int> c[N];
int qry(int x) {
	int ans = 0;
	for (; x; x -= x & -x) {
		if (c[x].size()) ans = max(ans, *(--c[x].end()));
	}
	return ans; 
}
void ins(int x, int v) {
	for (; x <= cnt; x += x & -x) c[x].insert(v);
}
void era(int x, int v) {
	for (; x <= cnt; x += x & -x) c[x].erase(c[x].find(v));
}
void dfs(int u, int pre) {
	dp[u] = qry(a[u] - 1) + 1;
	wk[u] = max(wk[pre], dp[u]);
	ins(a[u], dp[u]);
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (v == pre) continue;
		dfs(v, u);
	}
	era(a[u], dp[u]);
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], b[i] = a[i];
	sort (b + 1, b + n + 1);
	cnt = unique(b + 1, b + n + 1) - (b + 1);
	for (int i = 1; i <= n; ++i)
		a[i] = lower_bound(b + 1, b + cnt + 1, a[i]) - b; 
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; ++i) cout << wk[i] << endl;
	return 0;
}






Measured memory_bytes: 101456
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int inf = 1000000000;

//#define DEBUG

int main() {
    int n;
    cin >> n;

    bool is_different = true;
    map<int, int> mp;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (mp[a]) {
            is_different = false;
            break;
        }
        else {
            mp[a] = 1;
        }
    }

    if (is_different) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

const int mod=1000000007;
int N,K;
long ans;
vector<long> X(100100); //引き算する分を保存する配列
// https://h1guch.hatenablog.com/entry/2020/04/13/174426

//繰り返し二乗法
//a^n mod m を返す
long power(long a, long n, long m) {
  long ret = 1;
  for (; n > 0; n >>= 1, a = a * a % m) {
    if (n % 2 == 1) {
      ret = ret * a % m;
    }
  }
  return ret;
}

//ｎの約数をpush_backしたvectorを返す
vector<long> divisor(long n)
{
  vector<long> res;
  for(long i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      res.push_back(i);
      if(i * i != n) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.begin());
  return res;
}

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

  //Kからの降順にした
  for(int i = K; i > 0; i--) {
    //X[i]が引き算する分
    //i=Kでは当然X[i]=0
    long cnt = ((power(K/i, N, mod) - X[i]) % mod + mod) % mod;

    //最大公約数がｉである数列の個数がcnt個と分かった
    ans = (ans + i * cnt + mod) % mod;

    vector<long> d = divisor(i);
    //約数の子たちのために引き算する分を教えてあげている
    for(auto &it : d) {
      X[it] = (X[it] + cnt + mod) % mod;
    }
  }

  cout << ans << endl;
  return 0;
}

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

double solve(vector<vector<vector<double>>>& dp, int a, int b, int c, double N){
	if(dp[a][b][c] != 0){
		return dp[a][b][c];
	}
	if(a==0 && b==0 && c==0) return 0;
	double f = 0;
	f +=  1 / (1 - (N-a-b-c)/N );
	if(a>0) f += solve(dp,a-1,b,c, N)   * (a/N) /(1 - (N-a-b-c)/N );
	if(b>0) f += solve(dp,a+1,b-1,c, N) * (b/N) /(1 - (N-a-b-c)/N );
	if(c>0) f += solve(dp,a,b+1,c-1, N) * (c/N) /(1 - (N-a-b-c)/N );
	return dp[a][b][c] = f;

}

int main(){
	int N;
	cin >> N;
	vector<vector<vector<double>>> dp(N+1,vector<vector<double>>(N+1,vector<double>(N+1,0)));
	int a=0, b=0, c=0;
	for(int i=0; i<N; i++){
		int t; cin >> t;
		if(t==1) a++;
		else if(t==2) b++;
		else c++;
	}
	printf("%.9lf\n",solve(dp,a,b,c,(double)N));
	return 0;
}



Measured memory_bytes: 220016
//============================================================================
// Name        : f.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

int main() {
	int n,m;cin>>n>>m;
	vector<int> a(m),b(m);
	vector<vector<int>> e(m);
	vector<int> ex(n,-1),c(n,2000);
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		e[a[i]].push_back(b[i]);
	}
	c[0]=0;
	int flag=0;
	set<int> s;
	vector<int> v;
	for(int i=0;i<3*n;i++){
		for(int j=0;j<m;j++){
			if(c[a[j]]-1<c[b[j]]){
				ex[b[j]]=a[j];
				c[b[j]]=c[a[j]]-1;
				if(i>=2*n){
					flag=1;
					s.insert(b[j]);
					v.push_back(b[j]);
					break;
				}
			}
		}
		if(flag)break;
	}
	if(flag==0){
		cout<<-1<<endl;
		return 0;
	}
	while(1){
		int temp=v.back();
//		cout<<temp<<endl;
		int next=ex[temp];
		if(s.count(next)){
			v.push_back(next);
			break;
		}else{
			v.push_back(next);
			s.insert(next);
		}
	}
//	for(int i=0;i<v.size();i++){
//		cout<<v[i]<<' ';
//	}cout<<endl;
	flag=0;
	vector<int> v2;
	set<int> s2;
	int last=v.back();
	v2.push_back(v.back());
	s2.insert(v.back());
	v.pop_back();
	int vs=v.size();
	for(int i=1;i<vs;i++){
		if(last==v.back()){
			break;
		}else{
			v2.push_back(v.back());

			s2.insert(v.back());
			v.pop_back();
		}
	}
//	for(int i=0;i<v2.size();i++){
//		cout<<v2[i]<<' ';
//	}cout<<endl;
	int idx=0;
	set<int> s3;
	flag=1;
//	for(auto x:s2){
//			cout<<x<<' ';
//		}cout<<endl;
		vector<int> v3;
	while(flag){
		int temp=v2[idx];
		if(s2.count(temp)==0){
			idx++;
			continue;
		}
		v3.push_back(temp);
		for(int i=0;i<e[temp].size();i++){
			if(s3.count(e[temp][i])){
				flag=0;
				v3.push_back(e[temp][i]);
			}else if(s2.count(e[temp][i])){
				idx++;
				while(v2[idx]!=e[temp][i]){
					s2.erase(v2[idx]);
					idx++;
				}
				idx--;
			}
		}
		idx++;
		s3.insert(temp);
	}
//	for(int i=0;i<v3.size();i++){
//			cout<<v3[i]<<' ';
//		}cout<<endl;
//	for(auto x:s2){
//		cout<<x<<' ';
//	}cout<<endl;
	vector<int> ans;
	ans.push_back(v3.back());
	v3.pop_back();
	while(1){
		int temp=v3.back();
		v3.pop_back();
		if(ans[0]==temp)break;
		if(s2.count(temp)){
			ans.push_back(temp);
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]+1<<endl;
	}
	return 0;
}


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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

double getExpectedValue(int N, int i, int j, int k, vector<vector<vector<double>>>& memo) {
    if (i == 0 && j == 0 && k == 0 || i+j+k > N || i<0 || j<0 || k<0) return 0.0;
    if (memo[i][j][k] > 0) return memo[i][j][k];

    double value = N;
    value += i * getExpectedValue(N, i-1, j, k, memo);
    value += j * getExpectedValue(N, i+1, j-1, k, memo);
    value += k * getExpectedValue(N, i, j+1, k-1, memo);
    value /= (i+j+k);

    memo[i][j][k] = value;

    return value;
}

void solve(int N, vector<int>& A) {
    // dp[i][j][k]: 1, 2, 3
    // dp[i][j][k] = i / N * dp[i-1][j][k] + j / N * dp[i+1][j-1][k] + k / N * dp[i][j+1][k-1] + (N-i-j-k) / N * dp[i][j][k] + 1
    // dp[i][j][k] = 1 / (i+j+k) * {i*dp[i-1][j][k] + j*dp[i+1][j-1][k] + k*dp[i][j+1][k-1] + N}

    vector<vector<vector<double>>> memo(N+1, vector<vector<double>>(N+1, vector<double>(N+1, -1)));

	double answer = getExpectedValue(N, count(all(A), 1), count(all(A), 2), count(all(A), 3), memo);
	stringstream ss;
	ss << setprecision(10) << answer;
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N;
    cin >> N;
    
    vector<int> A(N);
    REP(i,0,N) cin >> A[i];
    
    solve(N, A);
    
    return 0;
}



Measured memory_bytes: 216960
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i:=0; i<len(nums); i++{
		fmt.Scan(&nums[i])
	}
	bubbleSort(nums)
}

func bubbleSort(nums []int){
	count := 0
	for i:=0; i<len(nums); i++{
		for j:=len(nums)-1; j>i; j--{
			if nums[j-1] > nums[j]{
				tmp := nums[j]
				nums[j] = nums[j-1]
				nums[j-1] = tmp
				count++
			}
		}
	}

	for k:=0; k<len(nums); k++{
		fmt.Print(nums[k])
		if k != len(nums)-1{
			fmt.Print(" ")
		}
	}
	fmt.Println("")
	fmt.Println(count)
}




Measured memory_bytes: 1132
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

mod = 10**9+7
N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
    x, y = map(int, input().split())
    G[x].append(y)
    G[y].append(x)
black = [1] * (N+1)
white = [1] * (N+1)

def dfs(prev, u):
    for v in G[u]:
        if v == prev:
            continue
        dfs(u, v)
        black[u] *= white[v]
        black[u] %= mod
        white[u] *= black[v] + white[v]
        white[u] %= mod

dfs(0, 1)
print((black[1] + white[1]) % mod)



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

using namespace std;

int main(void) {
    int x, y;
    int g1[7] = {1, 3, 5, 7, 8, 10, 12}, g2[4] = {4, 6, 9, 11};
    cin >> x >> y;
    
    if (x == 2 || y == 2) cout << "No\n";
    else {
        for (int i = 0; i < 7; i++) {
            if (g1[i] != x) continue;
            for (int j = 0; j < 7; j++) {
                if (g1[j] != y) continue;
                cout << "Yes\n";
                return 0;
            }
        }

        for (int i = 0; i < 4; i++) {
            if (g2[i] != x) continue;
            for (int j = 0; j < 4; j++) {
                if (g2[j] != y) continue;
                cout << "Yes\n";
                return 0;
            }
        }

        cout << "No\n";
    }

    return 0;
}

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

int main() {
  int A,B,C,D,E,K;
  cin >> A >> B >> C >> D >> E >> K;
  
  if(E - A > K){
    cout << ":(" << endl;
  }
  
  else{
    cout << "Yay!" <<endl;
  }
}

Measured memory_bytes: 256
import sys
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
f.reverse()
if sum(a)<=k:
  print(0)
  sys.exit()
pointer=0
l=0
r=0
for i in range(n):
  r=max(r,a[i]*f[i])
while l+1<r:
  try1=(l+r)//2
  required=0
  for i in range(n):
    required+=(max(0,a[i]-try1//f[i]))
  if required>k:
    l=try1
  else:
    r=try1
required=0
for i in range(n):
  required+=(max(0,a[i]-l//f[i]))
if required>k:
  print(r)
else:
  print(l)


Measured memory_bytes: 117772
n = gets.chomp.to_i
edge = Array.new(n+1).map{Array.new}
(n-1).times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    edge[a] << b
    edge[b] << a
end

cost_a = Array.new(n+1,0)
cost_b = Array.new(n+1,0)

done = Array.new(n+1,false)

queue = [1]
done[1] = true
cost_a[1] = 0
while(queue.size > 0)
    v = queue.pop
    
    edge[v].each do |i|
        if done[i] == false
            done[i] = true
            cost_a[i] = cost_a[v] + 1
            queue.push(i)
        else
        end
    end
end

done = Array.new(n+1,false)

queue = [n]
done[n] = true
cost_b[n] = 0
while(queue.size > 0)
    v = queue.pop
    
    edge[v].each do |i|
        if done[i] == false
            done[i] = true
            cost_b[i] = cost_b[v] + 1
            queue.push(i)
        else
        end
    end
end
b = 0
w = 0
1.upto(n) do |i|
    if cost_a[i] <= cost_b[i]
        b+=1
    else
        w+=1
    end
end
if b <= w
    puts 'Snuke'
else
    puts 'Fennec'
end

Measured memory_bytes: 15100
#include<bits/stdc++.h>
using namespace std;
 long long int memo[10000000]={0};
long long int  gcd(long long int x, long long int y) 
{	long long int a,b;
	a=x;
	b=y;
	if (x == 0) {
  		return y;
  	}
 	while (y != 0) {
    	if (x > y) {
      		x = x - y;
    }
    	else {
      		y = y - x;
    	}
  	}
	return x;
}
int main()
{	ios::sync_with_stdio(false);
	 long long int sum=0;
	long long int k;
	long long int y;
	cin>>k;
	for( int i=1;i<=k;i++)
	{
		for( int j=1;j<=k;j++)
		{
			for(int l=1;l<=k;l++)
			{		//if(memo[i*j*l]!=0) 
					//	sum+=memo[i*j*l];
					//else 
					//{
					y=gcd(gcd(i,j),l);
					sum+=y;
					//memo[i*j*l]=y;
					
	
		}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	V<int> a(3);
	fo(i,3)
	cin>>a[i];
	Sort(a);
	cout<<a[0]+a[1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> x[n], y[n];
    rep(i, n) {
        cin >> a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        rep(j, a[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++) {
        vector<int> cur(n);
        int cnt = 0;
        bool ok = 1;

        rep(i, n) {
            if((bit >> i) & 1) {
                cur[i] = 1;
                cnt++;
            }
        }

        rep(i, n) {
            rep(j, a[i]) {
                if(cur[i]) {
                    if(cur[x[i][j]] != y[i][j]) ok = 0;
                }
            }
        }
        if(ok) chmax(ans, cnt);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    else:
        sum1=m+f
        if m==-1 or f==-1:
            print("F")
        else:
            if 80<=sum1:
                print("A")
            if 65<=sum1<80:
                print("B")
            if 50<=sum1<65:
                print("C")
            if 30<=sum1<50:
                if r>=50:
                    print("C")
                else:
                    print("D")
            if sum1<30:
                print("F")


Measured memory_bytes: 5596
def toSecond str
    arr = str.split(":").map(&:to_i)
    return arr[0] * 3600 + arr[1] * 60 + arr[2]
end

while true
    n = gets.to_i
    break if n == 0

    arr = []
    n.times{arr << gets.chomp.split.map{|str| toSecond(str)}}
    arr.sort_by!{|a, b| [a, b]}
    
    yoyu, train, arr2 = 0, 0, []
    arr.each{|start, goal|
        before = arr2.length
        arr2.delete_if{|t| t <= start}
        yoyu += before - arr2.length
        if yoyu > 0
            yoyu -= 1
        else
            train += 1
        end
        arr2 << goal
    }
    puts train
end



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

int main() {
  int n,d,x,a,cnt=0;
  cin >> n >> d >> x;
  for(int i=0 ;i<n ;i++){
    cin >> a;
    cnt += (d-1)/a+1;
  }
  cout << cnt + x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long Q, H, S, D, N;
int main() {
	cin >> Q >> H >> S >> D >> N;
	int ms = min({ Q * 4, H * 2, S });
	int md = min({ Q * 8, H * 4, S * 2, D });
	cout << (N / 2) * md + (N % 2) * ms << endl;
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> x(n), y(n);
  rep(i, n) {
    ll a, b; cin >> a >> b;
    x[i] = a+b;
    y[i] = a-b;
  }
  sort(ALL(x));
  sort(ALL(y));

  ll ans = max(abs(x.front()-x.back()), abs(y.front()-y.back()));
  cout << ans << endl;
}

Measured memory_bytes: 6368
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();

        boolean ease = true;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (i % 2 == 0) {
                if (c == 'L') ease = false;
            } else {
                if (c == 'R') ease = false;
            }
        }

        if (ease) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int n, m;
    cin >> n >> m;

    cout << (m * (m - 1) / 2) + (n * (n - 1) / 2);

    return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i * j == n) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    ll n, d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        ll now = x*x + y*y;
        ans += (now <= d);
    }
    cout << ans << en;
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3648
import Control.Monad.State

type Stack a = StateT [a] IO a

main = getContents >>=  (\x -> evalStateT (moveCars x) []).map read.lines
pop :: Stack a
pop = do
    (x:xs) <- get
    put xs
    return x

push :: a -> Stack a
push x = do
    xs <- get
    put (x:xs)
    return x

moveCars :: [Int] -> StateT [Int] IO ()
moveCars lst = sequence_ $ map toFunc lst

toFunc :: Int -> Stack Int
toFunc x = if x == 0 then do
                         n <- pop
                         liftIO $ print n
                         return n
                     else push x

Measured memory_bytes: 3896
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

ll cnt[2000][2000][2];

ll pre_h, pre_w = -1;
V<string> vs;
ll H, W;

ll dfs(ll h, ll w, bool dh, ll cnt_now) {
    (dh ? pre_h : pre_w)++;
    DEBUG(h, w);
    if(!(0 <= h && h < H &&
         0 <= w && w < W)) return cnt_now;
    if(vs[h][w] == '#') return cnt_now;
    cnt_now++;
    return cnt[h][w][(dh ? 0 : 1)] = dfs(h + dh, w + !dh, dh, cnt_now);
}

int main() {
    cin >> H >> W;
    vs.resize(H);
    for(auto &s : vs) cin >> s;

    for(ll h = 0; h < H; h++) {
        pre_w = -1;
        while(pre_w < W) dfs(h, pre_w + 1, false, 0);
    }
    for(ll w = 0; w < W; w++) {
        pre_h = -1;
        while(pre_h < H) dfs(pre_h + 1, w, true, 0);
    }

    ll ans = 0;
    for(ll h = 0; h < H; h++) for(ll w = 0; w < W; w++) if(vs[h][w] == '.') {
        ll tmp = cnt[h][w][0] + cnt[h][w][1] - 1;
        DEBUG(make_tuple(cnt[h][w][0], cnt[h][w][1], h, w, tmp));
        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67200
#include "bits/stdc++.h"
using namespace std;

int calc(vector<vector<bool>> &graph){
  int area = 0;
  for(int i = graph.size() - 1; i >= 0; i--){
    for(int j = 0; j < graph.at(i).size(); j++){
      if(graph.at(i).at(j)){
        // cout << "o";
        area++;
        // }else{
          // cout << "x";
      }
    }
    // cout << endl;
  }
  return area;
}

void draw(vector<vector<bool>> &graph, int x, int y, int n){
  if(n == 1){
    for(int i = 0; i < graph.size(); i++){
      for(int j = 0; j < x; j++){
        graph.at(i).at(j) = false;
      }
    }
  }
  if(n == 2){
    for(int i = 0; i < graph.size(); i++){
      for(int j = x; j < graph.at(i).size(); j++){
        graph.at(i).at(j) = false;
      }
    }
  }

  if(n == 3){
    for(int i = 0; i < y; i++){
      for(int j = 0; j < graph.at(i).size(); j++){
        graph.at(i).at(j) = false;
      }
    }
  }

  if(n == 4){
    for(int i = y; i < graph.size(); i++){
      for(int j = 0; j < graph.at(i).size(); j++){
        graph.at(i).at(j) = false;
      }
    }
  }
}

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<bool>> graph(H, vector<bool>(W, true));
  for(int i = 0; i < N; i++){
    int x, y, n;
    cin >> x >> y >> n;
    draw(graph, x, y, n);
  }

  int ans = calc(graph);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define cub(x) ((x)*(x)*(x))
int main(int argc, char const *argv[])
{
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	if(k & 1)
	{
		ans = cub(n / k);
	}
	else
	{
		k >>= 1;
		ans = cub((n + k) / k / 2) + cub(n / k / 2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

map<ll, ll> m;

ll rec (ll a) {
    if (m.find(a) != m.end()) return m[a];
    return m[a] = 2*rec(a/2) + 1;
}

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

    ll H;
    cin >> H;

    m[1] = 1;
    cout << rec(H) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int h,w;
    cin >> h >> w;
    vector<int> a(h),b(h);
    rep(i,h){
        cin >> a[i] >> b[i];
        --a[i];--b[i];
    }

    map<int,int> mp;
    multiset<int> st;
    rep(i,w){
        mp[i]=i;
        st.insert(0);
    }
    vector<int> ans(h,-1);

    rep(i,h){
        auto it = mp.lower_bound(a[i]);

        int mr = -1;
        while(it != mp.end() && (it->first) <= b[i]+1){
            mr = max(mr,it->second);
            st.erase(st.find(it->first-it->second));
            it = mp.erase(it);
        }

        if(mr != -1 && b[i] < w-1){
            st.insert(b[i]+1-mr);
            mp[b[i]+1] = mr;
        }

        if((int)st.size() > 0){
            ans[i] = *st.begin() + i + 1;
        }
    }

    rep(i,h) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 24332
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}

int main() {
  int n; cin>>n;
  string s; cin>>s;
  int u[n], ii = 0;
  for(int i=0;i<n;i++) {
    if (s[i] == 'W') u[ii++] = i;
  }
  int an = 0, jj = 0;
  for(int i=n-1;i>=0;i--) {
    if (s[i] == 'R') {
      if (ii > jj && u[jj] < i) {
        an++; jj++;
      }
    }
  }
  cout<<an<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


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

#define LL long long int
#define mp make_pair
#define FOR(i, n) for(i = 0; i < n; ++i)
typedef vector <int> vi;
typedef vector <LL> vll;
typedef pair<LL, LL> iPair;
const int MOD = 1e9+7;

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

    LL t = 1;
    LL i,j;
    // cin>>t;
    
    while(t--)
    {
        int n, k;
        string s;
        cin>>n>>k;
        cin>>s;
        vector <char> arr(n);
        if(n==1) {
            cout<<"0";
            exit(0);
        }
        for(int i = 0;i < n; ++i) arr[i] = s[i];

        auto ip = unique(arr.begin(), arr.end());
        int a = ip - arr.begin();
        arr.resize(a);
        int ans = n - a;
        
        if(a%2==0)ans += min(2*k,2 *  ((a-1)/2) + 1);
        else ans += min(2*k,2 *  ((a-1)/2));

        cout<<ans;
        
    }

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,p;string s;cin >> n;
  pair<pair<string,int>,int> ans[n];
  for(i=0;i<n;i++){
    cin >> s >> p;
    ans[i] = make_pair(make_pair(s,-p),i+1);
  }
  sort(ans,ans+n);
  for(auto x:ans) cout << x.second << endl;
}

Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

AS, BS = stdin.readline().split()
A = int(AS)
B100 = int(BS.replace(".",""))

print((A * B100)//100) 



Measured memory_bytes: 9040