akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<max(0,b+c-a)<<endl;
}


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

int main(){

  char a[111],b[111];
  int c,d;

  scanf("%s",a);
  scanf("%s",b);

  c=strlen(a);
  d=strlen(b);

  if(c>d)
    printf("GREATER\n");

  if(c==d){
      if(strcmp(a,b)>0){
        printf("GREATER\n");
      }
      if(strcmp(a,b)==0){
        printf("EQUAL\n");
      }
      if(strcmp(a,b)<0){
        printf("LESS\n");
      }

    }

  if(c<d)
    printf("LESS\n");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int sort(const int *a,const int *b){
  return *b-*a;
}
int main(){
  int n,b=0,c=0,a[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),sort);
  for(int i=0;i<n;i++){
    if(i%2==0)b+=a[i];
    else c+=a[i];
  }
  printf("%d",b-c);
  return 0;
}

Measured memory_bytes: 128
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-13 22:50
# @url:https://atcoder.jp/contests/abc042/tasks/arc058_a

import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n,k=map(int,input().split())
    d=list(map(int,input().split()))
    mx=100000
    ans=100000
    while mx>=0:
        temp=str(mx)
        f=True
        for i in range(len(temp)):
            if int(temp[i]) in d:
                f=False
                break
        if f and mx>=n:
            ans=min(ans,mx)
        mx=mx-1
    print (ans)

