akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    FASTIO;
    int s, w;
    cin>>s>>w;
    (w>=s)?cout<<"unsafe"<<endl:cout<<"safe"<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 3648
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def change(x)
  case x
  when "a" then
      return 0
  when "b" then
      return 1
  when "c" then
      return 2
  end
end
Sa=get_nsp
Sb=get_nsp
Sc=get_nsp
Na=Sa.size
Nb=Sb.size
Nc=Sc.size
turn=0
a=0
b=0
c=0

loop do
  case turn
  when 0 then
    break if a==Na
    turn=change(Sa[a])   
    a+=1
  when 1 then
    break if b==Nb
    turn=change(Sb[b])
    b+=1
  when 2 then
    break if c==Nc
    turn=change(Sc[c])
    c+=1
  end 
  #puts "a:#{a} b:#{b} c:#{c}"
end
case turn
when 0 then
    puts "A"
when 1 then
    puts "B"
when 2 then
    puts "C"
end

Measured memory_bytes: 1788
using System;
using System.Linq;

namespace A___Sandglass2
{
    class Program
    {
        static void Main(string[] args)
        {
            var X_t = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var X = X_t[0];
            var t = X_t[1];

            Console.WriteLine(Math.Max(X - t, 0));
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
 
 
int main()
{
int W,H,x,y,r;
 
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 
if ( (x + r) <= W && (y + r) <= H && (x - r) >= 0 && (y - r) >= 0)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
 
 
return 0;
}

Measured memory_bytes: 584
M,D=map(int,input().split())

count=0
for i in range(M):
    for j in range(D):
        d_10=(j+1)//10
        d_1=(j+1)%10
        dd=d_1*d_10
        if dd==i+1 and d_1>=2 and d_10>=2 :
            count+=1
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    ll hasil=0;
    for(int i=1; i<=k; i++){
        if(i%2!=0){
            if(a%2!=0) a--;
            b+=a/2;
            a /= 2;
        }else{
            if(b%2!=0) b--;
            a+=b/2;
            b /= 2;
        }
        //cout << a << " " << b << endl;
    }
    cout << a << " " << b << endl;
}




Measured memory_bytes: 256
#B
import numpy as np

n, d = map(int, input().split())
x = []

for i in range(n):
    x_ = list(map(int, input().split()))
    x.append(x_)
    
is_integer = 0
x = np.asarray(x)

for j in range(0,n,1):
    for i in range(0,j,1):
        diff  = (sum((x[i] - x[j]) ** 2)) ** (1 / 2)
        if diff.is_integer():
            is_integer += 1
            
print(is_integer)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

pll meet(pll &a, pll &b){
	pll x, y;
	x.first = a.first;
	x.second = a.second;
	y.first = b.first;
	y.second = b.second;

	pll res;

	if(x.first>y.first) swap(x, y);

	if(x.first == -1 || y.first == -1){
		res = {-1, -2};
	}else if(y.first<=x.second){
		res = {y.first, min(x.second, y.second)};
	}else{
		res = {-1, -2};
	}

	return res;
}

vector<pll> left(vector<pll> &seg){
	ll n = seg.size();
	vector<pll> res(n);
	res[0] = seg[0];
	REP(i, n){
		if(i==0) continue;
		res[i] = meet(res[i-1], seg[i]);
	}
	return res;
}

vector<pll> right(vector<pll> &seg){
	ll n = seg.size();
	vector<pll> res(n);
	res[n-1] = seg[n-1];
	REP(i, n){
		if(i==0) continue;
		res[n-i-1] = meet(res[n-i], seg[n-i-1]);
	}
	return res;
}

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

    ll N;
    cin >> N;
    vector<pll> seg(N);
    REP(i, N){
    	cin >> seg[i].first >> seg[i].second;
    }

    ll res = -1;

    sort(seg.begin(), seg.end());

    auto LL = left(seg);
    auto RR = right(seg);

    //cout << LL << endl;
    //cout << RR << endl;

    REP(i, N-1){
    	ll lenL = LL[i].second - LL[i].first + 1;
    	ll lenR = RR[i+1].second - RR[i+1].first + 1;
    	//dump(lenL+lenR)
    	res = max(res, lenL+lenR);
    }

    ////////////////

