akhauriyash/Code-Regression huggingface dataset:
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> check(n, 0);
    REP(i, n){
        cin >> a[i];
    }
    int ans = 0;
    REP(i, n){
        if(a[i] == i+1){
            check[i] = 1;
        }
    }
    REP(i, n-1){
        if(check[i] == 1 && check[i+1] == 1){
            check[i] = 0;
            check[i+1] = 0;
            ans++;
        }
    }
    REP(i, n){
        if(check[i] == 1){
            check[i] = 0;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	string str;
  	cin>>str;
  	int len=str.size();
  	int cnt=0;
  	for(int i=len/2;i<len;++i)
      	if(str[i]!=str[len-i-1])
          	++cnt;
  	printf("%d\n",cnt);
  	return 0;
}

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for(auto &e : S) cin >> e;
    int ans = (H - 1) * (W - 1);
    for(int bit = 0; bit < (1 << (H - 1)); ++bit) {
        vector<vector<int>> A;
        vector<int> tmp(W);
        bool ng = false;
        int res = __builtin_popcount(bit);
        for(int i = 0; i < H; ++i) {
            rep(j, W) {
                tmp[j] += S[i][j] == '1';
                if(tmp[j] > K) ng = true;
            }
            if(bit & (1 << i)) {
                A.push_back(tmp);
                rep(j, W) tmp[j] = 0;
            }
        }
        if(ng) continue;
        if(tmp.size()) A.push_back(tmp);
        int N = A.size();
        vector<int> cnt(N);
        rep(j, W) {
            bool over = false;
            rep(i, N) {
                cnt[i] += A[i][j];
                if(cnt[i] > K) over = true;
            }
            if(over) {
                res++;
                rep(i, N) cnt[i] = 0;
                j--;
            }
        }
        ans = min(ans, res);
    }
    cout << ans << '\n';
    return 0;
}


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

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

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;

    i64 x = 1;
    while (x * (x + 1) / 2 < n) x++;

    for (i64 i = x; i > 0; i--) {
        if (n >= i) {
            cout << i << endl;
            n -= i;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int p[MAXN];
int cnt[MAXN];

int ans[MAXN];

set<int> st;
set<pii> stp;

int used[MAXN];

int top;

void add(int v) {
	st.erase(v);
	stp.erase(mp(cnt[v], v));
	
	used[v] = 1;
	ans[top] = v;
	top++;
	
	stp.erase(mp(cnt[p[v]], p[v]));
	cnt[p[v]]--;
	if (!used[p[v]]) {
		stp.insert(mp(cnt[p[v]], p[v]));
	}
}

void solve(){
	int n;
	scanf("%d", &n);
	
	if (n == 2) {
		printf("-1\n");
		return;
	}
	
	REPN(i, 1, n) {
		scanf("%d", &p[i]);
		cnt[p[i]]++;
	}
	
	REPN(i, 1, n) {
		if (cnt[i] == n - 1) {
			ans[1] = i;
			REPN(j, 1, n) {
				if (j != ans[1] && j != p[ans[1]]) {
					ans[2] = j;
					break;
				}
			}
			int top = 3;
			REPN(j, 1, n) {
				if (j != ans[1] && j != ans[2]) {
					ans[top++] = j;
				}
			}
			REPN(j, 1, n) {
				printf("%d ", ans[j]);
			}
			putchar('\n');
			return;
		}
	}
	
	used[1] = 1;
	ans[1] = 1;
	cnt[p[1]]--;
	REPN(i, 2, n) {
		st.insert(i);
		stp.insert(mp(cnt[i], i));
	}
	top = 2;
	REPN(i, 2, n) {
		int v = stp.rbegin()->_2;
		if (cnt[v] == n - i) {
			add(v);
			continue;
		}
		
		v = *st.begin();
		for(; ; v = *st.upper_bound(v)) {
			if (v == p[ans[i - 1]]) {
				continue;
			}
			break;
		}
		add(v);
	}
	
	/*REPN(i, 1, n) {
		printf("%d ", ans[i]);
	}
	putchar('\n');*/
	
	FA(it, st) {
		ans[top++] = *it;
	}
	
	/*REPN(i, 1, n) {
		printf("%d ", ans[i]);
	}
	putchar('\n');*/
	
	REP(i, 0, 30) {
		int fl = 0;
		REPN(i, 1, n - 1) {
			if (ans[i + 1] == p[ans[i]]) {
				//printf("%d: %d %d\n", i, ans[i], ans[i + 1]);
				fl = 1;
				break;
			}
		}
		if (!fl) {
			REPN(i, 1, n) {
				printf("%d ", ans[i]);
			}
			putchar('\n');
			return;
		}
		/*REPN(i, 1, n) {
			printf("%d ", ans[i]);
		}
		putchar('\n');*/
		next_permutation(ans + 1, ans + n + 1);
	}
	printf("-1\n");
	return;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

int N, T;

vector<pair<int, int>> AB;
int dp[3000 + 10][3000 + 10];

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		AB.push_back(make_pair(a, b));
	}
	
	sort(AB.begin(), AB.end());
	
	int ans = 0;
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= T - 1; j++) {
			dp[i][j] = dp[i - 1][j];
			ans = max(ans, dp[i][j] + AB[i - 1].second);
			if (j - AB[i - 1].first >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - AB[i - 1].first] + AB[i - 1].second);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 38956
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vl ans;
    ll p=n;
    while(true){
        bool ok=false;
        rep(i,min(k,p)){
            ll d=min(k,p)-i;
            // puta(k,p,d);
            if(p-d<0 or s[p-d]=='1')continue;
            ans.push_back(d);
            p-=d;
            ok=true;
            break;
        }
        if(!ok){
            puta(-1);
            return 0;
        }
        if(p==0)break;
    }
    reverse(all(ans));
    puta(ans);
    return 0;
}

