akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
    char a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "H\n";
    } else {
        cout << "D\n";
    }
}


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

using namespace std;

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

    int n, k;
    cin >> n >> k;

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

    sort(h, h+n);
    unsigned long long int brojac = 0;
    for (int i=0; i<n-k; i++)
        brojac += h[i];

    cout << brojac << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string T; cin>>T;
	for (int i=0; i<T.size(); i++)
		if(T[i]=='?') T[i]='D';
	cout<<T<<"\n";
	return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<cmath>
 
using namespace std;

int main()
{
	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
	#endif*/

	int n;
	cin >> n;
	int d[n];

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

	sort(d, d+n);

	if(n%2 == 1)
		cout << 0;
	else
		cout << d[n/2]-d[n/2 - 1];

}

Measured memory_bytes: 640
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const n = nextInt()
    const a = nextIntArray()
    let y = 0
    for(let i = 0; i<a.length; i++){
        y += a[i]
    }
    let x = 0
    let min = Number.POSITIVE_INFINITY
    for(let i = 0;i<a.length-1; i++){
        x += a[i]
        y -= a[i]
        min = Math.min(min, Math.abs(x-y))
    }
    console.log(min)
}
Main()


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;
	cin >> s;
	string m((int)s.size(), 'g');

	// int g = 0, p = 0;
	// for(int i = 0; i < (int)s.size(); i++){
	// 	if(s[i] == 'p' && g > p){
	// 		m[i] = 'p';
	// 		p++;
	// 	}else{
	// 		g++;
	// 	}
	// }

	// int win = 0, lose = 0;
	// for(int i = 0; i < (int)s.size(); i++){
	// 	if(s[i] == 'p' && )
	// }

	int p = 0;
	for(int i = 0; i < (int)s.size(); i++)
		if(s[i] == 'p')
			p++;

	cout << (int)s.size()/2 - p << endl;

	return 0;
}

Measured memory_bytes: 512
import std.stdio, std.array, std.conv, std.string, std.algorithm;

void main() {
  int n = to!int(chomp(readln()));
  string[] input = split(readln());

  long[] a = new long[n];
  for (int i = 0; i < n; ++i) {
    a[i] = to!long(input[i]);
  }

  writef("%d %d %d\n", minPos(a)[0], minPos!("a > b")(a)[0], reduce
  !("a + b")(a));
}

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

#define trade(a,b) tmp=(a);(a)=(b);(b)=tmp;

long M;

int sort(long l[],int N){
        int i=1,j,k;
        long tmp;

        for(i=0;i<N;i++){
                for(j=i;j>0;j=(j-1)/2){
                        if(l[j]<l[(j-1)/2]){
                                trade(l[j],l[(j-1)/2]);
                        }else{
                                break;
                        }
                }
        }

        for(i=0,k=N-1;i<N;i++){
                trade(l[0],l[k]);
                k--;
                for(j=0;j*2+1<=k;){
                        if(j*2+2>k || l[j*2+1]<l[j*2+2]){
                                if(l[j]>l[j*2+1]){
                                        trade(l[j],l[j*2+1]);
                                        j=j*2+1;
                                }else{
                                        break;
                                }
                        }
                        else if(l[j]>l[j*2+2]){
                                trade(l[j],l[j*2+2]);
                                j=j*2+2;
                        }else{
                                break;
                        }
                }
        }

        return 0;

}

long getmaxsum(long l[],int N){
                int i,j;
                long maxsum=0;

                for(i=0,j=N-1;j-i>=0;i++){
                        while(l[i]+l[j-1]<M && j-i>=0)
                                j--;
                        if(maxsum<l[i]+l[j])
                                maxsum=l[i]+l[j];
                }

                return maxsum;
}

