akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	}
	public static void main(String[] args){
		int n = sc.nextInt();
		long maxWeight = sc.nextLong();
		long weight[] = new long[n];
		int values[] = new int[n];
		int sum=0;
		for(int i=0;i<n;i++){
			weight[i]=sc.nextLong();
			values[i]=sc.nextInt();
			sum+=values[i];
		}
		long dp[][] = new long[n+1][sum+1];
		for(int i=0;i<dp[0].length;i++)dp[1][i]=(int)1e9;
		dp[1][0]=0;
		dp[1][values[0]]=weight[0];
		for(int i=2;i<dp.length;i++) {
			for(int j=0;j<dp[0].length;j++){
				if(j<values[i-1])
					dp[i][j]=dp[i-1][j];
				else
					dp[i][j]=Math.min(dp[i-1][j-values[i-1]]+weight[i-1],dp[i-1][j]);
			}
		}
		long max=0;
		for(int i=0;i<dp[0].length;i++){
			if(dp[dp.length-1][i]<=maxWeight)
				max=Math.max(max,i);
		}
		// for(int i=0;i<dp.length;i++){
		// 	System.out.println(Arrays.toString(dp[i]));
		// }
		System.out.println(max);
	}
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int x[3], y[3];
double l[3];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    for (int i = 0; i < 3; ++i)
        std::cin >> x[i] >> y[i];

    double m = 0;
    for (int i = 0; i < 3; ++i) {
        int n = (i + 1) % 3;
        auto xx = x[i] - x[n];
        auto yy = y[i] - y[n];

        l[i] = std::sqrt(xx * xx + yy * yy);
        m = std::max(m, l[i]);
    }

    auto ss = (l[0] + l[1] + l[2]) / 2;
    auto s = std::sqrt(ss * (ss - l[0]) * (ss - l[1]) * (ss - l[2]));
    auto r = 2 * s / (l[0] + l[1] + l[2]);

    std::cout << std::fixed << std::setprecision(10) << m * r / (2 * r + m) << std::endl;

    return 0;
}


Measured memory_bytes: 892
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[105];
int n, res, cnt;
int main() {
	cnt = 1;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)scanf("%d", &a[i]);
	for(int i = 2; i <= n; i++) {
		if(a[i] == a[i - 1])cnt++;
		else res += cnt / 2, cnt = 1;
	}
	res += cnt / 2;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
a_list = gets.split.map(&:to_i)

def calc(list, first_is_positive)
  first = list[0]
  count = if first_is_positive
    first > 0 ? 0 : 1 - first
  else
    first < 0 ? 0 : (-1 - first).abs
  end
  sum = first_is_positive ? first + count : first - count
  list[1..-1].each do |a|
    if sum > 0
      # plus to minus
      if a >= 0
        count += (a + sum) + 1
        sum = -1
      else
        if sum + a < 0
          sum += a
        else
          count += (sum + a) + 1
          sum = -1
        end
      end
    else
      # minus to plus
      if a >= 0
        if sum + a > 0
          sum += a
        else
          count += (sum + a).abs + 1
          sum = 1
        end
      else
        count += (a + sum).abs + 1
        sum = 1
      end
    end
  end
  count
end

ans = [
  calc(a_list, true),
  calc(a_list, false)
].min
puts ans


Measured memory_bytes: 8588
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;