Measured memory_bytes: 2244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    ll n=s.length();
    if(n&1)
    {
        cout<<"No";
        return 0;
    }
    bool fg=true;
    for(int i=0;i<n;i+=2)
    {
        if(s[i]!='h' || s[i+1]!='i')
            fg=false;
    }
    if(fg)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
from collections import deque
import copy
# https://atcoder.jp/contests/abc054/tasks/abc054_c
# n!の全探索が答えというのは知っているが、自分の開放の誤りを見つけるために自分のやり方でといてみる。

N, M = map(int, input().split())
V = [[] for _ in range(N)]
cont = [0 for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    V[a-1].append([b, copy.deepcopy(cont)])
    V[b-1].append([a, copy.deepcopy(cont)])

# solution
q = deque()
q.append([1, copy.deepcopy(cont)])
count = 0
while q:
    c_v = q.pop()
    c_v[1][c_v[0]-1] = 1
    next_vs = V[c_v[0]-1]
    ifComplete = 1
    for v in next_vs:
        if c_v[1][v[0]-1] == 1:
            continue
        else:
            ifComplete = 0
        # ここで続くvの探索が始まる時に全て訪問されていればcountを増やす。
        # その状態をどうやって管理すればいい？
        v[1] = copy.deepcopy(c_v[1])
        q.append(v)
    # 遷移先のノードが存在しない場合
    if ifComplete:
        flag = 1
        for x in c_v[1]:
            if x == 0:
                flag = 0
                break
        if flag:
            count += 1
print(count)


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

int main(){
  int n;
  char x[1001],y[1001];
  int dp[1010][1010];
  
  //load n;
  cin >>n;
  for(int i=0;i<n;i++){
    //load string
    scanf("%s",x);
    scanf("%s",y);
    //dp
    for(int j=0;j<strlen(x);j++){
      for(int k=0;k<strlen(y);k++){
	if(x[j]==y[k]){
	  dp[j+1][k+1]=dp[j][k]+1;
	}

	else{
	  if(dp[j][k+1]>dp[j+1][k]){
	    dp[j+1][k+1]=dp[j][k+1];
	  }

	  else{
	    dp[j+1][k+1]=dp[j+1][k];
	  }


	}
      }
    }

    //print
    cout <<dp[strlen(x)][strlen(y)]<<endl;
  }



  return 0;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
//#include <boost/range/algorithm.hpp>
#include <boost/algorithm/string/replace.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long           ll;
typedef pair<ll, ll>        P;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
const ll                    INF = 2e9;
const ll                    INF_LL = 1LL<<60;
const ll                    MOD = 1e9 + 7;

namespace {
	ll Ceil(ll val, ll div)   { return (val + div - 1) / div; };
	ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; };
	ll FloorN(ll x, ll n)     { return (x - x % n); };
	bool IsOdd(ll x)          { return ((x & 1) == 1); };
	bool IsEven(ll x)         { return ((x & 1) == 0); };
	template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
	template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
};

// 処理
void Solve()
{
	string S;
	cin >> S;

	string T;
	REP(i, S.size()) {
		if (S.compare(i, 2, "BC") == 0) {
			T += 'D';
			i++;
		} else {
			T += S[i];
		}
	}

	ll ans = 0;
	swap(S, T);
	for (ll i = 0; i < S.size(); i++) {
		ll j;
		ll dCnt = 0;
		ll dSum = 0;
		for (j = i; j < S.size(); j++) {
			if (S[j] == 'A' || S[j] == 'D') {
				if (S[j] == 'D') {
					dCnt++;
					dSum += (j - i);
				}
			} else {
				break;
			}
		}

		if (dCnt) {
			dSum -= (dCnt - 1) * dCnt / 2;
			ans += dSum;
		}
		i = j;
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 916
use proconio::input;

fn main() {
    input! {
        x: u64,
    }

    let mut now = 100u64;
    let mut count = 0;
    while now < x {
        now = ((now as f64) * 1.01) as u64;
        count += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 2076
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
int main()
{
    int n,k,le=0,ans=0;
    cin>>n;
    k=n;
    while(k)
    {
        k/=10;
        le++;
    }
    //cout<<le<<endl;
    int t=1;
    for(int i=1;i<le;i++)
    {
        if(i%2==1)
        {
            ans+=t*10-t;
        }
        t*=10;
    }
    if(le%2==1)
    {
        ans+=n-t+1;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int n, m, f = 0,cnt=0;
	char a[50][50], b[50][50];
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];

	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			for (int p = 0; p < m; p++) {
				for (int r = 0; r < m; r++) {
					if (a[i+p][j+r] != b[p][r]) f = 1;
				}
			}
			if (f == 0) {
				cout << "Yes" << endl;
				return 0;
			}
			f = 0;
		}
	}

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

Measured memory_bytes: 256
n,m=map(int,input().split(" "))
if n>=m:
  print(0)
  exit()
s=list(map(int,input().split(" ")))
s.sort()
t=[]
for i in range(1,m):
  t.append(s[i]-s[i-1])
t.sort()
for j in range(n-1):
  t.pop() 
print(sum(t))  

Measured memory_bytes: 13960
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <unordered_map>
using namespace std;
int INF = 10000000;

typedef pair<int, int> P;

struct edge
{
    int to, cost;
};

int main() {
    int H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    Ch -= 1;
    Cw -= 1;
    Dh -= 1;
    Dw -= 1;
    vector<string> S;
    string line;
    for (int i = 0; i < H; i++)
    {
        cin >> line;
        S.emplace_back(line);
    }
    vector<vector<P>> es(H*W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int k = i-2; k <= i+2; k++) {
                for (int l = j-2; l <= j+2; l++) {
                    if (0 <= k && k < H && 0 <= l && l < W && S[k][l] == '.') {
                        if (abs(i-k) + abs(j-l) == 1) {
                            es[i*W+j].emplace_back(P(k*W+l, 0));
                        } else {
                            es[i*W+j].emplace_back(P(k*W+l, 1));
                        }
                    }
                }
            }
        }
    }

    vector<int> dist(H*W, INF);
    int s = Ch*W+Cw, t = Dh*W+Dw;
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (auto e : es[v]) {
            int d = dist[v] + e.second;
            if (d < dist[e.first]) {
                dist[e.first] = d;
                que.push(P(d, e.first));
            }
        }
    }
    if (dist[t] == INF) {
        cout << -1 << endl;
    } else {
        cout << dist[t] << endl;
    }
}

Measured memory_bytes: 175640
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        ArrayList<Integer> A = new ArrayList<>();
        int totalVote = 0;
        for(int i=0; i<N; i++){
            int a = scanner.nextInt();
            A.add(a);
            totalVote += a;
        }
        Collections.sort(A, Comparator.reverseOrder());

        if(A.get(M-1) < totalVote/(4.0*M)){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>

#define moduloNum 1000000007

using namespace std;

template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }

    return false;
}

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

    vector<vector<char>> a(H + 1, vector<char>(W + 1, ' '));
    vector<vector<int>> dp(H + 1, vector<int>(W + 1, 0));
    dp[1][1] = 1;

    for (int i = 0; i < H + 1; i++) {
        for (int j = 0; j < W + 1; j++) {
            if (i == 0 || j == 0) {
                a[i][j] = '#';
                continue;
            }

            cin >> a[i][j];
        }
    }

    for (int n = 2; n < H + W + 1; n++) {
        for (int i = 1; i < n; i++) {
            int j;

            if (i < H + 1 && n - i < W + 1) {
                j = n - i;
            } else {
                continue;
            }

            if (i == 1 && j == 1) {
                continue;
            }

            if (a[i][j] == '#') {
                dp[i][j] = 0;
                continue;
            }

            if (a[i - 1][j] == '#' && a[i][j - 1] == '.') {
                dp[i][j] = dp[i][j - 1] % moduloNum;
            } else if (a[i][j - 1] == '#' && a[i - 1][j] == '.') {
                dp[i][j] = dp[i - 1][j] % moduloNum;
            } else {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % moduloNum;
            }
        }
    }

    // for (auto row : dp) {
    //     for (auto v : row) {
    //         cout << v << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[H][W] << endl;

    return 0;
}