main(){
        int i,j,k;

        long N;

        long l[1000+500500+1];

        while(1){
                scanf("%ld %ld",&N,&M);
                if(N==0)break;
                for(i=0;i<N;i++)
                        scanf("%ld",&l[i]);

                for(i=0,k=N;i<N;i++)
                        for(j=i;j<N;j++)
                                if(l[i]+l[j]<M)
                                        l[k++]=l[i]+l[j];
                l[k++]=0;
                N=k;

                sort(l,N);

                printf("%ld\n",getmaxsum(l,N));

        }
        return 0;
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
string s;

int main() {
  cin >> s;
  if (s == "AAA" || s == "BBB") {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int s,n,m,t,p;
int x[2000];

map<int,int> mp;
vector<int> A,B;
int dp[2005][2005];
 
int main(){
  scanf("%d %d %d",&s,&n,&m);
  for(int i=0;i<s;i++)scanf("%d",&x[i]);
  for(int i=0;i<n;i++){
    scanf("%d %d",&t,&p);
    mp[t-x[p-1]]++;
  } 
  A.push_back(0);
  B.push_back(0);
  map<int,int> :: iterator it;
  for(it=mp.begin();it!=mp.end();it++){
    A.push_back(it->first);
    B.push_back(it->second);
  }
  int size=A.size()-1,base=A[1];
  for(int i=1;i<=size;i++)A[i]-=base;
  fill(dp[1],dp[2005],1e9);
  for(int i=1;i<=size;i++){ 
    for(int j=1;j<=m;j++){
      int sum=0;
      for(int k=i-1;k>=0;k--){
        dp[i][j]=min(dp[i][j],dp[k][j-1]+sum);
        sum+=(A[i]-A[k])*B[k];
        if(sum>dp[i][j])break;
      }
    }
  }
  cout<<dp[size][m]<<endl;
  return 0;
}

Measured memory_bytes: 17052
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int n;
	char s[300][301];
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",s[i]);
	bool flag[601];
	fill(flag,flag+2*n+1,true);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=-n;k<=n;k++){
				if(s[i][j]!=s[(j+k+n)%n][(i-k+n)%n]) flag[k+n] = false;
			}
		}
	}
	int ans = 0;
	for(int i=-n;i<=n;i++){
		if(flag[i+n]) ans += min(n,n-i) - max(0,-i);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

int n=3,k;

int main(){
	cin>>k;
	vl dp(k+1);
	for(int i=k;i>0;i--){
		dp[i]=Pow(k/i,n);
		for(int j=2*i;j<=k;j+=i) dp[i]=(dp[i]-dp[j]+mod)%mod;
	}
	ll res=0;
	for(int i=1;i<=k;i++) (res+=dp[i]*i)%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 3580
N, T = map(int, input().split())
A = list(map(int, input().split()))

mx = [0] * (N + 1)
for i, a in enumerate(A[::-1], start=1):
    mx[-i] = max(mx[-i + 1], a)

mxD = 0
ans = 0
for i, a in enumerate(A):
    d = mx[i + 1] - a
    if mxD < d:
        mxD = d
        ans = 0
    if mxD == d:
        ans += 1

print(ans)


Measured memory_bytes: 15020
d = {}
n = int(input())
for i in range(n):
    *bfr, v = map(int, input().split())
    d[tuple(bfr)] = d.get(tuple(bfr), 0) + v


for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            print(f' {d.get((b, f, r), 0)}', end='')
        print()
    if b != 4:
        print('#' * 20)
    


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 2e5 + 7;

int p[N], ss[N], ok[N*2];

signed main()
{
	IO_OP;
	
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;
	for(int i=0;i<n;i++) {
		if(s[i] == 'o') {
			p[i] = (i-c-1 >= 0 ? p[i-c-1] : 0) + 1;
		} else {
			p[i] = i-1 >= 0 ? p[i-1] : 0;
		}
	}
	for(int i=n-1;i>=0;i--) {
		if(s[i] == 'o') {
			ss[i] = (i+c+1 >= 0 ? ss[i+c+1] : 0) + 1;
		} else {
			ss[i] = i+1 < n ? ss[i+1] : 0;
		}
	}
	c = max(c, 1);
	for(int l=-c;l<n;l++) {
		int r = l + c - 1;
		int has = (l-1 >= 0 ? p[l-1] : 0) + (r + 1 < n ? ss[r + 1] : 0);
		if(has >= k) {
			ok[max(l, 0)]++;
			ok[r+1]--;
		}
	}
	for(int i=1;i<n;i++) ok[i] += ok[i-1];
	for(int i=0;i<n;i++) {
		if(ok[i] == 0 && s[i] == 'o') {
			cout << i + 1 << endl;
		}
	}
}





Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(a==0)return b;
    
    return gcd(b,a%b);
}

int main()
{
  ll n,m,i,j,temp=0,flag=0,k;
string s;
cin>>k;

for(i=1;i<=k;i++)
{
    for(j=1;j<=k;j++)
    {
        for(m=1;m<=k;m++)
        {
            temp+=__gcd(__gcd(j,m),i);
        }
    }
}
cout<<temp<<endl;
return 0;

}






Measured memory_bytes: 3624
import collections
n = int(input())
a = list(map(int,input().split()))
a = collections.Counter(a)
a = list(a.items())
a.sort()
ans = 0
for i in range(len(a)):
    tar = a[i]
    if tar[0] < tar[1]:
        ans += tar[1]-tar[0]
    elif tar[1] < tar[0]:
        ans += tar[1]
print(ans)




Measured memory_bytes: 69160
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int N;
int a[40005];
int b[40005];

bool solve() {
    scanf("%d", &N);
    if (N == 0) { return false; }

    for (int j = 0; j < N; ++j) {
        scanf("%d", a+j);
    }
    for (int j = 0; j < N; ++j) {
        scanf("%d", b+j);
    }

    sort(a, a+N, greater<int>());
    sort(b, b+N, greater<int>());

    int wa = 0, wb = 0;

    for (int ia = 0, ib = 0; ia < N-1;) {
        if (a[ia] > b[ib]) {
            ++wa;
            ++ia;
        } else {
            ++wb;
            ++ia; ++ib;
        }

        if (wa > wb) {
            printf("%d\n", ia);
            return true;
        }
    }

    puts("NA");
    return true;
}

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

Measured memory_bytes: 3060
//Recursive sol, own
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll dp[100001], h[100001];

ll rec(int n){
    if (dp[n] != LLONG_MAX) return dp[n];
    dp[n] = min(dp[n], rec(n - 1) + abs(h[n - 1] - h[n]));
    if (n > 1) dp[n] = min(dp[n], rec(n - 2) + abs(h[n - 2] - h[n]));
    return dp[n];
}

int main()
{
    for (int i = 0; i <= 100000; i++) dp[i] = LLONG_MAX;
    dp[0] = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", &h[i]);
    printf("%lld", rec(n - 1));
    return 0;
}

Measured memory_bytes: 10024
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int n,k;

signed main(){
    string n;cin>>n;
    if(n[0]==n[1]&&n[0]==n[2])cout<<"Yes"<<endl;
    else if(n[1]==n[2]&&n[2]==n[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> pos(4);
    for(int i = 0; i < n; ++i){
        if(s[i] == 'R') pos[1].push_back(i);
        else if(s[i] == 'G')    pos[2].push_back(i);
        else    pos[3].push_back(i);
    }

    ll ans = 0;
    for(int i = 0; i < n - 2; ++i){
        int a;
        if(s[i] == 'R') a = 1;
        else if(s[i] == 'G')    a = 2;
        else    a = 3;

        for(int b = 1; b <= 3; ++b){
            if(b == a)  continue;
            int st = lower_bound(pos[b].begin(), pos[b].end(), i) - pos[b].begin();
            int sz = pos[b].size();

            for(int j = st; j < sz; ++j){
                int len = pos[b][j] - i;
                int c = a ^ b;
                int add = lower_bound(pos[c].begin(), pos[c].end(), pos[b][j] + len) - lower_bound(pos[c].begin(), pos[c].end(), pos[b][j]);
                add += pos[c].end() - upper_bound(pos[c].begin(), pos[c].end(), pos[b][j] + len);
                ans += add;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
N = int(input())
str_N = str(N)
digits = len(str_N)
lim = min(str_N[0], str_N[-1])

#print(digits, lim)

count = 0
for a in range(1,N+1):
    str_a = str(a)
    a_s = str_a[0]
    a_e = str_a[-1]
    dig_a = len(str_a)
    
    if int(a_e) > 0:
        #one digit b
        if a_s == a_e:
            count += 1
        #two or more digits
        for dig_b in range(2,digits):
            count += 10**(dig_b-2)
            
        reverse = int(a_e)*10**(digits-1) + int(a_s)
        if reverse <= N:
            if int(a_e) < int(str_N[0]):
                count += 10**(digits-2)
            else:
                count += (N - reverse)//10 + 1

    #print(a, count)

print(count)
        

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

const int maxn = 20;
const int maxN = 1000000;
const int maxt = 2000002;

struct node {
	node *ch[3];
	int lazy, id;
};

node* build(int d, int cur);
void pd(node *p);
void change(node *p, int d);
void cal(node *p, int d, int cur);

int n, t;
char str[maxt];
int powd[maxn];
int ans[maxN];

int main() {
	scanf("%d", &n);
	scanf("%s", str + 1);
	t = strlen(str + 1);
	powd[0] = 1;
	for (int i = 1; i < n; i++) {
		powd[i] = 3 * powd[i - 1];
	}
	node *rt = build(0, 0);
	for (int i = 1; i <= t; i++) {
		if (str[i] == 'S') rt->lazy ^= 1;
		else change(rt, 0);
	}
	cal(rt, 0, 0);
	int N = 1;
	for (int i = 1; i <= n; i++) N *= 3;
	for (int i = 0; i < N; i++) {
		printf("%d ", ans[i]);
	}
	return 0;
}

node* create() {
	static node pool[maxN];
	static node *p = pool;
	p->ch[0] = p->ch[1] = p->ch[2] = NULL;
	p->lazy = p->id = 0;
	return p++;
}

node* build(int d, int cur) {
	node *p = create();
	if (d == n) {
		p->id = cur;
		return p;
	}
	p->ch[0] = build(d + 1, cur);
	p->ch[1] = build(d + 1, cur + powd[d]);
	p->ch[2] = build(d + 1, cur + powd[d] + powd[d]);
	return p;
}

void pd(node *p) {
	if (!p->lazy) return;
	swap(p->ch[1], p->ch[2]);
	p->ch[0]->lazy ^= 1;
	p->ch[1]->lazy ^= 1;
	p->ch[2]->lazy ^= 1;
	p->lazy = 0;
}

void change(node *p, int d) {
	if (d == n) return;
	pd(p);
	swap(p->ch[0], p->ch[1]);
	swap(p->ch[0], p->ch[2]);
	change(p->ch[0], d + 1);
}

void cal(node *p, int d, int cur) {
	if (d == n) {
		ans[p->id] = cur;
		return;
	}
	pd(p);
	cal(p->ch[0], d + 1, cur);
	cal(p->ch[1], d + 1, cur + powd[d]);
	cal(p->ch[2], d + 1, cur + powd[d] + powd[d]);
}

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

using namespace std;

int main(){
  int X1, X2, X3 ,X4, X5;
  cin >> X1 >> X2 >> X3 >> X4 >> X5;
  if(X1 == 0){
    cout << 1;
  }else if(X2 == 0){
    cout << 2;
  }else if(X3 == 0){
    cout << 3;
  }else if(X4 == 0){
    cout << 4;
  }else if(X5 == 0){
    cout << 5;
  }

  return 0;
}


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

int main(){
  int m,d,a=0;
  cin >> m >> d;
  
  REP(i,m) REP(j,d){
    int jone=j%10, jten = (j-jone)/10;
    if(jone>=2 && jten>=2 && i==jone*jten) a++;
  }
  
  cout << a <<endl;  
}

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

int main(void) {
	int d,i,j;
	unsigned long long int c[64],s,m;
	double x,y[131072];
	for(i = 0;i <= 63;i++){
		c[i] = 0;
	}
	c[0] = K;
	for(i = 1;i <= 100000;i++){
		m = 0;
		for(j = 31;j >= 0;j--){
			x = x + ((c[j] / pow(2,j)) / K);
			s = c[j];
			c[j + 1] = s / pow(2,j);
			m += s - (s / pow(2,j));
		}
		c[0] = m;
		y[i] = x;
	}
	while(scanf("%d",&d) , d != 0){
		printf("%lf\n",y[d]);
	}
	return 0;
}

Measured memory_bytes: 1460
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, m, s;
    cin >> n >> m >> s;
    vector<vector<int>> edge(n, vector<int>());
    vector<vector<int>> fare(n, vector<int>());
    vector<vector<int>> time(n, vector<int>());
    int maxa = 0;
    for(int i=0; i<m; i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
        fare[u].push_back(a);
        fare[v].push_back(a);
        time[u].push_back(b);
        time[v].push_back(b);
        maxa = max(maxa, a);
    }

    vector<int> c(n), d(n);
    for(int i=0; i<n; i++){
        cin >> c[i] >> d[i];
    }

    // 所要時間、場所、所持銀貨
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> pq;

    // dis[i][j] は 銀貨 j 枚で i にたどり着く最小時間
    vector<vector<int>> dis(n, vector<int>(maxa*n+1, -1));
    if(s > maxa*n) s = maxa*n;
    pq.push(make_tuple(0, 0, s));

    auto all_visited = [&](){
        for(int i=0; i<n; i++){
            bool flag = false;
            for(int j=0; j<=maxa*n; j++){
                if(dis[i][j] != -1){
                    flag = true;
                    break;
                }
            }
            if(!flag) return false;
        }
        return true;
    };

    while(!all_visited()){
        int tim = get<0>(pq.top());
        int pla = get<1>(pq.top());
        int sil = get<2>(pq.top());
        pq.pop();
        if(dis[pla][sil] == -1) dis[pla][sil] = tim;
        else continue;

        // 買わないで進むパターン
        for(int i=0; i<edge[pla].size(); i++){
            int next_tim = tim + time[pla][i];
            int next_pla = edge[pla][i];
            int next_sil = sil - fare[pla][i];
            if(next_sil >= 0 && dis[next_pla][next_sil] == -1){
                pq.push(make_tuple(next_tim, next_pla, next_sil));
            }
        }

        // 一回だけ買うパターン
        if(sil+c[pla] < maxa*n){
            if(dis[pla][sil+c[pla]] == -1){
                pq.push(make_tuple(tim + d[pla], pla, sil + c[pla]));
            }
        }
        else{
            if(dis[pla][maxa*n] == -1) pq.push(make_tuple(tim + d[pla], pla, maxa*n));
        }
    }

    for(int i=1; i<n; i++){
        int min_dis = (1LL<<60);
        for(int j=0; j<=maxa*n; j++){
            if(dis[i][j] != -1) min_dis = min(min_dis, dis[i][j]);
        }
        cout << min_dis << endl;
    }

    return 0;
}

Measured memory_bytes: 10448
s = input()
if int(s[0])+int(s[1])+int(s[2])+int(s[3])==7:
    print(s[0]+'+'+s[1]+'+'+s[2]+'+'+s[3]+'=7')
elif int(s[0])+int(s[1])+int(s[2])-int(s[3])==7:
    print(s[0]+'+'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
elif int(s[0])+int(s[1])-int(s[2])+int(s[3])==7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
elif int(s[0])+int(s[1])-int(s[2])-int(s[3])==7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'-'+s[3]+'=7')
elif int(s[0])-int(s[1])+int(s[2])+int(s[3])==7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'+'+s[3]+'=7')
elif int(s[0])-int(s[1])+int(s[2])-int(s[3])==7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
elif int(s[0])-int(s[1])-int(s[2])+int(s[3])==7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
elif int(s[0])-int(s[1])-int(s[2])-int(s[3])==7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'-'+s[3]+'=7')

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <deque>

#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef unsigned long long ull;
typedef pair<ll, ll> pr;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    if(n%2==1){
        n++;
    }
    if(n/2>=k){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int result = 0;
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			if (p < min) {
				result++;
				min = p;
			}
		}
		sc.close();

		System.out.println(result);
	}
}


Measured memory_bytes: 62992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int len = (int)Math.Sqrt(n);
            int res = n;

            if (n % 2 == 0)
            {
                res -= res / 2;

                while (n % 2 == 0) n /= 2;
            }

            for (int i = 3; i <= len; i += 2)
            {
                if (n % i == 0)
                {
                    res -= res / i;

                    while (n % i == 0) n /= i;
                }
            }

            if (n != 1) res -= res / n;

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 9224
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] acs = new int[n + 1];
        int[] was = new int[n + 1];

        for(int i = 0; i < m; i++) {
            int p = Integer.parseInt(sc.next());
            String r = sc.next();
            if(r.equals("AC") && acs[p] == 0) {
                acs[p]++;
            }
            else {
                if(acs[p] == 0) {
                    was[p]++;
                }
            }
        }
        long ans = 0;
        long pen = 0;
        for(int i = 0; i < n; i++) {
            ans += acs[i + 1];
            pen += (acs[i + 1] == 1 ? was[i + 1] : 0);
        }
        System.out.println(ans + " " + pen);
    }
}


