akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 100007
#define ll long long int
using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(int x){writ(x);putchar('\n');}

int main()
{
	int a=read(),b=read(),c=read(),ans=maxn;
	for (int i=1;i<=100;++i) ans=min(ans,abs(i-a)+abs(i-b)+abs(i-c));
	write(ans);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N%10==3){
    cout << "bon" << endl;
  }
  else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    int s;
    cin >> s;
    map<int, int> M;
    ++M[s];
    int n = s;
    int i = 1;
    while(1) {
        if (n % 2) n = 3 * n + 1;
        else n /= 2;
        if (M[n]) break;
        else ++M[n], ++i;
    }

    cout << i + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
function main()
	n,k = parse.(split(readline()))
	count = 0
	if k%2 == 1
		print(div(n,k)^3)
	else
		t = div(n,k)
		if n%k >= div(k,2)
			t += 1
		end
		print(div(n,k)^3+t^3)
	end
end
 
main()

Measured memory_bytes: 120408
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pll = pair < ll, ll >;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
 
int main(){   
    ll n; cin >> n;
    map<string,int>cnt;
    string s;
    while(n--) {
        cin >> s;
        cnt[s]++;
    }
    cout << "AC " << "x " << cnt["AC"] << endl;
    cout << "WA " << "x " << cnt["WA"] << endl;
    cout << "TLE " << "x " << cnt["TLE"] << endl;
    cout << "RE " << "x " << cnt["RE"] << endl;
}

    

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007

ll n;
double ans, a[3005], b[3005], dp[3005][3005];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], b[i] = 1 - a[i];
    dp[0][0] = 1;
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= i; j++){
            dp[i + 1][j] += dp[i][j] * b[i + 1];
            dp[i + 1][j + 1] += dp[i][j] * a[i + 1]; 
        }
    }
    for (int i = n/2 + 1; i <= n; i++) ans += dp[n][i];
    cout << fixed << setprecision(20) << ans;
    return 0;
}


Measured memory_bytes: 69120
import math
if __name__ == '__main__':
	a,b = map(int,input().split())

	flg = False
	for x in range(1,1001):
		tmp1 = math.floor(x * 0.08)
		tmp2 = math.floor(x * 0.1)
		if tmp1 == a and tmp2 == b:
			print(x)
			flg = True
			break
	if flg == False:
		print("-1")

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
const double EPS = 1e-8;

double qabs(double x){
	return (x < 0.00) ? -x : x;
}
bool Equal(double d1, double d2){
	return qabs(d1 - d2) <= EPS;
}
struct point{
	double x;
	double y;
};
double Distance(point p1, point p2){
	double dx2 = 1.00 * (p1.x - p2.x) * (p1.x - p2.x);
	double dy2 = 1.00 * (p1.y - p2.y) * (p1.y - p2.y);
	return sqrt(dx2 + dy2);
}
point Middle(point A, point B){
	point ret;
	ret.x = (A.x + B.x) * 0.50;
	ret.y = (A.y + B.y) * 0.50;
	return ret;
}

struct line{ // y = kx + b
	double k, b;
};
line Connect(point A, point B){
	line l;
	l.k = 1.00 * (B.y - A.y) / (B.x - A.x);
	l.b = A.y - (l.k * A.x);
	return l;
}
line Pass(point A, double K){
	line ret;
	ret.k = K;
	ret.b = A.y - (K * A.x);
	return ret;
}
point jd(line l1, line l2){
	point ret;
	double kk = l1.k - l2.k;
	double bb = l2.b - l1.b;
	ret.x = bb / kk;
	ret.y = l1.k*ret.x + l1.b;
	return ret;
}

struct circle{
	point O;
	double r;
};
bool Inside(circle C, point P){
	return Distance(C.O, P) < C.r + EPS;
}
circle OuterCircle(point A, point B, point C){
	line AB = Connect(A, B);
	point M_AB = Middle(A, B);
	line l1 = Pass(M_AB, -(1.00 / AB.k));
	line AC = Connect(A, C);
	point M_AC = Middle(A, C);
	line l2 = Pass(M_AC, -(1.00 / AC.k));
	circle ret;
	ret.O = jd(l1, l2);
	ret.r = Distance(ret.O, A);
	return ret;
}
circle getC(point A, point B){
	circle ret;
	ret.O = Middle(A, B);
	ret.r = Distance(ret.O, A);
	return ret;
}