Measured memory_bytes: 5248
X,N = map(int, input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))
    K = X
    L = 0
    for i in range(X,103):
        if i in p:
            continue
        else:
            K = i-X
            L = i
            break
    if L == X:
        print(X)
    else:
        for i in range(X-K,X):
            if i in p:
             continue
            else:
             L = i
        print(L)


Measured memory_bytes: 9196
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-02-06
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int n,k;
    cin >> n >> k;
    if(n*500>=k)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int isIncludedInS(int x);

int n,q;
int S[100000],T[50000];
int count = 0;

main(){

  int i;
  int tmp;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&tmp);
    count += isIncludedInS(tmp);
  }

  printf("%d\n",count);

  return 0;

}

int isIncludedInS(int x){

  int i,j;
  int min,max;
  int middle;

  min = 0;
  max = n;
  while(min <= max){
    middle = (max+min)/2;
    if(x > S[middle]){
      min = middle + 1;
    }else if(x < S[middle]){
      max = middle - 1;
    }else if(x == S[middle]){
      return 1;
    }
  }
  return 0;

}

Measured memory_bytes: 756
import math 

A, B = [int(item) for item in input().split()]

def gdc(A, B):
    if B == 0:
        return A
    else:
        return gdc(B, A % B)

def chk_pn(num):

    flag = True
    if num  <= 3:
        pass

    else:    
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = False
                break
    return flag


