akhauriyash/Code-Regression huggingface dataset:
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n=int(input())
l=[0]*(n+1)
for i in range(1,n+1):
    c=prime_factorize(i)
    #print(c)
    for j in range(len(c)):
        l[c[j]]+=1
#print(l)
ans=1
for i in range(n+1):
    if l[i]!=0:
        ans=ans*(l[i]+1)%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 41564
n=int(input())
w=[int(i) for i in input().split()]
d=[0]*n
for i in range(n):
    d[i]=d[i-1]+w[i]
ans=chk=d[-1]
for i in range(n-1):
    ans=min(ans,abs(d[-1]-d[i]-d[i]))
print(ans)

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

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
    int num;
    cin >> num;
    for (int j=0; j<3; j++) {
      for (int k=0; k<3; k++) {
        if (a.at(j).at(k)==num) {
          a.at(j).at(k)=0;
          goto E;
        }
      }
    }
    E:continue;
  }
  bool ans=false;
  for (int i=0; i<3; i++) {
    if (a.at(0).at(i)==0 && a.at(1).at(i)==0 && a.at(2).at(i)==0) ans=true;
    if (a.at(i).at(0)==0 && a.at(i).at(1)==0 && a.at(i).at(2)==0) ans=true;
  }
  if (a.at(0).at(0)==0 && a.at(1).at(1)==0 && a.at(2).at(2)==0) ans=true;
  if (a.at(0).at(2)==0 && a.at(1).at(1)==0 && a.at(2).at(0)==0) ans=true;
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using ll = long long;

