akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
    #include <array>
    using namespace std;
    int  A,B,x;

    int main() {
    scanf("%d", &A);
    scanf("%d", &B);

    x = A+B;
    if (A-B > x){
       x = A-B;
    }
    if (A*B > x) {
        x = A*B;
    }

    printf("%d",x);
    }


Measured memory_bytes: 3224
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
llint X;

llint gcd(llint x,llint y){
    if(x<y)gcd(y,x);
    llint r;
    while((r=x%y)){
        x=y;
        y=r;
    }
    return y;
}

void solve(){
    cin >> n >> X;
    vector<llint>x(n);
    for(int i=0;i<n;i++)cin >> x[i];
    llint g=abs(X-x[0]);
    for(int i=1;i<n;i++){
        g=gcd(g,abs(X-x[i]));
    }
    cout << g << endl;
}  

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            set<string> st;
            int n;
            cin >> n;
            while(n--)
            {
                string s;
                cin >> s;
                st.insert(s);
            }
            cout << st.size() << endl;





           return 0;
        }
          

Measured memory_bytes: 19248
n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
goals = ['A', 'B', 'C', 'N']
from copy import copy
p = []

def search(i, goal, pre_abc):
  abc = copy(pre_abc)
  if goal == 'A':
    abc[0] += l[i]
  elif goal == 'B':
    abc[1] += l[i]
  elif goal == 'C':
    abc[2] += l[i]
  else:
    abc[3] += 1
  if i == len(l) - 1:
    if abc[0]!=0 and abc[1]!=0 and abc[2]!=0:
      p.append(abc)
  else:
    for goal in goals:
      search(i+1, goal, abc)
      
def mp(abc):
  return abs(abc[0]-a) + abs(abc[1]-b) + abs(abc[2]-c) + 10 * (n-3-abc[3])
      
def solve():
  for goal in goals:
    search(0, goal, [0,0,0,0])
  print(min(list(map(mp, p))))
  
solve()

Measured memory_bytes: 13404
N = int(input())
cnt = 0
for i in range(1,N+1):
    if i % 2 == 0:continue
    c = 0
    for j in range(1,N+1):
        if c > 8:
            cnt -= 1
            continue
        if i % j == 0:
            c += 1
    if c ==8:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
a = LIST()
count = 0
flag = 0
"""
while flag == 0:
	print(a)
	for i in range(N):
		if a[i] % 2 == 0:
			a[i] = int(a[i]/2)
			count += 1
			break
	else:
		flag = 1
"""
for i in a:
    while i % 2 == 0:
        count += 1
        i /= 2
print(count)

Measured memory_bytes: 4920
import java.io.PrintWriter
import java.util.*
import java.math.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val a = readListOfInt()

    val a1 = Math.abs(a[0] - a[1])
    val a2 = Math.abs(a[0] - a[2])
    val a3 = Math.abs(a[1] - a[2])

    val absList = listOf<Int>(a1, a2, a3).sorted()

    println(absList[0] + absList[1])
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 37928
N, M = map(int, input().split())

# ある部屋につながっている部屋を管理する
Heyas = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Heyas[a].append(b)
    Heyas[b].append(a)

#print(Heyas)

ans = [None for _ in range(N)]
visited = [False for _ in range(N)]
# 幅優先探索
que = [0]
while len(que) > 0:
    heya_i = que.pop(0)
    neighbors = Heyas[heya_i]
    for nei in neighbors:
        if not visited[nei]:
            ans[nei] = heya_i + 1
            visited[nei] = True
            que.append(nei)

print('Yes')
for i in range(1,N):
    print(ans[i])


Measured memory_bytes: 37440
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;

typedef long long ll;
typedef unsigned long long ull;

ll dp[1010][3][1010];

