akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	bool fl = true;
	for(int i=0;i<n-1;i++){
		if( a[i] >= a[i+1] ){
			fl = false;
		}
	}
	if( fl == true ){
		cout<<1<<endl;
		return 0;
	}
	int ng = 1, ok = n;
	while( ok - ng > 1 ){
		int m = (ok+ng)/2;
		//cout<<"m= "<<m<<endl;
		unordered_map<int,int> mope;
		stack<int> exist;
		int last = -1;
		bool isok = true;
		for(int i=0;i<n;i++){
			if( last < a[i] ){
				last = a[i];
				exist.push(a[i]);
			}
			else if( last == a[i] ){
				mope[last] ++ ;
			}
			else{
				while( !exist.empty() && exist.top() > a[i] ){
					mope[ exist.top() ] = 0;
					exist.pop();
				}
				mope[a[i]]++;
				exist.push(a[i]);
				last = a[i];
			}
			if( mope[last] == m ){
				while( mope[last] == m && last > 0){
					mope[last] = 0;
					last--;
					mope[last] += 1;
				}
				while( !exist.empty() && exist.top() > last){
					exist.pop();
				}
			}
			//for(int j=1;j<=last;j++){cout<<mope[j]<<" ";}cout<<endl;
			if( mope[0] != 0 ){
				isok = false;
				break;
			}
		}
		if(isok == true){
			ok = m;
		}
		else{
			ng = m;
		}
	}
	cout<< ok << endl;
	return 0;
}

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

using namespace std;

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long dist = abs(a - b);
  if (dist & 1) {
    dist = a + b - 2;
    dist = min(dist, n - a + n - b);
  }
  printf("%lld\n", (dist+1) / 2);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
