akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];

    int ans=0;

    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;

}

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

int main()
{
    char c[4];
    cin >> c;
    int sum = c[0] - '0';
    char eq[9];
    eq[0] = c[0];
    for (int tmp = 0; tmp < (1 << 3); tmp++)
    {
        bitset<3> bs(tmp);
        for (int i = 0; i < 3; i++)
        {
            if (bs.test(i) == true)
            {
                sum += c[i+1] - '0';
                eq[2*i+1] = '+';
                eq[2*i+2] = c[i+1];
            }
            else
            {
                sum -= c[i+1] - '0';
                eq[2*i+1] = '-';
                eq[2*i+2] = c[i+1];
            }
        }
        if (sum == 7) 
        {
            eq[7] = '='; eq[8] = '7';
            break;
        }
        else
        {
            sum = c[0] - '0';
        }
    }
    for (int i = 0; i < 9; i++)
    {
        cout << eq[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <utility> // move
using namespace std;

/*
template <class T>
int print(const std::list<T> &ls)
{
    if (ls.empty() == 1)
        {
            cout << " " << endl;
            return 0;

}else
        {
            for (const T &x : ls)
            {
                std::cout << x << ' ';
            }
            std::cout << std::endl;
            return 0;
        }
}*/

int main()
{
    long long size;
    cin >> size;
    list<long long> n[size];
    long long q;
    cin >> q;
    for (long long i = 0; i < q; i++)
    {
        long long a, t, x, s;
        cin >> a;
        if (a == 0)
        {
            cin >> t >> x;
            //n[t].enqueue(x);
            n[t].push_back(x);
        }
        else if (a == 1)
        {
            cin >> t;
            //cout << n[t].dump() << endl;
            //cout << n[t] << endl;

            long long cnt = 0;
            long long ntsize = n[t].size();
            for (auto x : n[t])
            {
                cnt++;
                if (ntsize == cnt)
                {
                    cout << x;
                }
                else{cout << x << ' ';}
            }
            cout << endl;
            //std::cout << std::endl;
        }
        else
        {
            cin >> s >> t;
            n[t].splice(n[t].end(), move(n[s]));
        }
    }
    return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	ll a, b, c, d, e, f, g;
	cin >> a >> b >> c >> d >> e >> f >> g;
	auto func = [&](vector<int> order){
		ll res = b*2;
		ll na = a;
		ll nd = d;
		ll ne = e;
		foreach(i, order){
			if(i==0){
				if(na>0&&nd>0&&ne>0){
					res += 6;
					--na;
					--nd;
					--ne;
				}
			}
			if(i==1){
				res += na/2*4;
				na&=1;
			}
			if(i==2){
				res += nd/2*4;
				nd&=1;
			}
			if(i==3){
				res += ne/2*4;
				ne&=1;
			}
		}
		return res;
	};
	ll ans = 0;
	vector<int> order(4);
	iota(all(order), 0);

	do{
		chmax(ans, func(order));
	}while(next_permutation(all(order)));

	cout << ans / 2 << endl;


	return 0;
}



Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	int a,b,c,i,j,k,arm,ans=0;
	scanf("%d%d%d%d",&a,&b,&c,&arm);
	for(i=0;i<=a;i++)
		for(j=0;j<=b;j++)
			for(k=0;k<=c;k++)
			{
				int mon=i*500+j*100+k*50;
				if(mon==arm)ans++;
				if(mon>arm)break;
			}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
//fck light 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
void solve()
{
    int n, count=0, x=0, prev=0, pres=0;
    cin >> n >> x;
    for (int i = 0; i < n - 1; i++) {
        cin >> pres;
        if (pres <= x) {
            prev++;
 
        }
        else {
            prev = 0;
        }
        if (prev > count) count = prev;
        x = pres;
    }
 cout << count;

}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
	//	cin >> t
		while(t--)
		{
			solve();
		}
	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 N = sc.nextInt();//データの数 
		int V[] = new int[N]; //配列数を決定
		int C[] = new int[N]; //配列数を決定
		//int ans[] = new int[N]; //配列数を決定
		int ans = 0;
		
		
		for(int i = 0; i<N; i++) {
			V[i] = sc.nextInt(); //配列の中身を挿入
			
		}
		
		for(int i = 0; i<N; i++) {
            C[i] = sc.nextInt(); //配列の中身を挿入
		}
		for(int i = 0;i<N;i++){
			if(V[i]>C[i])ans+=(V[i]-C[i]);
		}
		System.out.println(ans);
	}
}

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

int main() {
    int k;
    long long min = 2, max = 2;
    cin >> k;
    int a[k];
    for (int i = 0; i < k; i++) {
        cin >> a[i];
    }
    for (int i = k - 1; i >= 0; i--) {
        max = max - max % a[i] + a[i] - 1;
        if (max - max % a[i] < min) {
            cout << -1;
            return 0;
        }
        min = ((min - 1) / a[i] + 1) * a[i];
    }
    cout << min << ' ' << max;
    return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
for i in range(n-1):
  if a[i+1]-a[i]==1:
    ans+=c[a[i]-1]
    
print(ans+sum(b))

Measured memory_bytes: 9164
#インプットdata
input_n = int(input())
input_a = list(map(int, input().split()))
position = -1

#Partitionアルゴリズム
def partition(list, n):
    x = list[n-1]
    i = 0
    for j in range(n-1):
        if list[j] <= x:
            list[i], list[j] = list[j], list[i]
            i += 1
    list[i], list[n-1] = list[n-1], list[i]
    return i

#実行結果
position = partition(input_a, input_n)
print(" ".join(map(str, input_a[0:position])), end="")
print(f" [{input_a[position]}] ", end="")
print(" ".join(map(str, input_a[position+1:])))


Measured memory_bytes: 16400
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int res = Math.min(a + b, Math.min(b + c, c + a));
    System.out.println(res);
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {

	int n, p[10], max_p = 0, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		max_p = max(max_p, p[i]);
		sum += p[i];
	}
	cout << sum - max_p / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(int i=(a); i<(n); ++i)
#define rrep(i,a,n) for(ll i=(a); i>(n); --i)
#define erep(i,a,n) for(ll i=(a); i<=(n); ++i)
#define rerep(i,a,n) for(ll i=(a); i>=(n); --i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int) x.size())
#define print(X) cout << (X) << endl
#define _ << " " <<
static const int INF = 1e+9+7;

int V;
vi G[2000];
int match[2000];
bool used[2000];

void add_edge(int u, int v){
  G[u].pb(v);
  G[v].pb(u);
}


bool dfs(int v){
  used[v] = true;
  rep(i,0,(int)sz(G[v])){
    int u = G[v][i], w = match[u];

    if (w < 0 || (!used[w] && dfs(w))){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match, -1, sizeof(match));
  rep(v,0,V){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
        res++;
      }
    }
  }
  return res;
}

int gcd(int x, int y){
  if(y == 0)return x;
  return gcd(y,x % y);
}


int m,n;
int b[500],r[500];

int main(){
  while(cin >> m >> n){
    if (m==0 && n == 0) break;

    rep(i,0,m) cin >> b[i];
    rep(i,0,n) cin >> r[i];

    rep(i,0,2000) G[i].clear();

    rep(i,0,m){
      rep(j,0,n){
        if( gcd(b[i], r[j]) > 1) add_edge(i,m+j);
      }
    }

    V = m;
    cout << bipartite_matching() << endl;
  }

  return 0;
}



Measured memory_bytes: 4868
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n,ele,s=0;
  scanf("%lld",&n);
  map<ll,ll> m1;
  map<ll,ll> m2;
  for (int i=1;i<=n;i++)
  {
    scanf("%lld",&ele);
    m1[i-ele]++;
    m2[i+ele]++;
  }
  for (auto it=m1.begin();it!=m1.end();it++)
    s=s+((it->second)*m2[it->first]);
  printf("%lld\n",s);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  cout << a.at(N-1) - a.at(0);
}



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