Measured memory_bytes: 56400
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 367
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int n;
void dfs(string s="",char max='a'){
    if(SZ(s)==n)OUT(s);
    else{
        for(char c='a';c<=max;c++){
            dfs(s+c,((c==max)?char(max+1):max));
        }
    }
}
int main(){
    cin>>n;
    dfs();
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}



int main(){
    string s;
    cin >> s;

    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n / 2; i++){
        if(s[i] == s[n - 1 - i]) continue;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    string n;
    cin >> n;

    int sum = 0;
    for (char c : n) {
        sum += c - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << newl;

    return 0;
}

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

int main(void){
	long N;
	cin>> N;
	int order = log10(N) + 1;
	int ans = 0;

	if(order == 1){
		cout << N;
		return 0;
	}else if(order == 2){
		cout << 9;
		return 0;
	}else if(order == 3){
		int tmp = 9 + (N - 99);
		cout << tmp;
		return 0;
	}else if(order == 4){
		cout << 909;
		return 0;
	}else if(order == 5){
		int tmp = 909 + (N - 9999);
		cout << tmp;
		return 0;
	}else if(order == 6){
		cout << 90909;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	string S;
	cin >> S;

	int L=S.length();
	vi v(L+1,0);
	int count=1;

	for(int i=0; i<L; i++){
		if(S[i]=='<'){
			if(v[i+1]<count) v[i+1]=count;
			count++;
		}else{
			count=1;
		}
	}

	count=1;
	for(int i=0; i<L; i++){
		if(S[L-i-1]=='>'){
			if(v[L-i-1]<count) v[L-i-1]=count;
			count++;
		}else{
			count=1;
		}
	}

	ll ans=0;
	for(int i=0; i<L+1; i++){
		ans+=v[i];
	}

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

Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

#include <iostream>
#include <vector>

#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vc(t, n) vector<t>(n)

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

class UnionFind
{
    vector<p> data;
public:
    UnionFind(int N)
    {
        data.resize(N+1);
        lpn(i, N+1) data[i] = {i, 1};
    }
    int root(int i)
    {
        if (data[i].first == i) return i;
        auto r = root(data[i].first);
        data[i] = {r, data[r].second};
        return r;
    }
    ll size(int i)
    {
        return data[root(data[i].first)].second;
    }
    void unite(int i, int j)
    {
        auto ri = root(i), rj = root(j);
        if (ri == rj) return;
        data[ri] = data[rj] = data[i] = data[j] = {min(ri, rj), size(i) + size(j)};
    }
};

int main(void)
{
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    int X, Y, Z;
    while(M--)
    {
        cin >> X >> Y >> Z;
        uf.unite(X, Y);
    }
    int ans = 0;
    lpn(i, N) if (i+1 == uf.root(i+1)) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
S = input()
T = input()

from fnmatch import fnmatch

for i in range(len(S) - len(T), -1, -1):
    if fnmatch(T, S[i:i + len(T)]):
        r = S[:i] + T + S[i + len(T):]
        r = r.replace("?", "a")
        print(r)
        break
else:
    print("UNRESTORABLE")


Measured memory_bytes: 4084
#include<stdio.h>
int main()
{
    int n,i,temp,a[10],x,y,z,j,c;
    scanf("%d%d%d",&x,&y,&z);
    a[0]=x;
    a[1]=y;
    a[2]=z;
    for(i=0;i<3;i++){

        for(j=i+1;j<3;j++){

            if(a[i]<a[j]){


                temp=a[i];
                a[i]=a[j];
                a[j]=temp;


            }

        }

    }
    c=(a[0]-a[1])+(a[1]-a[2]);
    //printf("%d %d %d\n",a[0],a[1],a[2]);
    printf("%d",c);
    return 0;

}


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

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
		
	// k = 1e6
	int k; cin >> k;

	int cur = 7 % k, ans = 1;
	while (cur != 0) {
		cur = (cur*10) + 7;
		cur %= k;

		ans++;

		if (ans > 10000000) {
			cout << "-1\n"; exit(0);
		}
	}
	cout << ans << '\n';


	return 0;
}


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

int	main(void)
{
  int num;
  string color;
  int yellow = 0;
  cin >> num;
  
  while (num > 0)
  {
    cin >> color;
    if (color == "Y")
    {
      yellow++;
    }
    num--;
  }
  
  if (yellow > 0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}
    

Measured memory_bytes: 256
n,k=map(int,input().split())
x=list(map(int,input().split()))
mintime=abs(x[0])+abs(x[0]-x[n-1])
for i in range(n-k+1):
  r=abs(x[k+i-1])+abs(x[k+i-1]-x[i])
  l=abs(x[i])+abs(x[k+i-1]-x[i])
  if min(r,l)<mintime:
    mintime=min(r,l)
print(mintime)

Measured memory_bytes: 14252
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();

		int[] T = new int[N];
		for (int i = 0; i < N; i++) {
			T[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(T);
		int bus = 0;
		int last = -1;
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			cnt++;
			if (last == -1) {
				last = T[i];
			} else {
				if (last + K < T[i]) {
					bus++;
					cnt = 1;
					last = T[i];
				}
			}
			if (cnt >= C) {
				bus++;
				cnt = 0;
				last = -1;
			}
		}
		if (cnt > 0) {
			bus++;
		}
		System.out.println(bus);
	}
}


Measured memory_bytes: 50940
N = input()
TA = list(map(float,input().split()))
H = list(map(float,input().split()))
temp = 99999999999999.999
ind = 0
for x in H:
	if temp > abs(TA[1] -(TA[0]-x*0.006)):
		temp = abs(TA[1] -(TA[0]-x*0.006))
		ind = H.index(x)
print(ind+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  set<string> st;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19272
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] px = new int[n];
		int[] py = new int[n];
		int[] cx = new int[m];
		int[] cy = new int[m];
		int dist1;
		for(int i=0;i<n;i++) {
			px[i] = sc.nextInt();
			py[i] = sc.nextInt();
		}
		for(int i=0;i<m;i++) {
			cx[i] = sc.nextInt();
			cy[i] = sc.nextInt();
		}
		
		for(int i=0;i<n;i++) {
			int idx = 0;
			dist1=dist(px[i],py[i],cx[0],cy[0]);
			for(int k=0;k<m;k++) {
				if(dist(px[i],py[i],cx[k],cy[k])<dist1) {
					idx=k;
					dist1=dist(px[i],py[i],cx[k],cy[k]);
				}
			}
			System.out.println(idx+1);
		}
	}
	
	static int dist(int x1, int y1, int x2, int y2) {
		return Math.abs(x1 - x2) + Math.abs(y1 - y2);
	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (100010)
#define P ()
#define M (N<<1)
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,E,siz,fi[N],ne[M],b[M],c[M],col[N],cnt[3]; LL ans; bool fl;
void add(int x,int y,int z){
	ne[++E]=fi[x],fi[x]=E,b[E]=y,c[E]=z;
}
void dfs(int u){
	cnt[col[u]]++;
	for(int i=fi[u];i;i=ne[i]){
		int v=b[i];
		if(c[i]==1)siz++;
		if(~col[v])fl|=(col[v]!=(col[u]+c[i])%3);
		else col[v]=(col[u]+c[i])%3,dfs(v);
	}
}
int main(){
	read(n),read(m);
	for(int i=1;i<=m;i++){
		int x,y;
		read(x),read(y);
		add(x,y,1),add(y,x,2);
	}
	memset(col,-1,sizeof(col));
	for(int i=1;i<=n;i++)
	if(!(~col[i])){
		cnt[0]=cnt[1]=cnt[2]=siz=fl=0,col[i]=0;
		dfs(i); if(fl)ans+=1ll*(cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]);
		else if(cnt[0]&&cnt[1]&&cnt[2])ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
		else ans+=siz;
	}
	cout<<ans;
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main(){
 string s;
 string t;
 cin >> s;
 cin >> t;
 int c = 0;
 int i;
 for (i = 0; i< 3; i++){ 
  if(s[i] == t[i]) c ++;
 }
 cout << c << "\n";
 return 0;
}

Measured memory_bytes: 256
package main

import (
	. "fmt"
)

func main() {
	var s, t string
	Scan(&s, &t)

	mi := "UNRESTORABLE"
	for i := 0; i + len(t) <= len(s); i++ {
		f := false
		for j := 0; j < len(t); j++ {
			if s[i + j] == '?' {
				continue
			}

			if s[i + j] != t[j] {
				f = true
			}
		}

		if f {
			continue
		}

		nw := []byte(s[0:i] + t + s[i + len(t):])
		for j := 0; j < len(nw); j++ {
			if nw[j] == '?' {
				nw[j] = 'a'
			}
		}
		w := string(nw)

		if mi == "UNRESTORABLE" {
			mi = w
		} else if w < mi {
			mi = w
		}

	}

	Println(mi)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    ll n;
    ll d[110];
    cin >> n;
    rep(i, n) cin >> d[i];

    ll num[110] = {0};
    rep(i, n){
        num[d[i]]++;
    }

    ll ans;
    for(int i = 1; i <= 100; i++){
        if(num[i]) ++ans;
    }

    cout << ans << endl;
}
   

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

int n, m, k;
void solve(int i, int val, vector<int>& cnt) {
    if(i == n) {
        if(val <= k) {
            cnt[1]++;
        } else {
            cnt[val-k]++;
        }
        return;
    }
    for(int j=1; j<=m; ++j) {
        solve(i+1, val+j, cnt);
    }
}

int main() {
    while(cin >> n >> m >> k, n) {
        vector<int> cnt(n*m+1, 0);
        solve(0, 0, cnt);
        double ret = 0;
        for(int i=0; i<cnt.size(); ++i) {
            ret += i * cnt[i] / static_cast<double>(pow(m, n));
        }
        cout << fixed << setprecision(8) << ret << endl;
    }
}


Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 
 
#define MAX 200005
#define endl endl


int main()
{
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int x;
	cin>>x;
	
	if(x>=30){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(){

    int W, a, b;
    cin >> W >> a >> b;

    int ans;
    if (a <= b && b <= a + W){
        ans = 0;
    }else if (a <= b + W && b + W <= a + W){
        ans = 0;
    }else{
        ans = min(abs(a + W - b), abs(a - b - W));
    }
    
    cout << ans << endl;
    

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    Graph graph(N);
    rep(i, N) {
        ll u, k;
        cin >> u >> k;
        u--;
        rep(j, k) {
            ll v;
            cin >> v;
            v--;
            graph[u].push_back(v);
        }
    }
    vector<ll> dist(N, -1);
    dist[0] = 0;
    queue<P> que;
    que.push({0, 0});
    while (!que.empty()) {
        P p = que.front();
        que.pop();
        for (ll v: graph[p.first]) {
            if (dist[v] == -1) {
                dist[v] = p.second + 1;
                que.push({v, dist[v]});
            }
        }
    }
    rep(i, N) {
        cout << i + 1 << ' ' << dist[i] << '\n';
    }
}

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



Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
//#define int long long 
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
 
 
	ll n,r;
	cin>>n>>r;
	if(n>=10){
		cout<<r<<endl;
	}
	else{
		cout<<r+(100*(10-n))<<endl;
	}
 
 
 
 
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	int h,w,i,j;
	char c[310][300];
	scanf("%d %d",&h,&w);
	getchar();
	for(i=1;i<=h;i++){
		scanf("%s",&c[i]);
	}
	for(i=1;i<=h;i++){
			puts(c[i]);
			puts(c[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;
int32_t X[100000];
int32_t diff[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	for (int32_t i = 0; i < M; i++)
	{
		in >> X[i];
	}
	std::sort(X, X + M);
	for (int32_t i = 1; i < M; i++)
	{
		diff[i-1] =  (X[i] - X[i-1]);
	}
	std::sort(diff, diff + M-1);

	int64_t res = 0;
	for (int64_t i = 0; i < (M-N); i++)
	{
		res += diff[i];
	}
	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

signed main()
{
    warmup
    
    int n,i,x;
    cin>>n;
    for(i=1;i<=n;++i)
    {
        cin>>x;
        if((x%2==0) and (x%3 and x%5))
            break;
    }   
    cout<<(i<=n ? "DENIED":"APPROVED");
    
    
    return 0;
}


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

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main(){
    ll a,b;
    cin >> a >> b;
    auto f = factorize(gcd(a,b));
    int ans = (int)f.size() + 1;
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<ll,pii> piii;

int main () {
    int n; cin >> n;
    //vector<pii> v;
    vector<piii> v;
    for (int i=0;i<n;++i) {
        ll x,y; cin >> x >> y;
        v.push_back({x+y,{x,y}});
        //v.push_back(x+y);
        //v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll ans=0;
    ll del=1;
    for (piii i:v) {
        if (del == 1) ans += i.second.first;
        else ans -= i.second.second;
        del *= -1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4852
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N,x;

	cin >> N;

	long long A[N], ans;

	for(int j=0; ;){
		bool ok = true;
		for(long long i = 0; i < N; i++){
			if(j == 0) {
				cin >> x;
				A[i] = x;
				if(i == 0) ans = A[i];
			}
			if(A[i] % ans != 0){
				ans = A[i] % ans;
				ok = false;
			}
		}
		if(ok) break;
		j=1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1152