const int inf=0x7f;
vector<int> v[100005];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > qu;
int ans[100005];
int main()
{
	int n,m,i,j,uu,vv;
	cin>>n;
	for (i=1;i<=n-1;i++)
	{
		scanf("%d%d",&uu,&vv);
		v[uu].push_back(vv);	
		v[vv].push_back(uu);
	}
	cin>>m;
	memset(ans,0x7f,sizeof(ans));
	for (i=1;i<=m;i++)
	{
		scanf("%d%d",&uu,&vv);
		ans[uu]=vv;
		qu.push(make_pair(vv,uu));
	}
	while (!qu.empty())
	{
		int from=qu.top().second;
		int num=qu.top().first;
		qu.pop();
		for (i=0;i<v[from].size();i++)
		{
			int	to=v[from][i];
			if (ans[to]==ans[0])
			{
				ans[to]=ans[from]+1;
				qu.push(make_pair(ans[to],to));
			}
			if (abs(ans[to]-ans[from])!=1)
			{
				cout<<"No"<<endl;
				return 0;
			}
		} 
	}
	cout<<"Yes"<<endl;
	for (i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;	
} 

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

int n, a[12];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	int sum = 0;
	for (int i = 1; i < n; ++ i) sum += a[i];
	if (sum > a[n]) puts("Yes"); else puts("No");
	return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

ll mpow(ll base, ll num)
{
    if (num == 0)
        return 1;
    ll prev = mpow(base, num / 2);
    if (num % 2 == 0)
    {
        return (prev * prev) % MOD;
    }
    else
    {
        return ((prev * base) % MOD * prev) % MOD;
    }
}

ll com(ll n, ll b)
{
    ll frac = 1;
    ll div = 1;
    for (ll i = 0; i < b; i++)
    {
        frac *= (n - i);
        frac %= MOD;
        div *= (i + 1);
        div %= MOD;
    }
    return (frac * mpow(div, MOD - 2)) % MOD;
}

int main(int argc, char const *argv[])
{

    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = mpow(2, n) - 1;

    cerr << com(n, a) << " " << com(n, b) << endl;
    ans -= com(n, a);
    ans -= com(n, b);
    while (ans < 0)
        ans += MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int N;cin >> N ;
    if(N < 10){
        cout << N << endl;
    }
    else if(N >= 10 && N < 100){
        cout << 9 << endl;
    }
    else if(N >= 100 && N < 1000){
        cout << 9 + (N-100+1) << endl;
    }
    else if(N >= 1000 && N < 10000){
        cout << 909 << endl;
    }
    else if(N >= 10000 && N < 100000){
        cout << 909 + (N-10000+1) << endl;
    }
    else if(N = 100000){
        cout << 90909 << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, S):
    ret = 0
    for s in S:
        #print(s)
        ret += (1.0 / s)
        #print (ret)
    return (1.0/ret)



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    S = list(map(int, parsed_lines[1]))
    # S = parsed_lines[1][0]
    # return n, k, S
    return n, S


if not do_submit:
    n, S = input_parse("""
    2
    10 30
    """)
    print(sol(n, S))

    n, S = input_parse("""
    3
    200 200 200
    """)
    print(sol(n, S))

    n, S = input_parse("""
    1
    1000
    """)
    print(sol(n, S))



else:
    n = int(input().strip())
    S = list(map(int, input().split()))
    #S = input().split()
    # print(sol(n, k, S))

    #s = input().strip()
    # S = input().strip()
    print(sol(n, S))

Measured memory_bytes: 3688
n,m=map(int,input().split())
A=[]
B=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    A.append(b)
  elif b==n:
    B.append(a)
print("POSSIBLE" if len(set(A)&set(B))>0 else "IMPOSSIBLE")

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

bool cmp(pair<long long,int>x1,pair<long long,int>x2){
    return x1.first<x2.first;
}
//ABC099 D
int main(){
    int n,c;
    cin>>n>>c;

    long long d[c+1][c+1];
    rep2(i,c)rep2(k,c)cin>>d[i][k];

    long long grid[n+1][n+1];

    rep2(i,n)rep2(k,n)cin>>grid[i][k];
    vector<pair<long long,int> > change_cost[3];
    //cnt[l][k]:=割ったあまりがlのマスを色kに変えるコストの合計
    long long cnt[3][31]={};

    rep2(i,n){
        rep2(k,n){
            int now=(i+k);
            int l=now%3;
            rep2(col,c)
            cnt[l][col]+=d[grid[i][k]][col];
        }
    }





    rep2(i,c){
        rep(l,3){
            change_cost[l].push_back(make_pair(cnt[l][i],i));
        }
    }

    rep(l,3){
        sort(change_cost[l].begin(),change_cost[l].end(),cmp);
    }
    long long ans=INF;
    
    rep(k,3){
        int one=change_cost[0][k].second;
        rep(l,3){
            if(one==change_cost[1][l].second)continue;
    
            int two=change_cost[1][l].second;
            rep(i,3){
                if(one==change_cost[2][i].second || two==change_cost[2][i].second){
                    continue;
                }
                int three=change_cost[2][i].second;
                long long total=change_cost[0][k].first+
                                change_cost[1][l].first+
                                change_cost[2][i].first;
                ans=min(ans,total);
            }
        }
    }
    
    cout<<ans<<endl;

    return 0;

}
/*
2 3
0 1 1
1 0 1
1 4 0
1 2
3 3

3

4 3
0 12 71
81 0 53
14 92 0
1 1 2 1
2 1 1 2
2 2 1 3
1 1 2 2

428
*/


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

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

int main()
{
	int p,q,r;
	cin>>p>>q>>r;
	cout<<min(min(p+q,q+r),r+p)<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, M; cin >> N >> M;

  vvi s(M);
  rep(i,M) {
    int k; cin >> k;
    s.at(i).resize(k);
    rep(j,k) {
      cin >> s.at(i).at(j);
      s.at(i).at(j)--;
    }
  }

  vi p(M); rep(i,M) cin >> p.at(i);

  int ans = 0;
  rep(i,1<<N) {
    bool flag = true;
    rep(j,M) {
      int cnt = 0;
      for(id : s.at(j)) {
        if(i&(1<<id)) cnt++;
      }
      if(cnt%2!=p.at(j)) flag = false;
    }
    if(flag) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	template<typename T>
	struct edge {
		int to;
		T cost;
		edge(int t, T c) {
			to = t;
			cost = c;
		}
	};

	template<typename T>
	void dijkstra(int s, vector<vector<edge<T>>>& path, vector<T>& d) {
		using pi = pair<T, int>;
		priority_queue<pi, vector<pi>, greater<pi>> q;
		q.push(P(0, s));
		d[s] = 0;
		while (!q.empty()) {
			P p = q.top();
			q.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			REP(i, path[v].size()) {
				edge<T> e = path[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					q.push(P(d[e.to], e.to));
				}
			}
		}
		return;
	}

	void solve() {
		IOS;
		int n, m;
		cin >> n >> m;
		vector<int> u(m), v(m);
		vector<vector<int>> path(n);
		REP(i, m) {
			cin >> u[i] >> v[i];
			u[i]--, v[i]--;
			path[u[i]].push_back(v[i]);
			path[v[i]].push_back(u[i]);
		}
		vector<int> res(n,INT_MAX);
		res[0] = -1;
		queue<int> q;
		q.push(0);
		while (!q.empty()) {
			int p = q.front();
			q.pop();
			REP(i, path[p].size()) {
				int tmp = path[p][i];
				if (res[tmp] == INT_MAX) {
					res[tmp] = p;
					q.push(tmp);
				}
			}
		}
		REP(i, n) {
			if (res[i] == INT_MAX) {
				put("No");
				return;
			}
		}
		put("Yes");
		FOR(i, 1, n) {
			put(res[i]+1);
		}
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 11700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        double x = 0;
        String ans = "Yes";

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        x = Double.parseDouble((a + b));

        if (Math.sqrt(x) % 1 != 0) {
            ans = "No";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

#define MOD (1000000007)
typedef long long ll;

class Util {
public:
  Util(int a_max, int a_mod)
    : max(a_max), mod(a_mod), fac(a_max + 1), finv(a_max + 1), inv(a_max + 1) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= max; ++i) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i ) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  ll Comb(int n, int k) {
    assert(n <= max);
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
  
private:
  int max;
  int mod;
  vector<long long> fac;
  vector<long long> finv;
  vector<long long> inv;
};

int main() {
  Util util(2005, MOD);

  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= K; ++i) {
    ll val1 = util.Comb(K - 1, i - 1);
    if (N - K + 1 < i) {
      cout << 0 << endl;
      continue;
    }
    ll val2 = util.Comb(N - K + 1, i);
    cout << val1 * val2 % MOD << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  set<string> ans;
  map<string, int> m;
  cin>>n;string s;
  for(int i=0;i<n;i++)
  {cin>>s;m[s]++;}int mx=0;
  for(auto i: m)
  {
    mx=max(mx, i.second);
  }
  for(auto i:m)
  {
    if(i.second==mx)ans.insert(i.first);
  }
  for(auto i: ans)cout<<i<<"\n";
}

Measured memory_bytes: 34560
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int H,W;
char fld[20][20];
int main(){
	queue<pair<int,int> > p;
	while(cin>>W>>H,H,W){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>fld[j][i];
				if(fld[j][i]=='@'){
					fld[j][i]='#';
					p.push(make_pair(j,i));
				}
			}
		}
		int cnt=1;
		while(!p.empty()){
			int x=p.front().first,y=p.front().second;
			p.pop();
			for(int i=0;i<4;i++){
				int nx=x+dx[i],ny=y+dy[i];
				if(nx>=0 && nx<W && ny>=0 && ny<H && fld[nx][ny]=='.'){
					fld[nx][ny]='#';
					p.push(make_pair(nx,ny));
					cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1216
fun main(args: Array<String>) {
    var H = nextLong()
    var b = 1L
    var ans = 0L
    while (H > 0) {
        ans += b
        b *= 2
        H /= 2
    }
    println(ans)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()


Measured memory_bytes: 31532
#include <stdio.h>
long long a [100010];
int main ()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}


Measured memory_bytes: 2504
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; ++i) cin >> a[i];
    sort(a.rbegin(), a.rend());
    cout << 10 * a[0] + a[1] + a[2] << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

double bisearch(long double n) {
	double t = 5000;
	double width = 5000;
	while(1) {
		if (t * t > n)
		{
			if (t * t - n < 0.05)
				return t;
			else
			{
				t -= width / 2.0;
				width /= 2.0;
			}
		}
		else {
			if (n - t*t < 0.05) return t;
			else
			{
				t += width / 2.0;
				width /= 2.0;
			}
		}
		
	}
}

int main() {

	ll a,b,c;
	cin >> a >> b >> c;
	if (c-a-b > 0 && (c-a-b)*(c-a-b)-a*b*4 > 0) cout << "Yes" << endl;
	else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
class Dice
  def initialize(a,b,c,d,e,f)
    @top   = a
    @down  = b
    @right = c
    @left  = d
    @up    = e
    @back  = f
  end
  attr_accessor :top,:down,:right,:left,:up,:back
  def move(dice,m)
    top=@top
    down=@down
    right=@right
    left=@left
    up=@up
    back=@back

    if m=="S"
      @top=  up
      @down= top
      @right=right
      @left= left
      @up=   back
      @back= down
    elsif m=="W"
      @top=  right
      @down= down
      @right=back
      @left= top
      @up=   up
      @back= left
    elsif m=="N"
      @top=  down
      @down= back
      @right=right
      @left= left
      @up=   top
      @back= up
    elsif m=="E"
      @top=  left
      @down= down
      @right=top
      @left= back
      @up=   up
      @back= right
    end
  end
  def printDice
#    puts "top:#{@top}  down:#{@down}  right:#{@right}  lefr:#{@left} up:#{@up} back:#{@back}"
     puts @right
  end
end

a,b,c,d,e,f=gets.split.map(&:to_i)
dice1=Dice.new(a,b,c,d,e,f)
a,b,c,d,e,f=gets.split.map(&:to_i)
dice2=Dice.new(a,b,c,d,e,f)
flag = 0
1000.times do
  random = Random.new
  ran=random.rand(1..4)
  if ran == 1
    dice1.move(dice1,"W")
  elsif ran==2
    dice1.move(dice1,"S")
  elsif ran==3
    dice1.move(dice1,"E")
  elsif ran==4
    dice1.move(dice1,"N")
  end
  if dice1.top==dice2.top  && dice1.down==dice2.down && dice1.left==dice2.left  && dice1.right==dice2.right  && dice1.up==dice2.up && dice1.back==dice2.back

    flag=1
    break
  end

end
if flag==1
  puts "Yes"
elsif flag==0
  puts "No"
end



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

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

int main(){
     int W,H,C;
     cin>>W>>H>>C;
     int GCD=gcd(W,H);
     cout<<((W/GCD)*(H/GCD)*C)<<endl;
    
    return 0;
}


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

using namespace std;

const int MAXN = 2e5 + 7;
const long long mod = 1e9 + 7;

string s;

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

	long long n;

	cin >> n >> s;

	n = 2ll * n;

	long long ans = 1ll;
	long long l = 0;
	bool w = false;
	char pr = 'W';

	for(int i = 0; i < n; ++i){
		if(s[i] == pr){
			w = !w;
		}
		pr = s[i];

		if(!w){
			++l;
		}
		else{
			if(!l){
				cout << "0\n";

				return 0;
			}
			ans *= l;
			ans %= mod;
			--l;
		}
	}
	if(l > 0){
		cout << "0\n";

		return 0;
	}

	for(long long i = (n / 2ll); i >= 1ll; --i){
		ans *= i;
		ans %= mod;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    int x[n],y[n],h[n];
    int xt,yt,ht;
    bool flag = true;

    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0 and flag){
            xt = x[i];
            yt = y[i];
            ht = h[i];
            flag = false;
        }
    }

    
    Rep(i,0,101){
        Rep(j,0,101){
            int H = ht + abs(i-xt) + abs(j-yt);
            bool check = true;
            rep(k,n){
                if(h[k] > 0){
                    if(h[k]!=H-abs(x[k]-i)-abs(y[k]-j)){
                        check = false;
                        break;
                    }

                }else{
                    if(H-abs(x[k]-i)-abs(y[k]-j) > 0){
                        check = false;
                        break;
                    }
                    
                }

                
            }
            if (check){
                    cout << i << " " << j  << " " << H << endl;
                    return 0;
            }

        }
    
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define INF 10000000
using namespace std;

int main(){

  int n, m, x;
  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int> > a(n, vector<int>(m)); 
  rep(i,n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }

  int cost;
  int answer = INF;
  int value;
  bool ok = true;
  rep(bit, (1<<n)){
    cost = 0;
    ok = true;
    rep(s,m){
      value = 0;
      rep(t,n){
	if(bit & (1<<t)) value = value + a[t][s];
      }
      if(value < x) ok = false;
    }
    if(ok){
      rep(t,n){
	if(bit & (1<<t)) cost = cost + c[t];
      }
      answer = min(answer, cost);
    }
  }

  if(answer == INF) cout << -1 << endl;
  else cout << answer << endl;

  return 0;
}


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

int main(void)
{
  string s;
  cin >> s;
  bool easy = true;
    
  for(int i=0;i<s.size();i++){
    if(i%2==0 and s.at(i)=='L'){
      easy = false;
      break;
    }else if(i%2!=0 and s.at(i)=='R'){
      easy = false;
      break;
    }
  }

  if(easy){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
//#define min(a,b) (a)<(b)? (a) : (b)

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
int main()
{
  int n,m;
  cin>>n>>m;
  vector<int>a(n+1,0);
  for(int i=0;i<m;i++)
  {
    int c;
    cin>>c;
    a[c]=1;
  }
  vector<mint>dp(n+1);
  dp[0]=1;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<=min(i+2,n);j++)
    {
      if(!a[j])
      {
        dp[j]+=dp[i];
      }
    }
  }
  cout<<dp[n].x<<endl;
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
using namespace std;
int a[11][11];
int main()
{
	int n,d,ans=0,judge=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			cin>>a[i][j];
	for(int i=1;i<=n-1;i++)
	{
		int q=i+1;
		int p=n;
		for(int l=q;l<=p;l++)
		{
			for(int j=1;j<=d;j++)
				judge+=(a[i][j]-a[l][j])*(a[i][j]-a[l][j]);
			if(sqrt(judge)==floor(sqrt(judge)))
				ans++;
			judge=0;
		}
		
	}
	cout<<ans;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ch;
int n,s;
bool a[5];
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		cin>>ch;
		if(ch=='P'&&a[1]==0)a[1]++;
		if(ch=='W'&&a[2]==0)a[2]++;
		if(ch=='G'&&a[3]==0)a[3]++;
		if(ch=='Y'&&a[4]==0)a[4]++;
	}
	for(int i=1;i<=4;i++)if(a[i])s++;
	if(s==3)printf("Three\n");
	if(s==4)printf("Four\n");
}

Measured memory_bytes: 256
s=gets.split('')
a=[]
count=0
countw=0
s.each do |i|
  count+=1
  if i == 'W' 
    countw+=1
    a<<[count, countw]
  end
end
output=0
a.each do |i|
  output+=(i[0]-i[1])
end
puts output
  
  

Measured memory_bytes: 28028
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

# ans = max(a%10, b%10, c%10, d%10, e%10) + (a+(10-a%10)) + (b+(10-b%10))+(c+(10-c%10))+(d+(10-d%10))+(e+(10-e%10)) -10

min_amari = 10
lis = [a,b,c,d,e]
ans = -10
for e in lis:
    ama = e % 10
    if ama == 0:
        ans += e
    else:
        ans += e + (10-e%10)
        if min_amari > ama:
            min_amari = ama
ans += min_amari 

print(ans)

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

using namespace std;

string a = {};

void input()
{
  cin >> a;
}

void solve()
{
  if(a[0] == 'A')
  {
    string sub = {};
    int sum = 0;
    int index = 0;

    if(!islower(a[1]) || !islower(a[a.length() - 1]))
    {
      cout << "WA";
      return;
    }
    int ac = 0;
    int C = 0;
    for(auto c : a)
    {
      if(!islower(c))
      {
        ac++;
        if(c == 'C')
        {
          C++;
        }
      }
    }
    if(ac == 2 && C == 1)
    {
      cout << "AC";
      return;
    }
  }

  cout << "WA";
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  map<ll,ll> a;
  ll temp;
  rep(i,n){
    cin>>temp;
    a[temp]++;
  }
  ll ans=0;
  reps(x,a){
    if(x.fi>x.se){
      ans+=x.se;
    }else{
      ans+=x.se-x.fi;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6272
#include <stdio.h>
 
int main(void)
{
    int n;
	int sco[200] = {0}, pl[200][3];
    int i, j, k;
    int c;
     
    scanf("%d", &n);
     
    for (i = 0; i < n; i++){
        scanf("%d %d %d", &pl[i][0], &pl[i][1], &pl[i][2]);
    }
     
    for (i = 0; i < n; i++){
        for (j = 0; j < 3; j++){
            c = 1;
            for (k = 0; k < n; k++){ 
                if (c == 1 && pl[i][j] != pl[k][j]){
                    c = 1;
                }
                else if (i != k && pl[i][j] == pl[k][j]){
                    c = 0;
                }
            }
            if (c == 0){
                sco[i] += 0;
            }
            else if (c == 1){
                sco[i] += pl[i][j];
            }
        }
    }
    for (i = 0; i < n; i++){
        printf("%d\n", sco[i]);
    }
     
    return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second

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

    string s,t;
    cin>>s>>t;
    ll n=s.length(),m=t.length();
    ll dp[n+1][m+1];
    vector <char> v; 
    memset(dp,0,sizeof dp);
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
        }
    }
    ll i=n,j=m;
    while(i>0 && j>0)
    {
        if(dp[i][j]==dp[i-1][j])
            i--;
        else if(dp[i][j]==dp[i][j-1])
            j--;
        else
        {
            v.pb(s[i-1]);
            i--;
            j--;
        }
        
    }
    for(ll i=v.size()-1;i>=0;i--)
        cout<<v[i];
    cout<<'\n';
}   


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

int main(void){
	int n, i = 0;
	cin >> n;
	while(true){
		i++;
		if (pow(2, i) > n){
			i--;
			break;
		}
	}
	cout << pow(2, i) << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
typedef long long ll;
#define MAX 100000
#define SENTINEL 2000000000

int A[MAX], n;

int partition(int p,int r){
  int x,i,j,t;
  x = A[r];
  i = p - 1;
  for(j = p;j < r;j++){
    if(A[j] <= x){
      i = i + 1;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i+1;
}

int main(){
  cin >> n;
  rep(i,n) cin >> A[i];
  
  int q = partition(0,n-1);
  
  rep(i,n){
    if(i==q){
      cout <<"[" << A[i]<<"]"<<" ";
    }else if(i==n-1){
      cout << A[i] << endl;
    }else{
      cout << A[i] << " ";
    }
  }  
  return 0;
}
                                        
  
  
  
     






Measured memory_bytes: 3396
n, m = map(int, input().split())
ans = [-1 for i in range(n)]
for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        exit()
    elif ans[s-1] != -1 and ans[s-1] != c:
        print(-1)
        exit()
    ans[s-1] = c

for i in range(n):
    if ans[0] == -1 and n == 1:
        ans[0] = 0
    elif ans[0] == -1:
        ans[0] = 1
    elif ans[i] == -1:
        ans[i] = 0

print(int("".join(map(str, ans))))

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	int a, b; cin >> a >> b;
	if (1<=a&&a<=9&&1<=b&&b<=9) {
		COUT(a * b);
	}
	else {
		COUT(-1);
	}
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);

int main()
{
	double a, b, x;
	scanf("%lf%lf%lf", &a, &b, &x);
	double half = 1.0 * a * a * b / 2;
	double ans;
	
	if (x > half) 
	{
		double y = half * 2.0 - x;
		ans = atan2(y * 2.0 / a / a, a) / pi * 180;
	}
	else
	{
		ans = 90 - atan2(x * 2.0 / b / a, b) / pi * 180;
	}
	
	printf("%.8f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
constexpr double EPS = 1e-12;

int main(){
  int n;
  cin >> n;
  vector<int64> a(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  for(int i = 0; i < n; ++i){
    if(a[i] == 0LL){
      cout << 0 << endl;
      return 0;
    }
  }
  double keta = 0;
  for(int i = 0; i < n; ++i){
    keta += log10(a[i]);
  }
  if(keta > 18 + EPS){
    cout << -1 << endl;
    return 0;
  }
  int64 ans = 1;
  for(int i = 0; i < n; ++i){
    ans *= a[i];
  }
  if(ans > 1000000000000000000LL) cout << -1 << endl;
  else cout << ans << endl;
}

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

int main() {
  int N, x{};
  cin >> N;
  vector <int> a(N);
  for (auto &i: a) {
    cin >> i;
    x ^= i;
  }
  for (int i = 0; i !=N; ++i) {
    if (i) cout << " ";
    cout << (a[i]^x);
  }
  cout << endl;
}


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

int main() {
  int N;
  cin >> N;
  for(int i = 0;i < N;i++){
    string c;
    cin >> c;
    if(c == "Y"){
      cout << "Four" << endl;
      break;
    }
    if(i == N - 1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;cin>>a>>b>>c;
  if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>0){
    cout<<"Yes"<<endl;
  }else cout<<"No"<<endl;
  return 0;
}

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

int n,sum;
long long h,w,p,q;

int main(){
	cin>>n>>h>>w;
	for(int i = 1;i <= n;i++){
		cin>>p>>q;
		if(p >= h && q >= w){
			sum++;
		}
	}
	cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define MAXN (int)(1e5+233)
struct qwq
{
	int nex,to,id;
}e[MAXN<<1];
int h[MAXN],tot=0;
inline void add(int i,int x,int y)
{
	e[++tot].to=y;
	e[tot].nex=h[x];
	e[tot].id=i;
	h[x]=tot;
}
int sum=0;
int fa[MAXN],ans[MAXN];
inline void dfs(int x,int c)
{
	int cnt=0;
	for (int i=h[x],y;i;i=e[i].nex)
	{
		y=e[i].to;
		if (y==fa[x]) continue;
		fa[y]=x;
		if (cnt+1==c)
		{
			cnt=c+1;
			ans[e[i].id]=cnt;
			dfs(y,cnt);
		}
		else
		{
			cnt++;
			ans[e[i].id]=cnt;
			dfs(y,cnt);
		}
	}
	sum=max(sum,cnt);
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1,x,y;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		add(i,x,y); add(i,y,x);
	}
	dfs(1,0);
	printf("%d\n",sum);
	for (int i=1;i<n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string str;
    cin>>str;
    if(str==s)
        a--;
    else b--;
    cout<<a<<" "<<b;
    return 0;
}


Measured memory_bytes: 256
/* Life is all about calculated risks.
    But man am I bad at math. */

#include <bits/stdc++.h> 
#define ll long long int
#define ld long double
#define INF (ll)1e12
#define MOD 1000000007

#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;

using namespace std;

ld f(ll a, ll b, ll c);

ll n;
ll a[310];
vector<vector<vector<ld>>> dp(310, vector<vector<ld>>(310, vector<ld>(310,-10)));

vector<ll> cnt(5,0);

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

    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }

    printf("%.10Lf", f(cnt[1],cnt[2],cnt[3]));

    return 0;
}

ld f(ll a, ll b, ll c)
{
    if(dp[a][b][c] > -1)
    {
        return dp[a][b][c];
    }

    if(a==0 && b==0 && c==0)
    {
        return dp[a][b][c] = 0;
    }

    if(a==0 && b==0)
    {
        return dp[a][b][c] = (ld)n/(ld)(a+b+c) + ((ld)c/(ld)(a+b+c))*f(a,b+1,c-1);
    }
    if(b==0 && c==0)
    {
        return dp[a][b][c] = (ld)n/(ld)(a+b+c) + ((ld)a/(ld)(a+b+c))*f(a-1,b,c);
    }
    if(a==0 && c==0)
    {
        return dp[a][b][c] = (ld)n/(ld)(a+b+c) + ((ld)b/(ld)(a+b+c))*f(a+1,b-1,c);
    }

    if(a==0)
    {
        return dp[a][b][c] = (ld)n/(ld)(a+b+c) + ((ld)b/(ld)(a+b+c))*f(a+1,b-1,c) + ((ld)c/(ld)(a+b+c))*f(a,b+1,c-1);
    }
    if(b==0)
    {
        return dp[a][b][c] = (ld)n/(ld)(a+b+c) + ((ld)a/(ld)(a+b+c))*f(a-1,b,c) + ((ld)c/(ld)(a+b+c))*f(a,b+1,c-1);
    }
    if(c==0)
    {
        return dp[a][b][c] = (ld)n/(ld)(a+b+c) + ((ld)a/(ld)(a+b+c))*f(a-1,b,c) + ((ld)b/(ld)(a+b+c))*f(a+1,b-1,c);
    }

    return dp[a][b][c] = (ld)n/(ld)(a+b+c) + ((ld)a/(ld)(a+b+c))*f(a-1,b,c) + ((ld)b/(ld)(a+b+c))*f(a+1,b-1,c) + ((ld)c/(ld)(a+b+c))*f(a,b+1,c-1); 
}

Measured memory_bytes: 471168
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B,K;cin>>A>>B>>K;
	int i=100,count=0;
    while(count<=100){
    	if(A%i==0&&B%i==0){
    		count++;
    		if(count==K){
    			break;
    		}
    	}i--;
    }cout<<i<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

void solve(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    //??????????????????
    if(y+r <= h && y-r >= 0 && x-r >= 0 && x+r <= w){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3072
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let B: i64 = sc.get();
    let _C: i64 = sc.get();
    let K: i64 = sc.get();
    if K <= A {
        println!("{}", K);
    } else if K > A && K <= A+B {
        println!("{}", A);
    } else {
        println!("{}", A-(K - (A+B)));
    }
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<i64> H(N);
    for (i32 i = 0; i < N; i++) cin >> H[i];
    bool ok = true;
    i64 max_v = 0;
    for (i32 i = 0; i < N; i++) {
        if (H[i] > max_v) max_v = H[i] - 1;
        else if (H[i] == max_v) continue;
        else ok = false;
    }
    cout << YN("Yes", "No", ok) << endl;
}


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

typedef long long ll; 
typedef vector<int> veci;

int main()
{
    char x,y;
    cin>>x>>y;
    if(x==y)cout<<"="<<endl;
    if(x<y)cout<<"<"<<endl;
    if(x>y)cout<<">"<<endl;

return 0;
}


Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int A, B, T;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
        T = sc.nextInt();
    }

    void solve(PrintWriter out) {
        int sum = 0;
        int t = 0;
        for (int i = 1;; i++) {
            t = i * A;
            if (t > T + 0.5) break;
            sum += B;
        }
        out.println(sum);
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22996