int main(void){
    long long int N,M;
    while(1){
        scanf("%lld %lld",&N,&M);
        if(N==0&&M==0)break;
        else{
            vector<pair<long long int,long long int> > buri;
            for(int i=0;i<N;i++){
                long long int a,b;
                scanf("%lld %lld",&a,&b);
                buri.push_back(make_pair(b,a));
            }
                sort(buri.begin(),buri.end());
                long long int ans=0;
                while(!buri.empty()){
                    if(buri[N-1].second<M){
                        M-=buri[N-1].second;
                        buri.pop_back();
                        N--;
                        
                    }
                    else {
                        ans+=(buri[N-1].second-M)*buri[N-1].first;
                        buri.pop_back();
break;
                    }
                }
                for(int i=0;i<buri.size();i++)ans+=buri[i].first*buri[i].second;
                printf("%lld\n",ans);
            
        }
    }
    return 0;
}



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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int a, b;
	cin >> a >> b;
	string s, t;
	FOR(i, 0, a) s += (char)('0' + b);
	FOR(i, 0, b) t += (char)('0' + a);
	
	string ans = s;
	setmin(ans, t);
	cout << ans;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b;
	if(a>b)swap(a,b);
	if(a<=0&&b>=0)
	{
		printf("Zero\n");
		return 0;
	}
	if(a>0&&b>0)
	{
		printf("Positive\n");
		return 0;
	}
	c=b-a;
	if(c%2==1)
	{
		printf("Positive\n");
		return 0;
	}else 
	{
		printf("Negative\n");
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.*;

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

    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();

    int all = H * W;
    int black = (H * w + W * h) - (h * w);

    System.out.println(all - black); 
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,t,c; cin>>x; t=x; c=0;
    c=1000; 
    for(int i=c;i>=-c;i--){
        for(int j=c;j>=-c;j--){
            int u=pow(i,5)-pow(j,5); 
            if(u==x) {cout<<i<<" "<<j; return 0;}
        }
    }
    return 0;
}

Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            call(GetNumber());
        }

        static void call(int n)
        {
            int i = 1;

            while (true)
            {
                int x = i;

                if (x % 3 == 0)
                {
                    Console.Write(" {0}", i);
                }
                else
                {
                    while (x != 0)
                    {
                        if (x % 10 == 3)
                        {
                            Console.Write(" {0}", i);
                            break;
                        }
                        x /= 10;
                    }
                }

                if (++i > n)
                {
                    break;
                }
            }

            Console.WriteLine();
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static List<int> GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
        }

        static List<long> GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
        }

        static List<double> GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToList();
        }

        static List<string> GetStrings()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
    }
}

Measured memory_bytes: 9556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		if (d < 22 || m < 4) {
			System.out.println(0);
			return;
		}

		int count = 0;
		for (int i = 4; i <= m; i++) {
			for (int j = 22; j <= d; j++) {
				if (j % 10 < 2) continue;
				if ((j % 10) * (j / 10) == i) {
					count++;
				}
			}
		}

		System.out.println(count);
	}
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;



//区間加算BIT

template<class T> struct BIT{
    int n;
    vector<T> bit[2];
    BIT(int n_){
        init(n_);
    }
    void init(int n_){ 
        n = n_+1;
        REP(p,2) bit[p].assign(n,0);
    }

    void add_sub(int p, int i, T x){
        for(int id=i; id<n; id += (id&-id)){
            bit[p][id] += x;
        }
    }
    void add(int l, int r, T x){// [l,r)に加算！
        add_sub(0,l,-x*(l-1));
        add_sub(0,r,x*(r-1));
        add_sub(1,l,x);
        add_sub(1,r,-x);
    }
    T sum_sub(int p, int i){
        T s(0);
        for(int id=i; id>0; id -= (id&-id)){
            s += bit[p][id];
        }
        return s;
    }
    T sum(int l, int r){
        return sum_sub(0,r-1) + sum_sub(1,r-1) * (r-1) 
            - sum_sub(0,l-1) - sum_sub(1,l-1) * (l-1);
    }
};

struct Kukan{
    int l,r,id;
    bool operator<(const Kukan &o) const{
        return r < o.r;
    }
};

