akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  ci(n)
  vll A(n);
  vll B(n-1);
  ci(A[0])
  ll s=A[0];
  FOR(i,1,n){
    ll a;
    ci(a)
      s+=a;
    A[i]+=s;
  }
  
  FOR(i,0,n-1){
    B[i]=abs(s-A[i]-A[i]);
  }
  SORT(B);
  co(B[0])
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dist[210][210];

// ワーシャルフロイド
void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}

ll fact(ll n){
    if(n ==1) return 1;
    return n * fact(n-1);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M ,R;
    cin >> N >> M >> R;

    vector<ll> r(R);

    REP(i, R){
        cin >> r[i];
        r[i]--;
    }

    Fill(dist, INF);

    REP(i, M){
        ll a, b, c;
        cin >> a >> b >> c;
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }

    warshall_floyd(N);

    // REP(i, N){
    //     REP(j, N){
    //         cout << i << " " << j << " " << dist[i][j] << endl;
    //     }
    // }

    ll p = fact(R);
    ll ans = INF;
    REP(i, p){
        ll temp = 0;
        REP(j, R){
            // cout << r[j];
            if(j !=0){
                temp += dist[r[j-1]][r[j]];
            }
        }
        // cout << endl;

        ans = min(ans, temp);
        // 順列の遷移処理
        next_permutation(r.begin(), r.end());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int h,n;cin>>h>>n;
    int tmp,sum=0;
    rep(i,n){cin>>tmp;sum+=tmp;}
    if(h<=sum)co("Yes");else co("No");
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> A;
    priority_queue<int> N;

    for (int i = 0; i < n; i++)
    {
        int r;
        cin >> r;
        A.push_back(r);
        N.push(r);
    }

    for (auto &m : A)
    {
        int a = N.top();
        if (m == a)
        {
            N.pop();
            cout << N.top() << endl;
            N.push(a);
        }
        else
        {
            cout << a << endl;
        }
    }
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define ll long long 
#define INF 1e9
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int h,w,k,ans=0;
	cin>>h>>w>>k;
	string s[7] ;
	for(int i=0;i<h;i++)
	cin>>s[i];
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			int c=0;
			for(int a=0;a<h;a++)
			{
				for(int b=0;b<w;b++){
					if(i>>a&1&&j>>b&1&&s[a][b]=='#')
					c++;
				}
			}
			if(c==k)
			ans++;
		}
	}
	cout<<ans<<endl;

	
	}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,1,1,1,-1,-1,-1,-1};
const vector<ll> dy{1,1,-1,-1,1,1,-1,-1};
const vector<ll> dz{1,-1,1,-1,1,-1,1,-1};