def mk_factor(num):

    max_divisor = int(math.sqrt(num))+1
    divisor = 2
    factor_list = [1]

    while divisor <= max_divisor:
        if num % divisor == 0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1
    
    factor_list.append(num)
    return factor_list

GDC = gdc(A, B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]
# print(pn_factor)
print(len(set(pn_factor)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	string s;
	cin >> s;
	int cnt = 0;
	int ans = 0;
	for(int i = 0; i < 3; i++) {
		if(s[i] == 'R') {
			cnt++;
		}
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans;

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;

int main(){
    string S;
    cin >>S;
    ll N =S.size();
    ll K;
    cin >>K;
    int tempc=0,cc=0;
    if(S[0]==S[N-1]){
        char mark =S[0];
        ll lc=0,rc=0;
        rep(i,N-1){
            if(S[i]==mark) lc++;
            else break;
        }
        rep(i,N-1){
            if(S[N-1-i]==mark)  rc++;
            else break;
        }
        if(lc+rc==2*(N-1)) cout <<N*K/2<<endl;
        else{
            rep2(i,lc,N-rc-1){
                if(S[i]==S[i+1]) tempc ++;
                else{
                    cc += max(0,(tempc+1)/2);
                    tempc =0;
                }
            }
            cc += max(0,(tempc+1)/2);
            cout <<lc/2+rc/2+cc*K+((lc+rc)/2)*(K-1)<<endl;
        }
    }
    else{
        rep(i,N-1){
            if(S[i]==S[i+1]) tempc ++;
            else{
                cc +=max(0,(tempc+1)/2);
                tempc =0;
            }   
        }
        cc += max(0,(tempc+1)/2);
        cout <<cc*K<<endl;
    }
}


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

int main(void){
    int n=0;
    int i=0;
    int x[100]={0};
    int y[100]={0};
    double distance1=0.0;
    double distance2=0.0;
    double distance3=0.0;
    double distance4=0.0;
    int zettaichi=0;
    int max=0;

    scanf("%d",&n);
    n=n*1.0;

    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
    }
    
    for(i=0;i<n;i++){
        zettaichi=fabs(x[i]-y[i]);
        if(zettaichi>max){
            max=zettaichi;
        }
        distance1+=zettaichi;
        distance2+=pow(zettaichi,2);
        distance3+=pow(zettaichi,3);       
    }
    
    distance2=pow(distance2,0.5);
    distance3=pow(distance3,1.0/3);
    distance4=max*1.0;

    printf("%lf\n",distance1);
    printf("%lf\n",distance2);
    printf("%lf\n",distance3);
    printf("%lf\n",distance4);

    return 0;
}


Measured memory_bytes: 2108
unittest
{
	assert( [ "2", "3 1 2", "6 1 1" ].parse.expand.solve == "Yes" );
	assert( [ "1", "2 100 100" ].parse.expand.solve == "No" );
	assert( [ "2", "5 1 1", "100 1 1" ].parse.expand.solve == "No" );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto txys = new long[ 3 ][ n ];
	foreach( ref txy; txys )
	{
		input.popFront;
		txy = input.front.split.to!( long[] );
	}
	return tuple( txys );
}

auto solve( long[ 3 ][] txys )
{
	auto txy_p = [ 0L, 0L, 0L ];
	
	foreach( txy; txys )
	{
		auto dd = ( txy[ 1 ] - txy_p[ 1 ] ).abs + ( txy[ 2 ] - txy_p[ 2 ] ).abs;
		auto dt = txy[ 0 ] - txy_p[ 0 ];
		
		if( dt < dd || ( dt - dd ) % 2 == 1 ) return "No";
		
		txy_p[] = txy[];
	}
	
	return "Yes";
}


Measured memory_bytes: 4220
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int A,B,C;
	cin>>A>>B>>C;
	
	bool ans=false;
	if(A<C&&C<B)ans=true;
	if(A>C&&C>B)ans=true;
	
	if(ans) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
// int main() {
//     int N; cin >> N;
//     string S; cin >> S;
//     ll r = 0, g = 0, b = 0;
//     for (int i = 0; i < N; i++) {
//         if (S[i] == 'R') r++;
//         else if (S[i] == 'G') g++;
//         else if (S[i] == 'B') b++;
//     }
 
//     ll cnt = r*g*b;
//     for (int i = 0; i < N; i++) {
//         for (int j = i+1; j < N; j++) {
//             if (S[i] == S[j]) continue;
//             int k = j*2-i;
//             if (k >= N || S[k] == S[i] || S[k] == S[j]) {
//                 continue;
//             }
//             cnt --;
//         }
//     }
//     cout << cnt << endl;
// }

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<ll> r, g, b;
    for (ll i = 0; i < N; i++) {
        if (S[i] == 'R') r.push_back(i);
        else if (S[i] == 'G') g.push_back(i);
        else if (S[i] == 'B') b.push_back(i);
    }
    //vec[i]はポインタがi以上のbの要素の数
    vector<ll> vecR(N), vecG(N), vecB(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < b.size(); j++) {
            if (b[j] >= i) vecB[i] ++;
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < g.size(); j++) {
            if (g[j] >= i) vecG[i] ++;
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < r.size(); j++) {
            if (r[j] >= i) vecR[i] ++;
        }
    }
 
    ll cnt = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if (j == N-1) continue;
            ll s = vecB[j+1], t = vecR[j+1], u = vecG[j+1];
            if (S[i] == 'R' && S[j] == 'G') {
                cnt += s;
                if (2*j-i < S.size() && S[2*j-i] == 'B') cnt--;
            }
            if (S[i] == 'G' && S[j] == 'R') {
                cnt += s;
                if (2*j-i < S.size() && S[2*j-i] == 'B') cnt--;
            }
            if (S[i] == 'G' && S[j] == 'B') {
                cnt += t;
                if (2*j-i < S.size() && S[2*j-i] == 'R') cnt--;
            }
            if (S[i] == 'B' && S[j] == 'G') {
                cnt += t;
                if (2*j-i < S.size() && S[2*j-i] == 'R') cnt--;
            }
            if (S[i] == 'B' && S[j] == 'R') {
                cnt += u;
                if (2*j-i < S.size() && S[2*j-i] == 'G') cnt--;
            }
            if (S[i] == 'R' && S[j] == 'B') {
                cnt += u;
                if (2*j-i < S.size() && S[2*j-i] == 'G') cnt--;
            }
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 3740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        private static int MAX = 400000;
        private static long[] xs = new long[MAX + 1];
        private static long[] ys = new long[MAX + 1];
        static long MOD = (long) (1e9 + 7);

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int ans = 0;
            out.println(comb(N, 2) + comb(M, 2));
        }

        private long comb(int n, int r) {
            if (r < 0 || r > n) return 0;
            if (xs[0] == 0) {
                xs[0] = 1;
                for (int i = 1; i <= MAX; i++) {
                    xs[i] = xs[i - 1] * i % MOD;
                }
                long inv = modpow(xs[MAX]);
                ys[MAX] = inv;
                for (int i = MAX; i >= 1; i--) {
                    inv = inv * i % MOD;
                    ys[i - 1] = inv;
                }
            }
            return xs[n] * (ys[r] * ys[n - r] % MOD) % MOD;
        }

        private long modpow(long a) {
            return modpow(a, MOD - 2);
        }

        private long modpow(long a, long n) {
            long r = 1;
            while (n > 0) {
                r = r * ((n % 2) != 0 ? a : 1) % MOD;
                a = a * a % MOD;
                n >>= 1;
            }
            return r;
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 28756
// Problem : C - Tax Increase
// Contest : AtCoder - AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll a,b;
    cin>>a>>b;
    for(ll start=1;start<=1300;start++)
    {
    	ll x=start*8/100;
    	ll y=start/10;

    	if(x==a and y==b)
    	{
    		cout<<start;
    		return;
    	}
    }
    cout<<"-1";
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<P> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;

    sort(p.begin(), p.end());
    ll ans = 0;
    ll total = 0;

    rep(i, n) {
        ll yen = p[i].first;
        ll num = p[i].second;
        ll tmp = min(m-total,num);
        total += tmp;
        ans += tmp * yen;
        if(total == m) break;
    }
    cout <<  ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int N, K;
    cin >> N >> K;

    double p = 0;

    reple(i, 1, N)
    {
        int count = 0;
        ll x = 1;
        while (K > i * x)
        {
            count++;
            x *= 2;
        }
        p += (1.0 / N) * pow(1.0 / 2, count);
    }

    cout << setprecision(10) << setiosflags(ios::fixed);
    cout << p << endl;

    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int i = 1;
	while (i <= b) {
		i *= 10;
	}
	int n = i * a + b;
	if (n%(int)sqrt(n)==0) {
		cout << "Yes";
	}
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main ()
{
    ios_base::sync_with_stdio (false);
    cin.tie (NULL);
    
	int n;
    cin >> n;
    set <string> s;
    
    while (n--) {
        string str;
        cin >> str;
        s.insert (str);
    }
    
    cout << s.size() << endl;
  	return 0;
}

Measured memory_bytes: 19248
use proconio::{fastout, input};

pub trait LexicalPermutation {
    /// Return  if the slice was permuted,  if it is already
    /// at the last ordered permutation.
    fn next_permutation(&mut self) -> bool;
    /// Return  if the slice was permuted,  if it is already
    /// at the first ordered permutation.
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    /// Original author in Rust: Thomas Backman <serenity@exscape.org>
    fn next_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the last-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Find the rightmost element larger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }

        // Step 3: Swap that element with the pivot
        self.swap(j, i - 1);

        // Step 4: Reverse the (previously) weakly decreasing part
        self[i..].reverse();

        true
    }

    fn prev_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly increasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the first-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Reverse the weakly increasing part
        self[i..].reverse();

        // Step 3: Find the rightmost element equal to or bigger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }

        // Step 4: Swap that element with the pivot
        self.swap(i - 1, j);

        true
    }
}