    const ll UP = 1000000000+1;
    vector<pll> seg2(N);
    REP(i, N){
    	seg2[i].first = UP - seg[i].second;
    	seg2[i].second = UP - seg[i].first;
    }

    auto LLr = left(seg2);
    auto RRr = right(seg2);

    //cout << LLr << endl;
    //cout << RRr << endl;

    REP(i, N-1){
    	ll lenL = LLr[i].second - LLr[i].first + 1;
    	ll lenR = RRr[i+1].second - RRr[i+1].first + 1;
    	//dump(lenL+lenR)
    	res = max(res, lenL+lenR);
    }

    REP(i, N){
    	pll hidari, migi;

    	if(i==0) hidari = {-UP, UP};
    	else hidari = LL[i-1];

    	if(i==N-1) migi = {-UP, UP};
    	else migi = RR[i+1];

    	pll cnt = meet(hidari, migi);
    	ll tmp = (cnt.second - cnt.first + 1) + (seg[i].second - seg[i].first + 1);
    	res = max(res, tmp);
    }

    cout << res << endl;
    return 0;
}

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

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (1e6 + 5);
const int inf = (1e9 + 7);

int n,m;
int ans;

main () {
    cin >> n >> m;

    ans += min(n,m / 2);

    m -= (n * 2);

    if (m > 0) ans += (m / 4);
    cout << ans << endl;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]


ans = 0
for comb in combinations_with_replacement(range(M), N):
    tmp = 0
    for a, b, c, d in abcd:
        if comb[b - 1] - comb[a - 1] == c:
            tmp += d
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 9192
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int C = scn.nextInt();
        int D = scn.nextInt();
        
        while(C>0 && A>0){
            C = C-B;
            
            if(C<=0){
                break;
            }
            
            A = A-D;
        }    
          
        if(C<=0){
                System.out.println("Yes");
            }
        else if(A<=0){    
               System.out.println("No");
        }
    }
}

