akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lld;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"-1"<<endl;return 0
const int mod=1000000007;
const int big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
//19:04~
int main(void){
	int A,B,C,D,E,F;
	cin>>A>>B>>C>>D>>E>>F;
	int mizu[31]={0};//水
	int sato[3001]={0};//さとう
	for(int i=0;i<=30;i++){
		for(int j=0;j<=30;j++){
			if(A*i+B*j>30){break;}
			mizu[A*i+B*j]=1;
		}
	}
	for(int i=0;i<=3000;i++){
		for(int j=0;j<=3000;j++){
			if(C*i+D*j>3000){break;}
			sato[C*i+D*j]=1;
		}
	}
	int ans=100*A,ansa=0;//質量,佐藤
	for(int i=1;i<=30;i++){
		for(int j=0;j<=3000;j++){
			if(i*100+j>F){break;}
			if(i*E<j){break;}
			if(mizu[i]==0){break;}
			if(sato[j]==0){continue;}
			if(((double)ansa)/ans<((double)j)/(i*100+j)){
				ans=i*100+j;ansa=j;
			}
		}
	}
	cout<<ans<<" "<<ansa<<endl;
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
int n;
ll a[maxn];

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    ll b[3];
    int k = 0;
    for(int i = n-1; i > 0; i--)
    {
        if(a[i] == a[i-1])
        {
            k++;
            b[k] = a[i];
            i--;
        }
        if(k == 2) break;
    }
    ll ans = b[1]*b[2];
    if(k != 2) ans = 0;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;

//1, 12, 123, 1234
public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long sum = n;
		for (int i = 2; i <= 3; i++) {
			sum+=Math.pow(n, i);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26928
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,a[100000],ans;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2)ans++;
    }
    if(ans%2)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 640
from collections import deque
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N = int(readline())
if N == 1:
    print("First")
    exit(0)
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, readline().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
def bfs(s):
    dist = [None]*N
    que = deque([s])
    dist[s] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] is not None:
                continue
            dist[w] = d + 1
            que.append(w)
    d = max(dist)
    return dist.index(d), d
u, _ = bfs(0)
v, d = bfs(u)

memo = [-1]*(d+2)
memo[0] = 0
memo[1] = 1
memo[2] = 0
for i in range(3, d+2):
    if memo[i-1] == 0 or memo[i-2] == 0:
        memo[i] = 1
    else:
        memo[i] = 0
print("First" if memo[d+1] else "Second")

Measured memory_bytes: 95436
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m, 0));
  int ci,ai;
  for(int i=0; i<n; i++){
    cin >> c[i];
    for(int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }
  
  int ans = 10000000;
  vector<int> r(m,0);
  int price;
  bool ok = false;
  for(int i=0; i<pow(2,n); i++){
    ok = true;
    price= 0;
    for(int j=0; j<m; j++){
      r[j] = 0;
    }

    for(int j=0; j<n; j++){
      if(((i >> j)&1) == 1){
        price += c[j];
        for(int k=0; k<m; k++){
          r[k] += a[j][k];
        }
      }
    }

    for(int j=0; j<m; j++){
      if(r[j]<x){
        ok = false;
      }
    }
    if(ok){
      ans = min(ans, price);
    }
  }

  if(ans != 10000000){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
} 

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

int main(void)
{
    int n, k;
    cin >> n >> k;
    double arr[n];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    double sum = 0;
    for(int i = 0; i < k; i++)
        sum += (((double)arr[i] + 1)) / 2;
    double ans = sum;
    for(int i = k; i < n; i++)
    {
        sum -= ((double)(arr[i - k])+1)/2;
        sum += (((double)(arr[i])) + 1) / 2;
        ans = max(ans, sum);
    }
    
    cout <<setprecision(10)<< ans << "\n";
    return 0;
}

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        m: u64,
    }
    println!("{}", 24 + 24 - m);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define all(V) (V).begin(),(V).end()

