akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#define io ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=1e3+10;
char s[N][N];
int d[N][N];
struct node{
    int x,y,d;
};
int n,m,sx,sy,ex,ey;
bool check(int i,int j){
    return i>=1&&i<=n&&j>=1&&j<=m;
}
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
void solve(){
    //cin>>n>>m>>sx>>sy>>ex>>ey;
    scanf("%d%d%d%d%d%d",&n,&m,&sx,&sy,&ex,&ey);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    deque<node> q;
    memset(d,inf,sizeof(d));
    q.push_front(node{sx,sy,0});
    d[sx][sy]=0;
    while(q.size()){
        node p=q.front();q.pop_front();
        if(p.x==ex&&p.y==ey){
           break;
        }
        for(int k=0;k<4;k++){
            int x=p.x+dx[k],y=p.y+dy[k];
            if(!check(x,y))continue;
            if(s[x][y]=='#')continue;
            if(d[x][y]>d[p.x][p.y]){
                q.push_front(node{x,y,p.d});
                d[x][y]=d[p.x][p.y];
            }
        }
        for(int i=p.x-2;i<=p.x+2;i++){
            for(int j=p.y-2;j<=p.y+2;j++){
                if(!check(i,j))continue;
                if(s[i][j]=='#')continue;
                if(d[i][j]>d[p.x][p.y]+1){
                    d[i][j]=d[p.x][p.y]+1;
                    q.push_back(node{i,j,p.d+1});
                }
            }
        }
    }
    if(d[ex][ey]==inf)cout<<-1;
    else cout<<d[ex][ey];
}
int main(){
    //io;
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 8188
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	char N[3] = {};
	cin >> N;

	if ((N[0]=='9')||(N[1]=='9')){printf("Yes\n");}else{printf("No\n");}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    int n;
    cin>>n;
    ll k,q;
    cin>>k>>q;
    vector<ll>a(n);ll s=0;
    for(int i=0;i<n;i++)a[i]=0;
    for(int i=0;i<q;i++){
       int f;
       cin>>f;
       f--;
       a[f]++;
    }
    for(int i=0;i<n;i++){
        ll g = k-q+a[i];
        if(g<=0)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;

    }





    return 0;
}


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