#define pb push_back

const int N = 1e5 + 5;

int n;
int d1[N];
int d2[N];
vector <int> G[N];

void BFS(int d[], int source) {
    queue <int> Q;
    Q.push(source);
    d[source] = 1;

    while(!Q.empty()) {
        int x = Q.front();
        Q.pop();

        for(int y: G[x]) {
            if(d[y]) continue;
            d[y] = d[x] + 1;
            Q.push(y);
        }
    }
}

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

    for(int i = 1 ; i < n; i++)
    {
        int x, y;
        cin>>x>>y;
        G[x].pb(y);
        G[y].pb(x);
    }

    BFS(d1, 1);
    BFS(d2, n);

    int cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        if(d1[i] <= d2[i])
            cnt++;
    }

    cout<<(cnt > n - cnt ? "Fennec" : "Snuke")<<"\n";
    return 0;
}

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

int main(){
	string number;
	int sum, num;
	string::size_type size;
	
	while(1){
		cin >> number;
		if(number == "0")
			break;
		size = number.size();
		sum = 0;
		
		for(int i = 0; i < size; i++){
			sum += number[i]-'0';
		}
		
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        N = cin.nextint;
        int n = 1;
        while (n <= N) n *= 2;
        n /= 2;
        WriteLine(n);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll n;
    ll m = 0, a = 0, r = 0, c = 0, h = 0;
    cin >> n;
    imfor(i, n) {
        string s;
        cin >> s;
        if (s[0] == 'M') {
            m++;
        }
        else if (s[0] == 'A') {
            a++;
        }
        else if (s[0] == 'R') {
            r++;
        }
        else if (s[0] == 'C') {
            c++;
        }
        else if (s[0] == 'H') {
            h++;
        }
    }
    ll ans = 0;
    ans += m * a * r;
    ans += m * a * c;
    ans += m * a * h;
    ans += m * r * c;
    ans += m * r * h;
    ans += m * c * h;
    ans += a * r * c;
    ans += a * r * h;
    ans += a * c * h;
    ans += r * c * h;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	int n, i, j, p[111111],flag,q1,q2;
	char s[111111];
	cin >> n >> s;
	for (j = 0; j < 4; j++) {
		flag = 1;
		if (j == 0) {
			p[0] = 0;
			p[1] = 0;
		}
		if (j == 1) {
			p[0] = 1;
			p[1] = 0;
		}
		if (j == 2) {
			p[0] = 0;
			p[1] = 1;
		}
		if (j == 3) {
			p[0] = 1;
			p[1] = 1;
		}
		for (i = 1; i < n - 1; i++) {
			q1 = (p[i - 1] + p[i]) % 2;
			if (s[i] == 'o')
				q2 = 0;
			else
				q2 = 1;
			if (q1 == q2)
				p[i + 1] = 0;
			else
				p[i + 1] = 1;
		}
		q1 = (p[n - 2] + p[n - 1] + p[0]) % 2;
		if (s[n-1] == 'o')
			q2 = 0;
		else
			q2 = 1;
		if (q1 != q2)
			flag--;
		q1 = (p[n - 1] + p[1] + p[0]) % 2;
		if (s[0] == 'o')
			q2 = 0;
		else
			q2 = 1;
		if (q1 != q2)
			flag--;
		if (flag == 1) {
			for (i = 0; i < n; i++) {
				if (p[i] == 0)
					cout << "S";
				else
					cout << "W";
			}
			cout << endl;
			return 0;
		}
	}
	cout << "-1" << endl;;
}

Measured memory_bytes: 5504
import java.util.*;

public class Main {
    
    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        final int N = scanner.nextInt();
        final ArrayList<Integer> C = new ArrayList<>();
        final int mod = 1000000007;
        long[] two = new long[N+1];
        two[0] = 1;
        for(int i=0; i<N; i++){
            two[i+1] = (two[i]*2) % mod;
        }
        for(int i=0; i<N; i++){
            C.add(scanner.nextInt());
        }
        Collections.sort(C);
        long ans = 0;
        for(int i=0; i<N; i++){
            long sum;
            if(N-i-1 !=0){
                sum = (two[N-i-2] * (N-i-1)) % mod;
            }else{
                sum = 0;
            }
            sum = (two[N-i-1] + sum) % mod; 
            sum = (two[i] * sum) % mod; 
            sum = (C.get(i) * sum) % mod;
            ans = (ans + sum) % mod;
        }
        ans = (ans * two[N]) % mod;
        System.out.println(ans);
    }
}