if __name__ == "__main__":
    main()

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a * b;
  
  if (c%2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 384
x = int(input())


def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    for i in range(3, int(x ** 0.5) + 1, 2):
        if x % i == 0:
            return False
    return True


while isPrime(x) == False:
    x += 1
print(x)


Measured memory_bytes: 9460
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {in_n: u64};
    let mut n = in_n;
    let mut nums = HashMap::new();

    while n > 1 {
        for i in 2..n + 1 {
            if i * i > n {
                if nums.contains_key(&n) {
                    nums.insert(n, nums[&n] + 1);
                } else {
                    nums.insert(n, 1);
                }

                n = 1;
                break;
            }

            if n % i != 0 {
                continue;
            }

            if nums.contains_key(&i) {
                nums.insert(i, nums[&i] + 1);
            } else {
                nums.insert(i, 1);
            }

            n = n / i;

            break;
        }
    }

    let mut c = 0;

    for (_, nv) in &nums {
        let mut v = *nv;
        let mut p = 1;

        while v >= p {
            c += 1;
            v -= p;
            p += 1;
        }
    }

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


Measured memory_bytes: 2196
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int mod = 998244353;
const int maxn = 1000100;
long long power(long long x, long long k)
{
	long long ans = 1;
	while(k)
	{
		if(k & 1)
			(ans *= x) %= mod;
		(x *= x) %= mod;
		k >>= 1;
	}
	return ans;
}
int N;
long long fac[maxn], inv[maxn];
void init()
{
	fac[0] = 1;
	for(int i = 1; i <= N; i ++)
		fac[i] = fac[i - 1] * i % mod;
	inv[N] = power(fac[N], mod - 2);
	for(int i = N - 1; i >= 0; i --)
		inv[i] = inv[i + 1] * (i + 1) % mod;
}
long long C(int x, int y)
{
	if(x < y || y < 0)
		return 0;
	return fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int n, m;
long long g1[maxn], g2[maxn], f[maxn];
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> m;
	if(n < m)
		swap(n, m);
	N = n + m;
	init();
	g1[0] = C(N - 1, n - 1);
	g2[0] = C(N - 1, m - 1);
	f[0] = 0;
	for(int i = 1; i <= N; i ++)
	{
		//cout << i << " : " << endl;
		(f[i] = f[i - 1] + g1[i - 1] + g2[i - 1]) %= mod;
		//cout << g1[i - 1] << " " << g2[i - 1] << endl;
		g1[i] = g1[i - 1];
		g2[i] = g2[i - 1];
		if(i % 2 == 1)
		{
			int x = i / 2;
			(g1[i] += mod - C(x * 2, x) * C(N - x * 2 - 2, n - x - 1) % mod) %= mod;
			(g2[i] += mod - C(x * 2, x) * C(N - x * 2 - 2, m - x - 1) % mod) %= mod;
		}
		if(i % 2 == 0)
		{
			int x = i / 2;
			(g1[i] += C(x * 2 - 1, x) * C(N - x * 2 - 1, n - x - 1) % mod) %= mod;
		}
		if(i % 2 == 0)
		{
			int x = i / 2;
			(g2[i] += C(x * 2 - 1, x) * C(N - x * 2 - 1, m - x - 1) % mod) %= mod;
			//cout << C(x * 2 - 1, x) << " " << C(N - x * 2, m - x) << " " << C(x * 2, x - 1) << " " << C(N - x * 2 - 1, m - x) << endl;
		}
		if(i >= n * 2 - 1)
			g1[i] = 0;
		if(i >= m * 2 - 1)
			g2[i] = 0;
		//cout << g1[i] << " " << g2[i] << endl;
		//cout << f[i] << endl;
	}
	long long ans = 0;
	for(int i = 1; i <= N; i ++)
		(ans += f[i] * power(i, mod - 2)) %= mod;
	cout << ans * power(C(N, n), mod - 2) % mod << endl;
	return 0;
}
//2 3
//798595486
//3 3
//299473310

Measured memory_bytes: 39296
import numpy as np

N, W = map(int, input().split(' '))

items = [tuple(map(int, input().split(' '))) for _ in range(N)]

dp = np.zeros(shape=(N + 1, W + 1), dtype=int)

for i in range(N):
    weight = items[i][0]
    value = items[i][1]
    dp[i + 1][:weight] = dp[i][:weight]
    dp[i + 1][weight:] = np.maximum(dp[i][weight:], value + dp[i][:-weight])

print(dp[N][W])


Measured memory_bytes: 92616
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

using ll = long long;

#define FOR(i, m, n) for (ll i = m; i <= n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)

int gcd(int a, int b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    ll N, K;
    cin >> N >> K;

    ll ans = 0;

    while (N > 0) {
        N /= K;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    // int sum = 0;
    // rep(i, k) {
    //     sum += a[i];
    // }
    // int cur = sum, res = sum;
    for(int i = k; i < n; ++ i) {
        // cur -= a[i - k];
        // cur += a[i];
        if(a[i] - a[i - k] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  rep(i,n)cin>>x[i];
  int ans=0;
  rep(i,n){
    if(abs(x[i]-k)<x[i])ans+=2*abs(x[i]-k);
    else ans+=2*x[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int n;
	cin >> n;
	vector<int> v(n+1), w(n+1);
	rep(i, n) cin >> v[i+1] >> w[i+1];
	int q;
	cin >> q;
	rep(_, q) {
		int s, l;
		cin >> s >> l;
		vector<vector<P>> items(2);
		for(; s; s /= 2) {
			items[items[0].size() < 9 ? 0 : 1].emplace_back(w[s], v[s]);
		}
		vector<vector<P>> d(2);
		rep(t, 2) {
			vector<P> d1{{0, 0}};
			for(auto p: items[t]) {
				vector<P> d2;
				for(auto q: d1) {
					d2.emplace_back(p.first + q.first, p.second + q.second);
				}
				vector<P> nd;
				int i1 = 0, i2 = 0;
				while(i2 < d2.size()) {
					P p;
					if (i1 < d1.size() && d1[i1] < d2[i2]) {
						p = d1[i1++];
					} else {
						p = d2[i2++];
					}
					if (nd.empty()) {
						nd.push_back(p);
					} else if (nd.back().first == p.first) {
						nd.back().second = p.second;
					} else if (nd.back().second < p.second) {
						nd.push_back(p);
					}
				}
				d1 = move(nd);
			}
			d[t] = move(d1);
		}
		int ans = 0;
		int j = d[1].size() - 1;
		rep(i, d[0].size()) {
			while(j >= 0 && d[0][i].first + d[1][j].first > l) j--;
			if (j < 0) break;
			chmax(ans, d[0][i].second + d[1][j].second);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 5368
sv,m = input().split(" ") # 夏休みの日数と問題数を数値で格納
sv = int(sv)
m = int(m)

day = input().split(" ") #
days = 0 #

for i, new in enumerate(day): # 独学のP105をパクる
    days += int(day[i]) # 宿題を終わらせるのにかかる総日数を加算で出す

if days > sv: # 総日数が夏休み日数より多かったら-1を出力
    print("-1")
else: # じゃなかったら残り日数を遊べる日として出力
    print(sv - days)


Measured memory_bytes: 9528
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x-r<0||y-r<0||x+r>W||y+r>H){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string s, t;
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(auto i : s) {
		i-='A';
		i = (i+n)%26;
		i+='A';
		cout<<i;
	}
}


Measured memory_bytes: 256
def main():
    from sys import stdin
    input = stdin.readline
    h, w, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]

    ans = [0]*10
    d = {}

    for a, b in ab:
        for j in range(-1, 2):
            for k in range(-1, 2):
                d[(a+j, b+k)] = d.get((a+j, b+k), 0)+1

    for (i, j), k in d.items():
        if 2 <= i < h and 2 <= j < w:
            ans[k] += 1

    print((h-2)*(w-2)-sum(ans))
    for i in ans[1:]:
        print(i)


main()

Measured memory_bytes: 190936
import math

a,b,h,m = list(map(int,input().split()))
r = abs((30*h + m *0.5) -  (6*m))
if r > 180:
	r = 360 - r
cos = math.cos(math.radians(r))
nijo = (a**2) + (b**2) - 2 * (a*b*cos)
ans = math.sqrt(nijo)
print(ans)

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

int main() {

    int n; cin >> n;
    vector<int> a(n); 
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int a_point = 0;
    int b_point = 0;

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            a_point += a[i];
        }
        else {
            b_point += a[i];
        }
    }

    cout << a_point - b_point << endl;
    return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
hs = [int(input()) for i in range(N)]
hs.sort(reverse=True)

def defeat(atk):
    if atk*B >= hs[0]:
        return True
    count = 0
    for h in hs:
        if h <= atk*B: break
        rem = h - atk*B
        count += -(-rem//(A-B))
        if count > atk:
            return False
    return True

ok = 10**9
ng = 0
while ok - ng > 1:
    m = (ok+ng)//2
    if defeat(m):
        ok = m
    else:
        ng = m
print(ok)

Measured memory_bytes: 7380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  int l = 0;
  cin >> n >> l;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  ll ma = 0;
  ll num = 0;
  for(int i = 0;i < n - 1;i++){
    if(ma < a[i] + a[i + 1]){
      ma = a[i] + a[i + 1];
      num = i;
    }
  }
  if(ma < l){
    cout << "Impossible" << endl;
  }
  else{
    cout << "Possible" << endl;
    for(int i = 0;i < num;i++)cout << i + 1<< endl;
    for(int i = n - 1;i >= num + 1;i--)cout << i<< endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
/*ll qcheng(ll x,ll y)
{
	ll res=0;
	while(y)
	{
		if(y&1) res=(res+x)%mod;
		y/=2;
		x=x*2%mod;
	}
	return res%mod;
}*/
ll fpower(ll base,ll mi)
{
	ll res=1;
	while(mi)
	{
		//if(mi&1) res=qcheng(res,base)%mod;
		if(mi&1) res=res*base%mod;
		mi/=2;
		//base=qcheng(base,base)%mod;
		base=base*base%mod;
	}
	return res%mod;
}
int main()
{
	ll n;
	cin>>n;
	ll cnt=fpower(10,n);
	ll ans=fpower(9,n);
	ll arr=fpower(8,n);
	cout<<((cnt-2*ans+arr)%mod+mod)%mod<<"\n";
	return 0;
}

Measured memory_bytes: 3188
#include <bitset>
#include <stdio.h>
#include <string.h>
int fa[1401], siz[1401];
bool e[701][701];
std::bitset<1401> f;
int find(register int x) {
	return fa[x]==x ? x : (fa[x]=find(fa[x]));
}
void connect(register int x, register int y) {
	x=find(x);
	y=find(y);
	if(x!=y) {
		fa[y]=x;
		siz[x]+=siz[y];
	}
}
int main() {
	int n, m;
	register int i, j;
	scanf("%d%d", &n, &m);
	while(m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		e[a][b]=e[b][a]=1;
	}
	for(i=1; i<=2*n; ++i) {
		fa[i]=i;
		siz[i] = i<=n?1:-1;
	}
	for(i=1; i<=n; ++i) {
		for(j=1; j<i; ++j) {
			if(!e[i][j]) {
				connect(i+n, j);
				connect(j+n, i);
			}
		}
	}
	for(i=1; i<=n; ++i) {
		if(find(i)==find(i+n)) {
			puts("-1");
			return 0;
		}
	}
	f.set(n);
	for(i=1; i<=2*n; ++i) {
		if(fa[i]==i && siz[i]>0) {
			f = f<<siz[i] | f>>siz[i];
		}
	}
	for(i=0; !f.test(n+i); ++i);
	printf("%d\n", (n*(n-2)+i*i)/4);
	return 0;
}

Measured memory_bytes: 768
import math
n = list(map(int, input().split()))
distance = n[1]
points = [list(map(int, input().split())) for i in range(n[0])]
ans = 0
for i in points:
    x = i[0]
    y = i[1]
    d = math.sqrt(x**2 + y**2)
    if d <= distance:
        ans += 1
print(ans)

Measured memory_bytes: 45496
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  int mini = INF;
  for(int i = 0, temp; i < N; ++i){
    cin >>temp;
    if(temp <= mini) ans++;
    mini = min(temp,mini);;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int n, l;
    cin >> n >> l;

    int abs_min = 99999;
    int val;
    int sum = 0;
    for (int i = 0; i < n; i++){
        // cout << l + i << endl;
        if (abs(l + i) < abs_min){
            abs_min = abs(l + i);
            val = l + i;
        }
        sum += l + i;
    }
    cout << sum - val << endl;

}





















Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n, k;
  scan(n, k);
  ll ans = 1;
  rep (i, n) {
    ll n1 = ans * 2;
    ll n2 = ans + k;
    ans = min(n1, n2);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
H = [[0 for _ in range(n)] for _ in range(n) ]

for _ in range(m):
    a, b = map(int,input().split())
    H[a-1][b-1] = 1
    H[b-1][a-1] = 1
    
l = [0 for _ in range(n)]
ans = 0

def dfs(node,visited):
    global ans
    if visited.count(0) == 0:
        ans += 1 
        return 0
    else:
        visited[node] = 1
        for node_,edge_ in enumerate(H[node]):
            if edge_ == 1 and visited[node_] != 1:
                visited[node_] = 1
                visited[node] = 1
                dfs(node_,visited)
                visited[node_] = 0
dfs(0,l)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n,x,y;cin >> n >> x >> y;
    vector<vector<ll>> d(n+1,vector<ll>(n+1,INF));
    vector<ll> g[n+1];
    rrep(i,n-1){
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    rrep(i,n){
        queue<ll> q;
        q.push(i);
        d[i][i]=0;
        while(q.size()){
            ll now=q.front();
            q.pop();
            for(auto next: g[now]){
                if(d[i][next]==INF){
                    d[i][next]=d[i][now]+1;
                    q.push(next);
                }
            }
        }
    }
    vl cnt(n,0);
    rrep(i,n){
        rrep(j,n){
            if(d[i][j]!=INF){
                cnt[d[i][j]]++;
                //cout << d[i][j] << endl;
            }
        }
    }
    rrep(i,n-1){
        cout << cnt[i]/2 << endl;
    }
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,d,l,m,r,c,x,y=0,j;
  cin>>n>>a>>b;
  vector<int> h(n);
  d=a-b;
  for(j=0;j<n;j++){
    cin>>h.at(j);
    y=max(y,h.at(j));
  }
  l=y/a-1;
  r=y/b+1;
  while(r-l>1){
    m=(l+r)/2;
    c=0;
    for(j=0;j<n;j++){
      x=h.at(j)-b*m;
      if(x>0){
        c+=x/d;
        if(x%d>0) c++;
        if(c>m) break;
      }
    }
    if(j==n&&c<=m) r=m;
    else l=m;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 3736
A,B,C,D,E,F = map(int,input().split())

max_w = 0
max_s = 0
dens = 0
for a in range((F//(100*A))+1):
    for b in range((F//(100*B))+1):
        for c in range((F//C)+1):
            for d in range((F//D)+1):
                if 100*(A*a+B*b) + c*C + d*D > F:
                    break
                elif (c*C+d*D) <= (A*a+B*b)*E and 100*(A*a+B*b) != 0:
                    temp_dens = (C*c+D*d)/(C*c+D*d+100*(A*a+B*b))
                    if temp_dens >= dens:
                        max_w = 100*(A*a+B*b)
                        max_s = C*c + D*d
                        dens = temp_dens
                    
print(max_w + max_s, max_s)

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

char str[100000];

int cmpstr(const void * s1,const void * s2){
    if(strcmp((char *)s1,(char *)s2)>0)
	return 1;
    else if(strcmp((char *)s1,(char *)s2)<0)
	return -1;
    else
	return 0;
}

int main(){
    bool exist=false;
    int i=0;

    scanf("%s",str);
    qsort(str,strlen(str),sizeof(char),cmpstr);


    for(i=0;i<26;i++){
	exist=false;
	for(int n=0;n<strlen(str);n++){
    	    if((int)str[n]==(int)('a')+i){
		exist=true;
    		break;
	    }
	}
	if(exist==false)
	    break;
    }   
    
    if(exist==false)
	printf("%c\n",(char)('a'+i));
    else
	puts("None");

    return 0;
}



Measured memory_bytes: 380
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto a = aryread();
    a.sort();
    writeln((a == [5, 5, 7]) ? "YES" : "NO");
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<vector>
using namespace std;
vector<pair<int, int>> vt;
int check[100010];
int main()
{
	string a;
	cin >> a;
	int t = a.length();
	if (a[0] == '0' || a[t - 1] == '1' || a[t - 2] == '0')
	{
		puts("-1"); return 0;
	}
	if (t == 2)
	{
		printf("1 2");
		return 0;
	}
	int prev = 1;
	int update = 0;
	for (int i = 0; i < t-1; i++)
	{
		if (check[i])
		{
			vt.push_back({ prev,i+2 });
			continue;
		}
		if (a[i] != a[t - 2 - i])
		{
			puts("-1"); return 0;
		}
		if (a[i] == '0')update = 1;
		vt.push_back({ prev,i + 2 });
		if (a[i] == '1')
			prev = i + 2;
		check[i] = 1;
		check[t - 2 - i] = 1;
	}
	for (int i = 0; i < vt.size(); i++)
		printf("%d %d\n", vt[i].first, vt[i].second);
}

Measured memory_bytes: 2804
#include <stdio.h>


int main(void){
	
	int i, n, area, cnt = 0, cont = 1;
	
	scanf("%d", &n);
	
	int h[n];
	
	for(i = 0; i < n; i++){
		scanf("%d", &h[i]);
	}
	
	while(cont == 1){
		area = 0;
		for(i = 0; i < n; i++){
			if(h[i] == 0){
				if(area == 1){
					area = 0;
					cnt++;
				}
			}else{
				area = 1;
				h[i]--;
			}
		}
		if(area == 1){
			cnt++;
		}
		
		cont = 0;
		for(i = 0; i < n; i++){
			if(h[i] != 0){
				cont = 1;
				break;
			}
		}
		
	}
	
	printf("%d", cnt);
	
	return 0;
}

Measured memory_bytes: 128
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long a, long long b, long long c, std::vector<std::string> s){
    vector<i64> v{a, b, c};
    vector<int> ans;
    for(int i = 0; i < n; ++i){
        int x = s[i][0] - 'A';
        int y = s[i][1] - 'A';
        if(v[x] == v[y] && i != n - 1 && s[i] != s[i + 1]){
            vector<int> cnt(3, 0);
            ++cnt[x]; ++cnt[y]; ++cnt[s[i + 1][0] - 'A']; ++cnt[s[i + 1][1] - 'A'];
            for(int j = 0; j < 3; ++j){
                if(cnt[j] == 2){
                    ++v[j];
                    --v[x == j ? y : x];
                    ans.emplace_back(j);
                    break;
                }
            }
        }
        else{
            if(v[x] < v[y])
                swap(x, y);
            --v[x];
            ++v[y];
            ans.emplace_back(y);
        }
        for(int j = 0; j < 3; ++j)
            if(v[j] < 0){
                cout << "No" << endl;
                return;
            }
    }
    cout << "Yes" << endl;
    for(int i = 0; i < n; ++i)
        cout << char(ans[i] + 'A') << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
    }
    solve(N, A, B, C, std::move(s));
    return 0;
}


Measured memory_bytes: 7136
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  if(a[n/2]==a[n/2-1]){
    cout << 0 << endl;
    return 0;
  }else{
    cout << a[n/2]-a[n/2-1] << endl;
    return 0;
  }
}
  

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

struct node { ll a,b; } a1[200005];
int n,t,l1,l2,a0[200005],ans;
ll dp1[40], dp2[200005];

bool cmp(node a, node b) {
	return b.a * (a.b+1) < a.a * (b.b+1);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> t;

	for (int i = 1; i <= n; i++) {
		ll a, b;
		cin >> a >> b;
		if (a) a1[++l1] = {a, b};
		else a0[++l2] = b;
	}

	for (int i = 1; i <= 35; i++) dp1[i] = (1 << 30);

	if (l1 > 0) {
		sort(a1+1, a1+1+l1, cmp);
		for (int i = 1; i <= l1; i++)
			for (int j = 35; j >= 1; j--)
				dp1[j] = min(dp1[j], (dp1[j - 1] + 1) * (a1[i].a + 1) + a1[i].b);
	}

	sort(a0+1, a0+1+l2);
	for (int i = 1; i <= l2; i++)
		dp2[i] = dp2[i-1] + 1 + a0[i];

	for (int i = 0; i <= 35; i++)
		if (dp1[i] <= t) {
			int j = 0;
			while (j <= l2 && dp1[i] + dp2[j] <= t) j++;
			ans = max(ans, i + j - 1);
		}

	cout << ans << endl;
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n;
    scanf("%d",&n);
    int v[n];
    for(int i = 0;i<n;i++){
        scanf("%d",&v[i]);
    }
    for(int i = 1;i<n;i++){
        for(int j = 0;j<n - 1;j++){
            if(v[j] > v[j + 1]){
                int tmp = v[j];
                v[j] = v[j + 1];
                v[j + 1] = tmp;
            }
        }
    }
    double point = (double)v[0];

    for(int i = 1;i<n;i++){
        point = ((point + (double)v[i]) / 2);
    }
    printf("%lf",point);
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		int[] data = new int[10];
		try {
			for (int i = 0; i < 10; i++) {
				data[i] = Integer.parseInt(in.readLine());
			}
			Arrays.sort(data);
			
			for (int i = 0; i < 3; i++) {
				System.out.println(data[9 - i]);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24128
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void mmul(int n, int (*a)[128], int (*b)[128]) {
    static int t[128][128];
    rep (i, n) rep (j, n) {
        t[i][j] = 0;
        rep (k, n) t[i][j] |= a[i][k]&b[k][j];
    }
    rep (i, n) rep (j, n) a[i][j] = t[i][j];
}

void mpow(int n, int (*a)[128], int x) {
    static int r[128][128];
    rep (i, n) rep (j, n) r[i][j] = i == j;
    rep (i, 32) {
        if (x&(1<<i)) mmul(n, r, a);
        mmul(n, a, a);
    }
    rep (i, n) rep (j, n) a[i][j] = r[i][j];
}

int u[128], v[128], a[128][128];

bool valid(int i, int j) {
    if (i == j) return false;
    if (v[i] != u[j]) return false;
    if (u[i] == v[j]) return false;
    return true;
}

int main() {
    for (;;) {
        int n, m, z, s, d;
        scanf("%d%d%d", &n, &m, &z);
        if (n == 0 && m == 0 && z == 0) return 0;
        int k = 0;
        rep (i, m) {
            scanf("%d%d", &s, &d);
            s--, d--;
            u[k] = s; v[k] = d; k++;
            u[k] = d; v[k] = s; k++;
        }
        rep (i, k) rep (j, k) a[i][j] = valid(i, j);
        mpow(k, a, z-1);
        bool ans = false;
        rep (i, k) rep (j, k) if (a[i][j]) {
            if (u[i] == 0 && v[j] == n-1) ans = true;
        }
        puts(ans ? "yes" : "no");
    }
}

Measured memory_bytes: 1164
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi bitw(n+1), bitb(n+1);
    auto addw = [&](int i, int x) {
        while(i <= n) {
            bitw[i] += x;
            i += i&-i;
        }
    };
    auto sumw = [&](int i) {
        int res = 0;
        while(i) {
            res += bitw[i];
            i &= i-1;
        }
        return res;
    };
    auto addb = [&](int i, int x) {
        while(i <= n) {
            bitb[i] += x;
            i += i&-i;
        }
    };
    auto sumb = [&](int i) {
        int res = 0;
        while(i) {
            res += bitb[i];
            i &= i-1;
        }
        return res;
    };
    vvi W(n, vi(n+1)), B(n, vi(n+1));
    int cntw = 0, cntb = 0;
    vi placew(n), placeb(n);
    rep(i, 2*n) {
        char c;
        int num;
        cin >> c >> num;
        if(c == 'W') {
            int x = sumw(num);
            x = num-1-x;
            addw(num, 1);
            rep(j, n+1) {
                W[num-1][j] = x+j-sumb(j);
            }
            cntw++;
            placew[num-1] = i;
        } else {
            int x = sumb(num);
            x = num-1-x;
            addb(num, 1);
            rep(j, n+1) {
                B[num-1][j] = x+j-sumw(j);
            }
            cntb++;
            placeb[num-1] = i;
        }
    }

    vvi dp(n+1, vi(n+1, INF));
    dp[0][0] = 0;
    rep(i, n+1) {
        rep(j, n+1) {
            if(i) {
                chmin(dp[i][j], dp[i-1][j] + placew[i-1]+W[i-1][j]-i-j+1);
            }
            if(j) {
                chmin(dp[i][j], dp[i][j-1] + placeb[j-1]+B[j-1][i]-i-j+1);
            }
        }
    }

    cout << dp[n][n] << endl;
}

Measured memory_bytes: 50456
/* ##     ##  #######  # #  ######
    ##     ##  ##   ##  ###    ##
    ##     ##  ##    #  # #    ##
    #########  #######  # #    ## */
 
 #include <bits/stdc++.h>
 using namespace std;
 
 const long long int MODPRIME {1000000007};
 const long long int BABYMOD  {998244353};
 const long int MAXN = (long int) 1e6;
 
 typedef long long int ll;
 
 #define LUCILLE_IS_THIRSTY()       ios_base::sync_with_stdio(false); cin.tie(0)
 #define TESTCASES_ARE_THERE()      long int Test; cin>>Test; while(Test--)
 #define mems(arr,val)              memset((arr), val, sizeof((arr)))
 #define endl                       "\n"
 
 inline int readint() {
     int res = 0; char c = 0;
     while(!isdigit(c)) c = getchar();
     while(isdigit(c)) res = res*10+c-'0', c = getchar();
     return res;
 }
 
 
 void solveEach() {
     string s;
     cin >> s;
     long int n = s.length();

     for (int i=0; i<n-1; i++) {
         if (s[i] == 'P' and s[i+1] == '?') {
             s[i+1] = 'D';
         }
     }

     for (int i = 0; i<n-1; i++) {
        if (s[i] == '?' and s[i+1] == '?') {
            s[i] = 'P'; s[i+1] = 'D';
        }
     }
     
     for (int i=0; i<n; i++) {
         if (s[i] == '?') {
             s[i] = 'D';
         }
     }

     cout << s << endl;
     return;
 }
 
 signed main() {
 
     LUCILLE_IS_THIRSTY();

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     // freopen("output.txt", "w", stdout);
    // #endif 

    //  TESTCASES_ARE_THERE()
         solveEach();
 
     return 0;
 }
 /*
 THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
 SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
 (I Own the code if no link is provided here or I may have missed mentioning it)
 >>> DO NOT PLAGIARISE.
 TESTCASES:
 */

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> llp;
typedef pair<ld, ll> pi;
typedef pair<ll, llp> pii;
#define f first
#define s second
#define INF 1e7

priority_queue<pi, vector<pi>, greater<pi> > pq;
ll sx, sy, ex, ey, n;
ld dist[1005];
pii arr[1005];

inline ll sqr(ll x) {
	return x*x;
}

int main() {
	cin >> sx >> sy >> ex >> ey >> n;
	arr[0] = pii(0, pi(sx, sy));
	FOR(i, 1, n) cin >> arr[i].s.f >> arr[i].s.s >> arr[i].f;
	arr[n+1] = pii(0, pi(ex, ey));
	FOR(i, 0, n+1) dist[i] = -1;
	pq.push(pi(0, 0));
	dist[0] = 0;
	while(!pq.empty()){
		pi c = pq.top(); pq.pop();
		ll x = c.second;
		ld d = c.first; // x is node, d is dist
		if(d != dist[x]) continue; //Because dist[x] will be minimised, you don’t want to run with a greater distance.
		FOR(i, 0, n+1) {
			if (i == x) continue;
			ld dd = sqrt(sqr(arr[x].s.f - arr[i].s.f) + sqr(arr[x].s.s - arr[i].s.s)) - arr[x].f - arr[i].f;
			dd = max(dd, (ld) 0);
			if (dist[i] == -1 or dist[i] > d + dd) {
				dist[i] = d + dd;
				pq.push(pi(dist[i], i));
			}
		}
	}
	cout << fixed << setprecision(10) << dist[n+1];
}


Measured memory_bytes: 10604
#include<stdio.h>
#define GSIZE 100

void insertionSort(int *, int, int);
int shellSort(int *, int);

int cnt = 0;
int g[GSIZE];

int main(){
  int n, m;
  int i;

  scanf("%d", &n);

  int a[n];

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

  m = shellSort(a, n);

  printf("%d\n", m);
  for(i=m-1;i>=0;i--){
    if(i == 0) printf("%d\n", g[i]);
    else printf("%d ", g[i]);
  }
  printf("%d\n", cnt);
  for(i=0;i<n;i++){
    printf("%d\n", a[i]);
  }
  return 0;
}

void insertionSort(int *a, int n, int g){
  int v;
  int i, j;

  for(i=g;i<n;i++){
    v = a[i];
    j = i - g;
    while(j >= 0 && a[j] > v){
      a[j+g] = a[j];
      j -= g;
      cnt++;
    }
    a[j+g] = v;
  }
}

int shellSort(int *a, int n){
  int i = 0, j;
  
  g[0] = 1;
  while(g[i] <= n){
    i++;
    g[i] = 3 * g[i-1] + 1;
  }
  //printf("%d\n", i);
  //ここの時点でg[i] >= n
  //i+1がgの要素数

  //g[i]はnを超えてるから含めない
  for(j=i-1;j>=0;j--){
    insertionSort(a, n, g[j]);
  }

  return i;
}



Measured memory_bytes: 5760
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

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

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

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 * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
const int mod=1e9+7;
int a[100100],ans1,ans2;

int main()
{
	int n,k;
	read(n);read(k);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<i;j++)
			if (a[i]>a[j]) ans1++;
		for (int j=i+1;j<=n;j++)
			if (a[i]>a[j]) ans2++;
	}
	ll k1=1ll*k*(k-1)/2%mod,k2=1ll*k*(k+1)/2%mod;
	cout<<1ll*(ans1*k1+ans2*k2)%mod;
	return 0;
}









Measured memory_bytes: 2304
#include<stdio.h>

int main(){
    int N,i,cnt,j,c = 0;

    scanf("%d",&N);

    for(i = 1; i <= N; i++){
        cnt = 0;
        for(j = 1; j <= i; j += 2){
            if((i % j) == 0){
                cnt++;}
        }
        if(cnt == 8){
            c++;
        }
    }
    printf("%d\n",c);
    return 0;
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"


using namespace std;

long long n;
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	long long x = 1, s=0;
	while(s + x <= n)
		s+=x, x++;
	x--;
	if(x*(x+1)/2 == n)
	{
		cout << x << '\n';
		return 0;
	}
	cout << x+1 << '\n';

}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;

template<class Mint,int32_t lg>
struct ModIntTable{
	int N;
	vector<Mint>facts,finvs,invs;
	ModIntTable():N(1<<lg),facts(N),finvs(N),invs(N){
		const uint32_t mod=Mint(-1).a+1;
		invs[1]=1;
		for(int i=2;i<N;i++)invs[i]=invs[mod%i]*(mod-mod/i);

		facts[0]=1;
		finvs[0]=1;
		for(int i=1;i<N;i++){
			facts[i]=facts[i-1]*i;
			finvs[i]=finvs[i-1]*invs[i];
		}
	}
	inline Mint fact(int n)const{return facts[n];}
	inline Mint finv(int n)const{return finvs[n];}
	inline Mint inv(int n)const{return invs[n];}
	inline Mint binom(int n,int k)const{return facts[n]*finvs[k]*finvs[n-k];}
	inline Mint perm(int n,int k)const{return facts[n]*finvs[n-k];} 
};
ModIntTable<mint,19>mtable;

int B,W;

mint po[222222];
signed main(){
	mint uku=mint(2).inv();
	po[0]=1;
	for(int i=1;i<222222;i++)po[i]=po[i-1]*uku;

	cin>>B>>W;

	mint bx=0,wx=0;
	for(int i=0;i<B+W;i++){
		mint way=0;
		way+=wx;
		way+=(mint(1)-bx-wx)*po[1];
		cout<<way<<endl;

		if(i+1>=W)wx+=mtable.binom(i,W-1)*po[i+1];
		if(i+1>=B)bx+=mtable.binom(i,B-1)*po[i+1];
	}

	return 0;
}

Measured memory_bytes: 9216