int main(void) {

  ll a, b, k;
  cin >> a >> b >> k;

  if (a >= k) cout << a - k << " " << b << endl;
  else if (a + b <= k) cout << 0 << " " << 0 << endl;
  else cout << 0 << " " << b - (k - a) << endl;
  return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

string N;
ll mem[105][5][2], K;

ll dp(int idx, int nonZero, bool same) {
	if (idx == sz(N))
		return nonZero == 0;
	ll& ret = mem[idx][nonZero][same];
	if (ret != -1)
		return ret;
	ret = 0;
	for (int i = 0; i < 10; ++i) {
		if (i > (N[idx] - '0') && same)
			continue;
		if (i < (N[idx] - '0')) {
			if (i && nonZero)
				ret += dp(idx + 1, nonZero - 1, 0);
			if (!i)
				ret += dp(idx + 1, nonZero, 0);
		} else {
			if (i && nonZero)
				ret += dp(idx + 1, nonZero - 1, same);
			if (!i)
				ret += dp(idx + 1, nonZero, same);
		}
	}
	return ret;
}


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N >> K;

	for (int i = 0; i < 105; ++i) {
		for (int j = 0; j < 5; ++j) {
			for (int k = 0; k < 2; ++k) {
				mem[i][j][k] = -1;
			}
		}
	}
	cout << dp(0, K, 1) << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	pair<long, int> ab[n];
	for(int i = 0; i < n; i++)cin >> ab[i].first >> ab[i].second;
	sort(ab, ab + n);
	long res = 0;
	for(int i = 0; i < n; i++){
		if(m - ab[i].second <= 0){
			res += ab[i].first * m;
			break;
		}else{
			res += ab[i].first * ab[i].second;
			m -= ab[i].second;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;

struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9 + 7;
struct NODE{
    ll to, cost;
};
ll N, M, R;

ll d[210][210]; //点Kからある点に到着するのにかかるコスト
vector<vector<NODE> > g(30010);

int main() {
    cin >> N >> M >> R;
    
    for(int i=0; i<N; ++i) for(int j=0; j<N; ++j) if(i!=j)d[i][j]=INF;
    ll root[R];
    REP(i, R) {
        ll r; cin >> r; r--;
        root[i] = r;
    }
    REP(i, M){
        ll a, b, c; cin >> a >> b >> c;
        a--; b--; 
        if(d[a][b]>c) d[a][b]=d[b][a] = c;
    }
    
    
    for(int k=0; k<N; ++k){
        for(int i=0; i<N; ++i){
            for(int j=0; j<N; ++j){
                if(d[i][j]>d[i][k]+d[k][j]) d[i][j] = d[i][k]+d[k][j];
            }
        }
    }
    sort(root, root+R);
    ll ans=INF;
    do{
        ll t=0;
        for(int i=1; i<R; ++i)t+=d[root[i-1]][root[i]];
        ans = min(ans, t);
    }while(next_permutation(root, root+R));
    
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1280
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Control.Arrow

closest x [] = x
closest x [q]
  | x == q = x - 1
  | otherwise = x
closest x nums = sorted2
  where
    sorted = sortOn snd [(q, abs $ x - q) | q <- [x - 101..x + 101], not $ elem q nums]
    s = snd $ head sorted
    sortedFiltered = filter (\x -> s == (snd x)) sorted
    sorted2 = minimum $ map fst sortedFiltered

main = do
  let readInt = fmap (second B.tail) . B.readInt
  [x,n] <- map read . words <$> getLine
  ps <- VU.unfoldrN n readInt <$> B.getLine
  let ans = closest x $ VU.toList ps
  putStrLn $ show ans

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int>> dp(3, vector<int>(n));
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for(int i = 1; i < n; ++i) {
        int ai = a[i], bi = b[i], ci = c[i];
        dp[0][i] = ai + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = bi + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = ci + max(dp[1][i-1], dp[0][i-1]);
    }

    int ans = max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]));
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5760
N = int(input())
A_arr = list(map(int, input().split()))
A_abs = [abs(A_arr[i]) for i in range(N)]

count = 0
for i in range(N):
    if A_arr[i] < 0:
        count += 1

ans = 0
if 0 in A_arr:
    for i in range(N):
        ans += A_abs[i]

else:
    if count % 2 == 0:
        for i in range(N):
            ans += A_abs[i]
    else:
        for i in range(N):
            ans += A_abs[i]
        ans -= 2*min(A_abs)

print(ans)

Measured memory_bytes: 14412
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e3 + 15;
int n, a[N];
int sum[2];
vector <int> ord[2];
vector <pii> is;
vector <int> ans;

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// setin("input.txt");
	cin >> n;
	bool flag = false;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		if(a[i] >= 0) {
			ord[i & 1].pb(i);
			sum[i & 1] += a[i];
			flag = true;
		}
	}
	if(flag) {
		cout << max(sum[0], sum[1]) << endl;
		for(int i = 1; i <= n; ++i) {
			if(a[i] < 0 || i % 2 != (sum[0] > sum[1] ? 0 : 1))
				is.pb({a[i], 0});
			else
				is.pb({a[i], 1});
		}
		while(is.size() > 1 && is[0].se == 0)
			is.erase(is.begin()), ans.pb(1);
		while(is.size() > 1 && is.back().se == 0)
			is.ppb(), ans.pb(is.size() + 1);
		while(is.size() != 1) {
			for(int i = 1; i + 1 < is.size(); ++i) {
				if(is[i].se == 1)
					continue;
				if(is[i-1].se == is[i+1].se) {
					ans.pb(i + 1);
					is.erase(is.begin() + i - 1, is.begin() + i + 1);
					break;
				}
			}
		}
	}
	else {
		int ind = max_element(a + 1, a + 1 + n) - a;
		for(int i = n; i > ind; --i)
			ans.pb(i);
		for(int i = 1; i < ind; ++i)
			ans.pb(1);
		cout << a[ind] << endl;
	}
	cout << ans.size() << endl;
	for(int i : ans)
		cout << i << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int p[55]; rep(i, N) cin >> p[i];
    int cnt = 0;
    rep(i, N) {
        if(p[i] == i + 1) {
            cnt ++;
        }
    }
    if(cnt == N || cnt == N - 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
	return 0;
}

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