int main() {
    ll N,K;
    cin >>N>>K;
    //vector<tuple<ll,ll,ll,ll>>
    vector<ll>x(N);
    vector<ll>y(N);
    vector<ll>z(N);
    rep(i,N) cin>>x[i]>>y[i]>>z[i];
    ll ans =0;
    rep(i,8){
        vector<ll>now(N);
        rep(j,N){
            now[j] = dx[i]*x[j]+dy[i]*y[j]+dz[i]*z[j];
        }
        sort(all(now));
        reverse(all(now));
        ll tmp=0;
        rep(j,K){
            tmp+=now[j];
        }
        chmax(ans,tmp);
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
using namespace std;
int C; // 交換回数
void bubbleSort(int A[], int N)
{
bool flag = true;
while(flag){ flag = false;
 for(int j=N-1; j>=1; j--){ if(A[j]<A[j-1]){ swap(A[j], A[j-1]);
C++;
flag = true; } }
}
}
int main()
{
int N;
cin >> N;
int A[100];
for(int i=0; i<N; i++){ cin >> A[i];
}
C = 0;
bubbleSort(A, N);
for(int i=0; i<N; i++){ cout << A[i];
 if(i<N-1){ cout << ' '; } else{ cout << endl; }
}
cout << C << endl;
return 0;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

int main ()
{
    double N,X;
    const double taxrate = 1.08;

    cin >> N;
    X = N / taxrate;
    while ((int)X <= (int)N)
    {
        if ((int)((int)X*1.08) == (int)N)
        {
            cout << (int)X << endl;
            return 0;
        }
        X += 1.0;            
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3728
import java.util.*;
 
public class Main {
 
    static Scanner in = new Scanner(System.in);
    void solve() {
        int n = in.nextInt();
        for(int i = 40000; i > 1; i--){
            if(i * i <= n){
                System.out.println(i * i);
                return;
            }
        }
        System.out.println(1);
    }
 
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 21972
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    /*int t;cin>>t;
    while(t--){

    }*/
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans="";
    int nx=sx,ny=sy;
    //1
    while(ny<ty){
        ny++;
        ans+='U';
    }
    while(nx<tx){
        nx++;
        ans+='R';
    }

    //2
    while(ny>sy){
        ny--;
        ans+='D';
    }
    while(nx>sx){
        nx--;
        ans+='L';
    }

    //3
    ny--;ans+='D';
    while(nx<tx+1){
        nx++;
        ans+='R';
    }
    while(ny<ty){
        ny++;
        ans+='U';
    }
    nx--;ans+='L';

    //4
    ny++;ans+='U';
    while(nx>sx-1){
        nx--;
        ans+='L';
    }
    while(ny>sy){
        ny--;
        ans+='D';
    }
    nx++;ans+='R';

    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------




































Measured memory_bytes: 256
<?php
 
//N M
list($n,$m) = explode(' ', trim(fgets(STDIN)));
 
 
//k s...s
for($i=1; $i<=$m; $i++){
  $t = explode(' ', trim(fgets(STDIN)));
  for($j=1;$j<=$t[0]; $j++){
    $l[$i][$j] = $t[$j];
  }
}
 
 
//p...p
$p = explode(' ', trim(fgets(STDIN)));
array_unshift($p,"");
 
 
//bit全検索 スイッチの状態の数だけループ
$ans = 0;
for($i=0; $i<2**$n; $i++){
  
  //スイッチの状態 (ex.00 01 10 11)
  $ls = str_pad(decbin($i), $n, 0, STR_PAD_LEFT);
  
  //それぞれのスイッチの状態で電球の数だけループ
  $c = 0;
  for($j=1; $j<=$m; $j++){
    
    //電球に繋がったスイッチの数だけループ
    $on = 0;
    foreach($l[$j] as $s){
      //繋がったスイッチがオンになっている場合にカウント
      if ($ls[$s-1] == 1) $on++;
    }
    //オンのスイッチの総数を２で割った余りが 対応するpと一致する電球の数をカウント
    if ($on%2==$p[$j]) $c++;    
  }
  //余りがpと一致した電球の数が 電球の総数と一致したらカウント
  if ($c == $m) $ans++;
  
}
 
echo $ans;
 
 
  
?>

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

int main() {
  long long n; cin>>n;
  int c=1;
  long double t=sqrt(n);
  long long x=t;
  while(c==1){
    if(n%x==0){
      long long y=n/x;
      cout<<x+y-2<<endl;
      c=0;
    }
    x-=1;
  }
}

Measured memory_bytes: 256
S = input()
T = input()
num_S = len(S)
num_T = len(T)
match = 0

for i in range(num_S - num_T + 1):
    count = 0
    for j in range(num_T):
        if S[i+j] == T[j]:
            count += 1
    if count > match:
        match = count

print(num_T - match)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */
 
#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "T" : "F");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


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

  ll n; cin >> n;
  cout << (n*n-n) / 2 << endl;
}


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

int main(){
  int H,W;
  cin >>H>>W;
  string campus[H];
  for(int i=0;i<H;i++){
    cin >> campus[i];
  }
  int c;
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      if(campus[y][x]=='.'){
        continue;
      }
      c=0;
      c+=(x!=0 && campus[y][x-1]=='#')?1:0;
      c+=(x!=W-1 && campus[y][x+1]=='#')?1:0;
      c+=(y!=0 && campus[y-1][x]=='#')?1:0;
      c+=(y!=H-1 && campus[y+1][x]=='#')?1:0;
      if(c==0){
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int a[203] = {0};

int main() {
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++) {
        // cout << i << "\n";
        int temp = 1;
        while(1) {
            if(i*temp > n) {
                break;
            }
            a[i*temp]++;
            temp++;
        }
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++) {
        if(a[i] == 8 && i%2 == 1) {
            // cout << i << " ";
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{
	string s[3];cin>>s[0]>>s[1]>>s[2];
	int f=0,c[3]={};
	for(;;)
	{
		if(c[f]==s[f].size())
		{
			cout<<char('A'+f)<<endl;
			return 0;
		}
		else
		{
			f=s[f][c[f]++]-'a';
		}
	}
}


Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

func Comb(F, Finv *[]int, A ...int) int {
  S := SumInt(A...)
  C := (*F)[S]
  for _, a := range A {
    C *= (*Finv)[a]
    C %= p
  }
  return C
}

const p = 1000000007

func Solve() {
  var n, k int
  NextInt(&n, &k)
  F, Finv, _ := Factorial(n)
  K := MinInt(n - 1, k)
  cnt := 0
  for i := 0; i <= K; i++ {
    C := Comb(&F, &Finv, n - i, i)
    P := Comb(&F, &Finv, n - i - 1, i)
    cnt = (cnt + C * P % p) % p
  }
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 5504
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint n, m, d;
	cin >> n >> m >> d;
	cout << fixed << setprecision(10) << 1.0 * (n - d) * ((d != 0) + 1) / (n * n) * (m - 1) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
vector<int> to[200005];
vector<int> ans;
void dfs(int v,int p=-1){
  for (int u: to[v]){
    if(u==p)continue;
    ans[u]+=ans[v];
    dfs(u,v);
  }
}

int main(){
  int n,q;
  cin>>n>>q;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    --a;--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin>>p>>x;
    --p;
    ans[p]+=x;
  }
  dfs(0);
  rep(i,n){
    cout<<ans[i]<<endl;
  }
  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;

    vector<int> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    int a1 = *max_element(ALL(x));
    int b1 = *min_element(ALL(y));

    for (int i = X + 1; i <= Y; i++)
    {
        if (a1 < i && i <= b1)
        {
            OP("No War");
            return 0;
        }
    }
    OP("War");

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	a := readInt()
	b := readInt()
	c := readInt()

	if b-a == c-b {
		println("YES")
	} else {
		println("NO")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
double min(double a,double b){return a<b?a:b;}
int main(){
  int r,n;
  while(cin>>r>>n,r+n){
    vi in(50);//25=center
    while(n--){
      int a,b,c;
      cin>>a>>b>>c;
      loop(i,a,b)in[25+i]=max(in[25+i],c);
    }
    double out=1e9;
    for(int i=25-r+1;i<25+r;i++){
      int t=min(in[i],in[i-1]);
      double tim=t-sqrt(r*r-(25-i)*(25-i));
      out=min(tim,out);
    }
    printf("%.9f\n",out+r);
  }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C - (A - B)) << endl;
    return 0;
}

Measured memory_bytes: 384
n,a,b = [int(i) for i in input().split()]
ans = 0
#range(a,b,c)はstart:a,end:b-1,step:cである。注意。
for i in range(1,n+1):
    # h = i//100
    # l,m = divmod(i%100,10)
    # p = h+l+m
    p = sum(int(j) for j in str(i))
    if a <= p <= b:
        ans += i
print(ans)

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

int main()
{
    int n,m,c,i,j;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(i = 0;i < m;++i){
        cin >> b.at(i);
    }
    int ans = 0,sum = c,temp;
    for(i = 0;i < n;++i){
        for(j = 0;j < m;++j){
            cin >> temp;
            sum += temp*b.at(j);
        }
        if(sum > 0){
            ++ans;
        }
        sum = c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(void){
    for(;;){

	int a[5];
	int b[5];
	int r=0,p=0,s=0;
	for(int i=0;i<5;i++){
        cin>>a[i];
        if(a[i]==0)break;
        else if(a[i]==1)r++;
        else if(a[i]==2)s++;
        else if(a[i]==3)p++;

	}
	if(a[0]==0)break;
	//for(int i=0;i<5;i++)cout<<a[i]<<"+";


	if(r>0&&p>0&&s>0){
        for(int i=0;i<5;i++){
            b[i]=3;
     //       cout<<a[i]<<"-";
        }
	}
	else if(r>0&&p==0&&s==0){
        for(int i=0;i<5;i++){
            b[i]=3;
       //     cout<<a[i]<<"--";
        }
	}
	else if(r==0&&p>0&&s==0){
        for(int i=0;i<5;i++){
            b[i]=3;
     //       cout<<a[i]<<"---";
        }
	}
	else if(r==0&&p==0&&s>0){
        for(int i=0;i<5;i++){
            b[i]=3;
     //       cout<<a[i]<<".";
        }
	}
	else if(r==0&&s>0&&p>0){
        for(int i=0;i<5;i++){
            if(a[i]==2)b[i]=1;
            else if(a[i]==3)b[i]=2;
      //      cout<<a[i]<<"..";
        }
	}
	else if(r>0&&s==0&&p>0){
        for(int i=0;i<5;i++){
            if(a[i]==3)b[i]=1;
            else if(a[i]==1)b[i]=2;
      //      cout<<a[i]<<"...";
        }
	}
	else if(r>0&&s>0&&p==0){
        for(int i=0;i<5;i++){
            if(a[i]==1)b[i]=1;
            else if(a[i]==2)b[i]=2;
      //     cout<<a[i]<<"....";
        }
	}
	//cout<<endl;
	for(int i=0;i<5;i++){
        cout<<b[i]<<endl;
	}
}

	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
using namespace std;

int main(void){
	
	int b1,b2,b3;
	
	scanf("%d%d%d", &b1, &b2, &b3);
	
	if(b1 == b2 && b1 != b3)
		puts("Open");
	else
		puts("Close");
	
	return 0;
}

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

typedef long long int ll;

int main()
{
	ll x;
	scanf("%lld",&x);
	ll a=100;
	for(ll i=1;i<=100000000;i++)
	{
		a=a*1.01;
		if(a>=x)
		{
			printf("%lld\n",i);
			i=1000000000;
		}
	}
}



Measured memory_bytes: 3824
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            String[] input = br.readLine().split(":");
            int hour = Integer.parseInt(input[0]);
            int min = Integer.parseInt(input[1]);
            double lhand = (hour * 60 + min) / 2.0;
            double shand = (min * 6.0);
            double deg = Math.abs(lhand - shand);
            if ((0 <= deg && deg < 30) || (330 < deg && deg <= 360)) {
                System.out.println("alert");
            } else if ((90 <= deg && deg <= 180) || (180 <= deg && deg <= 270)) {
                System.out.println("safe");
            } else {
                System.out.println("warning");
            }
        }
    }
}


Measured memory_bytes: 25692
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int a,b,c;
signed main(){
	cin>>a>>b;
	if(a==1){
		if(b==2) puts("3");
		if(b==3) puts("2");
	}
	else if(a==2){
		if(b==1) puts("3");
		if(b==3) puts("1");
	}
	else{
		if(b==1) puts("2");
		if(b==2) puts("1");
	}
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))

if k>=n:
  print(abs(A[n-1]-A[0]))
else:
  dp=list(range(n))
  for i in range(k):
    dp[i]=abs(A[i]-A[0])
  for i in range(n-k):
    temp=list(range(k))
    for j in range(k):
      temp[j]=dp[i+j]+abs(A[i+k]-A[i+j])
    dp[i+k]=min(temp)
  print(dp[n-1])

Measured memory_bytes: 52448
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int a[201];
void solve()
{
	int n, l, sum = 0, sol = mod, in = 0;
	cin >> n>>l;
	for (int i = 1; i <= n; i++)
	{
		a[i] = i + l - 1;
		sum = sum + a[i];
		if (abs(a[i]) < sol)
		{
			sol = abs(a[i]);
			in = i;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i != in)
		{
			ans = ans + a[i];
		}
	}
	cout << ans;
}
int main()
{
	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define int long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<int> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const int ths = 1LL << 40;
const int NN = 5e3 + 6;

const int maxN = 500007;

///154_e
///

string n;
int K;
int cache[110][110][2];

int dp(int i, int k, int ok) {


    if(i == n.size() and  k == K)
        return 1;

    if(i >= n.size())
        return 0;

    int &ans = cache[i][k][ok];

    if(ans != -1)
        return ans;

    ans = 0;

    for(int j = 0; j < 10; j ++) {
        if(ok == 1) {
            if(j != 0)
                ans += dp(i + 1, k + 1, 1);
            else
                ans += dp(i + 1, k, 1);
        }
        else {
            int x = n[i] - '0';
            if(j == 0) {
                if(x == 0)
                    ans += dp(i + 1, k, 0);
                else
                    ans += dp(i + 1, k, 1);
            }
            else if(j < x)  {
                ans += dp(i + 1, k + 1, 1);
            }
            else if(j == x)
                ans += dp(i + 1, k + 1, 0);
        }
    }
    return ans ;
}


void solve()
{

    memset(cache, -1, sizeof cache);
    cin>>n>>K;

    int ans = dp(0, 0, 0);
    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

int main(){
    string s ;
    cin >> s ;
    map<char,ll> mp ;
    rep(i,s.size()){
        mp[s[i]]++ ;
    }
    ll count = 0 , tem = 0 ;
    for(auto p :mp ){
        count++ ;
        if( p.second%2 == 0 )tem++ ;
    }
    if(count == tem )cout <<"Yes" <<endl ;
    else cout  << "No" << endl ;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    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)];
    }
};
int main(){
	int n;
	while(cin>>n,n){
		int d[30]={0};
		bool q[30]={false};
		UnionFind uf(26);
		while(n--){
			string s;
			cin>>s;
			int a=s[0]-'a',b=s[s.size()-1]-'a';
			if(a==b)continue;
			d[a]++;
			d[b]--;
			q[a]=q[b]=true;
			uf.unionSet(a,b);
		}
		bool h=true;
		rep(i,26)if(d[i])h=false;
		rep(i,26)rep(j,26)if(q[i]&&q[j]&&!uf.findSet(i,j))h=false;
		if(!h)cout<<"NG"<<endl;
		else cout<<"OK"<<endl;
	}
}

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

int b(string s, string t) {
  int len = (int) s.size();
  int count = 0;
  for(int i=0;i<len;i++) {
    if(s[i] != t[i]) {
      count++;
    }
  }
  return count;
}
int main() {
  string s, t;
  cin >> s; 
  cin >> t;
  cout << b(s, t);
}

Measured memory_bytes: 4108
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main() {
#ifdef _75108D01685041AA959399A981476AD7
  std::freopen("input.txt", "r", stdin);
#endif

  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  string s;
  cin >> s;

  char ch = '0';
  int sum1 = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != ch) sum1++;
    ch = (ch == '0' ? '1' : '0');
  }
  int sum2 = 0;
  ch = '1';
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != ch) sum2++;
    ch = (ch == '0' ? '1' : '0');
  }

  cout << min(sum1, sum2) << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;


vector<ll> enumdivisor(ll n){
    vector<ll> y;
    for(ll k =1 ; k*k<=n;++k){
        if(n%k!=0)continue;
        y.push_back(k);

        if(k*k!=n)y.push_back(n/k);
    }
    return y;
}


int main(){
    ll n;
    cin >> n;
    ll ans=0;
    for(ll x : enumdivisor(n)){
        if(x==1)continue;
        ll tmp = n;
        while(tmp%x==0)tmp/=x;
        tmp%=x;
        if(tmp==1)++ans;
    }
    ans+=enumdivisor(n-1).size()-1;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef pair<int,int> P;
int res=0;
int m,n;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
map<int,vector<P>> pos;

bool check(vector<string> &s, int sx,int sy){
    map<int,int> mp;
    int gx,gy;
    bool f=false;
    for(int i=0;i<4;i++){
        gx=sx,gy=sy;
        while(true){
            gx += dx[i]; gy += dy[i];
            if(gx<0 || m<=gx || gy<0 || n<=gy) break;
            if(s[gx][gy]=='.') continue;
            int idx=s[gx][gy]-'A';
            if(mp[idx]){
                res+=2;
                f=true;
                P p1=pos[idx][0],p2=pos[idx][1];
                s[p1.first][p1.second]='.';
                s[p2.first][p2.second]='.';
            }
            else mp[idx]++;
            break;
        }
    }
    return f;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>m>>n;
    vector<string> s(m);
    for(int i=0;i<m;i++){
        cin>>s[i];
        for(int j=0;j<n;j++){
            if(s[i][j]=='.') continue;
            int idx=s[i][j]-'A';
            pos[idx].push_back(P(i,j));
        }
    }
    while(true){
        bool f=false;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(s[i][j]!='.') continue;
                f |= check(s,i,j);
            }
        }
        if(!f) break;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3468
object Main extends App {
	import scala.io.StdIn._
	
	val S = readLine
	val A = "abcdefghijklmnopqrstuvwxyz".toList.reverse
	var r: String = ""

	for(i<-A){
		if(! S.contains(i.toString)) r = i.toString		
	}

	if(r == "") println("None")
	else println(r)
}

Measured memory_bytes: 27212
const val EOF = "END_OF_TEXT"

fun main(args: Array<String>) {
    val target = readLine() ?: return
    var count = 0
    while (true) {
        val texts = readLine()?.split(" ")?.map { if(!it.equals(EOF))it.toLowerCase() else it } ?: break
        texts.forEach{
            if(it == target) count++
        }
        if(texts.contains(EOF)) break
    }
    println(count)
}


Measured memory_bytes: 31920
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  cout << "AB";
  if(n>=1000){
    cout << "D" << endl;
  }
  else{
    cout << "C" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  long long temp, a, b, c;
  cin >> a >> b >> c;
  temp = a;
  a = b;
  b = temp;
  temp = a;
  a = c;
  c = temp;
  cout << a << " " << b << " " << c << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	long long int L[100];
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i < 87; ++i)
	{
		L[i] = L[i-1] + L[i-2];
	}
	cout << L[n] << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int n;
vector<double> t;
vector<double> v;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> n;
  resz(t, n);
  resz(v, n);
  rep(i, n) {
    cin >> t[i];
    if(i) t[i] += t[i-1];
  }
  rep(i, n) {
    cin >> v[i];
  }

  double dp[2][101];
  fill(dp[0], dp[2], -1);
  double* curr = dp[0];
  double* next = dp[1];
  curr[0] = 0;
  int idx = 0;
  for(int i = 0; i < t[n-1]; i++) {
    if(i == t[idx]) idx++;
    //cout << i << endl;
    for(int j = 0; j < 101; j++) next[j] = -1;
    for(int j = 0; j <= v[idx]; j++) {
      if(curr[j] == -1) continue;
      chmax(next[j], curr[j]+j);
      if(j+1 <= v[idx]) chmax(next[j+1], curr[j]+j+1);
      if(j-1 >= 0) chmax(next[j-1], curr[j]+j-1);
      if(j+1 <= v[idx]) {
	chmax(next[j], curr[j]+(double)(j+(double)(j+j+1)/2)/2);
      }
      //cout << i << " " << j << " " << curr[j] << endl;
    }
    swap(curr, next);
  }
  cout << curr[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000
using namespace std;
typedef pair<int, int> P;
int main()
{
    int n;
    while (cin >> n, n)
    {
        vector<vector<P>> v(n);
        vector<vector<P>> w(8);
        int m;
        cin >> m;
        rep(i, m)
        {
            int x, y;
            cin >> x >> y;
            w[0].push_back(make_pair(x, y));
            w[1].push_back(make_pair(y, -x));
            w[2].push_back(make_pair(-x, -y));
            w[3].push_back(make_pair(-y, x));
        }
        rep(i, 4)
        {
            w[i + 4] = vector<P>(m);
            reverse_copy(begin(w[i]), end(w[i]), begin(w[i + 4]));
        }
        rep(i, 8)
        {
            int m = w[i].size();
            rep(j, m)
            {
                if (j == 0)
                    continue;
                w[i][j].first -= w[i][0].first;
                w[i][j].second -= w[i][0].second;
            }
            w[i][0] = P(0, 0);
        }
        rep(i, n)
        {
            int m;
            cin >> m;
            rep(j, m)
            {
                int x, y;
                cin >> x >> y;
                v[i].push_back(make_pair(x, y));
            }
            rep(j, m)
            {
                if (j == 0)
                    continue;
                v[i][j].first -= v[i][0].first;
                v[i][j].second -= v[i][0].second;
            }
            v[i][0] = P(0, 0);
            bool ok = false;
            rep(j, 8)
            {
                if (v[i] == w[j])
                    ok = true;
            }
            if (ok)
                cout << i + 1 << endl;
        }
        /*
        rep(i, 8)
        {
            rep(j, 8) cout << w[i][j].first << "," << w[i][j].second << "|";
            cout << endl;
        }*/
        cout << "+++++" << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 134212
def updiv(a,b):

    if a % b == 0:
        return a // b
    else:
        return a // b + 1

def able(n):

    nt = 0
    for i in range(N):
        if h[i] - B*n <= 0:
            continue
        nt += updiv(h[i] - B*n , A-B)
        #print (h[i],B,h[i]-B*n,A-B,nt)

    if nt <= n:
        return True
    else:
        return False

N,A,B = map(int,input().split())

h = []
for i in range(N):
    H = int(input())
    h.append(H)

l = 0
r = max(h)
lf = able(l)
rf = able(r)

while r - l != 1:

    m = (l + r) // 2
    mf = able(m)

    if not mf:
        l = m
        lf = mf
    else:
        r = m
        rf = mf

print (r)


Measured memory_bytes: 56280
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	long long ans = 0, arr[10][10];
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) arr[i][j] = 0;
	}
	for (int i = 1; i <= N; ++i) {
		int fd = to_string(i)[0] - '0';
		int ld = i % 10;
		ans += arr[ld][fd] * 2;
		if (fd == ld) ++ans;
		++arr[fd][ld];
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=2e3+10;
    static const ll MOD=1e9+7;
    int N,M;
    int S[MAXN],T[MAXN];
    ll dp[MAXN][MAXN];
    ll sum[MAXN][MAXN];
    void solve(){
        ios::sync_with_stdio(false);
        cin>>N>>M;
        dp[0][0]=1;
        sum[0][0]=1;
        for(int u=1;u<=N;u++){
            cin>>S[u];
            sum[u][0]=1;
        }
        for(int u=1;u<=M;u++){
            cin>>T[u];
            sum[0][u]=1;
        }
        for(int u=1;u<=N;u++){
            for(int v=1;v<=M;v++){
                //本身的情况已经考虑进去了,dp[0][0]=1
                if(S[u]==T[v])dp[u][v]=sum[u-1][v-1];
                else dp[u][v]=0;
                sum[u][v]=((sum[u-1][v]+sum[u][v-1])%MOD-sum[u-1][v-1]+MOD+dp[u][v])%MOD;
            }
        }
        cout<<sum[N][M];
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();  
}

Measured memory_bytes: 63360
#include<iostream>
#include <utility>
using namespace std;
#define MAX 100000
#define SENTINEL 100000001

struct Set{ char sign; int n; };
Set A[MAX], B[MAX], L[MAX], R[MAX];
bool flag = true;;

void merge(Set A[], int left, int right, int mid){
    int n1 = mid - left;
    int n2 = right - mid;
    int idx_l, idx_r;
    
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].n = SENTINEL;
    R[n2].n = SENTINEL;
    
    idx_l = 0;
    idx_r = 0;
    for(int i = left; i < right; i++){
        if(L[idx_l].n <= R[idx_r].n){
            A[i] = L[idx_l];
            idx_l++;
        }
        else{
            A[i] = R[idx_r];
            idx_r++;
        }
    }
}

void mergeSort(Set A[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right ) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, right, mid);
    }
}

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

void quickSort(int p, int r){
    int q;
    
    if(p < r){
        q = partition(p, r);
        quickSort(p, q-1);
        quickSort(q+1, r);
    }
}

int main(){
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> A[i].sign >> A[i].n;
        B[i] = A[i];
    }
    
    quickSort(0, n-1);
    mergeSort(B, 0, n);
    
    for(int i = 0; i < n; i++){
        if(A[i].sign != B[i].sign) flag = false;
    }
    
    if(flag) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    for(int i = 0; i < n; i++) cout << A[i].sign << " " << A[i].n << endl;
    
    return 0;
}


Measured memory_bytes: 5412