#[fastout]
fn main() {
    input! {n: usize, xy: [[i32; 2];n]};
    let mut sum: f64 = 0.0;
    let mut v = vec![];
    let mut count = 0;

    for i in 0..n {
        v.push(i as usize);
    }

    loop {
        let mut x = 0.0;
        for i in 0..n - 1 {
            x += (((xy[v[i]][0] - xy[v[i + 1]][0]).pow(2) + (xy[v[i]][1] - xy[v[i + 1]][1]).pow(2))
                as f64)
                .sqrt();
        }
        sum += x;
        count += 1;

        if !v.next_permutation() {
            break;
        }
    }

    println!("{}", sum / count as f64);
}


Measured memory_bytes: 2212
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int[] order = new int[4];
		for (int i = 0; i < 3; i++) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			order[A]++;
			order[B]++;
		}
		int max = 0;
		for (int i = 0; i < 4; i++) {
			max = Math.max(max, order[i]);
		}
		System.out.println(max == 2 ? "YES" : "NO");
	}

}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x[100],i=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x[i-2]  += x[i-1];
      i--;
    } else if ( s[0] == '-' ){
      x[i-2] -= x[i-1];
      i--;
    } else if ( s[0] == '*' ){
      x[i-2] *=  x[i-1];
      i--;
    } else {
      x[i] = atoi(s);
      i++;
    }
  }

  printf("%d\n",x[0]);
  return 0;
}