int main(){
  int N,M;
  vector<int> X(1),Y(1);
  cin>>N>>M>>X[0]>>Y[0];
  int a;
  for(int i=0;i<N;i++){
    cin>>a;X.push_back(a);
  }
  for(int i=0;i<M;i++){
    cin>>a;Y.push_back(a);
  }
  sort(all(X));reverse(all(X));sort(all(Y));
  if(X[0]<Y[0])
    cout<<"No War"<<endl;
  else
    cout<<"War"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

			if (N.contains("9")) {
				System.out.println("Yes");
				sc.close();
				return;
			}
		
		System.out.println("No");

		sc.close();
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  string s = "";
  while (n--) {
    s += char(n % 26 + 'a');
    n /= 26;
  }
  reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}

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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int t = a;
            a = b;
            b = t;
            t = a;
            a = c;
            c = t;
            out.println(a + " " + b + " " + c);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 23252
var
	K:Longint;
	L,R,M:int64;
function check(T:int64):Longint;
var
	dp:Array[1..12,0..1,0..9]of Longint;
	dpz:Array[1..12,0..1]of Longint;
	S:String;
	ls,i,j,k,l,nj,lim,sum,llim,rlim:Longint;
begin
	S:='';
	while T>0 do begin
		S:=Chr(T mod 10+48)+S;
		T:=T div 10;
	end;
	ls:=length(S);
	for i:=1 to ls+1 do for j:=0 to 1 do begin
		for k:=0 to 9 do dp[i,j,k]:=0;
		dpz[i,j]:=0;
	end;
	dpz[1,0]:=1;
	for i:=1 to ls do begin
		for j:=0 to 1 do begin
			if j=0 then lim:=ord(S[i])-48 else lim:=9;
			inc(dpz[i+1,1],dpz[i,j]);
			for l:=1 to lim do begin
				nj:=j;
				if l<lim then nj:=1;
				inc(dp[i+1,nj,l],dpz[i,j]);
			end;
			for k:=0 to 9 do begin
				llim:=k-1;if llim<0 then llim:=0;
				rlim:=k+1;if rlim>lim then rlim:=lim;
				for l:=llim to rlim do begin
					nj:=j;
					if l<lim then nj:=1;
					inc(dp[i+1,nj,l],dp[i,j,k]);
				end;
			end;
		end;
	end;
	sum:=0;
	for k:=0 to 9 do for i:=0 to 1 do begin
		inc(sum,dp[ls+1,i,k]);
	end;
	check:=sum;
end;
begin
	read(K);
	L:=0;
	R:=3234566667;
	while R-L>1 do begin
		M:=(L+R)div 2;
		if check(M)>=K then R:=M else L:=M;
	end;
	writeln(R);
end.


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w;
int fie[9][9];
bool flag;
bool used[9][9];

void check(int x,int y){
	if(fie[y][x]==0)flag=false;
	used[y][x]=true;
	if(y==h-1 && x==w-1)return;
	int cnt=0;
	if(y<h-1 && fie[y+1][x]==1){
		check(x,y+1);
		cnt++;
	}
	if(x<w-1 && fie[y][x+1]==1){
		check(x+1,y);
		cnt++;
	}
	if(cnt==2 || cnt==0)flag=false;
}

int main(void){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		string str;
		cin >> str;
		for(int j=0;j<w;j++){
			if(str[j]=='#')fie[i][j]=1;
		}
	}
	memset(used,false,sizeof(used));
	flag=true;
	check(0,0);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(fie[i][j]==1 && !used[i][j])flag=false;
		}
	}
	printf("%s\n",flag?"Possible":"Impossible");
	return 0;
}


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

