akhauriyash/Code-Regression huggingface dataset:
open Batteries
let () =
  let n, l = Scanf.scanf "%d %d" (fun x y -> x, y) in
  let f (acc, prev) t = (acc + min l (t - prev), t) in
  List.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))
  |> List.fold_left f (0, -l)
  |> fst |> Printf.printf "%d\n"


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

int Hs[300010] = {0};
int Ws[300010] = {0};
int hw[300010][2];

int main()
{
    int H, W, M, h, w;
    cin >> H >> W >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> h >> w;
        h -= 1;
        w -= 1;
        Hs[h] += 1;
        Ws[w] += 1;
        hw[i][0] = h;
        hw[i][1] = w;
    }

    int h_max=0, w_max=0, num_h_max=0, num_w_max=0;
    for (int i = 0; i < H; i++)
    {
        if (h_max < Hs[i]) {
            h_max = Hs[i];
            num_h_max = 1;
        }
        else if (h_max == Hs[i]) {
            num_h_max += 1;
        }
    }
    
    for (int i = 0; i < W; i++)
    {
        if (w_max < Ws[i]) {
            w_max = Ws[i];
            num_w_max = 1;
        }
        else if (w_max == Ws[i]) {
            num_w_max += 1;
        }
    }

    int tmp_sum_max = h_max + w_max;
    int num_sum_max_pat = num_h_max * num_w_max;

    int counter = 0;
    for (int i = 0; i < M; i++)
    {
        h = hw[i][0];
        w = hw[i][1];
        if (tmp_sum_max == Hs[h] + Ws[w]) counter++;
    }
    int sum_max;
    if (counter == num_sum_max_pat) sum_max = tmp_sum_max - 1;
    else sum_max = tmp_sum_max;
    
    cout << sum_max << endl;
    return 0;
}


Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   char S[3];
   cin>>S;
   if(S[2]==S[3] && S[4]==S[5]){
       cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;
   }
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  multiset<int> s;
  s.insert(-1); s.insert(N);
  s.insert(-1); s.insert(N);

  vector<int> o(N);
  iota(ALL(o), 0);

  sort(ALL(o), [&](int l, int r){
      return A[l] > A[r];
      });

  int ans = 0;
  REP(i, N){
    int I = o[i];

    auto it = s.upper_bound(I);
    int r1 = *it;
    it++;
    int r2 = *it;
    it--; it--;
    int l2 = *it;
    it--;
    int l1 = *it;

    ans += ((l2-l1)*(r1-I)+(r2-r1)*(I-l2))*A[I];

    s.insert(I);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d%d",&k,&n,&m);
	if(n+2>=m)
	{
		printf("%d",k+1);
	}
	else
	{
		if(k<n+1)
		{
			printf("%d",k+1);
		}
		else
		{
			printf("%lld",1ll*(k-n+1)/2*(m-n)+n+(k-n+1)%2);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

pair<long long, long long> i_hate_factorization(long long x) {
  for(long long a=-118;a<=119;a++) {
    for(long long b=-119;b<=118;b++) {
      if (x == ((a * a * a * a * a) - (b * b * b * b * b))) {
	return make_pair(a, b);
      }
    }
  }
  return make_pair(-1, -1);
}


int main() {
  long long x;
  cin >> x;
  auto ans = i_hate_factorization(x);
  cout << ans.first << " " << ans.second;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <set>

int main(void){
    Cin(int, n, m);
    multiset<int> a;
    Rep(n){
        Cin(int, x);
        a.insert(-x);
    }
    Rep(m){
        a.insert(*a.begin() / 2);
        a.erase(a.begin());
    }
    ll ans = 0;
    for(auto e : a) ans += e;
    Cout(-ans);
}





Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>
#include<ctype.h>
using namespace std;

int main(){
  int tmp = 0;
  int n;
  cin >> n;
  char a[n], b[n], c[n];
  int cntb[26]= {0}, cntc[26] = {0};
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  for (int i = 0; i <= n-2; i++){
    for (int k = 0; k < n; k++){
      b[k] = '\0';  c[k] = '\0';
    }
    for (int k = 0; k < 26; k++){
      cntb[k] = 0;  cntc[k] = 0;
    }
    for (int j = 0; j <= i; j++){
      b[j] = a[j];
    }
    for (int j = 0; j <= n-i-2; j++){
      c[j] = a[j+i+1];
    }
    for (int j = 0; j < (signed)strlen(b); j++){
      cntb[b[j]-'a']++;
    }
    for (int j = 0; j < (signed)strlen(c); j++){
      cntc[c[j]-'a']++;
    }
    int cnt = 0;
    for (int j = 0; j < 26; j++){
      if (cntb[j] > 0 && cntc[j] > 0){
        cnt++;
      }
    }
    if (tmp < cnt) tmp = cnt;
  }
  cout << tmp << endl;
}


Measured memory_bytes: 256
K,N=map(int,input().split())
List=list(map(int,input().split()))


arr = []

for i in range(N-1):
  a = List[i]
  b = List[i+1]
  arr.append(int(b-a))
  
arr.append(int(List[0]-0 + K - List[N-1]))

a = max(arr)
print(int(K-a))

Measured memory_bytes: 26060
using System;
class Program
{
    static void Main()
    {
        double pi = System.Math.PI;
        double r = double.Parse(Console.ReadLine());
        double menseki = r * r * pi;
        double ensyu = (2 * r) * pi;
        Console.WriteLine("{0:F6} {1:F6}",menseki,ensyu);
    }
}


Measured memory_bytes: 18032
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:54:25 2020

@author: Kanaru Sato
"""

a,b,c,k = list(map(int,input().split()))

if a>=k:
    print(k)
else:
    k = k-a
    if b>= k:
        print(a)
    else:
        k = k-b
        print(a-k)

Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, N);
	in_v(ll, a, N*3);
	sort(a.begin(), a.end(), greater<ll>());
	ll ans = 0;
	loop(i, N)
		ans += a[i * 2 + 1];
	cout << ans << endl;
	return 0;
}


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

int main(){
    ll n,m; cin >> n >> m;
    priority_queue<ll> que;
    for(ll i=0; i<n; ++i){
        ll a; cin >> a; que.push(a);
    }
    for(ll i=0; i<m; ++i){
        ll t = que.top(); que.pop();
        t /= 2;
        que.push(t);
    }
    ll sum = 0;
    while(!que.empty()){
        sum += que.top(); que.pop();
    }
    cout << sum << endl;
    return 0;
}

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var cup = new bool[3] { true, false, false };
			string s = "";
			while ((s = Console.ReadLine()) != null)
			{
				int a = s[0] - 'A';
				int b = s[2] - 'A';
				var tmp = cup[a];
				cup[a] = cup[b];
				cup[b] = tmp;
			}
			Console.WriteLine((char)('A' + Array.IndexOf(cup, true)));
		}
	}
}

Measured memory_bytes: 5696
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
const ll INF=99999999999999999;
ll a,b,c,d,e,f,ans=0;
int main(){
    ll n,q;
    string s;
    vl v;
  cin>>n>>q;
    cin>>s;
    a=s.size();
    for(int i=0;i<a-1;i++){
        if(s[i]=='A'&&s[i+1]=='C')v.push_back(i+1);
    }
    
    rep(i,q){
        cin>>a>>b;
        cout<<lower_bound(v.begin(),v.end(),b)-lower_bound(v.begin(),v.end(),a)<<endl;
    }
}

Measured memory_bytes: 1528
<?php
list($a,$b)=explode(" ",trim(fgets(STDIN)));
$x=(int)$a;
$y=str_replace(".","",$b);
$ans=(int)($x*$y);
$n=strlen($ans);
if($n<3){
  echo 0;
  exit;
}
echo substr($ans,0,$n-2);

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

using namespace std;

#define INF 2<<29

int main(){
  int a,b;
  cin>>a>>b;
  if(a>12) cout<<b<<endl;
  else if(a>5) cout<<b/2<<endl;
  else cout<<'0'<<endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

LL cmb[52][52];

void mainmain(){
	for(int i = 0; i < 52; ++i){
		cmb[i][0] = 1;
		for(int j = 1; j <= i; ++j){
			cmb[i][j] = cmb[i - 1][j - 1] + cmb[i - 1][j];
		}
	}

	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	vll v(n);
	for(int i = 0; i < n; ++i){
		scanf("%lld", &v[i]);
	}
	sort(RALL(v));

	double avg = accumulate(v.begin(), v.begin() + a, 0.0) / a;
	LL cnt = 0;
	int c = count(ALL(v), v[a - 1]);
	int k = find(ALL(v), v[a - 1]) - v.begin();
	if(k == 0){
		for(int i = a; i <= b; ++i){
			cnt += cmb[c][i];
		}
	}
	else{
		cnt = cmb[c][a - k];
	}
	printf("%f\n%lld\n", avg, cnt);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using G = vector<vector<int>>;

int in[10];
int main(){
  int a,b,c;
  
  cin >> a >> b >> c;
  in[a]++;
  in[b]++;
  in[c]++;
  for(int i=1;i<10;i++){
       if(in[i] == 2) 
       {cout << "Yes" << endl;
       return 0;
       }
  }
  cout << "No"<< endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

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

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

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


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BLucasNumber {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vl lucas(n + 1);
        lucas[0] = 2;
        lucas[1] = 1;
        FOR(i, 2, n + 1) {
            lucas[i] = lucas[i - 1] + lucas[i - 2];
        }
        ll res = lucas[n];
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BLucasNumber solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector < ll >
#define vvll vector < vll >
#define vld vector < ld >
#define pll pair < ll,ll >
#define ppll pair < ll, pll > 
#define pld pair < ld,ld > 
#define vpll vector < pll >
#define vpld vector < pld >
#define all(X) X.begin(),X.end()
#define rall(X) X.rbegin(),X.rend()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
vll emptyVector;
const ll MAX = 1e6 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884197169399375105;

ll binaryExpo(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n % 2 == 0)
		return binaryExpo((x*x) % MOD, n/2);
	return (x*binaryExpo((x*x) % MOD, n/2)) % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
/*-------------------------------------------		CODE STARTS FROM HERE		------------------------------------------*/

struct curve{
	ll h, c;

	ll eval(ll x){
		ll d = (x - h);
		return d*d + c;
	}

	ld Xintersect(curve C){
		return (1.0L*(h + C.h) / 2) + ((1.0L*(C.c - c) / (C.h - h)) / 2);
	}
};

void solve(void)
{
	ll n, c;
	cin >> n >> c;

	vector < curve > v;
	
	ll h;	cin >> h;
	curve cc = {h, 0};
	v.pb(cc);

	for(int i = 1; i < n; i++)
	{
		cin >> h;
		int mn = 0, mx = sz(v) - 1, ans = 0;
		while(mn <= mx)
		{
			int mid = (mn + mx) >> 1;
			if(mid == sz(v) - 1)
			{
				ans = mid;
				break;
			}
			if(v[mid].eval(h) <= v[mid + 1].eval(h))
			{
				ans = mid;
				mx = mid - 1;
			}
			else
				mn = mid + 1;
		}
		
		curve C = {h, v[ans].eval(h) + c};
		// cout << "ans = " << ans << endl;
		// cout << "h = " << v[ans].h << " c = " << v[ans].c << endl;
		// cout << v[ans].eval(h) + c << endl;

		while(sz(v) > 1 and C.Xintersect(v[sz(v) - 2]) <= v.back().Xintersect(v[sz(v) - 2]))
			v.pop_back();

		v.pb(C);
	}

	cout << v.back().eval(h) << endl;



	

}

int main(void)
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);


	// int t;
	// cin >> t;
	// while(t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n, m;
    cin >> n >> m;
    cout << (n + 1) * (m + 1) - 2 * (m + 1) - 2 * (n + 1) + 4;
    return 0;
}

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

int main()
{
    vector<int> x(5);
    rep(i, 5) cin >> x[i];
    rep(i, 5)
    {
        if (x[i] == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<algorithm>
bool f[5][5];
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int a[5][5];
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	}
	int n;
	cin>>n;
	int x;
	while(n--){
		cin>>x;
		for(int i=1;i<=3;i++){
			for(int j=1;j<=3;j++){
				if(a[i][j]==x)f[i][j]=true;
			}
		}
			
	}
	if(f[1][1]&&f[1][2]&&f[1][3]||f[2][1]&&f[2][2]&&f[2][3]||f[3][1]&&f[3][2]&&f[3][3]||f[1][1]&&f[2][1]&&f[3][1]||f[1][2]&&f[2][2]&&f[3][2]||f[1][3]&&f[2][3]&&f[3][3]||f[1][1]&&f[2][2]&&f[3][3]||f[1][3]&&f[2][2]&&f[3][1]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    
int main(){
    int x;
    cin >> x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    if (S == "RRR"){
        cout << 3 << endl;
    }
    else if (S == "RRS" ||S == "SRR"){
        cout << 2 << endl;
    }
    else if (S == "SSS"){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3604
n=input()
if n==2:print-1;exit(0)
r=range(n-1)
A=[[`1+(i+j+2)%n`for j in r]for i in[-1]+r]
i=n/2-1
if i:
 for j in range(i+1):A[j][i]=`j+i+1`;A[j][i-n]=`j+i+2`
print"\n".join(" ".join(e)for e in A)

Measured memory_bytes: 3076
#!python3

iim = lambda: map(int, input().rstrip().split())

from heapq import heappush, heappop

def resolve():
    N, W = iim()

    S = [list(iim()) for i in range(N)]
    S.sort(key=lambda x: x[0] / x[1], reverse=True)

    def ubounds(w, v, i):
        for j in range(i, N):
            vj, wj = S[j]
            if w + wj > W:
                return (-v, -v - vj / wj * (W - w))
            w += wj
            v += vj

        return (-v, -v)

    v1, v2 = ubounds(0, 0, 0)
    q = []
    heappush(q, (v2, v1, 0, 0, 0))
    vm1 = v1
    #print(W, S)
    while q:
        #print(q)
        vq1, vq2, wq, vq, i = heappop(q)

        if i == N:
            continue

        vi, wi = S[i]
        if wq + wi <= W:
            heappush(q, (vq1, vq1, wq+wi, vq+vi, i+1))
        v1, v2 = ubounds(wq, vq, i + 1)

        if v2 < vm1:
            if v1 < vm1:
                vm1 = v1
            heappush(q, (v2, v1, wq, vq, i + 1))

    print(-vm1)



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 5672
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split();
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(p);
        int n1 = 0;
        int n2 = 0;
        int n3 = 0;
        foreach (var i in p){
            if (i <= a)
                n1++;
            else if (i > a && i <= b)
                n2++;
            else
                n3++;
        }
        Console.WriteLine(Math.Min(Math.Min(n1,n2),n3));
    }
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    if(s=="RRR")cout<<3;
    if(s=="RRS"||s=="SRR")cout<<2;
    if(s=="RSS"||s=="SRS"||s=="RSR"||s=="SSR")cout<<1;
    if(s=="SSS")cout<<0;
}

Measured memory_bytes: 3648
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

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

class CForbiddenList {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
int n,r;
cin>>n>>r;
if (r==0) {
    cout<<n<<"\n";
    return;
}
int INF=1e9;
        vector<int> v(102, INF);
        vector<int> a(r);
        for (int i = 0; i < r; i++) {
            cin >> a[i];
        }
        for (int i = 0; i < 102; i++) {
            if (find(a.begin(), a.end(), i)==a.end()){
                v[i] = abs(i - n);
            }
        }
        int idx, min=1e9;
        for (int i = 0; i < 102; i++) {
            if (v[i]<min){
                min=v[i];
                idx=i;
            }
        }
        cout<<idx;
	}
};

#undef int
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    CForbiddenList solver;
    solver.solve(in, out);
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <cstring>

#define ll long long

using namespace std;

ll memo[101][101];
pair<int,int> cards[100];

ll solve(int left, int right){
    if(memo[left][right] != -1) return memo[left][right];
    
    if(right == left){
        return memo[left][right] = 0;
    }

    ll mini = (ll)1e+20;

    for(int i=left;i<right;++i){
        mini = min(mini, solve(left,i) + solve(i+1,right) + cards[left].first * cards[i].second * cards[i+1].first * cards[right].second);
    }
    
    return memo[left][right] = mini;
}

int main(){
    int n;
    while(cin >> n){
        fill((ll *)memo, (ll *)memo+101*101, -1);
        for(int i=0;i<n;++i){
            cin >> cards[i].first >> cards[i].second;
        }
        cout << solve(0, n-1) << endl;
    }
}

Measured memory_bytes: 0
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val w = (0 until n).map { sc.next() }
    println(problem109b(n, w))
}

fun problem109b(n: Int, w: List<String>): String {
    if (w.toSet().size != w.size) {
        return "No"
    }
    for (i in 1 until n) {
        if (w[i].first() != w[i - 1].last()) {
            return "No"
        }
    }
    return "Yes"
}

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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    ANS(N,(N-1)/2);
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split(" ")))
M = int(input())
T = list(map(int, input().split(" ")))
D.sort()
T.sort()

t = 0

for d in D:
    if t < len(T) and T[t] == d:
        t += 1
        d += 1

    if t == len(T):
        break

print('YES' if t == len(T) else 'NO')

Measured memory_bytes: 35556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int A, B, Q; cin >> A >> B >> Q;
    vel s(A), t(B); rep(i,A) cin >> s[i]; rep(i,B) cin >> t[i];
    sort(all(s)); sort(all(t));

    rep(i,Q) {
        ll x; cin >> x;
        ll ans = INF; ll sdl, sdr, tdl, tdr;

        int in_sdl, in_sdr, in_tdl, in_tdr;
        in_sdl = upper_bound(all(s), x) - s.begin() - 1;
        in_sdr = lower_bound(all(s), x) - s.begin();
        in_tdl = upper_bound(all(t), x) - t.begin() - 1;
        in_tdr = lower_bound(all(t), x) - t.begin();


        if(in_sdl != -1) sdl = x - s[in_sdl];
        else sdl = INF;
        if(in_tdl != -1) tdl = x - t[in_tdl];
        else tdl = INF;
        if(in_sdr != A) sdr = s[in_sdr] - x;
        else sdr = INF;
        if(in_tdr != B) tdr = t[in_tdr] - x;
        else tdr = INF;

        ll temp = max(sdl, tdl);
        chmin(ans, temp);
        temp = max(sdr, tdr);
        chmin(ans, temp);
        temp = 2*min(sdr, tdl) + max(sdr, tdl);
        chmin(ans, temp);
        temp = 2*min(sdl, tdr) + max(sdl, tdr);
        chmin(ans, temp);
        cout << ans << endl;
    }

}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll,ll>;

pii solve() {
    ll N, a;
    cin >> N;
    vector<ll> r{1,400,800,1200,1600,2000,2400,2800,3200};
    vector<ll> n(r.size());
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        int j = 0;
        while ( j < r.size()-1 && r[j+1] <= a) j++;
        n[j]++;
    }
    ll ans = 0;
    for ( int i = 0; i < r.size()-1; i++ ) {
        if ( n[i] > 0 ) ans++;
    }
    ll ans2 = ans + n.back();
    if ( ans == 0 ) ans = 1;
    return pii(ans, ans2);
}

int main() {
    auto ans = solve();
    cout << ans.first << " " << ans.second << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] town = new int[4];
		
		for (int i = 0; i < 6; i++) {
			int hoge = sc.nextInt() - 1;
            town[hoge]++;
		}
		
		boolean isAns = true;
		for (int i : town) {
			if (i > 2)
				isAns = false;
		}
		
		System.out.println(isAns ? "YES" : "NO");
	}
}

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

int findNumOfDigits(int n, int keta) {
	int num = 0;
	int z = 0;
	while (true) {
		num = n % 10;
		n /= 10;
		z++;
		if (z == keta)break;
	}
	return num;
}

int main() {
	int A, B; cin >> A >> B;
	int count = 0;
	for (int i = A; i <= B; i++) {
		if (findNumOfDigits(i, 1) == findNumOfDigits(i, 5) &&
			findNumOfDigits(i, 2) == findNumOfDigits(i, 4))count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
int n, m;
vector<int>G[maxn];
int b, w;
int color[maxn];
bool bipartite(int u, int c){
    if(color[u] != 0 && color[u] != c) return false;
    if(color[u] != 0 && color[u] == c) return true;
    color[u] = c;
    if(c == 1) b++;
    else w++;
    for(int i = 0; i < G[u].size(); i++){
        int v = G[u][i];
        if(!bipartite(v, 3 - c)) return false;
    }
    return true;

}
int main(){
    cin >> n >> m;
    int u, v;
    for(int i = 0; i < m; i++){
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    if(!bipartite(u,1)){
        cout <<(ll) n * (n-1) / 2 - m <<"\n";
    }
    else cout << (ll)b*w-m <<"\n";
    return 0;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k)cout << s << endl;
	else {
		rep(i, k) {
			cout << s[i];
		}
		cout << "...";
	}
}

Measured memory_bytes: 3628
n, m = gets.chomp.split(" ").map(&:to_i)

if(n >= 2 && m >= 2)
	puts (n * (n - 1) / 2) + (m * (m - 1) / 2)
elsif(n >= 2)
	puts n * (n - 1) / 2
elsif(m >= 2)
	puts m * (m - 1) / 2
else
	puts 0
end


Measured memory_bytes: 14308
#include <cstdio>

int n, m;

long long f[2];
long long g[2];

signed main() {
	scanf("%d%d", &n, &m);
	
	f[0] = 1;
	
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x); x &= 1;
		
		g[0] = f[0];
		g[1] = f[1];
		
		f[0] = g[0] + g[x];
		f[1] = g[1] + g[1 ^ x];
	}
	
	printf("%lld\n", f[m]);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int h, w;
        while((h = scn.nextInt()) != 0 | (w = scn.nextInt()) != 0) {
            frame(h, w);
            System.out.println();
        }
    }
    
    private static void frame(int h, int w) {
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(i == 0 || j == 0 || i == ~-h || j == ~-w) {
                    System.out.print("#");
                } else {
                    System.out.print(".");
                }
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 34200
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  int i;
  int sum = 0;
  for(i=0;i<N;i++) {
    cin >> A[i];
    sum += A[i];
  }
  sort(A.begin(),A.end(),greater<int>());
  cout << (A[M-1]>=(double)sum/(4*M)?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e3+5;

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

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a+1),q(b),r(c+1);
    for(int i=1;i<=a;i++) {
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    for(int i=0;i<b;i++) {
        cin>>q[i];
    }
    sort(q.begin(),q.end());
    for(int i=1;i<=c;i++) {
        cin>>r[i];
    }
    sort(r.begin(),r.end());
    vector<ll> temp_r(c+1);
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    ll sum = 0;
    for(auto it:q) {
        pq.push(it);
        sum += it;
    }
    for(int i=0;i<=c;i++) {
        if(i>0) {
            pq.push(r[i]);
            sum += r[i];
        }
        while(pq.size()>y) {
            sum -= pq.top();
            pq.pop();
        }
        temp_r[i] = sum;
    }
    for(int i=1;i<=a;i++) {
        p[i] += p[i-1];
    }
    for(int i=1;i<=c;i++) {
        r[i] += r[i-1];
    }
    ll ans = 0;
    for(int i=0;i<=x;i++) {
        if((c-(x-i))>=0 && ((c-(x-i))<=c))
        ans = max(ans,temp_r[c-(x-i)]+r[c]-r[c-(x-i)]+p[a]-p[a-i]);
    }
    cout<<ans;
}


Measured memory_bytes: 4600
n = int(input())
t, a = list(map(int, input().split(' ')))
hn = list(map(int, input().split(' ')))

def get_dif(h):
    temp = t - h * 0.006
    dif = abs(temp - a)
    return dif

result = hn.index(min(hn, key=get_dif)) + 1
print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>

int main()
{
	int H, W;
	while (std::cin >> H >> W, H || W)
	{
		for (int i = 0; i < H; i++)
		{
			if (i == 0 || i == H - 1)
			{
				for (int j = 0; j < W; j++)
				{
					std::cout << "#";
				}
			}
			else
			{
				for (int j = 0; j < W; j++)
				{
					if (j == 0 || j == W - 1)
					{
						std::cout << "#";
					}
					else
					{
						std::cout << ".";
					}
				}
			}
			std::cout << '\n';
		}
		std::cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(){

int a,b,c;
cin>>a>>b>>c;

if(a<=b&&b<=c){
	cout<<a<<" "<<b<<" "<<c<<endl;
}
else if(a<=c&&c<=b){
	cout<<a<<" "<<c<<" "<<b<<endl;
}
else if(b<=c&&c<=a){
	cout<<b<<" "<<c<<" "<<a<<endl;
}
else if(b<=a&&a<=c){
	cout<<b<<" "<<a<<" "<<c<<endl;
}
else if(c<=a&&a<=b){
	cout<<c<<" "<<a<<" "<<b<<endl;
}
else if(c<=b&&b<=a){
	cout<<c<<" "<<b<<" "<<a<<endl;
}


return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if (s[5] == '0' && (s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4')){
    cout << "Heisei";
  } else {
    cout << "TBD";
  }
}

Measured memory_bytes: 256
s = tuple(input())
t = tuple(input())
n = len(s)
m = len(t)

dp = [[0]*(m+1) for i in range(n+1)]

for i in range(1,n+1):
    for j in range(1,m+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1]  + 1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])

res = []
while n != 0 and m != 0:
    if dp[n][m] == dp[n-1][m]:
        n -= 1
    elif dp[n][m] == dp[n][m-1]:
        m -= 1
    else:
        n -= 1
        m -= 1
        res.append(s[n])
print(''.join(res[::-1]))

Measured memory_bytes: 113756
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const int mod = 1000000007;
double a;

int main(){ //srand((unsigned)time(NULL));
  double R;
  cin >> R;
  cout << syo(6) << R*2.0*M_PI << endl;
}


Measured memory_bytes: 3812
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c;
  cin >> a >> b >> c;
  if (a < b) swap(a, b);
  if (a < c) swap(a, c);
  if (b < c) swap(b, c);
  cout << b + c << endl;

  return 0;
}


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        l: [i32; n],
    }
    let mut l = l;
    l.sort();
    let mut answer = 0;
    for i in 0..(n-2) {
        for u in (i+1)..(n-1) {
            for t in ((u+1)..n).rev() {
                if l[i] + l[u] > l[t] {
                    answer += t - u;
                    break;
                }
            }
        }
    }
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint X;
  cin >> X;

  for(int i=1; i<=360; i++) {
    if(i*X%360 == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632