Measured memory_bytes: 2144
#include<stdio.h>
#include<string.h>
main(){
 int jn,jm,hm,s,max;
 scanf("%d%d%d",&jn,&jm,&hm);
 if(hm>=jm+jn){
	s=jm+jn;
 }else{
	s=hm;
 }
 if(hm>jn+jm){
	 max=s+jm+1;
	 printf("%d",max);
 }else{
	 printf("%d",hm+jm);
 }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>
using namespace std;
set<string> st;
int main(){
	string s;
	st.insert("KIHBR");
	st.insert("KIHBRA");
	st.insert("KIHBAR");
	st.insert("KIHABR");
	st.insert("KIHBARA");
	st.insert("KIHABRA");
	st.insert("KIHABAR");
	st.insert("KIHABARA");
	st.insert("AKIHBR");
	st.insert("AKIHBRA");
	st.insert("AKIHBAR");
	st.insert("AKIHABR");
	st.insert("AKIHBARA");
	st.insert("AKIHABRA");
	st.insert("AKIHABAR");
	st.insert("AKIHABARA");
	cin >> s;
	if(st.count(s)){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    operand_a, operand_b = map(int, input().split(' '))

    if operand_a < 10 and operand_b < 10:
        print(operand_a * operand_b)
    else:
        print(-1)

    return 0


if __name__ == '__main__':
    main()


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

using namespace std;

#define FAST_IO ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
typedef long long ll;

void dfs(int x, vector<int> adj[], int dp[], bool vis[]){
	vis[x] = true;
	for(auto y: adj[x]){
		if(!vis[y])
			dfs(y,adj,dp,vis);
		dp[x] = max(dp[x],1 + dp[y]);
	}
}
 
int main(){ 
	
	FAST_IO;
   
	int n,m;
	cin>>n>>m;

	vector<int> adj[n+1];

	for(int i=0; i<m; i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
	}

	int dp[n+1]={0};
	bool vis[n+1] = {false};

	for(int i=1; i<=n; i++){
		if(!vis[i])
			dfs(i,adj,dp,vis);
	}

	int ans = 0;
	for(int i=1; i<=n; i++){
		ans = max(ans,dp[i]);
	}
	cout<<ans<<endl;
}
 

Measured memory_bytes: 9600