Measured memory_bytes: 92868
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>
#include <queue>
#include <numeric>

int main() {
  size_t x, y, a, b, c;
  scanf("%zu %zu %zu %zu %zu", &x, &y, &a, &b, &c);

  std::vector<intmax_t> p(a), q(b), r(c);
  for (auto& pi: p) scanf("%jd", &pi);
  for (auto& qi: q) scanf("%jd", &qi);
  for (auto& ri: r) scanf("%jd", &ri);

  std::sort(p.rbegin(), p.rend());
  intmax_t left = std::accumulate(p.begin(), p.begin()+x, 0_jd);

  std::vector<std::pair<intmax_t, int>> g;
  g.reserve(b+c);
  for (auto qi: q) g.emplace_back(qi, 0);
  for (auto ri: r) g.emplace_back(ri, 1);
  std::sort(g.rbegin(), g.rend());

  intmax_t right = 0;
  size_t gg = 0;
  for (size_t i = 0; i < y; ++i) {
    right += g[i].first;
    if (g[i].second == 0) ++gg;
  }

  intmax_t res = left + right;
  for (size_t i = x, j = y; i--;) {
    left -= p[i];
    while (j < g.size()) {
      if (g[j].second == 1) {
        right += g[j++].first;
        break;
      }
      if (gg < y) {
        ++gg;
        right += g[j++].first;
        break;
      }
      if (++j == g.size()) break;
    }
    res = std::max(res, left+right);
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

int main(int argc, char const *argv[])
{
    char A, B;
    cin >>  A >> B;

    if(A > B) {
      cout << ">" << endl;
    }
    else if(A < B)
    {
      cout << "<" << endl;
    }
    else {
      cout << "=" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" is: "<<x<<endl;
#define sout(x) cout<<#x<<" is: "<<x<<endl;
#define countBits(x) __builtin_popcount(x)
#define mt make_tuple
#define eb emplace_back
#define pob pop_back
#define star(x) cout<<"********** "<<x<<" **********"<<endl;
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define prio priority_queue
#define greatPrio priority_queue <ll, vector<ll>, greater<ll>>
#define inf 1e9
#define mod 1000000007
#define N (int)1e6+9
ll vis[N];
void solve(){
	memset(vis,0,sizeof vis);
	ll n;
	cin>>n;
	vi a(n);
	rep(i,0,n){
		cin>>a[i];
	}
	sort(all(a));
	ll ans=0;
	rep(i,1,n){
		if(a[i]==a[i-1]){
			vis[a[i]]=true;
		}
	}
	rep(i,0,n){
		if(!vis[a[i]])
			ans++;
		if(i==0 or a[i]!=a[i-1]){
			for(ll j=2*a[i];j<N;j+=a[i]){
				vis[j]=true;
			}
		}
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n\n";
}

Measured memory_bytes: 12688
#include <climits>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;

class NumberString {
    public:
    static UInt Digits(Int number) {
        return to_string(number).length();
    }
};


int main(void) {
    Int n;
    cin >> n;
    Int sq = sqrt(n);

    Int ans = INT_MAX;
    for (Int i = 1; i <= sq; ++i) {
        if (n % i != 0) {
            continue;
        }
        Int len = NumberString::Digits(max(i, n / i));
        ans = min(ans, len);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3708
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vl = vector<ll> ;
using vvl = vector<vector<ll>> ; 
using vs = vector<string> ; 
using vvs = vector<vector<string>> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    ll n ;
    cin >> n ;
    vl a(n), b(n), c(n) ;
    rep(i, n) cin >> a[i] ;
    rep(i, n) cin >> b[i] ;
    rep(i, n) cin >> c[i] ;
    sort(a.begin(), a.end()) ;
    sort(b.begin(), b.end()) ;
    sort(c.begin(), c.end()) ;
    ll ans = 0 ;
    rep(i, n){
        ll u = (lower_bound(a.begin(), a.end(), b[i]) - a.begin()) ;
        ll v = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin()) ;
        ans += u * v ;
    }
    cout << ans << endl ;
} 

Measured memory_bytes: 5576
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int t[101];
int v[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&v[i]);
	}
	int mini=v[n];
	for(int i=n-1;i>=0;i--){
		mini+=t[i];
		v[i]=min(v[i],mini);
		mini=min(v[i],mini);
	}
	long double ans=0;
	int now=0;
	for(int i=0;i<n;i++){
		if(v[i]<=v[i+1]){
			if(now==v[i]){
				ans+=(long double)v[i]*t[i];
			}else{
				int ut=v[i]-now;
				if(ut>t[i]){
					ans+=(long double)t[i]*(now+now+t[i])/2.0;
					now+=t[i];
				}else{
					ans+=(long double)ut*(now+now+ut)/2.0;
					ans+=(long double)(t[i]-ut)*v[i];
					now=v[i];
				}
			}
		}else{
			if(now==v[i]){
				int bt=v[i]-v[i+1];
				ans+=(long double)(t[i]-bt)*now;
				ans+=(long double)bt*(now+now-bt)/2.0;
				now=v[i+1];
			}else{
				int ut=v[i]-now;
				int bt=v[i]-v[i+1];
				if(now+t[i]<=v[i+1]){
					ans+=(long double)t[i]*(now+now+t[i])/2.0;
					now+=t[i];
				}else if(ut+bt>t[i]){
					int uk=now-v[i+1];
					long double timeu=(long double)t[i]/2.0-(long double)uk/2.0;
					long double timed=(long double)t[i]/2.0+(long double)uk/2.0;
					ans+=(long double)timeu*((long double)now+now+timeu)/2.0;
					ans+=(long double)timed*((long double)v[i+1]+v[i+1]+timed)/2.0;
					now=v[i+1];
				}else{
					ans+=(long double)ut*(now+now+ut)/2.0;
					ans+=(long double)(t[i]-ut-bt)*v[i];
					ans+=(long double)bt*(v[i+1]+v[i+1]+bt)/2.0;
					now=v[i+1];
				}
			}
		}
	}
	printf("%.9f\n",(double)ans);
	return 0;
}

Measured memory_bytes: 256
#define _For(idx, from, to, inc, cmp) \
	for(auto idx=(from) ; idx cmp (to) ; inc idx)
#define ForLE(idx, from, to) \
	_For(idx, from, to, ++, <=)
#define ForGE(idx, from, to) \
	_For(idx, from, to, --, >=)
#define ForLT(idx, from, to) \
	_For(idx, from, to, ++, <)
#define ForGT(idx, from, to) \
	_For(idx, from, to, --, >)
#define For(idx, from, to) \
	_For(idx, from, to, ++, <)

#include <iostream>
void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
constexpr int NChar = 'z' - 'a' + 1;
int Count[NChar];
int main() {
	DisableIOSync();
	std::string str;
	std::getline(std::cin, str);
	uint64_t npat = 1;
	++Count[str[0] - 'a'];
	const int Len = str.length();
	For(i, 1, Len) {
		const int id = str[i] - 'a';
		npat += i - Count[id];
		++Count[id];
	}
	std::cout << npat << std::endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

ll solve(vl &K, vl &L, vl &R){
    // dump(K)
    // dump(L)
    // dump(R)

    ll N = K.size();
    vvl G(N);
    REP(i, N){
        ll idx = min(K[i], N-1);
        G[idx].push_back(i);
    }

    priority_queue<pll> pq;
    ll res = 0;
    for(ll i=N-1;i>=0;i--){
        for(auto idx: G[i]){
            pll tmp = {L[idx]-R[idx], idx};
            pq.push(tmp);
        }
        if(not pq.empty()){
            auto p = pq.top();
            pq.pop();
            res += L[p.second];
        }
    }
    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();
        res += R[p.second];
    }
    return res;
}

void solve(){
    ll N;
    cin >> N;
    vl K(N), L(N), R(N);
    REP(i, N) cin >> K[i] >> L[i] >> R[i];
    REP(i, N) K[i]--;

    vl l1, r1, k1, l2, r2, k2;
    ll res = 0;
    REP(i, N){
        if(K[i] == N-1){
            res += L[i];
        }else if(L[i]>=R[i]){
            l1.push_back(L[i]);
            r1.push_back(R[i]);
            k1.push_back(K[i]);
        }else{
            l2.push_back(R[i]);
            r2.push_back(L[i]);
            k2.push_back(N-2-K[i]);
        }
    }
    res += solve(k1, l1, r1);
    res += solve(k2, l2, r2);

    cout << res << endl;
    return;
}

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

    ll T;
    cin >> T;
    while(T--) solve();

    return 0;
}

Measured memory_bytes: 20052
# 2019/08/10

from bisect import bisect_left

n,k=map(int,input().split())
x=list(map(int,input().split()))

idx=bisect_left(x,0)
rn=n-idx
l=idx if rn>=k else idx-(k-rn)
r=l+k-1
ans=float('inf')

while 0<=l and idx<=r+1:
    if idx==l and r-l+2>=k:
        lf=float('inf')
        rf=x[r]
    elif idx==r+1 and r-l+2>=k:
        lf=abs(x[l])
        rf=float('inf')
    else:
        lf=abs(x[l])*2+x[r] 
        rf=x[r]*2+abs(x[l])
    ans=min(min(lf,rf),ans)

    l-=1;r-=1
print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use { sc ->
        val n = sc.nextInt()
        val y = sc.nextInt()

        for (ai in 0..n) {
            for (bi in 0..(n - ai)) {
                val ci = n - ai - bi
                if (ai * 10000 + bi * 5000 + ci * 1000 == y) {
                    println("$ai $bi $ci")
                    return
                }
            }
        }
        println("-1 -1 -1")
    }
}


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

#define fore(i,ii,iii) for(int i=ii;i<iii;i++)

const int N=1e5+15,INF=1e9;
int n,k,dp[N],h[N];

int f(int x){
  if(x==0)return 0;
  if(x<k)return abs(h[x]-h[0]);
  if(dp[x-1]>=0)return dp[x-1];
  int r=INF;
  fore(i,1,k+1)r=min(r,f(x-i)+abs(h[x]-h[x-i]));
  dp[x-1]=r;
  return dp[x-1];
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k; 
  fore(i,0,n){cin>>h[i];}
  memset(dp,-1,sizeof dp);
  cout<<f(n-1)<<endl;
}

Measured memory_bytes: 7296
N = int(input().strip())
K = int(input().strip())

# dp = [頭からi桁目][未満フラグ][これまでに出てきた0以外の数]
dp = [[[0 for i in range(K+1)] for f in range(2)] for n in range(len(str(N)))]

# init
Ni = int(str(N)[0])
# 頭が0
dp[0][1][0] = 1
if Ni == 1:
    dp[0][0][1] = 1  # 頭が1
else:
    dp[0][0][1] = 1  # 頭がNi
    dp[0][1][1] = Ni-1  # 頭が1~(Ni-1)

# print(dp[0])
for i in range(1,len(str(N))):
    Ni = int(str(N)[i])
    for k in range(K+1):
        # N未満であることが確定している
        dp[i][1][k] += dp[i-1][1][k]  # 0
        if k < K:
            dp[i][1][k+1] += dp[i-1][1][k]*9  # 1~9

        # N未満であることが確定していない(頭からi桁目までがNと一致している)
        if Ni == 0:
            # 0を選ぶしかない。未満フラグは立たない
            dp[i][0][k] += dp[i-1][0][k]
        elif Ni == 1:
            # 0 未満フラグが立つ
            dp[i][1][k] += dp[i-1][0][k]
            # 1 未満フラグが立たない
            if k < K:
                dp[i][0][k+1] += dp[i-1][0][k]
        else:
            # 0 未満フラグが立つ
            dp[i][1][k] += dp[i-1][0][k]
            # 1~(Ni-1) 未満フラグが立つ
            if k < K:
                dp[i][1][k+1] += dp[i-1][0][k]*(Ni-1)
            # Ni 未満フラグが立たない
            if k < K:
                dp[i][0][k+1] += dp[i-1][0][k]
    # print(dp[i])
print(dp[-1][0][K]+dp[-1][1][K])


Measured memory_bytes: 38384
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		long res = 0;

		if (vals[1] > vals[2]) { Console.WriteLine(res);
			return; }
		if (( vals[0] == 1 ) && vals[1] != vals[2]) { Console.WriteLine(res); 
			return; }


		long sa = vals[2] - vals[1];
		res = sa * (long)(vals[0]-2)+1;


		Console.WriteLine(res);


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 11092
n, d = gets.chomp.split.map(&:to_i)
arr = Array.new(n)

n.times do |i|
	arr[i] = gets.chomp.split.map(&:to_i)
end

lut = Array.new(1000)
(1..1000).each do |i|
	lut[i-1] = i ** 2
end

cnt = 0
(n-1).times do |i|
	(i+1..n-1).each do |j|
		sum = 0
		d.times do |k|
			sum += (arr[i][k] - arr[j][k]) ** 2
		end
		cnt += 1 if lut.index(sum) != nil 
	end
end
puts cnt

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B; cin >> A >> B;
  if(B < A) {
    swap(A, B);
  }

  REP(b,B) {
    cout << A;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, m, d;
    cin >> n >> m >> d;

    int x = 2 * d - n;
    if (x < 0) x = 0;

    double z = 1 / (double)n;
    double r = 0;

    if (x != 0) {
        double s = (double)x / n, t = 1 - s;
        for (int i = 1; i < m; i++) {
            r += t * z;
        }
    } else {
        x = 2 * d;
        if (x > n) x = n;
        double s = (double)x / n, t = 1 - s;
        if (d == 0) s = 1, t = 0;
        for (int i = 1; i < m; i++) {
            r += s * z + t * z * 2;
        }
    }

    printf("%.10f\n", r);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans;
		if(a>b){
			ans = a-1;
		}else{
			ans = a;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
import numpy as np

A = np.array([
  list(map(int, input().split()))
  for i in range(3)])
B = A < 0
N = int(input())
for _ in range(N):
  B |= A == int(input())

if (
  B.all(axis=0).any() or B.all(axis=1).any() or
  np.diag(B).all() or np.diag(B[::-1]).all()
):
  print("Yes")
else:
  print("No")

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

int arr[3],temp;
string s;
int main(){
  cin >> arr[0] >> arr[1] >> arr[2];
  sort(arr,arr+3);
  s = to_string(arr[2]) + to_string(arr[1]);
  cout << stoi(s) + arr[0]; 
  return 0;
}


Measured memory_bytes: 256
import math

x, y = input().split()
N = int(x)
D = int(y)

X = []
for i in range(N):
    X.append(list(map(int, input().strip().split(' '))))

answer = 0
for i in range(N):
    for j in range(N - i):
        res = 0.0
        tmpj = N - j - 1
        if i == tmpj:
            continue
        for d in range(D):
            res += (X[i][d] - X[tmpj][d]) ** 2
        res = math.sqrt(res)
        if res.is_integer():
            answer += 1
print(answer)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
int a[200000];
int gcd(int x,int y,int z)
{
	int i;
	for(i=z;i>=1;i--)
	{
		if(x%i==0&&y%i==0&&z%i==0)
		return i;
		
	}
}
int main()
{
	ll m,n,i,j,t,s=0,k;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{
				s+=gcd(i,j,k);
			}
		}
	}
	cout<<s;
 } 

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
int H,W,i,j;
for(;;){
scanf("%d %d", &H, &W);
if(W==0&&H==0){
break;
}
for(i=0;i<H;i++){
for(j=0;j<W;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}

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

typedef long double Double;
typedef vector<int> vi;

#define rep(var,n)  for(int var=0;var<(n);++var)
#define ALL(c)  (c).begin(),(c).end()


double solve(vi& x, vi& y){
    vector<double> a(3);
    rep(i,3) {
        a[i] = hypot(y[(i+1)%3]-y[i], x[(i+1)%3]-x[i]);
    }
    sort(ALL(a));
    double s = accumulate(ALL(a), 0.0) / 2;
    double area = sqrt(s * (s-a[0]) * (s-a[1]) * (s-a[2]));
    double h = area * 2 / a[2];
    
    double r = area / (s+h);
    return r;
}

int main() {
    vi x(3), y(3);
    rep(i,3) {
        scanf("%d%d", &x[i], &y[i]);
    }
    printf("%.12f\n", solve(x,y));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 100000000

struct Drink{
	int A;
	int B;

	Drink(int tmpA,int tmpB){
		A = tmpA;
		B = tmpB;
	}
	bool operator<(const Drink &another) const{
		return A < another.A;
	}
};

int main(){
	int N,M;
	int count = 0;
	long long sum = 0;
	int tmpA,tmpB;
	cin >> N >> M;
	vector<Drink> Dr;

	for(int i=0;i<N;i++){
		cin >> tmpA >> tmpB;
		Dr.push_back(Drink(tmpA,tmpB));
	}
	sort(Dr.begin(),Dr.end());
	auto itr = Dr.begin();

	while(count != M){
		if(count + itr->B >= M){
			sum += (long long)itr->A * (M-count);
			count = M;
		}else{
			count += itr->B;
			sum += (long long)itr->A * (itr->B);
		}
		++itr;
	}
	cout << sum << endl;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

signed main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  int x = 0, s = 0, l = 0;
  int ans = 0;
  for (int r = 0; r < N; r++)
  {
    x ^= A.at(r);
    s += A.at(r);
    //cerr << l << " " << r << " " << x << " " << s << endl;
    if (x < s)
    {
      for (; l <= r; l++)
      {
        if (x == s)
        {
          ans += r - l + 1;
          break;
        }
        x ^= A.at(l);
        s -= A.at(l);
        //cerr << l + 1 << " " << r << " " << x << " " << s << endl;
      }
    }
    else ans += r - l + 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
int main()
{
	int N,K,X,Y;
	int sum1,sum2,sum;
	scanf("%d",&N);
	scanf("%d",&K);
	scanf("%d",&X);
	scanf("%d",&Y);
	sum1=K*X;
	sum2=(N-K)*Y;
	sum=sum1+sum2;
	if(N<K)
		printf("%d\n",N*X);
	else
		printf("%d\n",sum);
return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

typedef struct node_t
{
    int iNum;               // リストが持つ値
    struct node_t *pstNext; // 次のノード
} NODE;

// プロトタイプ宣言
NODE *pstCreateNode(int iNum);
void vdPush(NODE **ppstList);
void vdTop(NODE **ppstList);
void vdPop(NODE **ppstList);

// 整数保持するn個のスタックに対し、以下の操作を行う
// ・push(t, x): Stに整数xを挿入
// ・top(t): Stから次に取り出される要素を出力
// ・pop(t): St空要素を取り出して削除
int main()
{
    NODE **ppstList; // リストを保持
    int iNumOfQuery; // 命令数
    int iNumOfList;  // リスト長
    int iQuery;      // 命令
    int iCount;      // counter
    // In: リスト長, 命令数
    scanf("%d %d", &iNumOfList, &iNumOfQuery);
    // NODEポインタ型配列を動的確保
    ppstList = (NODE **)malloc(sizeof(NODE *) * iNumOfList);

    for (iCount = 0; iCount < iNumOfQuery; iCount++)
    {
        // In: 命令
        scanf("%d", &iQuery);
        switch (iQuery)
        {
        case 0:
            vdPush(ppstList);
            break;
        case 1:
            vdTop(ppstList);
            break;
        case 2:
            vdPop(ppstList);
            break;
        default:
            break;
        }
    }

    // メモリ解放
    for (iCount = 0; iCount < iNumOfList; iCount++)
    {
        free(ppstList[iCount]);
    }
    free(ppstList);

    return 0;
}

// ノードを作成する関数
NODE *pstCreateNode(int iNum)
{
    // ノードを動的確保
    NODE *pstNode = (NODE *)malloc(sizeof(NODE));
    // 確保できなければ強制終了
    if (pstNode == NULL)
    {
        exit(1);
    }
    // 初期化
    *pstNode = (NODE){iNum, NULL};

    return pstNode;
}

// 整数を挿入する関数
void vdPush(NODE **ppstList)
{
    int iNum;         // 挿入する値
    int iListNum;     // 挿入するリストの場所
    NODE *pstNewNode; // 新規ノード用
    // In: リストの場所, 値
    scanf("%d %d", &iListNum, &iNum);
    pstNewNode = pstCreateNode(iNum);   // 新規ノードを作成
    // 新規ノードを先頭に挿入
    pstNewNode->pstNext = ppstList[iListNum];
    ppstList[iListNum] = pstNewNode;

    return;
}

// 次に取り出される要素を出力する関数
void vdTop(NODE **ppstList)
{
    int iListNum;   // リストの場所
    // In: リストの場所
    scanf("%d", &iListNum);
    // NULL以外なら出力
    if (ppstList[iListNum] != NULL)
    {
        printf("%d\n", ppstList[iListNum]->iNum);
    }

    return;
}

// 要素を取り出して削除する関数
void vdPop(NODE **ppstList)
{
    NODE* pstDeleteTmp; // 削除の際のテンポラリ
    int iListNum;   // リストの場所
    // In: リストの場所
    scanf("%d", &iListNum);
    // NULL以外なら先頭ノードを削除
    if (ppstList[iListNum] != NULL)
    {
        pstDeleteTmp = ppstList[iListNum]->pstNext;
        free(ppstList[iListNum]);
        ppstList[iListNum] = pstDeleteTmp;
    }

    return;
}


Measured memory_bytes: 7988
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
  int N, K;
  string S;
  while (cin >> N >> K >> S) {
    S[K-1] -= 'A' - 'a';
    cout << S << endl;
  }
}

















Measured memory_bytes: 256
#include <iostream>
using namespace std;
int i,j,a,x,n[30],pn[10000002],pf[10000002];
int main() {
	for (i=2;i<10000000;i++) {
		if (pn[i]==0) { pn[i]=1;
			if (i*2<1000001) for (j=i*2;j<1000000;j+=i) pn[j]=2;
		}
	}	
	while(cin >> a >> x) {
		if (a==0 && x==0) break;
		for (i=0;i<=x;i++) pf[i]=0; pf[0]=1;
		for (i=0;i<a;i++) cin >> n[i];
		for (i=0;i<a;i++) for (j=0;j<=x;j++) if (pf[j]==1 && j+n[i]<1000000) pf[j+n[i]]=1;
		for (i=x;i>1;i--) if (pf[i]==1 && pn[i]==1) break;
		if (i==1) cout << "NA"; else cout << i;
		cout << endl;   
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S;
    cin >> S;
    if(S[SZ(S)-1] == 's') S += "es";
    else S += "s";
    PR(S);

    return 0;
}

/*



*/

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			if(m == -1 && f == -1 && r == -1) {
				break;
			}
			if(m == -1 || f == -1) {
				System.out.println("F");
			}else if(m + f >= 80) {
				System.out.println("A");
			}else if(m + f >= 65) {
				System.out.println("B");
			}else if(m + f >= 50) {
				System.out.println("C");
			}else if(m + f >= 30) {
				if(r >= 50) {
					System.out.println("C");
				}else {
					System.out.println("D");
				}
			}else {
				System.out.println("F");
			}
		}
		scan.close();
	}
}


Measured memory_bytes: 26180