Measured memory_bytes: 35664
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int INF = 1e9 + 5;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    vector <int> val(n);
    for (int &x : val)
        scanf("%d", &x);
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j <= i + k; j++)
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(val[i] - val[j]));
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 1024
using System;
public class ProCon
{
    public static void Main(){     
        string[] line1 =　Console.ReadLine().Split(' ');
        int N = int.Parse(line1[0]);
        int M = int.Parse(line1[1]);
        int result = 0;
        // Nが２つ選ばれたら偶数
        // Mが２つ選ばれたら偶数
        if(N > 1)
        {
            result += (N * (N-1))/2;
        }

        if(M > 1)
        {
            result += (M * (M-1))/2;
        }
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 11092
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let (_, a): (usize, usize) = parse_line().unwrap();
    let x: Vec<usize> = parse_line().unwrap();

    let mut plus = vec![];
    let mut minus = vec![];
    for v in x {
        if v >= a {
            plus.push(v - a);
        } else {
            minus.push(a - v);
        }
    }

    let mut dp_plus: Vec<Vec<usize>> = vec![vec![0; 2501]; plus.len() + 1];
    let mut dp_minus: Vec<Vec<usize>> = vec![vec![0; 2501]; minus.len() + 1];
    // for _ in 0..(n + 1) {
    //     let mut v = vec![];
    //     v.resize(2501, 0);
    //     dp_plus.push(v);
    //     let mut v = vec![];
    //     v.resize(2501, 0);
    //     dp_minus.push(v);
    // }
    dp_plus[0][0] = 1;
    dp_minus[0][0] = 1;

    for i in 1..(plus.len() + 1) {
        for j in 0..2501 {
            if j >= plus[i - 1] {
                dp_plus[i][j] = dp_plus[i - 1][j] + dp_plus[i - 1][j - plus[i - 1]];
            } else {
                dp_plus[i][j] = dp_plus[i - 1][j];
            }
        }
    }
    for i in 1..(minus.len() + 1) {
        for j in 0..2501 {
            if j >= minus[i - 1] {
                dp_minus[i][j] = dp_minus[i - 1][j] + dp_minus[i - 1][j - minus[i - 1]];
            } else {
                dp_minus[i][j] = dp_minus[i - 1][j];
            }
        }
    }

    let mut ret = dp_plus.last().unwrap()[0];
    for i in 1..2501 {
        ret += dp_plus.last().unwrap()[i] * dp_minus.last().unwrap()[i];
    }
    ret -= 1;
    println!("{}", ret);
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define mod 2019
int main() {
  string s; 
  cin >> s;
  int n = s.length();
  int suf = 0;
  int power_of_ten = 1;
  vector<int> mp(mod);
  mp[0] = 1;
  int ans = 0;
  for(int i=n-1; i>=0; i--) {
    int digit = s[i] - '0';
    suf = (suf + digit*power_of_ten)%mod;
    power_of_ten = (10*power_of_ten)%mod;
    ans += mp[suf];
    mp[suf]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3732
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    }
    println!("{}",if a<=b{a}else{a-1})
}

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

int main(){
    int n;
    cin >> n;
    int m;
    cin >> m;
    int p[m];
    bool s[m];
    for(int i = 0; i < m; i++){
        cin >> p[i];
        string a;
        cin >> a;
        if(a == "AC")s[i] = true;
        else s[i] = false;
    }
    bool x[n];
    int y[n];
    for(int i = 0;i < n; i++){
        x[i] = false;
        y[i] = 0;
    }
    int ac = 0;
    int wa = 0;
    for(int i = 0; i < m; i++){
        if(x[p[i] - 1])continue;
        if(!(s[i])){
            y[p[i] - 1]++;
        }
        else {
            ac++;
            x[p[i] - 1] = true;
        }
    }
    for(int i = 0; i < n; i++){
        if(x[i]){
            wa += y[i];
        }
    }
    cout << ac << endl;
    cout << wa << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
using namespace std;
int N, M, red[100001], cnt[100001], ans;
int main() {
  scanf("%d %d", &N, &M);
  red[1] = 1;
  for(int i = 1; i <= N; ++i) cnt[i] = 1;
  for(int i = 1, x, y; i <= M; ++i) {
    scanf("%d %d", &x, &y);
    --cnt[x], ++cnt[y];
    if(red[x] == 1) red[y] = 1;
    if(cnt[x] == 0) red[x] = 0;
  }
  for(int i = 1; i <= N; ++i) {
    if(red[i] == 1 && cnt[i] > 0) ++ans;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>  // ver2.2.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,m,qw,er,ty;
  cin >> n;
  vector<double> a(n),b(n);
  rep(i,0,n) cin >> a[i] >> b[i];
  
  Vi ne(0);
  rep(i,0,n) ne.pb(i);
  
  double ans = 0.0;
  
  do {
     //Verr(ne);
    double now=0.0;
    rep(j,1,n){
      now += sqrt(pow(a[ne[j]]-a[ne[j-1]],2)+pow(b[ne[j]]-b[ne[j-1]],2));
    }
    //now /= n-1;
    ans += now;
   } while (next_permutation(ALL(ne)));
  cout << ans/stpow(n) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#define ll long long
using namespace std;

int main() {
    string a; 
    cin >> a;
    ll n = a.size()-1;
    ll ans=0;
    string moto(1, a[0]);
    for (ll bit = 0; bit < (1 << n); bit++) {
        ll anssub = 0;
        string subst = moto;
        for (ll i = 0; i < n; i++) {
            if (bit & (1 << i)) {
               anssub+= stoll(subst);
               subst = a[i+1];
            }
            else{
              subst += a[i+1];
            }
            if(i == n-1) anssub += stoll(subst);
        }
        ans+=anssub;
    }
    if(n == 0) cout<<a[0];
    else cout<<ans<<endl;
    return 0;
}

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

int N, M, X, C[12], A[12][12];

int main() {
    cin >> N >> M >> X;
    REP(i, N) {
        cin >> C[i];
        REP(j, M) cin >> A[i][j];
    }

    int min_cost = MOD;
    REP(bit, (1<<N)) {
        vector<int> rikai(M, 0);
        int cost = 0;
        REP(i, N) {
            if (bit & 1<<i) {
                cost += C[i];
                REP(j, M) rikai[j] += A[i][j];
            }
        }
        int ok = 1;
        REP(j, M) {
            if (rikai[j] < X) ok = 0;
        }
        if (ok) min_cost = min(min_cost, cost);
    }
    if (min_cost == MOD) PRINT(-1);
    else PRINT(min_cost);
    return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] antena = new int[5];
            for (int i = 0; i < antena.Length; i++)
            {
                antena[i] = RInt();
            }

            int k = RInt();

            int max = antena.Max();
            int min = antena.Min();

            int d = max - min;
            
            Console.WriteLine(max- min > k ? ":(" : "Yay!");

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13268
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int ddx[8]={0,0,-1,1,1,1,-1,-1};
int ddy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	string s;
	cin>>s;
	int alpha[26]={};
	for(int i=0;i<s.length();i++){
		alpha[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(!alpha[i]){
			cout<<(char)('a'+i)<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    ins = input().split(' ')
    k = int(ins[0])
    x = int(ins[1])
    xs = range(max(x-k+1, -1000000), min(x+k, 1000001))
    xxx = list(map(lambda s: str(s), xs))
    print(' '.join(xxx))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

ll N;
vector<vector<ll>> abc;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	cin >> N;
	abc = vector<vector<ll>>(N);

	rep(i, N) {
		abc[i].resize(3);
		cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
	}

	vector<vector<ll>> dp(N);
	dp[0] = abc[0];
	
	//cout << dp[0][0] << dp[0][1] << dp[0][2];

	for (int i = 1; i < N; i++) {
		dp[i].resize(3);
		for (int now = 0; now < 3; now++) {
			ll max = 0;
			for (int prev = 0; prev < 3; prev++) {
				if (prev == now) continue;
				max = std::max(max, dp[i - 1][prev] + abc[i][now]);
				//cout << to_string(i) + ":" + to_string(dp[i - 1][prev]) << endl;
			}
			dp[i][now] = max;
		}
	}
	/*
	for (int i = 0; i < N; i++) {
		//printf("%d:%d %d %d\n", i, dp[i][0], dp[i][1], dp[i][2]);
		cout << dp[i][0] << dp[i][1] << dp[i][2] << endl;
	}
	*/
	ll m = 0;
	for (int i = 0; i < 3; i++) {
		m = std::max(m,dp[N - 1][i]);
	}
	
	cout << m << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for(auto it = v.begin();it != v.end();it++) 
		min = std::min(min,*it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


Measured memory_bytes: 11392
from time import time
from random import random

start_time = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

def calc_score():
    S = 0
    last = [-1] * 26
    score = 0
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution():
    return [i % 26 for i in range(D)]

t = solution()
score = calc_score()
while time() - start_time < 1.5:
    d = int(random() * D)
    q = int(random() * 26)
    old = t[d]
    t[d] = q
    new_score = calc_score()
    if new_score < score:
        t[d] = old

for e in t:
    print(e + 1)


Measured memory_bytes: 9880
N = int(input())
s = input()

n_r = 0
n_b = 0
for i in range(len(s)):
    if s[i] == 'B':
        n_b += 1
    else:
        n_r += 1

if n_r > n_b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;

int main(){
        string s;
        cin >> s;
        rep(i,s.size()-1){
                if(s.substr(i,2)=="AC"){
                        cout << "Yes" << endl;
                        return 0;
                }
        }
        cout <<"No" << endl;
        
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	if len(s) == 3 {
		fmt.Printf("%s%s%s\n", string(s[2]), string(s[1]), string(s[0]))
	} else {
		fmt.Println(s)
	}
}


Measured memory_bytes: 640
<?php

$stdins = [];
while($line=fgets(STDIN)){
    $stdins[] = trim($line);
}

$params = explode(" ", $stdins[0]);
$A = $params[0];
$B = $params[1];
$C = $params[2];
$X = $params[3];
$Y = $params[4];

$count = 0;
if($A + $B >= $C*2){
    $min = min($X, $Y);
    $count += $C*$min*2;
    $X -= $min;
    $Y -= $min;
    if($A > $C*2){
        $count += $C*2*$X;
    }else{
        $count += $A*$X;
    }
    if($B > $C*2){
        $count += $C*2*$Y;
    }else{
        $count += $B*$Y;
    }
}else{
    $count = $A*$X + $B*$Y;
}

print("{$count}\n");

Measured memory_bytes: 3956
#include <iostream>
#include <vector>

using namespace std;
int N, M;
vector< vector<bool> > gragh(8,vector<bool>(8,false));

bool check_reached_all(bool reach[]){
  for(int i=0; i<N; i++){
    if(!reach[i]) return false;
  }
  return true;
}

int dfs(int cur, bool reach[]){
  if(check_reached_all(reach)) return 1;
  
  int ans=0;
  for(int i=1; i<N; i++){
    if(!gragh[cur][i]) continue;
    if(reach[i]) continue;
    reach[i] = true;
    ans += dfs(i,reach);
    reach[i] = false;
  }
  return ans;
}

int main(){
  cin >> N >> M;
  for(int m=0; m<M; m++){
    int i,j;
    cin >> i >> j;
    i--; j--;
    gragh[i][j] = gragh[j][i] = true;
  }
  
  bool reached[N]={false}; 
  reached[0]=true;
  cout << dfs(0,reached) << "\n";
}

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

int main() {
    int a, b;
    cin >> a >> b;

    vector<vector<char>> ans;
    for (int i = 0; i < 50; i++) ans.push_back(vector<char>(100, '#'));
    for (int i = 0; i < 50; i++) ans.push_back(vector<char>(100, '.'));

    a--, b--;
    for (int i = 0; a > 0; i += 2) {
        for (int j = 0; j < 100 && a > 0; j += 2, a--) {
            ans[i][j] = '.';
        }
    }
    for (int i = 51; b > 0; i += 2) {
        for (int j = 0; j < 100 && b > 0; j += 2, b--) {
            ans[i][j] = '#';
        }
    }

    cout << 100 << " " << 100 << endl;
    for (auto e : ans) cout << string(begin(e), end(e)) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashSet;
import java.util.*;

public class Main {
		public static void main(String[] args) throws Exception{
			Scanner sc=new Scanner(System.in);
			PrintWriter pw= new PrintWriter(System.out);
			int n=sc.nextInt();
			int r=sc.nextInt();
			if(n>=10) {
				pw.println(r);
			}
			else {
				pw.println(r+(100*(10-n)));
			}
			
			
			sc.close();
			pw.close();
			
		}
	
	
}


Measured memory_bytes: 23636
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])



l=[str(a),'+',str(b),'+',str(c),'+',str(d)]
for i in range(1):
    #+++
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='-'
    #-++
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='-'
    #--+
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break
    
    l[5]='-'
    #---
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='+'
    #+--
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='+'
    #++-
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='-'
    l[5]='+'
    #+-+
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='-'
    l[3]='+'
    l[5]='-'
    #-+-
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

Measured memory_bytes: 3064
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

void dfs(const vector<vector<pair<int,ll>>> &vs, VI &color, int v, int col) {
  if (color[v] >= 0) return;
  color[v] = col;
  FOR(e,vs[v]) {
    int u = e.first;
    ll w = e.second;
    int ncol = w % 2 == 0 ? col : 1 - col;
    dfs(vs, color, u, ncol);
  }
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<pair<int,ll>>> vs(n);
  REP(i,0,n-1) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    vs[u-1].emplace_back(v-1, w);
    vs[v-1].emplace_back(u-1, w);
  }
  VI color(n, -1);
  dfs(vs, color, 0, 0);
  FOR(c,color) {
    cout << c << endl;
  }

  return 0;
}


Measured memory_bytes: 10496
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;


int main()
{
	string input;
	cin >> input;
	int problem_size = input.size() - 1; // 文字の間のスペースがいくつあるか

	if (problem_size == 0) {
		cout << stoi(input) << endl;
		return 0;
	}

	int stop_count = 0;
	stop_count |= (1 << problem_size);
	int64_t sum = 0;

	for (int i = 0; i < stop_count; i++) { // +の位置をビット全探索で設定 1=+

//		if (i == 0) sum += stoi(input);

		int lower_bit = input.size();
		int cut_start_pos = 0;
		int cut_end_pos = 0;
		for (int j = 0; j < problem_size; j++) { // 設定された+位置に対し、総和を計算

			if (i & (1 << j)) { // found bit1 = +

				cut_start_pos = input.size() - 1 - j; // j=0 measn last char
				cut_end_pos = lower_bit;
				sum += stoll(input.substr(cut_start_pos, cut_end_pos- cut_start_pos+1) );
				lower_bit = cut_start_pos-1;
				
			}
		}
		sum += stoll(input.substr(0, lower_bit+1));

	}
	cout << sum << endl;
	return 0;

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e13

using namespace std;

ll dp[301][301][302];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
	vll h(n+1); h[0] = 0;
	rep(i, n) cin>>h[i+1];

	rep(i, n+1)rep(j, k+1)rep(l, n+2){
		dp[i][j][l] = INF;
	}
	dp[0][0][0] = 0ll;
	for(int i=0; i<n; i++){
		for(int j=0; j<=k; j++){
			for(int l=0; l<=n+1; l++){
				if (dp[i][j][l] != INF){
					dp[i+1][j][i+1] = min(dp[i+1][j][i+1], dp[i][j][l]+max(0ll, h[i+1]-h[l]));
					dp[i+1][j+1][l] = min(dp[i+1][j+1][l], dp[i][j][l]);
				}
			}
		}
	}

	ll ans = INF;
	for(int l=0; l<=n+1; l++){
		ans = min(ans, dp[n][k][l]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 214016
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    for (int i = 1 ; i < s.size() ; i++) {
        if (s[i - 1] != s[i]) {
            cout << "Yes\n";
            exit(0);
        }
    }
    cout << "No\n";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 double a,b,c,d,e,f,z,x,y;
 while(cin>>a>>b>>c>>d>>e>>f)
 {

    z= a*e-b*d;
    x=(c*e-b*f)/z;
    y=(a*f-c*d)/z;
    printf("%.3lf %.3lf\n",(x==-0)?0:x,(y==-0)?0:y);
 }

 return 0;
}

Measured memory_bytes: 3068
from collections import Counter, defaultdict

N = int(input())
S = [Counter(input()) for _ in range(N)]

dd = defaultdict(int)

for i in S:
    p = 0
    for j in i:
        p += 26**(ord(j)-ord('a'))*(i[j])
    dd[p] += 1

ans = 0
a = dd.keys()
for i in a:
    ans += (dd[i]-1)*dd[i]//2
print(ans)


Measured memory_bytes: 174640
n,x=map(int,input().split())

a,p=[1],[1]

for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if n==0: return 0 if x<=0 else 1
    elif x<=1+a[n-1]: return f(n-1,x-1)
    else: return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))

Measured memory_bytes: 38256
x, y = map(int, input().split())

if x == 1:
    a = 300000
elif x == 2:
    a = 200000
elif x == 3:
    a = 100000
else:
    a = 0
if y == 1:
    b = 300000
elif y == 2:
    b = 200000
elif y == 3:
    b = 100000
else:
    b = 0
if x == 1 and y == 1:
    a = 1000000
    b = 0
print(a+b)


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

int main(void)
{
    int n; cin >> n;
    int *a = new int[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    int count = 0;
    for (int i = 1; i < n; i++) {
        int t = 0;

        while (i < n && a[i-1] >= a[i]) {
            t++;
            i++;
        }
        if (t != 0) i--;
        count = max(t, count);
    }

    cout << count << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <bitset>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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 (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double kakudo = abs((h*30 + m*0.5) - m*6);
    if(kakudo > 180) kakudo = 360 - kakudo;

    //cout<<cos(3.141592653589 * kakudo / 180.0)<<endl;
    //cout<<kakudo<<endl;
    double ans = a*a + b*b - 2*a*b*cos(3.141592653589 * kakudo / 180.0);
    //cout<<2*a*b*cos(M_1_PI * kakudo / 180.0)<<endl;
    ans = sqrt(ans);
    printf("%.11lf\n",ans);
    return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
vector<int>temp;
int ans[100][100],dx[] = {1,-1,0,0},dy[]={0,0,1,-1};
int main(){
	//freopen("readin.txt","r",stdin);
	int h,w,n,c = 0;
	scanf("%d%d%d",&h,&w,&n);
	for(int i = 0;i < n;i++){
		int a;
		scanf("%d",&a);
		while(a--)temp.push_back(i + 1);
	}
	for(int j = 0;j < h;j++)
		if(!(j&1))
			for(int i = 0;i < w;i++)
				ans[j][i] = temp.back(),temp.pop_back();
		else for(int i = w - 1;i >= 0;i--)ans[j][i] = temp.back(),temp.pop_back();
	for(int i = 0;i < h;i++,printf("\n"))
		for(int j = 0;j < w;j++)printf("%d ",ans[i][j]);
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;
long int sum[10001];

int main(void){
	int i,n;
	sum[0]=1;
	for(i=1;i<=10000;i++){
		sum[i]=sum[i-1]+i;
	}
	while(~scanf("%d",&n)){
		printf("%d\n",sum[n]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s, t;
    cin >> s >> t;
    int res=0;
    rep(i,3){
        if(s[i]==t[i]){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    int minR = 999;
    int sum = 0;
    for(int i = 0; i < N; i++) {
        minR = min(minR, abs(L+i));
        sum += L+i;
    }
    if(sum > 0) {
        cout << sum - minR << endl;
    } else {
        cout << sum + minR << endl;
    }
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

A = [-1 * i for i in A]
heapq.heapify(A)

for i in range(M):
    fst = heapq.heappop(A)
    fst = int(fst / 2)
    heapq.heappush(A, fst)
    
ans = -1 * sum(A)
print(ans)

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

int main(){
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  int right, left, dist, maxi = 0;
  for(int i = 0; i < n; i++){
    if(i == 0) left = k - (a[n-1] - a[0]);
    else left = a[i] - a[i-1];
    if(i == n-1) right = k - (a[n-1] - a[0]);
    else right = a[i+1] - a[i];
    dist = max(right, left);
    maxi = max(maxi, dist);
  }
  
  cout << k - maxi << endl;
  return 0;
}

Measured memory_bytes: 4028
#include <stdio.h>
/* ltzzさん、FE合格おめでとう。僕もなんか受けてみます。 */
int main(){
        int a,b,c,d,e,f;
        while(scanf("%d %d",&a,&b)!=EOF){
/* 大きい方をaに入れたい */
                if(a<b){c=a;a=b;b=c;}
/* ユークリッドさんの互助会 */
                c=a;d=b;
                while((e=c%d) !=0){
                        c=d;d=e;
                }
/* 大きい方の倍数を小さい方で割り切れればおk*/
                for(f=1;f<=b;f++){
                        if((a*f%b)==0)break;
                }
                printf("%d %d\n",d,a*f);
        }
        return 0;
}

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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int A[200000],n,tot,pre;
signed main()
{
	scanf("%d",&n); tot=2; pre=2;
	for(int i=1;i<=n;i++) A[i]=read();
	if(A[n]!=2) {puts("-1"); return 0;}
	for(int i=n;i>=1;i--)
	{
		int K=(tot-1)/A[i]+1;
		tot=K*A[i];
		if(pre<tot) {puts("-1"); return 0;}
		int KK=pre/A[i]+1;
		pre=KK*A[i]-1; 
	}
	cout << tot << " " << pre << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <stack>
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define mp make_pair
typedef unsigned long long ull;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int n,ans=0;
	cin>>n;
	int a[n];
	rep(n)
	{
		scanf("%d",&a[i]);
		a[i]--;
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]==i) ans++,swap(a[i],a[i+1]);
	}
	if(n%2)
	{
		if(a[n-1]==n-1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int t = 1, ans = 0;
  for (int i = n; i--;) {
    int a;
    cin >> a;
    if (a == t)
      t++;
    else
      ans++;
  }
  cout << (t == 1 ? -1 : ans) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define countof(array) (sizeof(array) / sizeof(array[0]))
    #define rep(i,n) for(int i = 0; i < (n); ++i)
    #define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
    #define srep(i,n,s) for(int i = s; i < (n); ++i)
    #define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
    #define all(a) (a).begin(),(a).end()
    #define rall(a) (a).rbegin(),(a).rend()
    #define aall(a) (a), (a)+countof(a)//for array sorting
    #define raall(a) (a), (a)+countof(a), greater<>()
    #define show(x) cout<<#x<<" = "<<x<<endl;
    #define vfind(v, a) find(all(v), a) != v.end()
    #define yn(f) { if (f) puts("YES"); else puts("NO"); }
    #define yns(f) { if (f) puts("Yes"); else puts("No"); }
    #define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
    #define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
    #define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
    #define argmax(v) distance((v).begin(), max_element(all(v)))
    #define argmin(v) distance((v).begin(), min_element(all(v)))
    #define vmax(v) *max_element(all(v))
    #define vmin(v) *min_element(all(v))
    typedef long long int ll;
    typedef pair<ll, int> P;
    typedef vector<P> vpair;
    typedef vector<int> vint;
    typedef vector<ll> vll;
    typedef vector<double> vdouble;
    typedef vector<string> vstr;
    typedef vector<bool> vbool;
    typedef vector<vint> vvint;
    typedef vector<vll> vvll;
    typedef vector<vstr> vvstr;
    typedef vector<vbool> vvbool;
    const ll LINF = 2000000000000000000ll;
    const int INF = 1000000100;
    const ll MOD = 1e9+7;
     
     
    vector<pair<int, ll>> edges[100005];
    ll d[100005];
     
    void dijkstra(int s) {
        priority_queue<P, vector<P>, greater<P>> que;
        d[s] = 0;
        que.push(P(0, s));
     
        while (que.size()) {
            P p = que.top();
            que.pop();
            int v = p.se;
            if (d[v] < p.fi) continue;
            for (auto e : edges[v]) {
                if (d[e.fi] > d[v] + e.se) {
                    d[e.fi] = d[v] + e.se;
                    que.push(P(d[e.fi], e.fi));
                }
            }
        }
    }
     
    int main() {
        int n;
        cin >> n;
        fill(aall(d), LINF);
        int a, b, c;
        rep(i, n-1) {
            cin >> a >> b >> c;
            --a;
            --b;
            edges[a].emplace_back(b, c);
            edges[b].emplace_back(a, c);
        }
     
        int q, k;
        cin >> q >> k;
        --k;
     
        dijkstra(k);
     
        int x, y;
        rep(i, q) {    
            cin >> x >> y;
            --x;
            --y;
            ll ans = d[x] + d[y];
            cout << ans << endl;
        }
     
        return 0;
    }

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

int main() {
	int co = 0, N = 0;
	vector<int> c;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		cin >> co;
		c.emplace_back(co);
	}
	sort(c.begin(), c.end());
	cin >> N;
	
	for (int i = 0; i*c[2] <= N; i++) {
		for (int j = 0; j*c[1] + i*c[2] <= N; j++) {
			if ((N - (j*c[1] + i*c[2])) % c[0] == 0) {
				count++;
			}
		}
	}
	cout << count;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
count = 0
ans = "No"
for i in range(n):
    if d[i][0] == d[i][1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        ans = "Yes"
print(ans)

Measured memory_bytes: 9176
package main

import "fmt"

func main() {

	var a string

	fmt.Scan(&a)
	if a == "Sunny" {
		fmt.Println("Cloudy")
	} else if a == "Cloudy" {
		fmt.Println("Rainy")
	} else if a == "Rainy" {
		fmt.Println("Sunny")
	}

}


Measured memory_bytes: 512
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    import scala.io.StdIn._
    val n = readLong

    val nums = new ArrayBuffer[String]()

    def dfs(x: String): Unit = {
      if (!x.isEmpty && x.toLong > n) {
        // n を超えた数は以降の処理は対象外
        return
      }

      if (x.toCharArray.distinct.size == 4) {
        // 3, 5, 7 を少なくとも一つ含む場合は753数（頭の0があるので+1）
        nums += x
      }
      // 3, 5, 7を後ろにくっつけて再帰
      dfs(x + "3")
      dfs(x + "5")
      dfs(x + "7")
    }

    dfs("0")
    println(nums.size)
  }
}


Measured memory_bytes: 50296
using System;
using System.Linq;

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ') ;
            int K = int.Parse(input[0]);
            int X = int.Parse(input[1]);
            if (K * 500 < X) Console.WriteLine("No");
            else Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    
    return 0;
}

Measured memory_bytes: 3600
import sys
for n in map(int, sys.stdin):
    if not n:
        break
    a = [[-1]*(n+2)]+[[-1]+[0]*n+[-1] for _ in [0]*n]+[[-1]*(n+2)]
    x, y = (n+1)//2, (n+1)//2+1
    for i in range(1, n**2+1):
        while a[y][x]:
            if a[y][x] == -1:
                if x in {0, n+1}:
                    x = (1, n)[x==0]
                if y in {0, n+1}:
                    y = (1, n)[y==0]
            else:
                x, y = x-1, y+1
        a[y][x] = i
        x, y = x+1, y+1

    for l in a[1:-1]:
        print("".join(map(lambda x: "{:>4d}".format(x), l[1:-1])))


Measured memory_bytes: 5632