int N;
point p[55];
int main(){
	cin >> N;
	rep(i, N){
		cin >> p[i].x >> p[i].y;
	}
	double ans = 20000.0;
	rep(i, N){
		rep(j, N){
			if(i != j){
				circle C = getC(p[i], p[j]);
				if(C.r > ans) continue;
				bool ok = 1;
				rep(k, N){
					if(!Inside(C, p[k])){
						ok = 0;
						break;
					}
				}
				if(ok){
					ans = C.r;
				}
			}
		}
	}
	rep(i, N){
		rep(j, N){
			if(i != j){
				line l1 = Connect(p[i], p[j]);
				rep(k, N){
					line l2 = Connect(p[i], p[k]);
					if(Equal(l1.b, l2.b) && Equal(l1.k, l2.k)) continue;
					circle C = OuterCircle(p[i], p[j], p[k]);
					if(C.r > ans) continue;
					bool ok = 1;
					rep(kk, N){
						if(!Inside(C, p[kk])){
							ok = 0;
							break;
						}
					}
					if(ok){
						ans = C.r;
					}
				}
			}
		}
	}
	cout << fixed << setprecision(20) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# ABC104c
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

d, g = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(d)]
toku = [False]*d
# 全完を2^D通り探索


def dfs(i, su, cnt):
    #print(i, su, cnt)
    if (i >= d):
        if (su >= g):  # 目標点を超えている場合
            return cnt
        # 超えていない場合は、全完していない問題のうち一番点数が高い物を解いていこう
        for j in range(d - 1, -1, -1):
            if (toku[j]):
                continue
            tokuzo = min(p[j][0], math.ceil((g - su) / (100 * (j + 1))))
            if (su + 100 * (j + 1) * tokuzo >= g):
                return cnt + tokuzo
            return 99999

    # i問目を全完する場合としない場合
    toku[i] = True
    suru = dfs(i + 1, su + (i + 1) * p[i][0]
               * 100 + p[i][1], cnt + p[i][0])
    toku[i] = False
    sinai = dfs(i + 1, su, cnt)
    # print(i, suru, sinai)
    return min(suru, sinai)


print(dfs(0, 0, 0))

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

vector<int> dat;
vector<int> tmp;

int doubles, lengths;

bool compare_suffix(int i, int j)
{
	if (dat[i] == dat[j])
	{
		int ri = (i + doubles <= lengths ? dat[i + doubles] : -1);
		int rj = (j + doubles <= lengths ? dat[j + doubles] : -1);

		return ri < rj;
	}

	return dat[i] < dat[j];
}

vector<int> suffix_array(string S)
{
	lengths = S.size();

	vector<int> arrays(lengths + 1);

	dat.resize(lengths + 1);
	tmp.resize(lengths + 1);

	for (int i = 0; i <= lengths; i++)
	{
		arrays[i] = i;

		dat[i] = i < lengths ? S[i] : -1;
	}

	for (doubles = 1; doubles <= lengths; doubles <<= 1)
	{
		sort(arrays.begin(), arrays.begin() + lengths + 1, compare_suffix);

		tmp[arrays[0]] = 0;

		for (int i = 1; i <= lengths; i++)
		{
			tmp[arrays[i]] = tmp[arrays[i - 1]] + (compare_suffix(arrays[i - 1], arrays[i]) ? 1 : 0);
		}

		for (int i = 0; i <= lengths; i++)
		{
			dat[i] = tmp[i];
		}
	}

	return arrays;
}

int main()
{
	string S, T; int Q;
	
	while (true)
	{
		char c = getchar();

		if (c == '\n') break;

		S += c;
	}

	scanf("%d", &Q); getchar();

	vector<int> sa = suffix_array(S);

	for (int i = 0; i < Q; i++)
	{
		T = "";

		while (true)
		{
			char c = getchar();

			if (c == '\n') break;

			T += c;
		}

		int l = 0;
		int r = sa.size();

		bool flag = false;

		while (r - l > 1)
		{
			int m = (l + r) / 2;

			string S1 = S.substr(sa[m], T.size());

			if (S1 == T)
			{
				flag = true; break;
			}
			
			if (S1 < T)
			{
				l = m;
			}
			else
			{
				r = m;
			}
		}

		if (flag)
		{
			printf("1\n");
		}
		else
		{
			printf("0\n");
		}
	}

	return 0;
}