int main() {
    int N,Q; cin >> N >> Q;
    vector<int> C(N);
    REP(i,N){
        int c; cin >> c;
        c--;
        C[i] = c;
    }
    vector<Kukan> kukan(Q);
    REP(i,Q){
        int l,r; cin >> l >> r;//[l,r)にする
        l--;
        kukan[i] = {l,r,i};
    }
    sort(ALL(kukan));

    BIT<int> bit(2*N);
    vector<int> pos(N,-1);
    vector<int> ans(Q,0);

    int r = 0;
    for(auto k: kukan){
        while(r<k.r){
            bit.add(pos[C[r]]+2, r+1+1, 1);
            pos[C[r]] = r;
            r++;
        }
        int sums = bit.sum(k.l+1, k.l+2);
        ans[k.id] = max(ans[k.id], sums);
    }

    REP(i,Q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 23236
# coding:utf-8

A, B, K = map(int, input().split(' '))

if A == B and A < K and B < K:
    print('0 0')
else:
    if A - K < 0:
        tr = 0
        ar = B - (K - A)
        if ar < 0:
            print('{} {}'.format(tr, 0))
        else:
            print('{} {}'.format(tr ,ar))
    else:
        tr = A - K
        ar = B
        print('{} {}'.format(tr, ar))

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    bool allEven = true;
    rep(i, n) allEven &= (a[i]%2 == 0);

    cout << (allEven? "second":"first") << endl;

    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    string a,b,ans="";
    cin>>a>>b;
    int curr=0;
    int n=a.size();
    int m=b.size();
    vector<vector<int> > dp(n,vector<int>(m,0));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i == 0 && j == 0)
            {
                if(a[i] == b[j])
                    dp[i][j]=1;
            }
            else if(i == 0 && j>0)
            {
                if(a[i] == b[j])
                    dp[i][j]=1;
                else
                    dp[i][j]=dp[i][j-1];
            }
            else if(j == 0 && i>0)
            {
                if(a[i] == b[j])
                    dp[i][j]=1;
                else
                    dp[i][j]=dp[i-1][j];
            }
            else
            {
                if(a[i] == b[j])
                    dp[i][j]=1+dp[i-1][j-1];
                else
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    int i=n-1,j=m-1;
    while(i>0 && j>0)
    {
        if(a[i] == b[j])
            ans+=a[i],i--,j--;
        else
        {
            if(dp[i-1][j] >= dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    //cout<<ans<<endl;
    if(i == 0)
    {
        while(j>=0)
        {
            if( a[i] == b[j] )
            {
                ans+=a[i];
                break;
            }
            j--;
        }
    }
    else
    {
        while(i>=0)
        {
            if( a[i] == b[j] )
            {
                ans+=a[i];
                break;
            }
            i--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}



Measured memory_bytes: 38484
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    long long ans = N/(A+B)*A + min(N%(A+B),A);
    cout << ans << endl;
}

Measured memory_bytes: 384
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	string a;
	cin >> a;

	for (size_t i = 1; a.size()-i > 0; i++)
	{
		cout << a[a.size() - i];
	}
	cout << a[0];
	cout << endl;
	return 0;
}

Measured memory_bytes: 3188
import os
import math

def main():
	n,m = map(int, input().split())
	a_list = list(map(int, input().split()))
	total_check = math.ceil(sum(a_list)/(4*m))
	
	a_list.sort(reverse=True)
	flag = True
	for i in range(m):
		if a_list[i] < total_check:
			flag = False
	if flag:
		print("Yes")
	else:
		print("No")


if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;




int main(){
	int n, i, m, j;
	cin >> n;
	vector<int>va(1000);
	vector<int>vb(1000);
	for (i = 1; i <= 2 * n; i++) {
		va[i] = i;
	}
	cin >> m;
	for (i = 0; i < m; i++) {
		int k, f = 1;
		cin >> k;
		if (k == 0) {
			for (j = 1; j <= n; j++) {
				vb[f] = va[j];
				f++;
				vb[f] = va[n + j];
				f++;
			}
		}
		else {
			for (j = k + 1; j <= 2 * n; j++) {
				vb[f] = va[j];
				f++;
			}
			for (j = 1; j <= k; j++) {
				vb[f] = va[j];
				f++;
			}
		}
		for (j = 1; j <= 2 * n; j++) {
			va[j] = vb[j];
		}
	}
	for (i = 1; i <= 2 * n; i++) {
		cout << va[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main() {
    int n, s;
    while (cin >> n && n) {
        int mx = -1;
        int mn = 1001;
        int sum = 0;
        for (int i=0; i<n; ++i) {
            cin >> s;
            sum += s;
            mx = max(mx, s);
            mn = min(mn, s);
        }
        sum = sum - mx - mn;
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
N, M = list(map(int, input().split()))
L, R, flg = 1, N, True
for i in range(M):
    _L, _R = list(map(int, input().split()))
    if L <= _L and _R <= R:
        L = _L
        R = _R
    elif _L <= L and R <= _R:
        continue
    elif L <= _L <= R <= _R:
        L = _L
    elif _L <= L <= _R <= R:
        R = _R
    else:
        flg = False
if flg:
    print(R - L + 1)
else:
    print(0)


Measured memory_bytes: 9216
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string S;
        cin >> S;
        int ans = 0;
        for (int i = 0; i < 3; i++)
        {
                if (S[i] == '1')
                {
                        ans++;
                }
        }

        cout << ans << endl;

        return 0;
}


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

int32_t main()
{
    int x,y,tx,ty;
    cin>>x>>y>>tx>>ty;
    int dx=tx-x;
    int dy=ty-y;
    cout<<string(dy,'U')<<string(dx,'R');
    cout<<string(dy,'D')<<string(dx,'L');
    cout<<"L"<<string(dy+1,'U')<<string(dx+1,'R')<<"D";
    cout<<"R"<<string(dy+1,'D')<<string(dx+1,'L')<<"U";

}

Measured memory_bytes: 3528
#include <iostream>
#include <limits.h>
#include <vector>
using namespace std;

int main(){
	int n,m,mi,mih,mit;
	while(cin >> n >> m && n && m){
		vector<int> taro(n);
		vector<int> hanako(m);
		int t=0,h=0;		
		for(int i=0;i<n;i++){
			cin >> taro[i];
			t+=taro[i];
		}
		for(int i=0;i<m;i++){
			cin >> hanako[i];
			h+=hanako[i];
		}
		mi = (1<<21);
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if( t - taro[i] + hanako[j] == h - hanako[j] + taro[i] ){
					if(taro[i]+hanako[j]<mi){
						mi = taro[i]+hanako[j];
						mit = taro[i];
						mih = hanako[j];
					}
				}
			}
		}
		if(mi == 1<<21)cout << -1 << endl;
		else cout << mit << " " << mih << endl;
	}
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int* p, * q;
	p = new int[n];
	q = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> p[i];
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i];
	}
	for (int i = 0;i < n;i++) {
		if (p[i] < q[i])break;
		if (p[i] > q[i]) {
			swap(p, q);
			break;
		}
	}
	int cnt = 0;
	while (1) {
		bool flag = true;
		for (int i = 0;i < n;i++) {
			if (p[i] != q[i]) {
				flag = false;
				break;
			}	
		}
		if (flag)break;
		next_permutation(p, p + n);
		cnt++;
	}
	cout << cnt << endl;
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, p, a[55];
ll dp[55][55];

int main() {
	megaRandom();
	cin >> n >> p;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
		a[i] %= 2;
	}
	dp[0][0] = 1;
	for(int i = 1; i <= n; i ++) {
		if(!a[i]) {
			for(int j = 0; j < i; j ++) {
				dp[i][0] += dp[j][0];
				dp[i][1] += dp[j][1];
			}
  	} else {
			for(int j = 0; j < i; j ++) {
				dp[i][0] += dp[j][1];
				dp[i][1] += dp[j][0];
			}
  	}
  	//cout << dp[i][0] << ' ' << dp[i][1] << "\n";
	}
	ll res = 0;
	for(int i = 0; i <= n; i ++)
		res += dp[i][p];
	cout << res;
	return 0;         
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {

	int h, w; cin >> h >> w;

	vector<string> a(h);

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

	vector<int> cnts(26);

	for (int i = 0; i < h; i++) {
		string buf = a[i];

		for (char c : buf) {
			++cnts[c - 'a'];
		}
	}

	//奇数は1つ、4で割って2余る数がキー。
	int odd = 0;
	int r2 = 0;

	for (int i = 0; i < 26; i++) {
		if (cnts[i] % 2)odd++;
		if (cnts[i] & 2)r2++;
	}


	//両方偶数なら4のペアしか使えない。奇数個のもの、4で割って2余るものがあると
	//達成できない。

	//4444
	//4444
	//4444
	//4444

	//片方偶数なら、偶数の方の辺の半分が2個のペア。
	//424
	//424
	//424
	//424

	//両方奇数なら、中心のみ1、4で割って2余る数がh/2+w/2だけある。
	//424
	//424
	//212
	//424
	//424

	if (h % 2 == 0 && w % 2 == 0) {
		if (odd || r2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else if (h % 2 == 0) {
		if (odd || r2 > h / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else if (w % 2 == 0) {
		if (odd || r2 > w / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else {
		if (odd != 1 || r2 > h / 2 + w / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

inline intmax_t updiv(intmax_t n, intmax_t d) { return (n + d - 1) / d; }

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<int> cost(N), start(N), f(N);
    for (size_t i = 0; i < N - 1; ++i) {
        cin >> cost[i] >> start[i] >> f[i];
    }

    for (size_t i = 0; i < N; ++i) {
        int t = 0;
        for (size_t j = i; j < N - 1; ++j) {
            int leave = max<intmax_t>(start[j], f[j] * updiv(t, f[j]));
            t = leave + cost[j];
        }
        cout << t << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

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

    ll ans = 0;
    FOR(i, 1, N) {
        ll d = N / i;
        if(N % i != 0) {
            ++d;
        }

        ans += d - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,res=1432214;
	string s;
	cin>>s;
	n=s.size(); 
	for(int i=0;i<=n-3;i++){
		int sum=0;
		for(int j=0;j<3;j++){
			sum*=10;
			sum+=s[i+j]-'0';
		}
		res=min(res,abs(753-sum));
	}
//	for(int i=0;i<n-4;i++){
//		int sum=0;
//		for(int j=0;j<4;j++){
//			sum*=10;
//			sum+=s[i+j]-'0';
//		}
//		res=min(res,abs(753-sum));
//	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if(a.second!=b.second) {
        return a.second<b.second;
    } else {
        return a.first<b.first;
    }
}

int main() {
    string S, T;
    cin >> S >> T;
    
    vector<pair<int, int> > s, t;
    for(int i=0; i<S.size(); i++) {
        int ss=S[i];
        ss %= 26;
        int tt=T[i];
        tt %= 26;
        bool flags=true, flagt=true;
        for(int j=0; j<s.size(); j++) {
            if(s[j].first==ss) {
                s[j].second++;
                flags=false;
            }
            if(t[j].first==tt) {
                t[j].second++;
                flagt=false;
            }
        }
        if(flags) {
            s.push_back(make_pair(ss, 1));
        }
        if(flagt) {
            t.push_back(make_pair(tt, 1));
        }
    }
    
    sort(s.begin(), s.end(), cmp);
    sort(t.begin(), t.end(), cmp);
    
    bool flag=true;
    for(int i=0; i<s.size(); i++) {
        if(s[i].second==t[i].second) {
            continue;
        } else {
            flag=false;
            break;
        }
    }
    
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
    
}

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

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  int e = 0;
  int w = 0;
  rep(i, n) {
    char t;
    cin >> t;
    v[i] = t == 'W' ? -1 : 1;
    if (v[i] == 1) e++;
  }
  int res = n;
  rep(i, n) {
    if (v[i] == 1) e--;
    if (i > 0) if (v[i-1] == -1) w++;
    res = min(res, e+w);
  }
  cout << res << endl;
}

Measured memory_bytes: 1408
n,m,c = map(int, input().split())
ans = 0
b = list(map(int, input().split()))
for i in range(n):
    a = list(map(int, input().split()))
    total = 0
    for j in range(m):
        total+=a[j]*b[j]
    total+=c
    if total > 0:
        ans+=1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;    cin >> s >> t;
    bool can = false;

    for (int i = 0; i < s.length(); i++) {
        if (s == t) {
            can = true;
            break;
        }
        s = s.back() + s.substr(0, s.length()-1);
    }
    if (can)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())

a=[]
for i in range(2):
    b=list(map(int,input().split()))
    a.append(b)

ans=False
for i in range(X,Y+1):
    if i > X and i <= Y:
        if max(a[0]) < i and min(a[1]) >= i:
            ans=True

if ans:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int a[n][m],b[m];
  int i,j;
  for(i=0;i<m;i++){
    cin >> b[i];
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  int count=0;
  for(i=0;i<n;i++){
    int sum=0;
    for(j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    sum+=c;
    if(sum>0){
      count++;
    }
  }
  cout << count;
}
    

Measured memory_bytes: 256
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc174_e.cpp"

bool f(int x, vi &a, int k) {
  int cnt = 0;
  for (const auto el : a) {
    cnt += (el - 1) / x;
  }
  return cnt <= k;
}

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

  int n, k;
  cin >> n >> k;
  vi a(n);
  cin >> a;

  int ok = 2e9;
  int ng = 0;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (f(mid, a, k)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;
}


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

int main(void) {
	int row, col;
	int productcol;
	//??????????????°?????????????????°????¬?????????°
	scanf("%d %d %d\n", &row, &col, &productcol);

	//??????????????°??¨????????????????????????
	int productrow=col;

	int i, j;
	int num[500][500];
	int product[500][500];

	//?????°????????????
	for (i = 0; i < row;i++) {
		char tmp[10000];
		//??\???
		fgets(tmp, sizeof(tmp), stdin);
		num[i][0] = atoi(strtok(tmp," "));
		//?????°????????????
		for (j = 1; j < col; j++) {
			num[i][j] = atoi(strtok(NULL, " "));
		}
		//?????°??????????????????
	}
	//?????°??????????????????

	//??????????????????
	for (i = 0; i < productrow; i++) {
		char tmp[15000];
		//??\???
		fgets(tmp, sizeof(tmp), stdin);
		product[i][0] = atoi(strtok(tmp, " "));
		//??????????????????
		for (j = 1; j < productcol; j++) {
			product[i][j] = atoi(strtok(NULL, " "));
		}
		//?????°??????????????????
	}
	//????????????????????????

	long sum[500][500] = { 0 };
	int k;
	//?????°???????????? 3???
	for (i = 0; i < row; i++) {

		//???????????????????????????????????°????§?????????????????????????
		for (j = 0; j < productcol; j++) {
			//??????????????????
			for (k = 0; k < productrow; k++) {
				//???????¶?????????????
				sum[i][j] += num[i][k] * product[k][j];
			}
			//????????????????????????
				
			//???????????????????????¨???????????????????¬????
			if (j == productcol - 1) {
				printf("%ld\n", sum[i][j]);
				break;
			}
			printf("%ld ", sum[i][j]);
		}
		//????????????????????????

	}
	//?????°??????????????????


	return 0;
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
typedef long long lint;

int main(){
   lint N;
   cin >>N; lint M[N];
   rep(i,N)cin >> M[i];
   lint dp[N];
   dp[0]=0;
   dp[1]=abs(M[1]-M[0]);
   rep(i,N-2){
       dp[i+2]=min(dp[i+1]+abs(M[i+2]-M[i+1]),dp[i]+abs(M[i+2]-M[i]));
      
   }
   cout<<dp[N-1]<<endl;
   
 }



  


Measured memory_bytes: 1792
main = 
    interact (calc . map (read) . words)

calc :: [Int] -> String
calc (0:0:_) = ""
calc (h:w:xs) = 
    ln h w ++ "\n" ++ calc xs

ln :: Int -> Int -> String
ln 0 _ = ""
ln h w = 
    (replicate w '#') ++ "\n" ++ (ln (h-1) w)


Measured memory_bytes: 5056
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N; R(N);
    VI A(N);
    REP(i,N)R(A[i]);
    multiset<int>AA(ALL(A));
    int two=1;
    while(two<=*AA.rbegin())two<<=1;
    int an=0;
    while(SZ(AA)){
        int x=*AA.rbegin();
        while(two/2>x)two/=2;
        AA.erase(prev(AA.end()));
        if(AA.find(two-x)!=AA.end()){
            an++;
            AA.erase(AA.find(two-x));
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 10368
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <tuple>
#include <iomanip>
#include <cstring>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
/*
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};
*/

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  double x1, y1;
  cin >> x1 >> y1;
  double x2, y2;
  cin >> x2 >> y2;
  double x3, y3;
  cin >> x3 >> y3;
  double a = pow(pow(x1-x2, 2.0) + pow(y1-y2, 2.0), 0.5);
  double b = pow(pow(x2-x3, 2.0) + pow(y2-y3, 2.0), 0.5);
  double c = pow(pow(x3-x1, 2.0) + pow(y3-y1, 2.0), 0.5);
  double s = (a + b + c) / 2.0;
  double S = pow(s * (s - a) * (s - b) * (s - c), 0.5);
  double r = 2.0 * S / (a + b + c);
  double ans = max(a, max(b, c)) * r / (max(a, max(b, c)) + 2.0 * r);
  cout << fixed << setprecision(20) << ans << endl;
}


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

int main() {
	// your code goes here
    long long k,n,i,j,x,a[100005],b[100005],c[100005],l,r,memo,memo1,kotei=1;
    long long d[100005],e[100005];
    cin >> n >> k;
    if(2*k>n+1){
        cout << "-1" << endl;
        return 0;
    }
    l=k; r=2*k-1;
    for(i=k-1;i>0;i=i-2){
        d[i]=l; e[i]=r;
        l++; r--;
        if(l==r) kotei=l;
    }
    l=2*k; r=2*k+k-2;
    for(i=k-2;i>0;i=i-2){
        d[i]=l; e[i]=r;
        l++; r--;
        if(l==r) kotei=l;
    }
    for(i=0;i<n;i++){
        memo=k+2*n+i;
        if(memo==2*k+2*n-1){
            cout << kotei << " " << 2*k+2*n-1-(kotei) << " " << memo << endl;
        } else if(memo>2*k+k+2*n-2){
            memo1=memo-(2*k+k+2*n-2);
            memo1=memo1+2*k+k-2;
            cout << memo1 << " " << 2*k+2*n-1-memo1 << " " << memo << endl;
        } else {
            memo1=abs(2*k+2*n-1-memo);
            if(memo<2*k+2*n-1){
                cout << d[memo1] << " " << 2*k+2*n-1-e[memo1] << " " << memo << endl;
            } else {
                cout << e[memo1] << " " << 2*k+2*n-1-d[memo1] << " " << memo << endl;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>

using namespace std;
int main(){
    string s;
    cin>>s;
    
    if(
       ((s.at(0)==s.at(1)&&s.at(2)==s.at(3))&&s.at(1)!=s.at(2))||
       ((s.at(0)==s.at(3)&&s.at(1)==s.at(2))&&s.at(0)!=s.at(1))||
       ((s.at(0)==s.at(2)&&s.at(1)==s.at(3))&&s.at(1)!=s.at(2))
       ){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
count = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [[0] * 10 for _ in range(N+1)]
for i in range(N+1):
    if i > 0 and all(dp[i][j] == 0 for j in range(10)):
        continue
    for a in A:
        if i + count[a] <= N:
            ndp = list(dp[i])
            ndp[a] += 1
            ca = sum(ndp)
            cb = sum(dp[i+count[a]])
            if ca > cb:
                dp[i+count[a]] = ndp
            if ca == cb:
                for j in range(10)[::-1]:
                    if dp[i+count[a]][j] > ndp[j]:
                        break
                    if dp[i+count[a]][j] < ndp[j]:
                        dp[i+count[a]] = ndp
                        break
ans = ''
for i in range(10)[::-1]:
    ans += str(i) * dp[N][i]
print(ans)



Measured memory_bytes: 50396
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

using si = string::const_iterator;
class ParseError {};

using ll = long long;
using ull = unsigned long long;

void cch(si &p, char exp) {
  if (*p != exp) {
    cerr << "expected '" << exp << "' but got '" << *p << "'" << endl;
    cerr << "rest: '";
    for (; *p; *p++) cerr << *p;
    cerr << "'" << endl;
    throw ParseError();
  }
  p++;
}

ll number(si &p) {
  ll ret = 0;
  for ( ; isdigit(*p); p++)
    ret = ret * 10 + (*p - '0');
  return ret;
}

ll expr(si &p);

ll factor(si &p) {
  if (*p == '(') {
    cch(p, '(');
    ll ret = expr(p);
    cch(p, ')');
    return ret;
  }
  return number(p);
}

ll term(si &p) {
  ll ret = factor(p);
  while (true) {
    if (*p == '*') {
        cch(p, '*');
        ret *= factor(p);
    } else if (*p == '/') {
        cch(p, '/');
        ret /= factor(p);
    } else break;
  }
  return ret;
}

ll expr(si &p) {
  ll ret = term(p);
  while (true) {
    if (*p == '+') {
        cch(p, '+');
        ret += term(p);
    } else if (*p == '-') {
        cch(p, '-');
        ret -= term(p);
    } else break;
  }
  return ret;
}

int main(void) {
  int n;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);

    si p = s.begin();
    ll ans = expr(p);
    cch(p, '=');
    cout << ans << endl;
  }
}



Measured memory_bytes: 3052
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N,sum[110];
    char s[110];
    cin>>N;
    scanf("%s",s);
    memset(sum,0,sizeof(sum));
    for(int i=0;i<N;i++){
            map<char,int>m;
            int counted=0;
        for(int j=0;j<=i;j++){
            if(!m[s[j]]){
                m[s[j]]++;
            }
            sum[i]=m[s[j]]+sum[i];
        }
        for(int j=i+1;j<N;j++){
            if(m[s[j]]){
                counted++;
                m[s[j]]=0;
            }
        }
        sum[i]=min(sum[i],counted);
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans=max(ans,sum[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  long long N;
  cin>>N;
  long long h,n;
  for(h=1;h<=3500;h++){
      for(n=1;n<=3500;n++){
          long long w=4*h*n-N*h-N*n;
          if(w>0&&(h*n*N)%w==0){
              cout<<h<<' '<<n<<' '<<(h*n*N)/(4*h*n-N*h-N*n)<<endl;
              return 0;
          }
      }
  }
    
}


Measured memory_bytes: 384