int main() {
    ll n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll x = 5;
    ll cnt = 0;
    n /= 2;
    while (x <= n) {
        cnt += n / x;
        x *= 5;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextStrSlice() []string {
	arr := []string{}
	for _, v := range s.nextStr() {
		arr = append(arr, string(v))
	}
	return arr
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	arr := make([][]string, N)
	for i := 0; i < N; i++ {
		arr[i] = sc.nextStrSlice()
	}
	count := 0
	M := make(map[string]int)
	for i := 0; i < N; i++ {
		str := toSortedStr(arr[i])
		if M[str] > 0 {
			count += M[str]
			M[str]++
		} else {
			M[str]++
		}
	}
	fmt.Println(count)
}

func toSortedStr(a []string) string {
	sort.Strings(a)
	return strings.Join(a, "")
}

func isMatch(a, b []rune) bool {
	am := make(map[rune]int)
	bm := make(map[rune]int)
	for _, v := range a {
		am[v]++
	}
	for _, v := range b {
		bm[v]++
	}
	flg := true
	for k, v := range am {
		if v != bm[k] {
			flg = false
		}
	}
	return flg
}


Measured memory_bytes: 53888
#ifdef __GNUG__
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
#endif

//#pragma optimize GCC("O3")
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<ll> l(n);
	for (int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	int ans = 0;
	for (ll i : l)
	{
		for (ll j : l)
		{
			for (ll k : l)
			{
				if (i < j && j < k && i + j + k > 2ll * max({ i, j, k }))
				{
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int n;
vector<int> c, s, f;


int main() {
  cin >> n;
  c.resize(n - 1);
  s.resize(n - 1);
  f.resize(n - 1);
  for(int i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];
  for(int i = 0; i < n; i++) {
    int t = 0;
    for(int j = i; j < n - 1; j++) {
      if(t < s[j]) t = s[j] + c[j];
      else {
        t += (f[j] - t % f[j]) % f[j] + c[j];
      }
    }
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [f64; n],
    }

    let mut dp = vec![vec![0f64; n + 1]; n + 1];
    dp[0][0] = 1.0;
    for i in 1..n + 1 {
        for j in 0..n + 1 {
            dp[i][j] += dp[i - 1][j] * (1.0 - p[i - 1]);
            if j > 0 {
                dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
            }
        }
    }
    println!("{}", dp[n][n/2+1..].iter().fold(0f64, |sum, &v| sum + v));
}


Measured memory_bytes: 90364
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    Vi a(n);
    rp(i,n) cin >> a.at(i);
    Sort(a);
    princ(a[0]);
    ll mid, ok = n, ng = 1;
    while(abs(ok-ng)>1){
        mid = (ok+ng)/2;
        if(a.at(mid)<=a[0]/2)ok = mid;
        else ng = mid;
    }//midではなくokを使わないとバグる!
    if(a[0]&1){
        if(abs(a[ok]-a[0]/2)<abs(a[ng]-(a[0]/2+1))) print(a[ok]);
        else print(a[ng]);
    }else{
        if(abs(a[ok]-a[0]/2)<abs(a[ng]-(a[0]/2))) print(a[ok]);
        else print(a[ng]);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main(){
    int S;
    cin >> S;
    int h=0, m=0, s;

    while (S >= 3600)
    {
        S -= 3600;
        h++;
    }
    while (S >= 60)
    {
        S -= 60;
        m++;
    }
    s = S;
    
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


ll solve(ll a, ll b){
	ll tmp = a / b;
	ll ret = tmp * b * 2;
	if( a % b == 0 ){
		return ret - b;
	}
	return ret + solve(b, a%b);
}

int main(){
	ll N, x, ans=0;

	cin >> N >> x;
	ans = N;
	ans += solve(x, N-x);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
h,w,m=map(int,input().split())
bomb=[]
x=[0]*(h+1)
y=[0]*(w+1)
for i in range(m):
    h1,w1=map(int,input().split())
    x[h1]+=1
    y[w1]+=1
    bomb.append((h1,w1))
maxx=max(x)
maxy=max(y)
r=[]
c=[]
bomb=set(bomb)
for i in range(1,h+1):
    if x[i]==maxx:
        r.append(i)
for j in range(1,w+1):
    if y[j]==maxy:
        c.append(j)
for j in r:
    for k in c:
        if (j,k) not in bomb:
            print(maxx+maxy)
            exit()
print(maxx+maxy-1)

Measured memory_bytes: 201232
s = list(x for x in input())
ans = 'Yes'
for i in range(1, len(s)+1):
  if i % 2 == 1:
    if s[i-1] == 'L':
      ans = 'No'
      break
  elif i % 2 == 0:
    if s[i-1] == 'R':
      ans = 'No'
      break
print(ans)

Measured memory_bytes: 3060
import sys
import collections
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))

    c = collections.Counter(A)

    s = 0
    for (k, v) in c.items():
        s += (v * (v -1) //2)

    for x in A:
        print(s - (c[x] - 1))


if __name__ == "__main__":
    main()


Measured memory_bytes: 25916
/*
Atcoder ABC165F
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define mid (l+r>>1)

int n,a[200005];
int ee,h[200005],nex[200005<<1],to[200005<<1];
int ans[200005],f[200005];
vector<int> lsh;
int cnt,root[200005];
struct hjtree{
	int l,r,v;
}t[200005<<6];

void addedge(int x,int y)
{
	nex[++ee] = h[x];
	to[ee] = y;
	h[x] = ee;
}

void lsh_()
{
	sort(lsh.begin(),lsh.end());
	lsh.erase(unique(lsh.begin(),lsh.end()),lsh.end());
}

void insert(int &o,int pre,int l,int r,int x,int v)
{
	o = ++cnt;
	t[o] = t[pre];
	t[o].v = max(t[o].v,v);
	if(l==r)
		return;
	if(x<=mid)
		insert(t[o].l,t[pre].l,l,mid,x,v);
	else
		insert(t[o].r,t[pre].r,mid+1,r,x,v);
}

int query(int o,int l,int r,int ql,int qr)
{
	if(ql>qr)
		return 0;
	if(l>=ql && r<=qr)
		return t[o].v;
	int res=0;
	if(ql<=mid)
		res = max(res,query(t[o].l,l,mid,ql,qr));
	if(qr>mid)
		res = max(res,query(t[o].r,mid+1,r,ql,qr));
	return res;
}

void dfs(int x,int pre)
{
	f[x] = query(root[pre],1,n,1,lower_bound(lsh.begin(),lsh.end(),a[x])-lsh.begin())+1;
	ans[x] = max(ans[pre],f[x]);
	insert(root[x],root[pre],1,n,lower_bound(lsh.begin(),lsh.end(),a[x])-lsh.begin()+1,f[x]);
	for(int i=h[x];i;i=nex[i])
		if(to[i]!=pre)
			dfs(to[i],x);
}

signed main()
{
	cin>>n;
	for(int i=1;i<=n;cin>>a[i++]);
	for(int i=1;i<=n;i++)
		lsh.push_back(a[i]);
	lsh_();
	for(int i=1,x,y;i<n&&cin>>x>>y;i++)
		addedge(x,y), addedge(y,x);
	dfs(1,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	
	return 0;
}

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

typedef long long ll;
const int maxn = 2e5 + 5,inf = 0x3f3f3f3f;
int n,t,cnt,tot;
ll dp[35],pre[maxn];

struct node
{
    int a,b;
    bool operator<(const node&rhs) const
    {
        return 1LL * a * (rhs.b + 1) > 1LL * rhs.a * (b + 1);
    }
}p[maxn];

int cal()
{
    for(int i=0;i<35;i++) dp[i] = inf;
    dp[0] = 0;
    for(int i=0;i<tot;i++){
        for(int j=30;j>=0;j--){
            if(dp[j]==inf) continue;
            dp[j+1] = min(dp[j+1],(dp[j] + 1) * (p[i].a + 1) + p[i].b);
            if(dp[j+1]>t) dp[j+1] = inf;
        }
    }
    int ans = 0;
    for(int i=0;i<=31;i++){
        if(dp[i]!=inf){
            int x = t - dp[i];
            int y = upper_bound(pre,pre+cnt+1,x) - pre - 1;
            ans = max(ans,i+y);
        }
    }
    return ans;
}

int main()
{
    scanf("%d%d",&n,&t);
    pre[0] = cnt = tot = 0;
    for(int i=1,a,b;i<=n;i++){
        scanf("%d%d",&a,&b);
        if(a==0) pre[++cnt] = b;
        else p[tot++] = {a,b};
    }
    sort(pre+1,pre+cnt+1),sort(p,p+tot);
    for(int i=1;i<=cnt;i++) pre[i] = pre[i] + 1 + pre[i-1];
    printf("%d\n",cal());
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
b = [0] * N
M = 0
for i in range(N, 0, -1):
    ball = 0
    for j in range(i + i, N + 1, i):
        ball ^= b[j - 1]
    b[i - 1] = ball ^ a[i]
M = sum(b)
print(M)
for i in range(N):
    if b[i]:
        print(i + 1, end = ' ')

Measured memory_bytes: 7148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s;cin>>s;
  rep(i,0,siz(s)){
    cout<<'x';
  }
  cout<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int a, b;
  while(scanf("%d%d", &a, &b) != EOF){
    a += b;
    int cnt = 0;
    while(a){
      cnt++;
      a /= 10;
    }
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 1028
N , K = [int(x) for x in input().split()]
A = [0] + [int(x) for x in input().split()]

orb = [1]
counter = [-1] * (N + 1)
v = A[1]
counter[1] = 0
c = 0
while 1:
    c += 1
    if counter[v] == -1:
        counter[v] = c
        orb.append(v)
        v = A[v]
    else:
        break

L = c - counter[v]
T = counter[v]

if K < c:
    ans = orb[K]
else:
    ans = orb[(K - T) % L + T]

print(ans)

Measured memory_bytes: 32324
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	int n;
	double x, sum = 0.0;
	string u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;
		if (u == "BTC") sum += (380000 * x);
		else sum += x;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
println = stdout.write

def main():
    D, N = map(int, input().split())

    if not D:
        ans = N if N < 100 else 101
    elif D == 1:
        ans = 100 * N if N < 100 else 10100
    else:
        ans = 10000 * N if N < 100 else 1010000
    print(ans)

main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

const int N_MAX = 1e5; // = 100000

int main(void){
    int n, A, B;
    cin >> n >> A >> B;

    int x[N_MAX];
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }

    long long res = 0;
    for(int i = 1; i < n; i++){
        long long len = x[i] - x[i - 1];
        long long diff = min(len * A, 1LL * B);

        res += diff;
    }

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	sum := make([]float64, n)
	var p float64
	for i := 0; i < n; i++ {
		fmt.Scan(&p)
		if i > 0 {
			sum[i] = sum[i-1] + (p+1)/2
		} else {
			sum[i] = (p + 1) / 2
		}
	}
	max := -1.0
	if k == n {
		max = sum[n-1]
		fmt.Println(max)
		return
	}
	for j := 0; j+k < n; j++ {
		if max < sum[j+k]-sum[j] {
			max = sum[j+k] - sum[j]
		}
	}
	fmt.Println(max)
	return
}


Measured memory_bytes: 4992
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    int n = 0, m = 0;
    cin >> n >> m;
    vector<vector<ll>> value(n, vector<ll>(3));
    for (int i=0; i<n; i++) {
        cin >> value.at(i).at(0) >> value.at(i).at(1) >> value.at(i).at(2);
    }
    vector<int> a = {1,1,1,1,-1,-1,-1,-1};
    vector<int> b = {1,1,-1,-1,1,1,-1,-1};
    vector<int> c = {1,-1,1,-1,1,-1,1,-1};
    ll ans = 0;
    for (int i=0; i<8; i++) {
        vector<ll> buf(n);
        int a_buf = a.at(i), b_buf = b.at(i), c_buf = c.at(i);
        for (int j=0; j<n; j++) {
            buf.at(j) = a_buf * value.at(j).at(0) + b_buf * value.at(j).at(1) + c_buf * value.at(j).at(2);
        }
        sort(buf.begin(), buf.end());
        ll bubu = 0;
        for (int j=n-m; j<n; j++) {
            bubu += buf.at(j);
        }
        if (bubu > ans) ans = bubu;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int n, m; cin >> n >> m;
  
  priority_queue<int> pq;
  while (n--) {
    int a; cin >> a;
    pq.push(a);
  }
  
  while (m--) {
    pq.push(pq.top()/2);
    pq.pop();
  }
  
  long long ans = 0;
  while (pq.size()) {
    ans += pq.top();
    pq.pop();
  }
  
  cout << ans << endl;
  return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, u, v;
  std::cin >> n >> u >> v;
  u--;
  v--;
  std::vector<std::set<int64_t>> no(n);

  for (int64_t i = 0; i < n - 1; i++) {
    int64_t a, b;
    std::cin >> a >> b;
    a--;
    b--;
    no[a].insert(b);
    no[b].insert(a);
  }

  std::vector<int64_t> t(n, n);
  t[u] = 0;
  std::queue<int64_t> q;
  q.push(u);

  while (!q.empty()) {
    const auto i = q.front();
    q.pop();

    for (const auto j : no[i]) {
      if (t[j] == n) {
        t[j] = t[i] + 1;
        q.push(j);
      }
    }
  }

  std::vector<int64_t> a(n, n);
  a[v] = 0;
  q.push(v);

  while (!q.empty()) {
    const auto i = q.front();
    q.pop();

    for (const auto j : no[i]) {
      if (a[j] == n) {
        a[j] = a[i] + 1;
        q.push(j);
      }
    }
  }

  int64_t ans = 0;

  for (int64_t i = 0; i < n; i++) {
    if (t[i] < a[i]) {
      ans = std::max(ans, a[i] - 1);
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

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

using namespace std;

int n, k;
int v[50];
int values[50];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int max_value = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j <= n; j++) {
      int used_moves = i + (n - j);
      if (used_moves > k) {
        continue;
      }
      int count = 0;
      for (int ip = 0; ip < i; ip++) {
        values[count] = v[ip];
        count += 1;
      }
      for (int jp = j; jp < n; jp++) {
        values[count] = v[jp];
        count += 1;
      }
      sort(&values[0], &values[count]);
      int idx = 0;
      while (idx < k - used_moves && idx < count && values[idx] < 0) {
        idx += 1;
      }
      int sum = 0;
      while (idx < count) {
        sum += values[idx];
        idx += 1;
      }
      if (sum > max_value) {
        max_value = sum;
      }
    }
  }
  printf("%d\n", max_value);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  // 解答
  cout << ((a * b) & 1 ? "Odd" : "Even") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
    int t;

    scanf("%d", &t);
    while (t--) {
        int n, k;

        scanf("%d %d", &n, &k);
        vector<int> data(n - 1);
        int a, b;

        scanf("%d", &a);
        for (int i = 0; i < n - 1; ++i) {
            scanf("%d", &b);
            data[i] = b - a;
            a = b;
        }

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

        int ans = 0;
        for (int i = 0; i < n - k; ++i)
            ans += data[i];

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1604
#include <iostream>
using namespace std;
int p[50100];
int main()
{
  int i,j;
  for(i=2;i*i<50100;i++){
    if(p[i]==0){
      for(j=i*2;j<50100;j+=i){
	p[j] = 1;
      }
    }
  }
  while(cin >> i){
    for(j=i-1;p[j];j--){}
    cout << j << ' ';
    for(j=i+1;p[j];j++){}
    cout << j << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define MAX(a,b) (((a)>(b))?(a):(b))

long dp[100][101][301];

int main(int argc, char const *argv[]){
	long n,w,i,we,va,w1,j,k,max=0;
	scanf("%ld %ld",&n,&w);
	scanf("%ld %ld",&w1,&va);
	for(i=0;i<n;i++){
		for(j=0;j<=i+1;j++){
			for(k=0;k<=3*j;k++){
				dp[i][j][k]=-1;
			}
		}
	}
	dp[0][0][0]=0;
	dp[0][1][0]=va;
	for(i=1;i<n;i++){
		scanf("%ld %ld",&we,&va);
		dp[i][0][0]=0;
		for(j=1;j<=i+1;j++){
			for(k=0;k<=j*3;k++){
				if(k-(we-w1)<0 || dp[i-1][j-1][k-(we-w1)]==-1){
					if(dp[i-1][j][k]!=-1) dp[i][j][k]=dp[i-1][j][k];
				}else{
					dp[i][j][k]=dp[i-1][j-1][k-(we-w1)]+va;
					if(dp[i-1][j][k]!=-1) dp[i][j][k]=MAX(dp[i-1][j][k],dp[i][j][k]);
				}
			}
		}
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=i*3;j++){
			if(w1*i+j>w) break;
			if(dp[n-1][i][j]!=-1) max=MAX(max,dp[n-1][i][j]);
		}
	}
	printf("%ld\n",max);
	return 0;
}

Measured memory_bytes: 22016
#include <iostream>
using namespace std;
int sign[10]={0};
int main()
{
	int N,K,t=0,a,flag;
	cin>>N>>K;
	for(int i=0;i<K;i++)
	{
		cin>>a;
		sign[a]=1;
	}
	for(int i=N;i<100000;i++)
	{
		int j=i;
		flag=1;
		while(j)
		{
			if(sign[j%10]==1)
			{
				flag=0;
				break;
			}	
			j=j/10;
		}
		if(flag==1)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<double, double> P;
typedef vector<double> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;


int main(void) {
	int n;
	double ans = 0;
	cin >> n;
	double x[8], y[8];
	int a[8];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		a[i] = i;
	}
	double k=1;
	for (int i = 2; i <= n; i++) {
		k*= i;
	}

	do {
		for (int i = 0; i < n-1; i++) {
			 ans+= sqrt((x[a[i]]-x[a[i+1]])*(x[a[i]] - x[a[i + 1]]) + (y[a[i]] - y[a[i + 1]])*(y[a[i]] - y[a[i + 1]]));
		}
	} while (next_permutation(a, a+n));
	printf("%.9lf",ans/k);
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int dist[110][110];
vector<int> G[110];
vector<int> D[110];
vector<int> E[110];

int main(){
  int N, M, L;
  while(cin >> N >> M >> L && N + M + L){
    REP(i, 110) {
      G[i].clear();
      D[i].clear();
      E[i].clear();
    }
    
    REP(i, M){
      int a, b, d, e;
      cin >> a >> b >> d >> e;
      G[a].push_back(b);
      D[a].push_back(d);
      E[a].push_back(e);
      G[b].push_back(a);
      D[b].push_back(d);
      E[b].push_back(e);
    }
    priority_queue<pair<int,P>, vector<pair<int,P> >, greater<pair<int,P> > > que;

    fill(&dist[0][0], &dist[0][0] + 110 * 110, INF);
    dist[1][L] = 0;
      
    que.push(MP(0, P(1, L)));
      
    while(!que.empty()){
      int c = que.top().first;
      int v = que.top().second.first;
      int l = que.top().second.second;
      que.pop();
      if(v == N){
        cout << c << endl;
        break;
      }
      if(c > dist[v][l]) continue;
        
      REP(i, G[v].size()){
        int to    = G[v][i];
        int cost  = D[v][i];
        int enemy = E[v][i];
        if(cost <= l && c < dist[to][l-cost]){
          dist[to][l-cost] = c;
          que.push(MP(c, P(to, l-cost)));
        }
          
        if(c + enemy < dist[to][l]){
          dist[to][l] = c + enemy;
          que.push(MP(c + enemy, P(to, l)));
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
namespace mp = boost::multiprecision;

int main() {
  mp::cpp_dec_float_100 a, b, c;
  cin >> a >> b >> c;

  cout << ((mp::sqrt(a) + mp::sqrt(b) < mp::sqrt(c)) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 512
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    auto ok = [&](int x, int n) {
        if (m % x) {
            return false;
        }
        int sum = m / x;
        return sum >= n;
    };

    int res = 1;
    for (int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            for (auto x : {i , m / i}) {
                if (ok(x, n)) {
                    res = max(res, x);
                }
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int x = stdIn.nextInt();
        int y = stdIn.nextInt();
        //int c = stdIn.nextInt();
        //int w = stdIn.nextInt();
        //int n = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean heisei = true;
        
        System.out.println(x + y / 2);
        
        
        //System.out.println();
        //System.out.print();
    }
}


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

// 2つの整数の場合
long long GetGreatestCommonDivisor(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main() {

	ll n, z; cin >> n >> z;
	vector<ll> x(n + 1);
	for (ll i = 0; i < n; i++) {
		cin >> x[i];
	}
	x[n] = z;
	sort(x.begin(), x.end());
	vector<ll> d(n);
	for (int i = 0; i < n; i++) {
		d[i] = x[i + 1] - x[i];
	}
	// 3つ以上の整数の場合
	long long gcd = d[0];
	for (int i = 1; i < n; i++) {
		gcd = GetGreatestCommonDivisor(gcd, d[i]);
	}
	cout << gcd << endl;
	return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>  // ver2.2.5
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,i) upper_bound(ALL(a),i)-lower_bound(ALL(a),i)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int a,b;
  cin >> a >> b;
  if(a>=10||b>=10) cout<<-1<<endl;
  else cout<<a*b<<endl;
  return 0;
}

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

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  string S, T;
  cin >> S >> T;
  int cnt = 0;
  REP(i, 3) {
    if(S[i] == T[i]) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		int n = s.size();
		map<int,int> dp;
		dp[0] = 0;
		using bs = bitset<26>;
		bs tmp = 0;
		int ans;
		REP(i,n){
			int c = s[i]-'a';
			tmp[c] = !tmp[c];
			int mi = INF;
			REP(i,n) {
			}
			REP(j,26){
				auto t = tmp;
				t[j] = !t[j];
				auto ite = dp.find(t.to_ulong());
				if(ite != dp.end()) {
					chmin(mi, ite->S+1);
				}
			}
			{
				auto ite = dp.find(tmp.to_ulong());
				if(dp.find(tmp.to_ulong()) != dp.end()){
					chmin(mi,ite->S+1);
				}
			}
			ans = mi;

			{
				auto ite = dp.find(tmp.to_ulong());
				if(ite == dp.end()) {
					dp[tmp.to_ulong()] = mi;
				}
			}
			chmin(dp[tmp.to_ulong()], mi);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 9876
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    string tar, l, r, t1, l1, r1;
    getline (cin, tar);
    l=tar.substr(0, tar.length()/2);
    r=tar.substr(tar.length()/2+1, tar.length()/2);
    t1=tar, l1=l, r1=r;
    reverse (t1.begin(), t1.end());
    reverse (l1.begin(), l1.end());
    reverse (r1.begin(), r1.end());
    if (t1==tar && r1==r && l1==l) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
#ifdef LOCAL
#include"rprint2.hpp"
#else
using namespace std;
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << '\n';
    return 0;
}


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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int mn = 1000, mx = 0;
  for(int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
  }

  cout << mx - mn << endl;
}

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

int main() {
    
	int a, b, c, x; cin >> a >> b >> c >> x;
	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) ans++;
			}
		}
	}
	cout << ans << endl;
    return 0;
}

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

using namespace std;

using l = long;
using ll = long long;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using pii = vector<pair<int, int>>;

int main()
{
    int n, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 1) cnt++;
    }
    printf("%.10f", (double)cnt / (double)n);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>

using namespace std;
using LLI = long long int;

//vector<int>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//vector<int>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//vector<int>dir_x2 = { 0,0,1,-1 };
//vector<int>dir_y2 = { 1,-1,0,0 };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	bool a = true;
	string S, T;
	cin >> S >> T;
	vector<char>alp = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	map<char, char>MAP;
	map<char, char>MAP2;

	for (int i = 0; i < alp.size();i++) {
		MAP.insert(make_pair(alp[i],NULL));
		MAP2.insert(make_pair(alp[i],NULL));
	}
	for (int i = 0; i < S.size();i++) {
		if (MAP.at(S[i]) == NULL) {
			MAP[S[i]] = T[i];
		}
		else {
			if (MAP[S[i]] != T[i]) {
				a = false;
			}
		}
	}
	for (int i = 0; i < S.size(); i++) {
		if (MAP2.at(T[i]) == NULL) {
			MAP2[T[i]] = S[i];
		}
		else {
			if (MAP2[T[i]] != S[i]) {
				a = false;
			}
		}
	}
	if (a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main(){
  long long X,K,D,A;
  cin >> X >> K >> D;
  X=abs(X);
  A=X/D;
  if(K<=A){
    cout << X-K*D << endl;
    return 0;
  }
  X-=A*D;
  K-=A;
  if(K%2==0){
    cout << X << endl;
  }
  else{
    cout << abs(X-D) << endl;
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
long double a,b;
int main()
{
	cin>>a>>b;
	a*=b;
	re((ll)a);
	return 0;}

Measured memory_bytes: 3732
#coding: UTF-8
import math

A, B, DEGREE = list(map(int, input().split()))
RADIAN = math.radians(DEGREE)

C = math.sqrt(A*A+B*B-2*A*B*math.cos(RADIAN))
S =A*B*math.sin(RADIAN)/2.0
H = 2*S/A

print("%.10f %.10f %.10f"%(S, A+B+C, H))


Measured memory_bytes: 5720
def read():
    S = input()
    return S,

def is_palindrome(x):
    n = len(x)
    for i in range(n):
        if x[i] != x[n-1-i]:
            return False
    return True

def solve(S):
    N = len(S)
    a = S[:N//2]
    b = S[N//2+1:]
    if is_palindrome(S) & is_palindrome(a) & is_palindrome(b):
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 3064
H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for rA in A:
    for n in rA:
        if n >= 0:
            ans += c[n][1]

print(ans)

Measured memory_bytes: 3316
N,X = map(int, input().split())

if N/2 == X:
    l = X*3
elif N/2 > X:
    l = N
    x = X
    n = N - X
    while x > 0:
        l += (n//x)*2*x
        c = x
        x = n%x
        n = c
    l -= n
else:
    l = N
    x = X
    n = N - X
    while x > 0:
        l += (n//x)*2*x
        c = x
        x = n%x
        n = c
    l -= n
print(l)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
namespace UnionTree {
template <typename T>
int root(vector<T> &u, int x) {
    if (x < 0 || u.size() <= x) return -1;
    if (u[x].parent == -1)
        return x;
    else
        return u[x].parent = root(u, u[x].parent);
}
template <typename T>
bool connect(vector<T> &u, int a, int b) {
    a = root(u, a), b = root(u, b);
    if (a == b || a < 0 || b < 0) return false;
    u[b].parent = a;
    return true;
}
// O(u.size())
template <typename T>
void count(vector<T> &u, map<int, int> &ret) {
    for (int i = 0; i < u.size(); i++) {
        int tmp = u[i].parent;
        if (tmp == -1) tmp = i;
        if (!ret.count(tmp)) {
            ret[tmp] = 0;
        }
        ret[tmp]++;
    }
}
};  // namespace UnionTree

using namespace UnionTree;

struct Node {
    int parent;
};

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M;
    cin >> N >> M;
    vector<Node> uf(N);
    for(int i = 0; i < N; i++) {
        uf[i].parent = -1;
    }
    for(int i = 0; i < M; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        connect(uf, x, y);
    }
    set<int> s;
    for(int i = 0; i < N; i++) {
        s.insert(root(uf, i));
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
    long long n, d;
    cin >> n >> d;

    vector<pair<long long, long long> > p(n);

    long long count = 0LL;
    long long x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        if (sqrt(pow((double)x, 2) + pow((double)y, 2)) <= d) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 6464
#include <stdio.h>

int main(int argc, const char * argv[])
{
  
    int num;
    double m, kg;
    
    while (scanf("%d, %lf, %lf", &num, &kg, &m) != EOF) {
        double BMI = 0;
        BMI = kg / (m * m);
        if (BMI >= 25) {
            printf("%d\n", num);
        }
    }
    
    return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

string s[100];

signed main()
{   
    int H,W; cin>>H>>W;
    REP(i,H) cin>>s[i];

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

    REP(i,H) REP(j,W){
        if(s[i][j]=='#') continue;

        int cnt=0;
        REP(k,8){
            int y=i+dy[k],x=j+dx[k];
            if(y<0 or H<=y or x<0 or W<=x) continue;
            if(s[y][x]=='#') cnt++;
        }
        s[i][j]=(char)(cnt+'0');
    }
    REP(i,H) cout<<s[i]<<endl;
    
}


Measured memory_bytes: 256