int main() {
    long h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
    } else {
        cout << (h * w + 1) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min({P+Q, Q+R, R+P}) << endl;
  return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
const int mod=998244353;
int num[N];
ll qpow(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1) ans=ans*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return ans;
}
int main(){
    int n;
    scanf("%d",&n);
    int x;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(i==1&&x!=0) {
            printf("0");
            return 0;
        }
        ++num[x];
    }
    if(num[0]!=1){
        printf("0");
        return 0;
    }
    ll ans=1;
    for(int i=1;i<=n;i++){
        //cout<<num[i]<<" ";
        if(num[i]&&!num[i-1]) ans=0;
        else if(num[i]&&num[i-1])ans=ans*qpow(num[i-1],num[i])%mod;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,k;
    cin >> n >> m >> k;
    if(n>=k){
        cout << n-k << " ";
    }
    else cout << "0" << " " ;
    if(k>n)k=k-n;
    else k=0;
    if(m>=k){
        cout << m-k << endl;
    }
    else cout << "0" << endl;
}



Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

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

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

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

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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

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

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

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	B := make([]int, N)
	for i := 0; i < N; i++ {
		B[i] = sc.nextInt() - (i + 1)
	}
	sort.Ints(B)
	b := B[N/2]
	ans := 0
	for i := 0; i < N; i++ {
		ans += abs(B[i] - b)
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 5120
n=int(input())
a=list(map(int, input().split()))
fumidai=fumidau=0
try:
    for i in range(len(a)):
        kijun=a[i]
        if kijun>a[i+1]:
            fumidau=kijun-a[i+1]
            fumidai+=fumidau
            a[i+1]=a[i+1]+fumidau

except:
    pass
print(fumidai)

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second

#define pow10(n) stoll("1"+string(n,'0'))

#define debug(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LNF = 1e18;

void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    int n; cin >> n;
    int cnt = 0;
    for(int i=1; i<=n; ++i) {
        int a; cin >> a;
        if(i & 1 && a & 1)
            ++cnt;
    }
    cout << cnt;
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  string s;
  cin >> n >> s >> k;
  k--;
  for(int i = 0; i < n; i++){
    s[i] = (s[i] == s[k] ? s[i] : '*');
  }
  cout << s << endl;
}


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

bool num_check(char c){
    if(c=='0' || c=='1' || c=='2' || c=='3' || c=='4' || c=='5' || c=='6' || c=='7' || c=='8' || c=='9'){
        return true;    
    }
    return false;
}

string num_max(string a, string b){
    if(a.size() < b.size()) return b;
    else if(a.size() > b.size()) return a;
    else return a>b ? a:b;
}

int main(void){
    int W, H;
    char field[71][71];
    string dp[71][71];
    
    while(cin>>W>>H){
        if(W+H==0)  break;
        string c;
        for(int i=0; i<H; i++){
            cin >> c;
            for(int j=0; j<W; j++){
                field[i][j]=c[j];
            }
        }
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(num_check(field[i][j])) dp[i][j]=field[i][j];
                else dp[i][j]="0";
            }
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(dp[i][j]=="0")   continue;;
                if(i+1<H && num_check(field[i+1][j])) {
                    dp[i+1][j]=num_max(dp[i+1][j], dp[i][j]+field[i+1][j]);
                    //cout << "dp[" << (i+1) << "][" << j << "]=" << dp[i+1][j];
                }
                if(j+1<W && num_check(field[i][j+1])){
                    dp[i][j+1]=num_max(dp[i][j+1], dp[i][j]+field[i][j+1]);
                    //cout << "dp[" << i << "][" << (j+1) << "]=" << dp[i][j+1];
                }
            }
        }
        
        string ans="0";
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                ans=num_max(dp[i][j], ans);
            }
        }
        cout << ans << "\n";
        
    }
    
    
    
    
}



Measured memory_bytes: 3340
import math
k = int(input())
ans = k**3 - (k-1)**3
for a in range(2,k+1):
  for b in range(2,k+1):
    tmp = math.gcd(a,b)
    for c in range(2,k+1):
      ans += math.gcd(tmp, c)
print(ans)

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

#define ll long long
#define mod 1e9+7
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll n;
double dp[301][301][301];
ll arr[301];

double solve(ll a,ll b,ll c){
	//cout<<a<<" "<<b<<" "<<c<<"\n";
	if(a<0||b<0||c<0)
		return 0;
	if(a==0 && b==0 && c==0)
		return 0;
	
	if(dp[a][b][c] != -1)
		return dp[a][b][c];

	double p=(1.0)*(a+b+c);

	dp[a][b][c] = 0.0;
	
	dp[a][b][c]=(a/p)*solve(a-1,b,c)+(b/p)*solve(a+1,b-1,c)+(c/p)*solve(a,b+1,c-1)+(double)n/p;
	return dp[a][b][c];	
}

int main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //ll n;
    cin>>n;
    ll a=0,b=0,c=0;
    
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    	if(arr[i]==1)
    		a++;
    	else if(arr[i]==2)
    		b++;
    	else
    		c++;
    }
    for(int i=0;i<301;i++){
    	for(int j=0;j<301;j++){
    		for(int k=0;k<301;k++)
    			dp[i][j][k]=-1.0;
    	}
    }
    //memset(dp,-1.00,sizeof(dp));
    //dp[0][0][0]=(1.0);
    //dp[1][0][0]=(1.0);
    double ans=solve(a,b,c);
    cout<<setprecision(27)<<ans;
    return 0;
}


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