using namespace std;
typedef long long ll;
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7

template<typename T>
string printVector(const vector <T> &data) {
    stringstream ss;
    ostream_iterator <T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m;
    vector <vector<int>> switches;
    vector<int> p;

    for (int i = 0; i < m; ++i) {
        vector<int> input_switches;
        cin >> k;

        for (int j = 0; j < k; ++j) {
            int t;
            cin >> t;
            input_switches.push_back(t);
        }
        switches.push_back(input_switches);
    }

    for (int i = 0; i < m; ++i) {
        int t;
        cin >> t;
        p.push_back(t);
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        int ok = 0;
        for (int j = 0; j < m; ++j) {
            int acc = 0;
            for (auto x : switches[j]) {
                if (i & (1 << (x - 1))) {
                    acc++;
                }
            }
            if (acc % 2 == p[j]) {
                ok++;
            }
        }
        if (ok == m) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
def sol():
    mod=1000000007
    ans=0
    n=int(input())
    a=[int(i) for i in input().split()]
    x=[[0]*61 for i in range(n+1)]
    l=[pow(2,i,mod) for i in range(61)]

    for i in range(n):
        d=a[i]
        cnt=0
        for j in range(61):
            if d&1:
                x[i+1][cnt]=x[i][cnt]+1
            else:
                x[i+1][cnt]=x[i][cnt]
            cnt+=1
            d=d>>1

    for i in range(1,n):
        for j in range(61):
            p=x[i][j]-x[i-1][j]
            if p:
                ans+=l[j]*((n-i)-(x[-1][j]-x[i][j]))
            else:
                ans+=l[j]*(x[-1][j]-x[i][j])
            ans%=mod
    print(ans)

if __name__=="__main__":
    sol()


Measured memory_bytes: 203084
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <tuple>

using namespace std;
using PII = pair<int, int>;

int main() {
	int N, C;
	cin >> N >> C;

	int s, t, c;
	vector<vector<PII>> tvs(C+1);
	for (int i = 0; i < N; i++) {
		cin >> s >> t >> c;
		tvs[c].emplace_back(make_pair(s, t));
	}

	priority_queue<PII, vector<PII>, greater<PII>> que;
	for (auto tv: tvs) {
		if (tv.empty()) {
			continue;
		}
		sort(tv.begin(), tv.end());

		vector<PII> v;
		for (auto p: tv) {
			if (v.empty()) {
				v.emplace_back(p);
			} else if (p.first == v.back().second) {
				v.back().second = p.second;
			} else {
				v.emplace_back(p);
			}
		}

		for (auto p: v) {
			que.push(p);
		}
	}

	priority_queue<int, vector<int>, greater<int>> recorder;
	recorder.push(-1);

	while (!que.empty()) {
		tie(s, t) = que.top();
		que.pop();

		auto x = recorder.top();
		// printf("recorder %2d: s %d t %d\n", x, s, t);
		if (x < s) {
			recorder.pop();
			recorder.push(t);
		} else {
			// printf("add!\n");
			recorder.push(t);
		}
	}

	cout << recorder.size() << endl;
	return 0;
}


Measured memory_bytes: 2648
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    let a: usize = iter.next().unwrap().parse().unwrap();
    let p: usize = iter.next().unwrap().parse().unwrap();

    let sum_piece: usize = a * 3 + p;
    let can_make_pie: usize = sum_piece / 2;

    println!("{}", can_make_pie);
}

Measured memory_bytes: 4352
S = input()
T = input()
l = len(S)
m = len(T)

for n in range(l-m+1):
  if all(c in "?"+d for c,d in zip(S[-n-m:],T)):
    S = S.replace("?","a")
    print(S[:-n-m]+T+S[l-n:])
    exit()

print("UNRESTORABLE")

Measured memory_bytes: 9000
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int ok(const string & s, int prev, int start, int n) {
	if (prev < 0) {
		return true;
	}
	if (n != start - prev) {
		return true;
	}
	for (int i = 0; i < n; i++) {
		if (s[prev + i] != s[start + i]) {
			return true;
		}
	}
	return false;
}

int main() {
	char tmp[300000];
	scanf("%s", tmp);
	string s(tmp);
	int length = s.size();
	while (s[length - 1] < 'a' || s[length - 1] > 'z') {
		length--;
	}
	int prev = -1;
	int now = 0;
	int count = 0;
	for (int i = 1; i <= length; i++) {
		if (ok(s, prev, now, i - now)) {
			prev = now;
			now = i;
			count += 1;
		}
	}
	printf("%d\n", count);
	return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define dbg(x) cout << #x"="<< (x) << endl
#define fi first
#define se second
#define square(x) (x)*(x)

int main(){
	int n;
	cin >> n;
	vector<pair<double,double> > x(3);
	vector<double> d(3),r(3);
	pair<double,double> ans;
	double R;
	rep(j,n){
		rep(i,3){
			cin >> x[i].fi >> x[i].se;
		}
		d[0] = square(x[2].fi-x[1].fi) + square(x[2].se-x[1].se);
		d[1] = square(x[2].fi-x[0].fi) + square(x[2].se-x[0].se);
		d[2] = square(x[0].fi-x[1].fi) + square(x[0].se-x[1].se);
		r[0] = d[0]*(d[1]+d[2]-d[0]);
		r[1] = d[1]*(d[2]+d[0]-d[1]);
		r[2] = d[2]*(d[0]+d[1]-d[2]);
		R = r[0]+r[1]+r[2];
		ans.fi = (r[0]*x[0].fi+r[1]*x[1].fi+r[2]*x[2].fi)/R;
		ans.se = (r[0]*x[0].se+r[1]*x[1].se+r[2]*x[2].se)/R;
		R = square(x[0].fi-ans.fi) + square(x[0].se-ans.se);
		printf("%.3f %.3f %.3f\n",ans.fi,ans.se, sqrt(R));
	}
}

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

bool kaibun(string s){
  int n = s.size() ;
  if(n%2 == 0 ){
    string t = s.substr(n/2) ;
    reverse(t.begin(),t.end()) ;
    if(s.substr(0,n/2) == t ) return true ;
    else return false ;
  }
  else{
    string t = s.substr(n/2+1 );
    reverse(t.begin(),t.end()) ;
    if(s.substr(0,n/2) == t ) return true ;
    else return false ;
  }
}

int main() {
  string S ;
  cin >> S ;
  int m = S.size() ;
  string a = S.substr(0,(m-1)/2);
  string b = S.substr((m+3)/2-1)  ;
  //cout << a << kaibun(a) << endl;
  //cout << b << kaibun(b) << endl;
  //cout << S << kaibun(S) << endl;
  if(kaibun(a)&&kaibun(b)&&kaibun(S)) cout << "Yes" << endl; 
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N),B(N);
    rep(n,0,N) cin>>A.at(n);
    rep(n,0,N) cin>>B.at(n);

    int64_t aRem=0;
    rep(i,0,N){
        if(A.at(i)>B.at(i)) aRem+=(A.at(i)-B.at(i))*2;
    }

    rep(i,0,N){
        if(A.at(i)<B.at(i)) aRem-=min(aRem,2*((B.at(i)-A.at(i))/2));
    }
    
    string ans="Yes";
    if(aRem) ans="No";
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
	long long A,B,K;
	long long i,j;
	
	cin>>A>>B>>K;

	if(A>=K){
		cout<<A-K<<" "<<B<<endl;
		exit (0);
	}
	if(A<=K && B>=K-A){
		cout<<"0 "<<B-(K-A)<<endl;
		exit (0);
	}
	if(A<=K && B<=K-A){
		cout<<"0 0"<<endl;
		exit (0);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


map<ll,int> prime_factor(ll n) {
    map<ll,int> res;
    repr(i,2,sqrt(n)+1) {
        while (n%i==0) {
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) ++res[n];
    return res;
}


int main() {
    ios_base::sync_with_stdio(false); 

    ll n;
    cin >> n;
    map<ll,int> pf=prime_factor(n);
    int ans=0;
    repitr(itr,pf) {
        int cnt=itr->second;
        int k=0;
        while (cnt>=k*(k+1)/2) ++k;
        ans+=k-1;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
int permutation(int a[],int n){
    int cnt=0;
    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    int i=0;
    do{
        i=0;
        bool flug = false;
        for(auto x : v){
            if(a[i]!=x){
                flug = true;
                break;
            }
            i++;
        }
        cnt++;
        if(!flug)
            break;
        
    }while(next_permutation(v.begin(), v.end()));
    return cnt;
}
int main(){
    int n;
    cin >> n;
    int p[n],q[n];
    int i=0,l;
    while(i<n){
        cin>>l;
        p[i++] = l;
    }
    i=0;
    while(i<n){
        cin>>l;
        q[i++] = l;
    }
    int pcnt = permutation(p,n);
    int qcnt = permutation(q,n);
    cout << abs(pcnt - qcnt) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

// AtCoder Educational DP -D Knapsack 1

// N-1個分を、重量Xで持つときの最大値を盛っておけばよい。
// とどのつまり、ans[N][K]は、MAX(ans[N-1][K], ans[N-1][K-treasure[N].weight] + treasure[N].value)である。
// これはすなわち、今回の品物をピックした場合の最大値（＝今回の品物+その重量を引いた重量でのN-1個の最大値）
// と、今回の品物をピックしない場合の最大値（＝今の重量でのN-1の最大値）のどちらか大きいほうということ。


public class Program{

	public static void Main(){
	
		
		
		var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
		var N = input[0];
		var W = input[1];
		
		var list = new List<Prize>();
		
		var dp = new long[N+1,W+1];
		
		for(int i = 0; i < N; i++){
			list.Add(new Prize(Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse)));
			dp[i,0] = 0;
		}
		
		for(int i = 0; i < W; i++){
			dp[0,W] = 0;
		}
		
		for(int NL = 1; NL <= N; NL++){
		
			for(int WL = 1; WL <= W; WL++){
			
				if(WL >= list[NL-1].weight){
					dp[NL,WL] = Math.Max(dp[NL-1,WL], list[NL-1].value + dp[NL-1, WL-list[NL-1].weight]);
				}else{
					dp[NL,WL] = dp[NL-1, WL];
				}
			
			}
		
		
		}
		
		Console.WriteLine(dp[N,W]);
	
	
	}
	
	
	class Prize{
	
		public long weight{get;set;}
		public long value{get;set;}
		
		public Prize(long[] input){
		
			this.weight = input[0];
			this.value = input[1];
		}
	
	
	}




}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;

  ll tmp = (n + 1) * n / 2;  // 6
  for (ll i = k; i <= n + 1; ++i) {
    ll a = i * (i - 1) / 2; // 3
    ll b = (n - i) * (n - i + 1) / 2; // 0
    ll c = tmp - b; // 6
    if (c < a) continue;
    ans += (c - a + 1);    
    ans %= MOD;
  }

  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;

    priority_queue<int> q;
    int a;
    for(int i=1;i<=n;i++){
        cin>>a;
        q.push(a);
    }
    
    int temp;
    for(int i=1;i<=m;i++){
        temp=q.top();
        temp/=2;

        q.pop();
        
        q.push(temp);
    }

    long long ans=0;
    for(int i=1;i<=n;i++){
        ans+=q.top();
        q.pop();
    }

    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
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;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int a,b; cin >> a >> b;
    a--; b--;
    int ans = b/a;
    if(b % a != 0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;

int main ()
{
    FASTIO
    ll n , m ;
    cin >> n >> m ;
    ll sum=0;
    for(int i=0;i<m;i++){
        ll a;
        cin >> a;
        sum += a;
    }
    cout << max(n-sum,-1ll) << endl;
    return 0;
}
/**

*/


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    set<string> st;
    li n;
    cin >> n;
    rin{
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << sz(st) << endl;


    return 0;
}

Measured memory_bytes: 19188
n,a,b = map(int, input().split())
s = input()
ya=0
yb=0
for c in s:
  if c=="a" and ya+yb<a+b:
    print("Yes")
    ya+=1
  elif c=="b"and ya+yb<a+b and yb<b:
    print("Yes")
    yb+=1
  else:
    print("No")

Measured memory_bytes: 4016
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll a, b, k;
//ld ;
//string s, t;
 
int main() {
  cin >> a >> b >> k;
  ll newa = (a>=k) ? a-k : 0;
  ll newb = (a>=k) ? b : (a+b>=k) ? b-(k-a) : 0;
  cout << newa << " " << newb << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using ll = long long;
using namespace std;
int x, y, z, l, m=0, n, r, q, k;

void solve() {
    int sum = 0;
    cin>>n;
    for(int i=0;i<n;i++){
        int num;
        cin>>num;
        sum+=num;
        m = max(m, num);
    }
    if(sum-m>m) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';

}

int main() 
{
    std::ios::sync_with_stdio(false); \
        std::cin.tie(NULL);
    int test;
    test  = 1;
    while (test--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int h, w;
    cin >> h >> w;
    string s[55];
    for(int i = 0; i < h; i++){
        string in;
        cin >> in;
        s[i] = in;
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '.'){
                continue;
            }
            bool flag = false;
            if(i > 0){
                if(s[i - 1][j] == '#'){
                    flag = true;
                }
            }
            if(i < h - 1){
                if(s[i + 1][j] == '#'){
                    flag = true;
                }
            }
            if(j > 0){
                if(s[i][j - 1] == '#'){
                    flag = true;
                }
            }
            if(j < w - 1){
                if(s[i][j + 1] == '#'){
                    flag = true;
                }
            }
            if(flag == false){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
        return 0;
}

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

const int N = 305;
const long long mod = 998244353ll;

int n;
bool f[N][N][N];
long long g[N][N][N], ans = 0ll;
char str[N];

int main () {
	scanf("%s", str), n = strlen(str);

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= i - j; k++) f[i][j][k] = false;
		}
	}
	f[0][0][0] = true;
	for (int i = 0; i < n; i++) {
		for (int j = i; j >= 0; j--) {
			for (int k = i - j; k >= 0; k--) {
				if (!f[i][j][k]) continue;
				if (i < n - 1) {
					if (str[i] == '0' || str[i + 1] == '0') f[i + 2][j + 1][k] = true;
					if (str[i] == '1' || str[i + 1] == '1') f[i + 2][j][k + 1] = true;
				}
				if (j && j + k >= 2) f[i][j - 1][k] = true;
				if (k && j + k >= 2) f[i][j][k - 1] = true;
				if (j + k) f[i + 1][j][k] = true;
				if (j && str[i] == '1') f[i + 1][j - 1][k + 1] = true;
				if (k && str[i] == '0') f[i + 1][j + 1][k - 1] = true;
			}
		}
	}
	for (int i = 0; i <= n + 1; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n - j; k++) g[i][j][k] = 0ll;
		}
	}
	g[n + 1][0][0] = 1ll;
	for (int i = n + 1; i > 1; i--) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n - j; k++) {
				if (str[i - 2] == '0') {
					g[i - 1][j + 1][k] = (g[i - 1][j + 1][k] + g[i][j][k]) % mod;
					g[i][j][k + 1] = (g[i][j][k + 1] + g[i][j][k]) % mod;
				}
				else {
					g[i - 1][j][k + 1] = (g[i - 1][j][k + 1] + g[i][j][k]) % mod;
					g[i][j + 1][k] = (g[i][j + 1][k] + g[i][j][k]) % mod;
				}
			}
		}
	}

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			bool flag = false;
			long long tmp = 0ll;
			int zero = 0, one = 0;
			for (int k = n + 1; k; k--) {
				if (k <= n) {
					if (str[k - 1] == '0') zero++;
					else one++;
				}
				if (i - zero >= 0 && j - one >= 0 && f[k - 1][i - zero][j - one]) flag = true;
				if (flag) {
					tmp = (tmp + g[k][i][j]) % mod;
					ans = (ans + g[k][i][j]) % mod;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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


using ll = long long int;

using namespace std;

const int MAX_N = 100000;

vector<int> dist(MAX_N);
vector<vector<int>> g(MAX_N);

void dfs(int v, int p)
{
    for(auto u: g[v])
    {
        if (u == p) continue;
        dist[u] = dist[v] + 1;
        dfs(u, v);
    }
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int i, j, n, T, A, u, v;
    
    cin >> n >> T >> A;
    
    --T, --A;
    
    for(i = 0; i < n - 1; ++i)
    {
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    vector<int> from_T, from_A;
    
    dfs(T, -1);
    from_T = dist;
    dist[A] = 0;
    dfs(A, -1);
    from_A = dist;
    
    int ans;
    ans = 0;
    
    for(i = 0; i < n; ++i)
    {
        //cout << from_T[i] << "  " << from_A[i] << endl;
        if (from_T[i] < from_A[i])
        {
            ans = max(ans, from_A[i]);
        }
    }
    
    if (ans > 0)
        --ans;
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ll a,zheng,xiao,ans,dd;int b,c,d;
  cin >> a;
  getchar();
  scanf("%d.%d",&b,&c);
  d=b*100+c;
  dd=(ll)d;
  ans=(a*d)/100;

  
  cout << ans;
 
}

Measured memory_bytes: 3712
# include <cstdio>
# include <iostream>
# include <cstring>
using namespace std;
int main ()
{
	int a;
	cin>>a;
	if (a<1200)
	  printf ("ABC\n");
	 else if  (a>=1200&&a<2800)
	  printf ("ARC\n");
	else if  (a>=2800)
	  printf ("AGC\n");
	 return 0;	  
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    double result;
    result = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
    
    cout.precision(5);
    cout << fixed << result << endl;
    
    return 0;
}

Measured memory_bytes: 3268
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

typedef long long ll;

int power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y>0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x)%p;} return res;}
int modInverse(ll n) {ll p = MOD;return power(n, p-2, p);}
int min(int a, int b, int c) { return min(a, min(b, c)); }
int max(int a, int b, int c) { return max(a, max(b, c)); }
inline void swap(int &a, int &b) { int t = a; a = b; b = t;}
bool cmp(int a, int b){return a>b;}

vector<bool> sieve;
vector<int> ans(3000000);

void fill(){
    sieve.assign(3000010, true);
    for(int i = 2; i*i<=3000000; i++){
        if(sieve[i]){
        for(int j = i*i; j<=3000000; j+=i){
            sieve[j] = false;
        }
        }
    }
    ans[1] = 0;
    for(int i = 2; i<2100000; i++){
        ans[i] = ans[i-1];
        if(sieve[i]) ans[i]++;
    }
}

int main(){
    int n, ans = 0;
    string s;
    cin>>s; n = s.size();
    for(int i = 0; i<n; i++){
        if(i%2) {if(s[i]=='0') ans++;}
        else {if(s[i]=='1') ans++;}
    }
    cout<<min(ans, n-ans);
    return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repv(i,a,b) for(ll i=b-1;i>=a;i--)
#define MAXN 300005
#define endl "\n"

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;}

int n,x;
int arr[105];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>x;
    for(int i=1;i<=n;i++) cin>>arr[i];
    int d1=0;
    for(int i=1;i<=n;i++)
    {
        arr[i]+=d1;
        d1=arr[i];
    }
    // for(int i=0;i<=n;i++) cout<<arr[i]<<" ";
    // cout<<endl;
    int temp=upper_bound(arr,arr+n+1,x)-arr;
    cout<<temp<<endl;
}

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


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    if(k==2){
        cout << n-1 << endl;
        return 0;
    }
    int ans = n/(k-1);
    if(n%(k-1) > 1){ans += 1;}
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 640
#include <stdio.h>
int main() {
  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  y = 2018;
  if( m<10 && d<10) printf("%d/0%d/0%d\n",y,m,d);
  else if( m<10 ) printf("%d/0%d/%d\n",y,m,d);
  else if( d<10 ) printf("%d/%d/0%d\n",y,m,d);
  else printf("%d/%d/%d\n",y,m,d);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    int main() {
        int n,r[4001]={0},b[4001]={0},g[4001]={0};
        unsigned long long sum=0;
        string s;
        cin>>n>>s;
        for(int i=0;i<n;i++){
            if(s[i]=='R')r[++r[0]]=i+1;
            else if(s[i]=='G')g[++g[0]]=i+1;
            else b[++b[0]]=i+1;
        }
        for(int i=1;i<=r[0];i++){
            for(int j=1;j<=g[0];j++){
                int k=0;
                int x=min(r[i],g[j]),y=max(r[i],g[j]),z;
                z=y*2-x;
                if(z>y&&0<z&&z<=n&&s[z-1]=='B')k--;
                z=(y+x)/2;
                if((y+x)%2==0&&0<z&&z<=n&&s[z-1]=='B')k--;
                z=x*2-y;
                if(z<x&&0<z&&z<=n&&s[z-1]=='B')k--;
                sum+=b[0]+k;        
            }
        }
    	cout<<sum<<"\n";
    	return 0;
    }

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

using namespace std;

#define intt long long

const int MAXN = 1003;
const int INF = 2000000003;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << min(n, k) * x + max(0, n - k) * y << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

using Item = tuple<ll,ll,ll>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<ll> price(4); cin >> price;
    ll n; cin >> n;
    n *= 4;
    vector<Item> v;
    rep(i, 4) {
        ll x = 1LL<<i;
        v.pb((Item){price[i]*8/x, x, price[i]});
    }
    sort(all(v));
    ll ans = 0;
    rep(i, 4) {
        ll a, b, c; tie(a, b, c) = v[i];
        ll num = n / b;
        ans += c * num;
        n -= b * num;
    }
    assert(n == 0);
    cout << ans << endl;
}


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

#define ASORT(arr, n)          sort(arr,arr+n)
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for (int i=0; i<n; i++)
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI                  acos(-1.0)

using namespace std;

typedef long long              ll;
typedef unsigned long long     ull;
typedef vector<int>            vi;

const double eps = 1e-9;


int main()
{
  fastIO();
	ll n , zcnt = 0, res = 1; 
	cin>>n;
	ll arr[n];
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
	}
	//cheking zeros in array
	for(int i=0; i<n; i++)
	{
		if(arr[i]==0)
		{
			zcnt++;
		}
	}
	if(zcnt>0)
	{
		cout<<0<<'\n';
		return 0;
	}
	// 10^18 checking 
	for(int i=0; i<n; i++)
	{
		if(arr[i]<=1000000000000000000/res)
		{
			res = res * arr[i];
		}
		else
		{
			cout<<-1<<'\n';
			return 0;
		}
	}
	cout<<res<<'\n';


 return 0;
 }


Measured memory_bytes: 4360
<?php
$n = (int)trim(fgets(STDIN));
if ($n === 1) {
	echo 1;
	exit();
}

$point_list = [];
for ($i=0; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$point_list[] = [
		(int)$input[0],
		(int)$input[1],
	];
}
usort($point_list, function($a, $b){
	return ($a[0] === $b[0]) ? $a[1] - $b[1] : $a[0] - $b[0];
});

$x_map = [];
foreach ($point_list as $key => $p) {
	if (isset($x_map[$p[0]])) {
		$x_map[$p[0]][$p[1]] = $key;
	}else{
		$x_map[$p[0]] = [];
		$x_map[$p[0]][$p[1]] = $key;
	}
}

$min = $n;
for ($i=0; $i < $n; $i++) { 
	for ($j=$i+1; $j < $n; $j++) { 
		$tmp_p = $point_list[$j][0] - $point_list[$i][0];
		$tmp_q = $point_list[$j][1] - $point_list[$i][1];
		if ($tmp_p === 0 && $tmp_q === 0) {
			continue;
		}
		$cost = 0;
		$keys = [];
		for ($k=0; $k < $n; $k++) { 
			if (in_array($k, $keys)) {
				continue;
			}
			$cost += 1;
			$right_x = $point_list[$k][0];
			$right_y = $point_list[$k][1];
			while (isset($x_map[$right_x + $tmp_p][$right_y + $tmp_q])) {
				$keys[] = $x_map[$right_x + $tmp_p][$right_y + $tmp_q];
				$right_x += $tmp_p;
				$right_y += $tmp_q;
			}
			$left_x = $point_list[$k][0];
			$left_y = $point_list[$k][1];
			while (isset($x_map[$left_x - $tmp_p][$left_y - $tmp_q])) {
				$keys[] = $x_map[$left_x - $tmp_p][$left_y - $tmp_q];
				$left_x -= $tmp_p;
				$left_y -= $tmp_q;
			}
		}
		// echo $tmp_p . ', ' . $tmp_q . ' cost:' . $cost . PHP_EOL;
		$min = min($min, $cost);
	}
}
echo $min;

Measured memory_bytes: 4728