int main() {
  int n,m;
  while(cin >> n >> m&& n) {
    int d[n][n],a[n];
    memset(d,0,sizeof(d));
    memset(a,0,sizeof(a));
    for(int i=0; i<m; i++) {
      int x,y;
      cin >> x >> y;
      d[x-1][y-1]=d[y-1][x-1]=1;
    }
    for(int i=0; i<n; i++) {
      if(d[0][i]) {
	a[i]=1;
	for(int j=0; j<n; j++) a[j]|=d[i][j];
      }
    }
    int ans=0;
    for(int i=1; i<n; i++) ans+=a[i];
    cout << ans << endl;
  }
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int cnt[1000];
signed main(){
    int n,m;
    int a,b;
    cin >> n >> m;
    rep(i,m){
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }   
    reps(i,n) cout << cnt[i] << '\n';
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

const ll BIG = 1'000'000'000;

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    mcf_graph<ll, ll> G(2*N + 2);
    ll s = 2*N;
    ll t = 2*N + 1;

    // 捨てる辺(K以下なので、使わない場合はここを通すイメージ)
    G.add_edge(s, t, N*K, BIG);

    // s,tと結ぶ辺
    REP(i, N){
        G.add_edge(s, i, K, 0);
        G.add_edge(N+i, t, K, 0);
    }

    REP(i, N){
        REP(j, N){
            ll a;
            cin >> a;

            // 辺を張る
            G.add_edge(i, N+j, 1, BIG-a);
        }
    }

    auto result = G.flow(s, t, N*K);

    cout << N*K*BIG - result.second << endl;

    vector<vector<char>> ans(N, vector<char>(N, '.'));

    auto edges = G.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0) continue;

        // cout << e.from << " " << e.to << endl;
        ll v0 = e.from;
        ll v1 = e.to - N;
        ans[v0][v1] = 'X';
    }

    REP(i, N){
        REP(j, N){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
lld fuck(lld x)
{
    lld cnt=0;
    while(x>0)
    {
        x=x/10;
        cnt++;
    }
    return cnt;
}
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        cin>>n;
        for(i=1;i<=n;i++)
        {
            x=fuck(i);
            if(x%2==1)
                ans++;
        }
        cout<<ans<<endl;

    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[5],x,y;
int main(){
   for(int i=1;i<=4;i++)
   scanf("%d",&a[i]);
   x=a[1]-a[3];y=a[4]-a[2];
   printf("%d %d %d %d",a[3]-y,a[4]-x,a[1]-y,a[2]-x);
}

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

using namespace std;

int main()
{


long long int h,a;
cin >> h >> a;
long long sum=0;
for (int i=0; i<a; i++ )
    {   long long now;
        cin >> now;
        sum+=now;
    }
if (h<=sum) cout <<"Yes"; else cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
   char s[1<<19], t[1<<19];
   int count = 0;
   scanf("%s", s);
   scanf("%s", t);
   for(int i = 0; i < 200000; i++){
       if(s[i] != t[i]){
           s[i] = t[i];
           count++;
       }
   }
   printf("%d\n", count);
}    


Measured memory_bytes: 2128
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;


int main() {
	ll n, k,d,mem;
	cin >> n >> k;
	vector<ll> okashi(n, 0);
	for (ll i = 0; i < k; i++) {
		cin >> d;
		for (ll j = 0; j < d; j++) {
			cin >> mem;
			okashi[mem - 1] ++;
		}
	}
	mem = 0;
	for (ll i = 0; i < n; i++) {
		if (okashi[i] == 0) {
			mem++;
		}
	}
	cout << mem << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<int>d(N);
  for(int i=0;i<N;i++)cin>>d[i];
  ll ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans+=d[i]*d[j];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import heapq

n, m= list(map(int, input().split()))
a = list(map(lambda x: -1*int(x), input().split()))
#print(a)
heapq.heapify(a)
#print(a)

for i in range(m):
  maxa = heapq.heappop(a)
  heapq.heappush(a, maxa/2)
  
ans = 0
for i in range(n):
  ans += int(heapq.heappop(a))
  
print(-ans)

Measured memory_bytes: 14180
#include <cstdio>
#include <iostream>
using namespace std;
#define mod 1000000007
int x[100010];

int main(){
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    x[k]++;
  }
  if (n % 2 == 1) {
    bool flag = true;
    long long ans = 1;
    if (x[0] != 1) flag = false;
    for (int i = 2; i < n; i += 2) {
      if (x[i] != 2) flag = false;
      ans *= 2;
      ans %= mod;
    }
    if (!flag) cout << 0 << endl;
    else cout << ans << endl;
  } else {
    bool flag = true;
    long long ans = 1;
    for (int i = 1; i < n; i += 2) {
      if (x[i] != 2) flag = false;
      ans *= 2;
      ans %= mod;
    }
    if (!flag) cout << 0 << endl;
    else cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 640
from collections import deque
def BFS(N,M,List):
    Graph = [[] for T in range(N+1)]
    for NodeM in range(0,M):
        Graph[List[NodeM][0]].append(List[NodeM][1])
        Graph[List[NodeM][1]].append(List[NodeM][0])

    Distance = [-1]*(N+1)
    Distance[0] = 0
    Distance[1] = 0
    From = [0]*(N+1)
    From[1] = 1

    Deque = deque()
    Deque.append(1)
    while Deque:
        V = Deque.popleft()
        for NodeV in Graph[V]:
            if Distance[NodeV]==-1:
                Distance[NodeV] = Distance[V]+1
                Deque.append(NodeV)
                From[NodeV] = V

    return Distance[1:],From[1:]
  
N,M = (int(X) for X in input().split())
List = [[] for T in range(0,M)]
for T in range(0,M):
    List[T] = [int(X) for X in input().split()]
Distance,From = BFS(N,M,List)
print('\n'.join(['Yes']+[str(X) for X in From[1:]]))

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

const int maxn = 20 + 5;
int h[maxn];

int main()
{
    int n = 0;  cin >> n;
    int temp = -9999;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
        temp = max(temp, h[i]);
        if (i)
        {
            if (h[i] >= temp)   ans++;
        }
        else
        {
            ans++;
        }
        
    }
    cout << ans;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

struct Edge{
  int u,v; double cost;
  Edge(){}
  Edge(int u, int v, double cost):u(u),v(v),cost(cost){}
  bool operator<(const Edge &a)const{
    return cost < a.cost;
  }
};

struct UnionFind{
  int par[10005];
  int rank[10005];
  UnionFind(int n){ init(n); }
  void init(int n){
    for(int i=0;i<n;i++){
      par[i] = i;
      rank[i] = 0;
    }
  }
  int find(int x){
    if(x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  int same(int x, int y){
    return find(x) == find(y);
  }
  void unite(int x, int y){
    x = find(x); y = find(y);
    if(x==y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }
};

Edge es[50000000];
int N,M;
int x[10005],y[10005];

double kruskal(){
  UnionFind uf(N);
  double res = 0;
  sort(es, es+M);
  for(int i=0;i<M;i++){
    Edge e = es[i];
    if(!uf.same(e.u, e.v)){
      uf.unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}
  
int main(){
  double sum = 0.0;

  scanf("%d%d",&N,&M);
  rep(i,N) scanf("%d%d", &x[i],&y[i]);
  rep(i,M){
    int p,q;
    scanf("%d%d",&p,&q); p--; q--;
    es[i] = Edge(p,q, -sqrt(SQ(x[p]-x[q])+SQ(y[p]-y[q])));
    sum += sqrt(SQ(x[p]-x[q])+SQ(y[p]-y[q]));
  }
  //  printf("%lf %lf\n",sum,kruskal());
  printf("%lf\n", sum+kruskal());
  return 0;
}

Measured memory_bytes: 1824
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define MAX_N 1000
const int INF = 1e9 + 7;
char s1[MAX_N + 1], s2[MAX_N + 1];
int num1, num2, dp[MAX_N + 1][MAX_N + 1];

void DP() {
	REP(i, num1) REP(j, num2) {
		dp[i + 1][j + 1] = min({(s1[i] == s2[j]) ? dp[i][j] : INF, dp[i + 1][j] + 1, dp[i][j + 1] + 1, dp[i][j] + 1});
	}
	cout << dp[num1][num2] << "\n";
}

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

	cin >> s1 >> s2;
	num1 = strlen(s1);
	num2 = strlen(s2);
	REP(i, num1 + 1) REP(j, num2 + 1) {
		dp[i][j] = INF;
	}
	REP(i, num1 + 1) dp[i][0] = i;
	REP(i, num2 + 1) dp[0][i] = i;

	DP();

	return 0;
}



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

int main(){
	int n; cin>>n;
	string s; cin>>s;
	int r=0, b=0;
	rep(i,n){
		if(s[i]=='R') r++;
		else b++;
	}
	cout<<(r>b?"Yes":"No")<<endl;
}

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

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

    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s.at(i);

    sort(s.begin(), s.end());

    int cnt = 1;
    for (int i = 1; i < n; i++) {
        if (s.at(i-1) != s.at(i)) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

constexpr inline ll mod = 998244353;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int n, s;
    cin >> n >> s;
    vector<int> as(n);
    rep(i, n) {
        cin >> as[i];
    }

    ll res = 0;
    vector<ll> dp(s+1);
    rep(i, n) {
        int a = as[i];
        if (a > s) {
            continue;
        }
        ll prev = dp[s];
        for (int j = s - a; j >= 1; j--)
        {
            dp[j + a] += dp[j];
            dp[j + a] %= mod;
        }
        dp[a] += i + 1;
        dp[a] %= mod;
        res += (dp[s] - prev + mod) * (n - i) % mod;
        res %= mod;
    }
    cout << res << endl;

    return 0;
}


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

namespace abc096_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = int.Parse(Console.ReadLine());
            Array.Sort(x);
            x[2] *= (int)Math.Pow(2, n);
            Console.WriteLine(x.Sum());
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
  int k,s;

  cin>>k>>s;
  int ans = 0;
  for(int i = 0;i<=k;i++){
    for(int j = 0;j<=k;j++){
      int z = s-(i+j);
      if(z >= 0 && z <= k)
	ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){

	int i,count[26]={0};
	char word;

	while(scanf("%c",&word)!=EOF){
		if(word>='a'&&word<='z')
			count[word-'a']++;
		else if(word>='A'&&word<='Z')
			count[word-'A']++;
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,count[i]);
	}
	return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> s(n+1, 1);
  vector<ll> p(n+1, 1);
  ll ans = 0;
  rep(i, n) {
    s[i+1] = 2 * s[i] + 3;
    p[i+1] = 2 * p[i] + 1;
  }
  repr(i, n) {
    if (x < s[i]) {
      x--;
      continue;
    }
    ans += p[i];
    x -= s[i];
    if (x) {
      ans++;
      x--;
    }
    i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int abs(int x){
    if(x > 0) return x;
    else return -x;
}

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

    if(abs(a - b) <= d && abs(b - c) <= d){
        puts("Yes");
        return 0;
    }else if (abs(a - c) <= d){
        puts("Yes");
        return 0;      
    } 
    puts("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
    ll a,b;
    cin>>a>>b;
     b = 2*b+1;
    ll ans = ceil(a/(double)b);
    cout<<ans;
}


Measured memory_bytes: 256
N=int(input())
arr=[]
temp=N
for i in range(2, int(N**0.5//1+1)):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp=temp//i
        # arr.append([i,cnt])
        arr.append(cnt)
if temp!=1:
    # arr.append([temp,1])
    arr.append(1)
if arr==[] and N!=1:
    # arr.append([N,1])
    arr.append(1)
# print(arr)
ans=0
for i in range(len(arr)):
    for n in range(1,100):
        if arr[i]>=n:
            ans+=1
            arr[i]-=n
        else:
            break
print(ans)

Measured memory_bytes: 9372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS

int main(int argc, char const *argv[])
{
	double n,k;
	double sumRate = 0.00000000;
	double tempRate;

	scanf("%lf %lf",&n,&k);
	for (double i = 1.00; i <= n; i += 1.00)
	{
		if(i < k)	tempRate = pow(0.50000000, ceil(log2(k / i))) / n;
		else tempRate += 1.0000000000 / n;
		sumRate += tempRate;
		tempRate = 0.00000000;
	}
	printf("%.12f\n", sumRate);
	return 0;
}


Measured memory_bytes: 128
# 2019/08/09

a,b,c=map(int,input().split())
if a==b==c:
    if a%2:
        print(0)
    else:
        print(-1)
    exit()

cnt=0
while a%2==0 and b%2==0 and c%2==0:
    a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
    cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<iostream>
#include<algorithm>
#define ll long long

using namespace std;

const int N = 4e5+10; 

ll sum[N],ans;
ll n,k;
vector<ll>Q;

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


struct bttree{
	ll t[N<<1];
	void add(ll x){while(x<=N){t[x]++,x+=x&(-x);}}
	ll query(ll x,int r=0){for(;x;x-=x&(-x))r+=t[x];return r;}
}tr;
int main(){
	cin>>n>>k;
	for(ll i=1;i<=n;i++){sum[i]=read();sum[i]+=sum[i-1]-k;}//*****
	for(ll i=0;i<=n;i++)Q.push_back(sum[i]);
	sort(Q.begin(),Q.end());
	for(ll i=0;i<=n;i++)sum[i]=lower_bound(Q.begin(),Q.end(),sum[i])-Q.begin()+1;//***
	for(ll i=0;i<=n;i++){		
		ans+=tr.query(sum[i]);
		tr.add(sum[i]);		
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, m, c;
    cin >> n >> m >> c;
    ll ans = 0;
    vector<ll> b(m);
    rep(i, 0, m) cin >> b[i];
    rep(i, 0, n) {
        ll tmp = c;
        rep(j, 0, m){
            ll a;
            cin >> a;
            tmp += a * b[j];
        }
        if(tmp > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define maxn 1000100
#define mod 1000000007
using namespace std;
int fac[maxn],inv[maxn],A[10010];
int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)ans=1ll*ans*a%mod;
	return ans;
}
int C(int x,int y){
	if(y<0||y>x)return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main(){
	int n;
	scanf("%d",&n);
	inv[0]=1,fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=1;--i)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	int ans=0;
	for(int i=0;i<n;++i)
		ans=(ans+1ll*(C(n-1,i)-C(i-1,n-i-1)+mod)*fac[i]%mod*fac[n-i-1]%mod)%mod;
	printf("%d",ans);
}

Measured memory_bytes: 8064
n = input()
S = [raw_input() for i in xrange(2)]

dp = [[[0]*3 for i in xrange(3)] for j in xrange(n)]

MOD = 10**9 + 7

if S[0][0] == S[1][0]:
    for i in xrange(3):
        dp[0][i][i] = 1
else:
    for i in xrange(3):
        for j in xrange(3):
            if i == j:
                continue
            dp[0][i][j] = 1

for i in xrange(1, n):
    if S[0][i-1] == S[0][i]:
        for p in xrange(3):
            for q in xrange(3):
                dp[i][p][q] = dp[i-1][p][q]
    else:
        if S[0][i-1] == S[1][i-1]:
            if S[0][i] == S[1][i]:
                # AB
                # AB
                for s in xrange(3):
                    for t in xrange(3):
                        if s == t:
                            continue
                        dp[i][s][s] += dp[i-1][t][t]
                        dp[i][s][s] %= MOD
            else:
                # AB
                # AC
                for u in xrange(3):
                    for s in xrange(3):
                        if u == s:
                            continue
                        for t in xrange(3):
                            if u == t or t == s:
                                continue
                            dp[i][s][t] += dp[i-1][u][u]
                            dp[i][s][t] %= MOD
        else:
            if S[0][i] == S[1][i]:
                # AC
                # BC
                for u in xrange(3):
                    for s in xrange(3):
                        if u == s:
                            continue
                        for t in xrange(3):
                            if u == t or t == s:
                                continue
                            dp[i][u][u] += dp[i-1][s][t]
                            dp[i][u][u] %= MOD
            else:
                # AC ps
                # BD qt
                for p in xrange(3):
                    for q in xrange(3):
                        if p == q:
                            continue
                        for s in xrange(3):
                            if p == s:
                                continue
                            for t in xrange(3):
                                if s == t or q == t:
                                    continue
                                dp[i][s][t] += dp[i-1][p][q]
ans = 0
for i in xrange(3):
    for j in xrange(3):
        ans += dp[n-1][i][j]
print ans % MOD

Measured memory_bytes: 2824
N,M = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(M)]

right = N
left = 0

for i in e:
    if left < i[0]:
        left = i[0]
    if right > i[1]:
        right = i[1]
if right >= left:
    print(right - left + 1) 
else:
    print("0")


Measured memory_bytes: 21156
#include<iostream>
using namespace std;
int main(){
    int x,y,z;
    cin>>x>>y>>z;
    if(x==y&&z!=y)
    {
      cout<<z<<endl;
    }
   else if(z==y&&z!=x)
    {
      cout<<x<<endl;
    }
   else if(x==z&&z!=y)
    {
      cout<<y<<endl;
    }
  
  return 0;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())

answer = [int(input()) for i in range(q)]

l = [0 for i in range(10**5)]

for i in answer:
    l[i-1] += 1

for i in range(n):
    if l[i] > (q-k):
        print('Yes')
    
    else:
        print('No')

Measured memory_bytes: 8636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

ll N;
ll solve(){
   ll ans=0;
   

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

    cin>>N;
    for(int h=1;h<=3500;h++){
        for(int n=1;n<=3500;n++){
            ll numerator=h*n*N;
            ll denominator=4*h*n-n*N-h*N;
            if(denominator!=0&&numerator%denominator==0){
                ll res=numerator/denominator;
                if(res>0&&res<=3500){
                cout<<h<<" "<<n<<" "<<res;
                return 0;
                }
            }
        }
    }
    //cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

#define IMGHGT 100
#define IMGWDT 100
#define FRMHGT (IMGHGT + 2)
#define FRMWDT (IMGWDT + 2)

int ih, iw, fh, fw;
char id[IMGHGT][IMGWDT], fd[FRMHGT][FRMWDT];

void read(void)
{
    int r, c;
    
    scanf("%d %d%*[\n]", &ih, &iw);
    for (r = 0; r < ih; ++r) {
        for (c = 0; c < iw; ++c)
            scanf("%c", &id[r][c]);
        scanf("%*[\n]");
    }
}

void exec(void)
{
    int ir, ic, fr, fc;
    
    fh = ih + 2, fw = iw + 2;
    for (fr = 0, fc = 0; fc < fw; ++fc)
        fd[fr][fc] = '#';
    for (fr = 1, ir = 0; ir < ih; ++ir, ++fr) {
        fd[fr][fc = 0] = '#';
        for (++fc, ic = 0; ic < iw; ++ic, ++fc)
            fd[fr][fc] = id[ir][ic];
        fd[fr][fc] = '#';
    }
    for (fr = fh - 1, fc = 0; fc < fw; ++fc)
        fd[fr][fc] = '#';
}

void write(void)
{
    int fr, fc;
    
    for (fr = 0; fr < fh; ++fr) {
        for (fc = 0; fc < fw; ++fc)
            printf("%c", fd[fr][fc]);
        putchar('\n');system("pause > NUL");
    }
}

int main(void)
{
    read();
    exec();
    write();
    return 0;
}


Measured memory_bytes: 460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
ll a[200010];
ll dp[200010][6];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n){
		dp[i+1][0]=a[i]              +dp[i][0];
		dp[i+1][1]=(a[i]==0?2:a[i]%2)+min(dp[i][0],dp[i][1]);
		dp[i+1][2]=(a[i]+1)%2        +min(dp[i][0],min(dp[i][1],dp[i][2]));
		dp[i+1][3]=(a[i]==0?2:a[i]%2)+min(dp[i][0],min(dp[i][1],min(dp[i][2],dp[i][3])));
		dp[i+1][4]=a[i]              +min(dp[i][0],min(dp[i][1],min(dp[i][2],min(dp[i][3],dp[i][4]))));
		rep(j,0,5)dp[i+1][j]=min(dp[i+1][j],INF);
	}
	printf("%lld",min(dp[n][0],min(dp[n][1],min(dp[n][2],min(dp[n][3],dp[n][4])))));
}

Measured memory_bytes: 11136
N = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if p[i] == i+1:
        if i != N-1:
            temp = p[i]
            p[i] = p[i+1]
            p[i+1] = temp
            cnt += 1
        else:
            cnt += 1
print(cnt)

Measured memory_bytes: 52908
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int dp[100100][4];
int ha[100100][5];
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ha[i][1]>>ha[i][2]>>ha[i][3];
	}
	dp[1][1]=ha[1][1];
	dp[1][2]=ha[1][2];
	dp[1][3]=ha[1][3];
	for(int i=2;i<=n;i++){
		for(int j=1;j<=3;j++){
			dp[i][j]=0;
			for(int k=1;k<=3;k++){
				if(j!=k){
					dp[i][j]=max(dp[i][j],dp[i-1][k]);
				}
			}
			dp[i][j]+=ha[i][j];
		}
	}
	cout<<max(max(dp[n][1],dp[n][2]),dp[n][3])<<endl;
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;
inline int mul(int x, int y) {return (ll)x * y % mod;}
inline int inc(int x, int y) {x += y; return x >= mod ? x - mod : x;}
inline int qpow(int x, int y)
{
	int res = 1;
	for (; y; y >>= 1, x = (ll)x * x % mod)
		if (y & 1) res = (ll)res * x % mod;
	return res; 
}
const int MAXN = 1e6 + 10;
int n, fac[MAXN], inv[MAXN];
inline int binom(int x, int y) {return y < 0 || y > x ? 0 : mul(fac[x], mul(inv[y], inv[x - y]));}

int main()
{
	cin >> n;
	if (n == 2) return puts("1"), 0;
	if (n == 3) return puts("4"), 0;
	fac[0] = inv[0] = 1;
	for (int i = 1; i <= n; i ++)
		fac[i] = mul(fac[i - 1], i);
	inv[n] = qpow(fac[n], mod - 2);
	for (int i = n; i >= 2; i --)
		inv[i - 1] = mul(inv[i], i);
	int ans = fac[n - 1];
	for (int i = 1; i < n - 1; i ++)
	{
		int cnt = binom(i - 1, n - i - 1);
		cnt = mul(cnt, fac[i]);
		cnt = mul(cnt, fac[n - i - 1]);
		cnt = inc(fac[n - 1], mod - cnt);
		ans = inc(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
int main() {
	int a, b, c, d;
	double e;
	scanf("%d%d", &a, &b);
	c = a / b;
	d = a % b;
	e = (double)a / b;
	printf("%d %d %f", c, d, e);
	return 0;
}

Measured memory_bytes: 2756
#include<stdio.h>
int main(){
  int n,m,i,j;
  scanf("%d %d",&n,&m);
  if(m==0){
    for(i=0;i<(1<<n);i++){
      if(i)printf(" ");
      printf("%d %d",i,i);
    }
    printf("\n");
    return 0;
  }
  if((1<<n)<=m||(n==1&&m==1)){
    printf("-1\n");
    return 0;
  }
  for(i=0;i<(1<<n);i++){
    if(i-m)printf("%d ",i);
  }
  printf("%d ",m);
  while(i--){
    if(i-m)printf("%d ",i);
  }
  printf("%d\n",m);	    
  return 0;
}


Measured memory_bytes: 1792
#import <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392, X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288, X20 = 1048576;

ll cnt = 0;
class UnionFind {
private:
    vector<int> p, rank;
    int N;
    int findSet2(int i, bool* A){A[i] = 1;return (p[i] == i) ? i : (p[i] = findSet2(p[i], A));}
public:
    UnionFind(int N) {
        rank.assign(N, 0);
        p.assign(N, 0);
        for (int i = 0; i < N; i++) p[i] = i;
        this->N = N;
    }

    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }

    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }

    void unionSet(int i, int j) {
        if (!isSameSet(i, j)) {
// if from different set
            int x = findSet(i), y = findSet(j);
            if (rank[x] > rank[y]) p[y] = x;
// rank keeps the tree short
            else {
                p[x] = y;
                if (rank[x] == rank[y]) rank[y]++;
            }
        }
    }


    int numDisjointSets(){
        set<int> s;
        bool* visited = new bool[this->N];
        memset(visited, 0, sizeof(bool)*this->N);
        for (int i = 0; i < N; ++i) {
            if(!visited[i])s.insert(findSet2(i, visited));
        }
        return s.size();
    }

    int maxElements(){
        int mx = 0;
        map<int, int> m;
        for (int i = 0; i < N; ++i) {
            m[findSet(i)] ++;
        }
        set<pair<int, int>> s;
        for(auto p : m){
            s.insert({p.second, p.first});
        }
        return s.rbegin()->first ;
    }


};


void _() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        cnt += (bool)isupper(s[i]);
    }
    cout << (s[0]-'A' || cnt -2 || s[1]=='C'|| s[s.size()-1]=='C'? "WA" : "AC");
}


int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








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

using namespace std;
int main(){
	string S,ans;
  	int i;
  	cin >> S;
  	
  	if(S.length()%2 != 0) ans = "No";
  	else{
    	for(i=0;i<S.length();i++){
        	if(i%2==0){
            	if(S[i]!='h'){
                  ans = "No";
              	  break;
                }
            }
          	else{
            	if(S[i]!='i'){
                	ans = "No";
                  	break;
                }
              	ans = "Yes";
            }
        }
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split());M=[input()for _ in"_"*H];D=[[0]*-~W for _ in"_"*-~H];m=999
for i in range(H):
  for j in range(W):D[i+1][j+1]=min([m,D[i][j+1]+(M[i-1][j]>M[i][j])][i>0],[m,D[i+1][j]+(M[i][j-1]>M[i][j])][j>0],m*(i+j>0))
print(D[-1][-1]+(M[0][0]<".")) 

Measured memory_bytes: 9280
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int N;
    cin >> N;
    int S = 0;
    int n10 = 1e8;
    for(int i = 0; i < N; i++) {
        int s;
        cin >> s;
        if(s % 10 != 0) {
            n10 = min(n10, s);
        }
        S += s;
    }
    if(n10 == 1e8) cout << 0 << endl;
    else cout << S - (S % 10 == 0 ? n10 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
L, R = map(int, input().split())
if R - L + 1 >= 2019:
    print(0)
else:
    x = np.arange(L, R+1)
    x = x % 2019
    m = 2018
    for i in range(len(x)-1):
        y = (x[i+1:]*x[i])%2019
        m = min(m, np.min(y))
    print(m)

Measured memory_bytes: 14292
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=105;
const int INF=0x3f3f3f3f;
string ss[maxn];
int minn[maxn][maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>ss[i];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            if(i==0&&j==0)
            {
                minn[i][j]=(ss[i][j]=='#');
                continue;
            }
            minn[i][j]=INF;
            if(i>0) minn[i][j]=min(minn[i][j],minn[i-1][j]+(ss[i-1][j]=='.'&&ss[i][j]=='#'));
            if(j>0) minn[i][j]=min(minn[i][j],minn[i][j-1]+(ss[i][j-1]=='.'&&ss[i][j]=='#'));
        }
    cout<<minn[n-1][m-1]<<'\n';
    return 0;
}


Measured memory_bytes: 384
/*
[abc106] B - 105
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int N;

ll solve() {
    int ans = 0;
    for (int n = 1; n <= N; n += 2) {
        int cnt = 0;
        for (int d = 1; d <= N; d++) {
            if (n % d == 0) {
                cnt++;
            }
        }
        if (cnt == 8) {
            ans++;
        }
    }
    return ans;
}

int main() {
    cin >> N;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const double pi = acos(-1);

int n, m;
vector<int> G[600];

void solve() {
    cin >> n >> m;
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].emplace_back(t);
    }
    vector<double> dist(n, 0);
    for (int v = n - 2; v >= 0; v--) {
        double d = 0;
        for (auto u : G[v]) {
            d += dist[u] + 1;
        }
        dist[v] = d / (double)G[v].size();
    }
    double ans = dist[0];
    for (int v = 0; v < n - 1; v++) {
        if ((int)G[v].size() == 1) continue;
        double md = -1;
        int t;
        for(auto u : G[v]) {
            if(chmax(md, dist[u])){
                t = u;
            }
        }
        G[v].erase(remove(all(G[v]), t), G[v].end());
        vector<double> dist2(n, 0);
        for (int i = n - 2; i >= 0; i--) {
            double d = 0;
            for (auto u : G[i]) {
                d += dist2[u] + 1;
            }
            dist2[i] = d / (double)G[i].size();
        }
        G[v].emplace_back(t);
        chmin(ans, dist2[0]);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

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


Measured memory_bytes: 4784
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest085-C
#  TODO https://atcoder.jp/contests/abc085/tasks/abc085_c

def solveProblem(AllSheet,GivenMoney):
	cash1000 = 0
	cash5000 = 0
	cash10000 = 0
	searchFlag = False
	for cash1000 in range(0,AllSheet+1,+1):
		for cash5000 in range(0,AllSheet+1-cash1000):
			cash10000=AllSheet-cash1000-cash5000
			nowTotal = cash10000*10000+cash5000*5000+cash1000*1000
			if nowTotal == GivenMoney:
				answer=[cash10000,cash5000,cash1000]
				searchFlag = True
				break
	if searchFlag != True:
		answer=[-1,-1,-1]
	return answer

if __name__ == '__main__':
	N,Y = map(int,input().strip().split(' '))
	solution=solveProblem(N,Y)
	print("{} {} {}".format(solution[0], solution[1], solution[2]))


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

int main(){
  long long n, m; cin >> n >> m;
  set<long long> d;
  d.insert(1); d.insert(m);
  for(int i = 2; i*i <= m; i++){
    if(m % i == 0){
      d.insert(i);
      d.insert(m/i);
    }
  }
  long long ans = 0;
  for(auto k: d){
    if(k*n > m) break;
    ans = max(ans, k);
  }
  cout << ans << endl;
}
  
  
      

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    int x=0,y=0,t=0;
    cin >> N;
    rep(i,0,N){
        int T,X,Y;
        cin >> T >> X >> Y;
        if(abs(X-x) + abs(Y-y) > T - t){
            cout << "No" << endl;
            return 0;
        }
        if((abs(X-x) + abs(Y-y)) % 2 != (T - t) % 2  ){
            cout << "No" << endl;
            return 0;
        }
        x = X;
        y = Y;
        t = T;
    }

    cout << "Yes" << endl;



    return 0;
}


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

long long hundred(long long& n) {
	int count = 0;
	while (n % 100 == 0) {
		n /= 100;
		++count;
	}
	return count;
}

int main() {
	long long d, N; std::cin >> d >> N;
    if (N == 100) N = 101;
    if (d == 0) std::cout << N << std::endl;
    else if (d == 1) std::cout << 100 * N << std::endl;
    else if (d == 2) std::cout << 10000 * N << std::endl;
}


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

int main() {
    int a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a, a+3);
    for(int i = 0; i < 3; i++) {
        i != 2 ? cout << a[i] << " " : cout << a[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3136
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut cnt = 0;
    for i in 1..n + 1 {
        if i.to_string().len() % 2 != 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    if(n%2!=0) cout<<n/2<<endl;
    else cout<<n/2-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n;
	ll a[100000];
	cin >> n;
	REP(i, n) cin >> a[i];

	sort(a, a+n);

	int p = (n-1) / 2;
	int q = n-2-p;

	ll pts = 0, pt = 0;

	if(n % 2 == 1){
		REP(i, n){
			if(i < p) pts -= 2*a[i];
			elif(i >= n-q) pts += 2*a[i];
			else pts += a[i];
		}
		REP(i, n){
			if(i < q) pt -= 2*a[i];
			elif(i >= n-p) pt += 2*a[i];
			else pt -= a[i];
		}
	}
	else{
		REP(i, n){
			if(i < p) pts -= 2*a[i];
			elif(i >= n-q) pts += 2*a[i];
			elif(i == p) pts -= a[i];
			else pts += a[i];
		}
		REP(i, n){
			if(i < q) pt -= 2*a[i];
			elif(i >= n-p) pt += 2*a[i];
			elif(i == q) pt -= a[i];
			else pt += a[i];
		}
	}

	cout << max(pts, pt) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d);
}


Measured memory_bytes: 256