int main()
{
    string dance;
    cin >> dance;
    for (int i = 0; i < dance.length(); i++)
    {
        if (dance[i] == 'U' || dance[i] == 'D')
            continue;
        if (i % 2 == 0)
        {
            if (dance[i] == 'L')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else if (i % 2 == 1)
        {
            if (dance[i] == 'R')
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
  int N;
  cin >> N;   
  
  float H[N]={};
  for(int i=0;i<N;++i) cin >> H[i];
  
  sort(H, H+N);
  
  for(int i=1;i<N;++i){
    H[i] = (H[i]+H[i-1])/2;
    
  }
  
  cout << H[N-1] << endl;
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  ll N;
  cin >> N;
  ll sum = 0;
  char neg = 0;
  ll vMin = (ll)(1e10);
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    if (a < 0) {
      neg = 1 - neg;
      a = -a;
    }
    sum += a;
    vMin = min(vMin, a);
  }
  if (neg == 0) {
    cout << sum << endl;
  }else {
    cout << sum - 2*vMin << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i=0;i<m;i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    vector<P> d(m);
    d[0]=make_pair(INT_MIN,0);
    for(int i=1;i<m;i++){
        d[i]=make_pair(x[i]-x[i-1],i);
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    vector<int> index(n-1);
    for(int i=0;i<n-1;i++){
        if(i>=m){
            break;
        }
        index[i]=d[i].second;
    }
    sort(index.begin(),index.end());
    /*
    for(int i=0;i<min(n-1,m-1);i++){
        cout << index[i] << endl;
    }
    */
    int indexx=0,ans=0;
    for(int i=0;i<min(n-1,m-1);i++){
        ans+=x[index[i]-1]-x[indexx];
        indexx=index[i];
    }
    cout << (n<m?ans+x[m-1]-x[indexx]:0) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
/*
int main(){
    pair<pair<string,int>,int> p[5];
    for(int i=0; i<5; i++){
        string s; cin >> s;
        int a; cin >> a;
        p[i] = make_pair(make_pair(s,a),5-i);
    }

    sort(p,p+5);
    puts("");
    for(int i=0; i<5; i++){
        cout << p[i].first.first << " " << p[i].first.second << " "  << p[i].second << endl;
    }
    return 0;
}
*/

int main(){
    //pair使わないでACする
    int n;
    cin >> n;
    string s[n];
    string ascS[n];
    int p[n];
    for(int i=0; i<n; i++){
        cin >> s[i] >> p[i];
        ascS[i] = s[i];
    }
    sort(ascS,ascS+n);
    int writed[n]={};
    for(int i=0; i<n; i++){
        int score=-1, write=0;
        for(int j=0; j<n; j++){
            if(ascS[i]==s[j] && writed[j]==0){
                if(score<p[j]){
                    score=p[j];
                    write=j;
                }
            }
        }
        cout << write+1 << endl;
        writed[write]++;
    }
}


Measured memory_bytes: 256
def countdiv(n):
	m = n
	cnt = 0
	while m % 2 == 0:
		cnt += 1
		m = m / 2
	return cnt

n = int(raw_input())
max = 0
nmb = 1

for i in range(1, n+1):
	tmp = countdiv(i)
	if tmp > max:
		max = tmp
		nmb = i

print nmb

Measured memory_bytes: 2568
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
	long long n,k;
	cin >> n >> k;
 
	long long ans=0;
	ans+=(n/k)*(n/k)*(n/k);
	if(k%2==0)
	{
		long long x = n/(k/2)-n/k;
		ans+=x*x*x;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
const int lim = (1 << 20);
const int mod = (int)1e9 + 7;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    vector<int> in(n), pre;
    int tot;
    FOR(i, n)cin >> in[i];
    tot = 0;
    FOR(i, n)tot ^= in[i], pre.pb(tot);
    vector<int> ans(pre.size());
    unordered_map<int, int> zero;
    unordered_map<int, int> cum;
    vi prev(n), zCum(n);
    vi last(lim);
    vector<bool> found(lim);
    for(int i = pre.size() - 1; i >= 0; i--){
        if(found[pre[i]]){
            prev[i] = last[pre[i]];
        }
        found[pre[i]] =true;
        last[pre[i]] = i;
    }
    int pp = 0;
    FOR(i, n)pp += (pre[i] == 0), zCum[i] = pp;
    
    FOR(i, n){
        if(prev[i])prev[i] = zCum[prev[i]] - zCum[i];
 //       cout << prev[i] << " ";
    }
  //  cout <<endl;
    
    bool first = false;
    FOR(i, pre.size()){
//        cout << pre[i] << " ";
        if(pre[i]){ // xor != 0
            ans[i] = cum[pre[i]] + 1; 
            ans[i] %= mod;
            zero[pre[i]] += ans[i];
            zero[pre[i]] %= mod;
            cum[pre[i]] += zero[pre[i]] * prev[i]; 
            cum[pre[i]] %= mod;
           //we need to consider all the beginnings behind zero
           //add 1 to make this the initial interval 
        }else{ // xor is 0
            if(!first)zero[0] = 1;
            else zero[0] *= 2;
            zero[0] %= mod;
            int j = i -1;
           /* while(j != prev){
                zero[pre[j]] += ans[j];
                zero[pre[j]] %= mod;
                j--;
            }
            for(pii x: zero){
                cum[x.first] += x.second;
                cum[x.first] %= mod;
            }*/
            first = true;
        } 
    }
  //  cout <<endl;
    if(tot)cout << ans[n-1];
    else{
        int sum = 0;
        for(pii x: zero)sum += x.second, sum %= mod;
        cout << sum;
    }
}




Measured memory_bytes: 56428
#include <iostream>
#include <iomanip>
#include <cmath>

typedef long double ld;

ld dissq(double x1, double y1, double x2, double y2)
{
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}

int main()
{
	ld x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		ld x0, y0;
		std::cin >> x0 >> y0;
		ld s = (dissq(x0,y0,x1,y1) + dissq(x1,y1,x2,y2) - dissq(x0,y0,x2,y2)) / (2.0 * dissq(x1,y1,x2,y2));
		ld x = (1.0 - s) * x1 + s * x2;
		ld y = (1.0 - s) * y1 + s * y2;
		std::cout << std::setprecision(8) << std::fixed << x << " " << y << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3268
//AtCoder ABC044 B - 美しい文字列 / Beautiful Strings
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    string w;
    cin>>w;
    unordered_map<char,int> cm;
    for(auto c:w){
        cm[c]++;
    }
    bool ans=true;
    for(auto&& d:cm){
        if(d.second%2) {
            ans=false;
            break;
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String S = in.readLine();
		int k = S.length();
		for (int i = 1; i < S.length(); ++i) {
			if (S.charAt(i - 1) != S.charAt(i)) {
				k = Math.min(k, Math.max(i, S.length() - i));
			}
		}
		System.out.println(k);
	}
}

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

typedef long long ll;

const int N = 1e5 + 5;
int mid[N];
int arr[N*2];
int n, t;
priority_queue<int, vector<int>, greater<int>> a;
multiset<int> m1;
multiset<int> m2;
ll suma, sumc, ans;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        suma += t;
        a.push(t);
    }
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        mid[i] = arr[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> arr[n + i];
    }
    sort(arr, arr + n * 2);
    for (int i = 0; i < n; ++i) {
        sumc += arr[i];
        m1.insert(arr[i]);
    }
    for (int i = n; i < n * 2; ++i)
        m2.insert(arr[i]);

    ans = suma - sumc;

    for (int i = 0; i < n; ++i) {
        int num = mid[i];
        int t = a.top();
        if (num > t) {
            suma += num - t;
            a.pop();
            a.push(num);
        }
        auto p1 = m1.find(num);
        if (p1 != m1.end()) {
            m1.erase(p1);
            auto p2 = m2.begin();
            sumc -= num;
            sumc += *p2;
            m1.insert(*p2);
            m2.erase(p2);
        } else {
            m2.erase(m2.find(num));
        }
        ans = max(ans, suma - sumc);
    }

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



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

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

int* interleavedlist(int n, int *m){
	int i = 1, j = 0;
	*m = log10(2*n+1) / log10(3);
	int *g = new int[*m];
	while(i<=n){
		g[j] = i;
		++j;
		i = 3 * i + 1;
	}
	return g;
}

void shellSort(int a[], int n){
	int cnt = 0;
	int m;
	int *g = interleavedlist(n,&m);
	
	cout<<m<<endl;
	for(int i=m-1;i>=0;--i)cout<<g[i]<<(i?" ":"");
	cout<<endl;
	
	for(int i=m-1;i>=0;--i){
		cnt += insertionSort(a,n,g[i]);
	}
	cout<<cnt<<endl;
}

int main() {
	int n, *data;
	
	cin>>n;
	data = new int[n];
	for(int i=0;i<n;++i){
		cin>>data[i];
	}
	
	shellSort(data,n);
	
	for(int i=0;i<n;++i){
		cout<<data[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5144
#include <stdio.h>

int main(){
  int a,b,t,i;
  int result = 0;
  scanf("%d %d %d",&a,&b,&t);
  for(i=a;i<t+0.5;i+=a){
    result += b;
  }
  printf("%d\n",result);
  //printf("%d %d %d\n",a,b,t);
  return 0;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n,i;
    cin>>n;
    ll a[n],b[n];
    forn(i,n) cin>>a[i]>>b[i];
    for(i=0;i<=n-3;i++){
        if(a[i]==b[i] and a[i+1]==b[i+1] and a[i+2]==b[i+2]){
            cout<<"Yes" el;
            return;
        }
    }
    cout<<"No" el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
int N,f[105],a[105],t[105],x[105],y[105],np,i;
double res[2][2]={-1,-1,-1,-1},tm,tt;
int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d%d%d",&f[i],&a[i],&t[i],&x[i],&y[i]);
		if(i==0)
			np=0;
		else if(t[i]!=t[np]||(t[i]==t[np]&&a[i]==a[np]))
		{
			np=i;
		}
		else if(t[i]==t[np]&&a[i]!=a[np])
		{
			tm=sqrt(pow(1.0*x[i]-x[np],2)+pow(1.0*y[i]-y[np],2));
			tt=(1.0*f[i]-f[np])/60.0;
			if(res[t[np]][0]<=tm)
			{
				res[t[np]][0]=tm;
				res[t[np]][1]=res[t[np]][0]!=tm&&tt-res[t[np]][1]>0?res[t[np]][1]:tt;
			}
			np=i;
		}
	}
	for(i=0;i<2;i++)
		printf("%lf %lf\n",res[i][0],res[i][1]);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout << max({a*c, a*d, b*c, b*d})<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
vector<pair<int,int>> hen[100000];
int iro[100000]={};

signed main() {
int n,k;
cin>>n>>k;
int d[n],a;
for(int i=0;i<n;i++){
    cin>>a;
    d[i]=(a+k-1)%k;
}
if(k==1){
    cout<<0;
    return 0;
}
int m[n+1];
m[0]=0;
for(int i=1;i<=n;i++)m[i]=(m[i-1]+d[i-1])%k;
map<int,int> ans;
int ans2=0;
ans[0]++;
for(int i=1;i<=n;i++){
    ans2+=ans[m[i]];
    ans[m[i]]++;
    if(i-k+1>=0)ans[m[i-k+1]]--;
}


cout<<ans2;


return 0;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 0x3f3f3f3f
#define pll pair<long long , long long>
const int MAX=5e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;

int main() 
{
    string s , t ;
    cin>>s>>t;
    int ans = t.size();
    for(int i=0;i<=s.size()-t.size();i++){
        int cnt = 0;
    //    cout<<i<<endl;
        for(int j=i;j<i+(t.size());j++){
            if(s[j]!=t[j-i])
                cnt = cnt+1;
        }
        ans = min(cnt,ans);
    }
    cout<<ans;

}


Measured memory_bytes: 3628
#include <stdio.h>
int main(void)
{
	int n,i,k,t=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&k);
		t^=k;
	}
	if(t==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	v.push_back(-1);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<v.size();j++)
			if (a[i]>v[j])
			{
				v[j]=a[i];
				break;
			}
			else if (a[i]<=v[v.size()-1])
			{
				v.push_back(a[i]);
				break;
			}
	}
	cout<<(int)v.size();
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int N;
vector<int> t(110, 0), v(110, 0), cum(110, 0);

double f(int i, double t){
    if(i == 0) return t;
    else if(i == N+1) return cum[N] - t;
    else if(cum[i-1] <= t && t <= cum[i]) return v[i];
    else if(t <= cum[i-1])                return v[i] + cum[i-1] - t;
    else if(cum[i] <= t)                  return v[i] + t - cum[i];

    return 0.0;
}

void input(){
    cin >> N;
    repr(i, 1, N+1) cin >> t[i];
    repr(i, 1, N+1) cin >> v[i];
    repr(i, 1, N+1) cum[i] = cum[i-1] + t[i];
}

void solve(){
    double ans = 0.0;
    double h1 = 0.0, h2 = 0.0;
    for(double t=0.5; t<=cum[N]; t+=0.5){
        h2 = 100000.0;
        rep(i, N+2) chmin(h2, f(i, t));
        ans += (h1 + h2) * 0.25;
        h1 = h2;
    }
    cout << setprecision(16) << ans << endl;
}

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

    input();
    solve();
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[]) {
	ll n, ans = 0, min_capa = LLONG_MAX;
	cin >> n;
	rep(i, 5) {
		ll capa;
		cin >> capa;
		ans++;
		min_capa = min(min_capa, capa);
	}

	if (min_capa < n) {
		ans += n / min_capa;
		if (n % min_capa == 0) ans--;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   ll n;
   cin>>n;
   V<ll> a(n);
   for(int i=0;i<n;i++)cin>>a[i];
   sort(all(a),greater<ll>());
   ll ans=a[0];
   if(n==2){
	   cout<<ans<<"\n";
	   return 0;
   }
   priority_queue<ll> q;
   ans=0;
   q.push(a[0]);
   for(ll i=1;i<n;i++){
	   ans+=q.top();
	   q.pop();
	   q.push(a[i]);
	  q.push(a[i]);
   }
   cout<<ans<<"\n";
}

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

#define mx 100005
#define ll long long

int tc = 1;


void solve(int kk)
{
    ll d,t,s;
    cin >> d >> t >> s;
    ((double)d/s <= t) ? cout << "Yes\n" : cout << "No\n";
    
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("D:\\Codings\\CPP\\input.in", "r", stdin);
    freopen("D:\\Codings\\CPP\\output.in", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int kk = 0;
    //cin >> tc;
    //scanf("%d", &tc);
    while (++kk <= tc)
        solve(kk);

    return 0;
}

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

int main(){
	char a, b;
	cin >> a >> b;
	bool judge;
	if(a=='H'){
		if(b=='H') judge=true;
		if(b=='D') judge=false;
	}
	if(a=='D'){
		if(b=='H') judge=false;
		if(b=='D') judge=true;
	}
	if(judge) cout << 'H' << endl;
	else cout << 'D' << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define mp make_pair
#define x first
#define y second
typedef long long int ll;
// typedef tree< ll, null_type, less_equal< ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define pii pair<ll,ll>
const ll N = 3e5 +9;
// const ll m = 1e9 + 7;
const ll inf= 1e16;
const ll mod = 1e9 + 7;

ll dp[3005][3005][2];
ll a[3005];
void rec(ll i,ll j){
	if(i==j){
		dp[i][j][0] = a[i];
		dp[i][j][1]  = 0;
		// cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<'\n';
		return;	
	}
	else if(dp[i][j][0]!=-1){
		// cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<'\n';
		return ;
	}
	else{
		ll t = inf,sz;
		for(int k = i;k<j;k++){
			rec(i,k);rec(k+1,j);
			ll sum = dp[i][k][0]+dp[i][k][1]+dp[k+1][j][0]+dp[k+1][j][1];
			if(t>sum){
				t = sum;
				sz = dp[i][k][0]+dp[k+1][j][0];
			}
		}
		dp[i][j][0] = sz;
		dp[i][j][1] = t;
		// cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<'\n';
		return;
	}
}

int main() {   
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
    
     ll t=1;
     // cin>>t;
     while(t--){
     	ll n;cin>>n;
     	for(int i = 0;i<n;i++){
     		cin>>a[i];
     	}
     	memset(dp,-1,sizeof(dp));
     	rec(0,n-1);
     	cout<<dp[0][n-1][1];
     }     
}

Measured memory_bytes: 141440