Measured memory_bytes: 16640
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    cin >> n;
    n++;
    vector<Int> t(n), x(n), y(n);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (Int i = 1; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool ans = true;
    for (Int i = 0; i < n - 1; i++) {
        Int tt, xx, yy;
        tt = t[i + 1] - t[i];
        xx = x[i + 1] - x[i];
        yy = y[i + 1] - y[i];
        Int dis = abs(xx) + abs(yy);

        if (tt < dis) {
            ans = false;
            break;
        }

        Int rem_time = tt - dis;
        if (rem_time % 2 != 0) {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
using namespace std;
       
int main()
{
int L,A,B,C,D,K,E,F;
cin>>L>>A>>B>>C>>D;
E=A/C;
F=B/D;
if(A%C>0){
E+=1;
}
if(B%D>0){
F+=1;
}
if(E>F){
K=L-E;
}
else
K=L-F;
cout<<K<<'\n';
return 0;
}

Measured memory_bytes: 1160
object Main {
  def main(args:Array[String]){
    val vals = readLine().split(" ").map(s => s.toInt)
    val w = vals(0)
    val h = vals(1)
    val x = vals(2)
    val y = vals(3)
    val r = vals(4)
    if (x <= w-r && x >= r && y <= h - r && y >= r) {
      println("Yes")
    }else{
      println("No")
    }
  }
}

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

int main(){
unsigned long long int a,d,b,c;
  cin>>a;
  d=a;
  int e,f,h;
  e=1;
  f=102;
  for(int i=1;i<d;i++){
    if(d/10>1000000)
      d=d/100;
    if(a%i==0){
     b=i;
     c=a/i;
     c=max(b,c);
     for(int j=0;j<100;j++){
      h=15;
      if(j==0)
        e=1;
      if(c/10>0){
       c=c/10;
       e++;
      }
      else
        break;
     }
 }
   if(f>e&&h==15)
      f=e;
    h=0;
    
}   
  if(a==1)
    cout<<1<<endl;
  else
     cout<<f<<endl;
 }


Measured memory_bytes: 256
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!{
        n: usize
    }
    let mut ans = 0;
    for i in 3..10 {
        for j in 4..3usize.pow(i as u32) {
            let mut m = 0;
            let mut k = j;
            for l in 0..i {
                m *= 10;
                if k % 3 == 0 {
                    m += 3;
                } else if k % 3 == 1 {
                    m += 5;
                } else if k % 3 == 2 {
                    m += 7;
                }
                k /= 3;
            }
            if m <= n && is_753(m) {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn is_753(mut n: usize) -> bool {
    let mut f3 = false;
    let mut f5 = false;
    let mut f7 = false;
    while n > 0 {
        let t = n % 10;
        if t == 3 {
            f3 = true;
        } else if t == 5 {
            f5 = true;
        } else if t == 7 {
            f7 = true;
        } else {
            return false;
        }
        n /= 10;
    }
    f3 && f5 && f7
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

long long int N, A, B;
vector<long long int> h;

bool solve(long long int x)
{
  long long int sum = 0;
  rep(i, N)
    {
      sum += (max(h[i] - B*x, 0LL) + (A-B-1)) / (A-B);
    }
  // cout << "sum=" << sum << endl;
  if(sum > x)
    {
      return false;
    }
  return true;
}

int main()
{
  cin >> N >> A >> B;
  rep(i, N)
    {
      long long int tmp;
      cin >> tmp;
      h.push_back(tmp);
    }
  long long int ok = 1000000000;
  long long int ng = 0;
  while(abs(ok-ng) > 1)
    {
      long long int mid = (ok + ng)/2;
      if(solve(mid))
	{
	  //	  cout << "ok=" << mid << endl;
	  ok = mid;
	}
      else
	{
	  //	  cout << "ng=" << mid << endl;
	  ng = mid;
	}
    }
  cout << ok << endl;
  
  return 0;
}


Measured memory_bytes: 1400
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

class Sieve(max: Int) {
    private val f = IntArray(max + 1)

    init {
        f[0] = -1
        f[1] = -1
        for (i in 2..max) {
            if (f[i] > 0) continue
            for (j in i..max step i) {
                f[j] = i
            }
        }
    }

    fun factors(x: Int): Set<Int> {
        val result = mutableSetOf<Int>()
        var i = x
        while (i != 1) {
            result.add(f[i])
            i /= f[i]
        }
        return result
    }
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = Array(N) { sc.next().toInt() }
        val s = Sieve(1000000)
        val fs = HashMap<Int, Int>()
        A.forEach { a ->
            s.factors(a).forEach { f ->
                fs[f] = (fs[f] ?: 0) + 1
            }
        }
        //dprint(fs)
        val max = fs.values.max() ?: 1
        when (max) {
            1 -> pw.println("pairwise coprime")
            N -> pw.println("not coprime")
            else -> pw.println("setwise coprime")
        }
    }
}


Measured memory_bytes: 88976
#include "bits/stdc++.h"
using namespace std;

long long N;
static vector<long long> V[100000];

long long DFS(long long P) {
	if (V[P].empty()) return 0;
	vector<long long> VX;
	long long Cur = 0;
	for (int X : V[P]) VX.push_back(DFS(X));
	sort(VX.begin(), VX.end());
	for (long long Y : VX) Cur = max(Cur, Y) + 1;
	return Cur;
}

int main() {
	cin >> N;
	for (int i = 1; i < N; i++) {
		long long A;
		cin >> A;
		A--;
		V[A].push_back(i);
	}
	cout << DFS(0) << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int s1 = 0;
  int s2 = 0;
  int curr = 1;
  vi tt(N);
  vi t1(N);
  vi t2(N);
  for(int x = 0; x<N; x++)
    cin >> tt[x];
  for(int x = 0; x<N; x++){
    int t= tt[x];
    s1 += t*curr;
    s2 += t*curr*-1;
    curr*=-1;
    t1[x]=s1;
    t2[x]=s2;
  }
  curr = t1[N-1];
  vi oup(N);
  oup[0]=curr;
  for(int x = 0; x+1<N; x+=2){
    if(x-1<0)
      curr += t2[x+1]-t1[x+1];
    else{
      curr += t2[x+1]-t2[x-1]-(t1[x+1]-t1[x-1]);
    }
    if(x+2<N)
      oup[x+2]=curr;
  }

  s1 = 0;
  s2 = 0;
  curr = 1;
  for(int x = 0; x<N; x++){
    int t= tt[(x+1)%N];
    s1 += t*curr;
    s2 += t*curr*-1;
    curr*=-1;
    t1[x]=s1;
    t2[x]=s2;
  }
  curr = t1[N-1];
  oup[1]=curr;
  for(int x = 0; x+1<N; x+=2){
    if(x-1<0)
      curr += t2[x+1]-t1[x+1];
    else{
      curr += t2[x+1]-t2[x-1]-(t1[x+1]-t1[x-1]);
    }
    if(x+3<N)
      oup[x+3]=curr;
  }


  for(auto e:oup)
    cout << e << " ";
  cout << endl;

  return 0;
}

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

int main(){
  int N;
  cin>>N;
  int64_t X;
  cin>>X;
  int64_t sum=0;

  while(X>0){
    if(X<=pow(2,N+1)-2){
      --N;
      --X;
    }
    else if(X==pow(2,N+1)-1){
      sum += int64_t(pow(2,N));
      break;
    }
    else if(X==pow(2,N+2)-3){
      sum += int64_t(pow(2,N+1))-1;
      break;
    }
    else{
      X -= int64_t(pow(2,N+1))-1;
      sum += int64_t(pow(2,N));
      --N;
    }
  }

  cout<<sum<<endl;

}

Measured memory_bytes: 384
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            System.Collections.Generic.List<int> list = new System.Collections.Generic.List<int>();
            foreach(string i in s.Split(' ')){
                list.Add(int.Parse(i));
            }
           
            int K = int.Parse(Console.ReadLine());
            list.Sort();
            Console.WriteLine(list[0] + list[1] + list[2] * Math.Pow(2,K));
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int curr1 = 0, curr2 = 0;
        for (int i = 0; i < N.length(); i++) {
            int c = N.charAt(i) - '0';
            curr1 += c == i % 2 ? 1 : 0;
            curr2 += c == i % 2 ? 0 : 1;
        }
        System.out.println(Math.min(curr1, curr2));
    }
}


Measured memory_bytes: 39116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// # #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
// namespace mp = boost::multiprecision;

// types
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

// consts
int MOD = 1000000007;  // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

struct Swap { ll v; int x; int y; };

int main() {
    ll n, a;
    cin >> n;
    vector<pll> v;
    for (ll i = 0; i < n; ++i) {
        cin >> a;
        v.emplace_back(make_pair(a, i));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, INT_MIN));
    dp[0][0] = 0;
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i <= k + 1; ++i) {
            int j = k - i + 1;
            // k = 0 i = 0 j = 1
            // k = 0 i = 1 j = 0
            // k = n-1 i = 0 j = n
            // k = n-1 i = n j = 0
            ll A = v[k].first;
            ll i0 = v[k].second;
            if (i-1 >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j] + A * abs(i - 1 - i0));
            if (j-1 >= 0) dp[i][j] = max(dp[i][j], dp[i][j-1] + A * abs(n - j - i0));
            // cout << "i " << i << "\tj " << j << "\ti0 " << i0 << "\tA " << A << "\tdp[i][j] " << dp[i][j] << endl;
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= n; ++i) {
        ll j = n - i;
        ans = max(ans, dp[i][j]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 34628
unittest
{
	assert( [ "6 1 2 2", "2 1 1 3 0 2" ].parse.expand.solve == 5 );
	assert( [ "6 1 5 2", "2 1 1 3 0 2" ].parse.expand.solve == 3 );
	assert( [ "10 4 8 5", "7 2 3 6 1 6 5 4 6 5" ].parse.expand.solve == 8 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmvp = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nmvp[ 1 ], nmvp[ 2 ], nmvp[ 3 ], as );
}

auto solve( long m, long v, long p, long[] as )
{
	as.sort!( ( x, y ) => y < x );
	auto ap = as[ p - 1 ];
	
	// 採用可能性有無の境目を二分探索
	auto ans = 0L;
	auto l = 0L;
	auto r = as.length.signed - 1;
	while( l < r )
	{
		auto c = ( l + r + 1 ) / 2;
		auto ac = as[ c ];
		
		auto ok = false;
		if( ap <= ac )
		{
			// 最初からp問以内に入っている場合、全ジャッジがp問に投票すれば採用される
			ok = true;
		}
		else if( ac + m < ap )
		{
			// +m点してもp問以内に入れない場合、どうやっても無理
			ok = false;
		}
		else
		{
			// 投票されるとacの採用可否に影響する問題をピックアップ
			// （スコアが大きい順にp-1問 もしくは ac以下のスコアの問題 は投票されても影響しない）
			auto bs = as[ p - 1 .. c ];
			auto vr = v - ( as.length.signed - bs.length.signed );
			if( vr <= 0 )
			{
				// bsに対して投票する必要がないので採用される
				ok = true;
			}
			else
			{
				// bsに対してm人がvr問ずつ投票したときにac+m点以下にできるか？
				// 各bへの投票可能数はm以下確定なので、単純に投票可能数合計を計算して投票数合計以下ならOK
				auto t = reduce!( ( x, y ) => x + ac + m - y )( 0L, bs );
				ok = ( m * vr <= t );
			}
		}
		
		if( ok ) l = c;
		else     r = c - 1;
	}
	return l + 1;
}


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

int main()
{
	int32_t N, Q;
	cin >> N >> Q;

	string S;
	cin >> S;

	vector<int32_t> cnts(N);
	cnts[0] = 0;
	for (int32_t i = 0; i < N - 1; i++) {
		cnts[i + 1] = cnts[i];
		if (S[i] == 'A' && S[i + 1] == 'C')
			cnts[i + 1]++;
	}

	for (int32_t i = 0; i < Q; i++) {
		int32_t l, r;
		cin >> l >> r;
		l--;
		r--;
		cout << (cnts[r] - cnts[l]) << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////


int main() {
	int N, K; cin >> N >> K;
	string S; cin >> S;
	int cnt = 0;
	for (int i = 1; i < N; ++i) {
		if (S[i] != S[i - 1]) {
			cnt++;
			char key = S[i - 1];
			S[i] = key;
			if (i == N - 1)break;
			while (S[i + 1] != S[i]) {
				S[i + 1] = key;
				i++;
				if (i >= N - 1)break;
			}
		}
		if (cnt == K)break;
	}
	int ans = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (S[i] == 'R'&&S[i + 1] == 'R') {
			ans++;
		}
	}
	for (int i = N - 1; i > 0; --i) {
		if (S[i] == 'L'&&S[i - 1] == 'L') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n, d, x, a[100], choco = 0;
  cin >> n >> d >> x;
  for(int i = 0;i < n;i++) cin >> a[i];

  for(int i = 0;i < n;i++){
    int hoge = 1;
    while(hoge <= d){
      choco++;
      hoge += a[i];
    }
  }

  cout << choco + x << "\n";
  return 0;
}


Measured memory_bytes: 256
list = map(int, raw_input().split())
x0 = list[2] - list[4]
y0 = list[3] - list[4]
x1 = list[2] + list[4]
y1 = list[3] + list[4]

if x0 >= 0 and y0 >= 0 and x1 <= list[0] and y1 <= list[1]:
    print "Yes"
else :
    print "No"
    

Measured memory_bytes: 6444
#include<bits/stdc++.h>
#define int long long 
#define endl "\n"
using namespace std;

int32_t main(){
	int a , b , c;
  	cin>>a>>b>>c;
  	int ans = min({a+b,a+c,b+c});
  	cout<<ans<<endl;

	return 0;
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; j < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(max(a + b, a - b), a * b) << endl;
}


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

typedef struct {
	char word[ 31 ];
	int cnt, page[ 100 ];
} Data;

Data data[ 100 ];

int compare1( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

int compare2( const void *a, const void *b ) {
	return strcmp( (*(Data *)a).word, (*(Data *)b).word );
}

int main( void ) {
	int i, j;
	char word[ 31 ];
	int page, cnt;

	cnt = 0;
	while ( scanf( "%s %d", word, &page ) != EOF ) {

		for ( i = 0; i < cnt && strcmp( word, data[ i ].word ); i++ ) ;
		if ( i == cnt )
			strcpy( data[ cnt++ ].word, word );
		data[ i ].page[ data[ i ].cnt++ ] = page;
	}

	for ( i = 0; i < cnt; i++ )
		qsort( data[ i ].page, data[ i ].cnt, sizeof(int), &compare1 );

	qsort( data, cnt, sizeof(Data), &compare2 );

	for ( i = 0; i < cnt; i++ ) {
		printf( "%s\n", data[ i ].word );
		for ( j = 0; j < data[ i ].cnt; j++ )
			printf( "%d%c", data[ i ].page[ j ], j == data[ i ].cnt - 1 ? '\n' : ' ' );
	}


	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string str;
bool x[2][8010], y[2][8010];
vector<int> vx, vy;
int X, Y;

vi solve_sub(bool dp[2][8010], vector<int> vec) {
	int n = sz(vec);
	bool now = 0, next = 1;
	dp[0][0] = true;
	rep(i, 0, n) {
		memset(dp[next], 0, sizeof(dp[next]));
		rep(j, 0, 8001) {
			if(!dp[now][j]) continue;
			dp[next][j + vec[i]] = true;
			dp[next][abs(j - vec[i])] = true;
		}
		swap(now, next);
	}
	return vi(dp[now], dp[now] + 8001);
}

void solve() {
	cin >> str;
	N = sz(str);
	cin >> X >> Y;
	bool bx = true;
	int cnt = 0;
	rep(i, 0, N) {
		if(str[i]  == 'F') cnt++;
		else {
			if(bx) {
				vx.pb(cnt);
				bx = false;
			}
			else {
				vy.pb(cnt);
				bx = true;
			}
			cnt = 0;
		}
	}
	if(bx) vx.pb(cnt);
	else vy.pb(cnt);
	// debug(vx, vy);
	vector<int> ansx, ansy;
	if(sz(vx) > 0) {
		X -= vx[0];
		ansx = solve_sub(x, vi(vx.begin() + 1, vx.end()));
	}
	ansy = solve_sub(y, vy);

	// debug(X, Y, vi(ansx.begin(), ansx.begin() + 10), vi(ansy.begin(), ansy.begin() + 10));
	if(ansx[abs(X)] && ansy[abs(Y)]) {
		cout << "Yes\n";
	}
	else cout << "No\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000];
vector<int> vs, v[2];
map<int, int> mp;
signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	rep(i,n)v[i%2].pb(a[i]);
	rep(i,2)sort(all(v[i]));
	rep(i,n)vs.pb(v[i%2][i/2]);
	sort(a, a+n);
	rep(i,n)mp[a[i]] = i%2;
	int ans = 0;
	rep(i,n)if(mp[vs[i]] != i%2)ans++;
	printf("%lld\n", ans/2);
	return 0;
}







Measured memory_bytes: 8816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>

using namespace std;

int main()
{
    long long x;
    std::cin >> x;

    long long ans = 0;
    long long deposit = 100;
    while(deposit < x)
    {
        ans++;
        deposit += deposit * 0.01;
    }
    
    std::cout << ans;

    return EXIT_SUCCESS;
} 

Measured memory_bytes: 3184
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int i; cin >> i;

    cout << n - i + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // 文字列処理の関数
#include <ctype.h> // 文字変換(大文字/小文字)の関数

int main() {
char buf[100];
scanf("%s",buf);
int i,j;
for (i=0;buf[i] != '\0';i++);
for (j=0;j<=i-9;j++) {
 printf("%c",buf[j]);
}
printf("\n");
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner; 
public class Main { 
    public static void main(String[] args){ 
        Scanner sc = new Scanner(System.in); 
        while(true){ int H =sc.nextInt(); 
            int W =sc.nextInt(); 
            if(H==0 && W==0){ 
                break; 
            } 
            for(int i=0;i<H;i++){ 
                for(int j=0;j<W;j++){ 
                    System.out.printf("#"); 
                } System.out.printf("\n"); 
            } System.out.printf("\n"); 
        } 
    } 
} 


Measured memory_bytes: 64432
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def divisors(N: int) -> set:
    """ 約数の列挙・個数 """
    from math import sqrt

    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

def compare(a, b):
    return max(len(str(a)), len(str(b)))

N = INT()

ans = INF
for div1 in divisors(N):
    div2 = N // div1
    ans = min(ans, compare(div1, div2))
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int h, n, p, m, k, bar[600];
double dp[2][110][510];

int main(){
	cin >> h >> n >> p >> m >> k;
	rep(i, m){
		int a, b;
		cin >> a >> b;
		bar[a] = b;
	}
	dp[0][p][0] = 1;
	int cur = 0, next = 1;
	
	for(int i = h; i > 0; i--){
		memset(dp[next], 0, sizeof(dp[next]));
		for(int j = 1; j <= n; j++) rep(l, k + 1){
			if(dp[cur][j][l] == 0) continue;
			double P = dp[cur][j][l];
			if(bar[i]){
				int nj = j == bar[i] ? j + 1 : j == bar[i] + 1 ? j - 1 : j;
				dp[next][nj][l] = P;
			}
			else{
				double t = k * 1.0 / (h - m);
				int cnt = 0;
				if(j < n){
					dp[next][j + 1][l + 1] += P * t / (n - 1);
					cnt++;
				}
				if(j > 1){
					dp[next][j - 1][l + 1] += P * t / (n - 1);
					cnt++;
				}
				dp[next][j][l + 1] += P * t * (n - 1 - cnt) / (n - 1);
				dp[next][j][l] += P * (1 - t);
			}
		}
		swap(cur, next);
	}
	double ans = 0, s = 0;
	rep(i, n){
		ans = max(ans, dp[cur][i + 1][k]);
		s += dp[cur][i + 1][k];
	}
	printf("%.9f\n", ans / s);
	
	return 0;
}

Measured memory_bytes: 2072
for i=1to read_int()do Scanf.scanf"%f %f %f %f %f %f
"(fun a b c d e f->let g=2.*.(c-.a)and h=2.*.(d-.b)and i=2.*.(e-.c)and j=2.*.(f-.d)and k=c*.c+.d*.d-.a*.a-.b*.b and l=e*.e+.f*.f-.c*.c-.d*.d in let m=g*.j-.h*.i in let x=j/.m*.k-.h/.m*.l and y=g/.m*.l-.i/.m*.k in Printf.printf"%.3f %.3f %.3f
"x y (sqrt((a-.x)**2.+.(b-.y)**2.)))done

Measured memory_bytes: 2300
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <set>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(ary) do { for(auto i:ary){ cout << i << " "; } cout << endl; } while (0)
int main()
{
    int N; cin >> N;
    vector<bool> B(N);
    REP(i, N) {
        int p; cin >> p;
        if (i == p - 1) B[i] = true;
    }
    int cnt = 0;
    REP(i, N-1) {
        if (B[i] && B[i+1]) {
            cnt++;
            B[i] = B[i+1] = false;
        }
    }
    REP(i, N) if (B[i]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		sc.close();

		//各和を比較
		int max = a + b;
		if(max > (b + c)) {
			max = b + c;
		}

		if(max > (c + a)) {
			max = c + a;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll n; cin >> n;
    ll t[n], x[n], y[n];
    t[0] = 0, x[0] = 0, y[0] = 0;
    bool flag = true;
    ll length = 0;
    for(ll i = 1; i <= n; i++){
        cin >> t[i] >> x[i] >> y[i];
        length = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        if((t[i]-t[i-1]-length) % 2 != 0 || (t[i]-t[i-1]-length < 0)){
            flag = false;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pi acos(-1)
#define mod 1000000007
#define inf INT_MAX
#define scl(x) scanf("%lld",&x)
#define sc(x) scanf("%d",&x)
ll a[200005];
int main()
{

    //ios_base::sync_with_stdio(false);cin.tie(NULL);

    ll i,j,k,n,t,ans=0,x,ct=0,ln,ok=0,m,y,sum=0;
    memset(a,0,sizeof(a));
    cin>>n;
    m=sqrt(n)+1;
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=m;j++)
        {
            for(k=1;k<=m;k++)
            {
                ans=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k);
                if(ans>n)
                    break;
                a[ans]++;
            }
        }
    }
    for(i=1;i<=n;i++)
        printf("%lld\n",a[i]);



}




Measured memory_bytes: 5244
N = int(input())
A_list = [int(i) for i in input().split()]

cnt = 0
for A in A_list:
    if A < 0:
        cnt += 1

if cnt % 2 == 0:
    print(sum(map(abs, A_list)))
else:
    A_list_abs = list(map(abs, A_list))
    minimum = min(A_list_abs)
    A_list_abs.remove(minimum)
    print(sum(A_list_abs) - minimum)


Measured memory_bytes: 14284
S=input()
n=len(S)

N=S[0:int((n-1)/2)]
M=S[int((n-1)/2+1):n]

def pal(l):
    k=len(l)
    ok=0
    for i in range(len(l)):
        if l[i]==l[k-1-i]:
            ok+=1
    if ok==k:
        return 'y'
    else:
        return 'n'

if pal(S)=='y' and pal(N)=='y' and pal(M)=='y':
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int w = in.nextInt();
		int h = in.nextInt();
		int n = in.nextInt();
		
		int x1 = 0;
		int x2 = w;
		int y1 = 0;
		int y2 = h;
		
		for (int i = 0; i < n; i++) {
			int x = in.nextInt();
			int y = in.nextInt();
			int a = in.nextInt();
			
			if (a == 1) x1 = Math.max(x, x1);
			else if (a == 2) x2 = Math.min(x2, x);
			else if (a == 3) y1 = Math.max(y1, y);
			else if (a == 4) y2 = Math.min(y2, y);
		}
		
		if (x1 < x2 && y1 < y2) {
			System.out.println((y2 - y1) * (x2 - x1));
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> a(M),b(M);
  for(int i=0;i<M;i++){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  vector<int> count(N);
  for(int i=0;i<M;i++){
    count.at(a.at(i))++;
    count.at(b.at(i))++;
  }
  bool flag=true;
  for(int i=0;i<N;i++){
    if(count.at(i)%2==1){
      flag=false;
    }
  }
  if(flag){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    double D,T,S;
    cin >> D >> T >> S;
    double time;
    time = D/S;
    if(T >= time){
        cout << "Yes" << endl;
    }
    else{
        cout<< "No" << endl;
    }
}

Measured memory_bytes: 3708
// Working program with FastReader
import java.io.BufferedReader; 

import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer;
import java.lang.*;
public class Main
{ 
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

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

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} 

	long gcd(long a, long b) {
		if(b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int n = ob.nextInt();
		int arr[] = new int[n];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = ob.nextInt();
		}
		int ans=1;
		for (int i = 0; i < arr.length; i++) {
			if(arr[i]==ans) {
				ans++;
			}
		}
		if(n-ans+1<=n-1) {
			System.out.println(n-ans+1);
		}
		else {
			System.out.println(-1);
		}
	}

} 


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

#define int long long

signed main() {
    string a, b;
    cin >> a >> b;
    int c = stoi(a + b);

    int d = sqrt(c);
    if(d*d==c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

int main(){
    int a, b, ans; cin >> a >> b;
    if(a < 1 || a > 9 || b < 1 || b > 9) ans = -1;
    else ans = a * b;
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M;

    cin >> N >> M;

    ll total = 0;
    REP(i, M){
        ll t;
        cin >>  t;
        total += t;
    }

    cout << (((N-total) < 0) ? -1 : (N-total)) << endl;

}


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

const unordered_map<string, int> sounds{
	{"C", 0},
	{"C#", 1},
	{"D", 2},
	{"D#", 3},
	{"E", 4},
	{"F", 5},
	{"F#", 6},
	{"G", 7},
	{"G#", 8},
	{"A", 9},
	{"A#", 10},
	{"B", 11}};

const int NUM = sounds.size();

int input() {
	string s;
	cin >> s;
	return sounds.at(s);
}

bool solve() {
	int n, m;
	cin >> n >> m;

	vector<int> stairs(n), music(m);
	for(auto &e : stairs) e = input();
	for(auto &e : music)  e = input();

	for(int last = n - 2; last < n; ++last) {
		int pos = last;
		for(int i = m - 1; i >= 0; --i) {
			if(pos < 0 || pos >= n) goto next;

			switch((music[i] - stairs[pos] + NUM) % NUM) {
			case  0:
				pos -= 1;
				break;
			case  1:
				pos -= 2;
				break;
			case 11:
				pos += 1;
				break;
			default:
				goto next;
			}
		}
		if(pos == -1) return true;
	next:;
	}

	return false;
}

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

	int t;
	cin >> t;
	while(t--) cout << (solve() ? "Yes" : "No") << endl;;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1532