akhauriyash/Code-Regression huggingface dataset:
import heapq  # heapqライブラリのimport

N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(len(A)):
  A[i] = A[i] * (-1)

heapq.heapify(A)  # リストを優先度付きキューへ

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

Measured memory_bytes: 72428
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<string> st;
void saiki(string,int,int);
int main(){
  cin >> n >> m;
  saiki("",0,0);
  sort(st.begin(),st.end());
  for(int i=0;i<st.size();i++){
    cout << st[i] << endl;
  }
  
  return 0;
}
void saiki(string s,int a,int b){
  // cout << s << endl;
  if(a==n&&b==m){
    st.push_back(s);
  }
  if((a<5&&b<5)||(a>=4&&b>=4&&a+b<10))
    saiki(s+'A',a+1,b);
  if((a<5&&b<5)||(a>=4&&b>=4&&a+b<10))
    saiki(s+'B',a,b+1);
}
  

Measured memory_bytes: 3200
#include<stdio.h>

int main(){
 int a1,b1,c1,d1,a2,b2,c2,d2,sum1,sum2;

 scanf("%d %d %d %d",&a1,&b1,&c1,&d1);
 scanf("%d %d %d %d",&a2,&b2,&c2,&d2);
 sum1=a1+b1+c1+d1;
 sum2=a2+b2+c2+d2;
 printf("%d\n",sum1<sum2?sum2:sum1);
 return 0;
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n - 1; ++i)
        cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n - 1; ++i) {
        int t = s[i];
        for (int j = i; j < n - 1; ++j) {
            if (t <= s[j]) t = s[j] + c[j];
            else {
                int nxt = (t + f[j] - 1) / f[j];
                t = nxt * f[j] + c[j];
            }
        }
        cout << t << endl;
    }
    cout << "0\n";

    return 0;
}


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

namespace AtCoder
{
    class ASomethingOnIt
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var price = 700;
            var count = 0;

            for (var i = 0; line.Length > i; i++)
            {
                if (line[i] == 'o')
                {
                    count++;
                }
            }

            Console.WriteLine(price + count * 100);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int x, y;
  std::cin >> x >> y;
  std::set<int> s1, s2, s3;
  s1.insert(1);
  s1.insert(3);
  s1.insert(5);
  s1.insert(7);
  s1.insert(8);
  s1.insert(10);
  s1.insert(12);
  s2.insert(4);
  s2.insert(6);
  s2.insert(9);
  s2.insert(11);
  s3.insert(2);
  if ((s1.find(x) != s1.end() && s1.find(y) != s1.end()) ||
      (s2.find(x) != s2.end() && s2.find(y) != s2.end()) ||
      (s3.find(x) != s3.end() && s3.find(y) != s3.end())) {
    cout(yes);
  } else {
    cout(no);
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination(int, int);
};
int Combination::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination::Combination(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

void A_Round_One(void) {

	int A, B;
	cin >> A >> B;

	if		(A != 1 && B != 1)	cout << 1 << flush;
	else if (A != 2 && B != 2)	cout << 2 << flush;
	else						cout << 3 << flush;
}

void B_Strings_with_the_Same_Length(void) {

	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;

	for (int loop = 0; loop < N; loop++) cout << S[loop] << T[loop] << flush;
	return;
}

void C_Snack(void) {

	int A, B;
	cin >> A >> B;

	if (A == 1 || B == 1) {
		cout << A * B << flush;
	}
	else {
		map<int, int> Afact;
		for (int loop = 2; loop * loop < A; loop++) {
			if (A % loop == 0) {
				A /= loop;
				Afact[loop]++;
				if (A == 1) break;
			}
		}
		if (A > 1) Afact[A]++;
		map<int, int> Bfact;
		for (int loop = 2; loop * loop < B; loop++) {
			if (B % loop == 0) {
				B /= loop;
				Bfact[loop]++;
				if (B == 1) break;
			}
		}
		if (B > 1) Bfact[B]++;
		map<int, int> LCMfact;
		for (auto it = Afact.begin(); it != Afact.end(); it++) {
			LCMfact[it->first] = max(LCMfact[it->first], it->second);
		}
		for (auto it = Bfact.begin(); it != Bfact.end(); it++) {
			LCMfact[it->first] = max(LCMfact[it->first], it->second);
		}
		long long LCM = 1;
		for (auto it = LCMfact.begin(); it != LCMfact.end(); it++) {
			LCM *= (long long)pow(it->first, it->second);
		}
		cout << LCM << flush;
	}

	return;
}

void D_Brick_Break(void) {

	int N;
	cin >> N;
	vector<int> A(N);
	for (int& it : A) cin >> it;

	int flag = 0;
	int counter = 0;
	for (int loop = 1; flag < N; loop++) {
		if (A[flag] != loop) {
			loop--;
			counter++;
		}
		flag++;
	}
	cout << ((counter == N) ? -1 : counter) << flush;
	return;
}

int main(void) {

	//A_Round_One();
	//B_Strings_with_the_Same_Length();
	//C_Snack();
	D_Brick_Break();
	return 0;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc112/tasks/abc112_c
let inputs =
    Array.init (stdin.ReadLine() |> int) (fun _ ->
        stdin.ReadLine().Split()
        |> Array.map int
        |> function [|x; y; h|] -> (x, y), h | _ -> failwith "input error")
let xy0, h0 = inputs |> Array.find (snd >> (<>) 0)
let manhattan (x1, y1) (x2, y2) = abs (x1 - x2) + abs (y1 - y2)
let (cx, cy), h =
    seq { for cx in 0 .. 100 do for cy in 0 .. 100 -> cx, cy }
    |> Seq.map (fun center -> center, manhattan center xy0 + h0)
    |> Seq.find (fun (center, height) ->
        let heightAt xy = height - manhattan center xy |> max 0
        inputs |> Array.forall (fun (xy, h) -> heightAt xy = h))
printfn "%d %d %d" cx cy h


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

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    int n;
    n = (1000 / k) + 1;
    int ans;
    bool ok = false;

    for (int i = 1; i <= n; i++)
    {
        ans = k * i;
        if (a <= ans && ans <= b)
        {
            ok = true;
        }
    }
    if (ok)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
}

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

int main()
{
    int A,B,sum,sum1;
    scanf("%d%d",&A,&B);
    if(B%A==0)
    {
        sum=A+B;
        printf("%d",sum);
    }
    else
    {
        sum1=B-A;
        printf("%d",sum1);
    }
    return 0;
}


Measured memory_bytes: 128
#include<set>
#include<iostream>
#include<ctime>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<string.h>
#include<limits.h>
using namespace std;

int a[300000];
signed main() {
	int b = 10;//???????????°???????????????????????§????????¢
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		b -= 10;
		if (b < 0) { puts("no"); return 0; }
		b = max(b, a[i]);
	}
	b = 10;
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		b -= 10;
		if (b < 0) { puts("no"); return 0; }
		b = max(b, a[i]);
	}
	puts("yes");
}

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

int main() {
    int n,d;
    cin>>n>>d;
    int temp = 2*d+1;
    for (int i=1; i<100000; i++) {
        if (temp*i >= n) {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;

ll dp[8][1002][1002];
ll x[1002], y[1002], z[1002];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	for (int t = 0; t < 8; t++) {
		for (int i = 0; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				dp[t][i][j] = -1e18;
			}
		}
	}
	for (int t = 0; t < 8; t++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				dp[t][i][j] = max(dp[t][i - 1][j], dp[t][i - 1][j - 1] + ((t&1)? 1 : -1)*x[i] + (((t >> 1)&1) ? 1 : -1)*y[i] + (((t >> 2) & 1) ? 1 : -1)*z[i]);
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < 8; i++) ans = max(ans, dp[i][n][m]);
	cout << ans << endl;
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

struct mint {
    // Preparation: MOD is already defined.
    ll value;

    mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.value);
    }

    mint inv() const {
        ll a = value, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    mint &operator+=(const mint a) {
        if ((value += a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((value += MOD - a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (value *= a.value) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> dict;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        dict[a]++;
        dict[b]++;
    }

    rep(i, n) {
        if (dict[i] % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 5504
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  int cnt=0;
  string str;
  cin>>n;
  cin>>str;
  for(int i=0;i<n-2;i++){
    if(str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C'){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   int sum=0;
   int a[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       sum+=a[i];
   }
   int x =(sum/(4*m));
   if(sum % (4*m)!=0)x++;
   //debug(x);
   int cnt=0;
   for(int i=0;i<n;i++)
   {
       if(a[i]>=x)cnt++;
   }
   if(cnt>=m)cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}


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

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// セグメント木　学習中
template <class T>
class SegmentTree {
	int n;	// 葉の数
	vector<T> data;	// データを格納するvector
	T def;	// 初期値かつ単位元
	function<T(T, T)> operation; // 区間クエリで使う処理
	function<T(T, T)> update;	// 点更新で使う処理

	// 区間[a,b)の総和。ノードk=[l,r)に着目している。
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def; // 交差しない
		if (a <= l && r <= b)
			return data[k]; // a,l,r,bの順で完全に含まれる
		else {
			return operation(_query(a, b, 2 * k + 1, l, (l + r) / 2), _query(a, b, 2 * k + 2, (l + r) / 2, r));	//左右を分割して再帰
		}
	}

public:
	// _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
	// _update:更新関数
	SegmentTree(size_t _n, T _def, function<T(T, T)> _operation,
		function<T(T, T)> _update)
		: def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}

	// 場所i(0-indexed)の値をxで更新
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	// [a, b)の区間クエリを実行
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	// 添字でアクセス
	T operator[](int i) {
		return data[i + n - 1];
	}
};

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	cin >> N;
	ll A;
	ll t;
	ll ans = 0;
	cin >> t;
	rep(i, 1, N) {
		cin >> A;
		ans += max(0LL, t-A);
		t = max(t, A);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
H,W = map(int,input().split())
S = [input() for _ in range(H)]
answer = [[0 if cell == '.' else '#' for cell in row] for row in S]

import itertools
for i in range(H):
  for j in range(W):
    if S[i][j] != '#':
      continue
    for dx,dy in itertools.product([-1,0,1],repeat=2):
      x = i+dx
      y = j+dy
      if x < 0 or x >= H:
        continue
      if y < 0 or y >= W:
        continue
      if S[x][y] == '#':
        continue
      answer[x][y] += 1

      
for row in answer:
  print(*row,sep='')


Measured memory_bytes: 3444
# -*- coding: utf-8 -*-
# 標準入力の取得
N = int(input())

# 求解処理
result = str()
first_place = N % 10
if first_place in [2, 4, 5, 7, 9]:
    result = "hon"
elif first_place in [0, 1, 6, 8]:
    result = "pon"
else:
    result = "bon"

# 求解処理
print(result)


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

int main(){
    int a, b, c, k;
    int cnt = 0;
    cin >> a >> b >> c >> k;
    while(a >= b){
        b *= 2;
        cnt++;
    }
    while(b >= c){
        c *= 2;
        cnt++;
    }
    cout << (cnt <= k ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

int main() {
    using namespace std;
    int h, w;
    cin >> h >> w;
    char s[h+2][w+2];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i+1][j+1];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i+1][j+1] == '#') {
                if (s[i][j+1] != '#' && s[i+1][j] != '#'  && s[i+1][j+2] != '#' && s[i+2][j+1] != '#') {
                        cout << "No" << endl;
                        return 0;
                    }
            }
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

int prize[3] = {300000, 200000, 100000};

int x, y;

int main() {
    scanf("%d%d", &x, &y);
    int ans = 0;
    if (x <= 3)
        ans += prize[x-1];
    if (y <= 3)
        ans += prize[y-1];
    if (x == 1 && y == 1)
        ans += 400000;

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int x;
    cin >> x;
    cout << x * x * x << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
	string s;
	int st, ed;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			st = i;
			break;
		}
	}
	for (int i = s.length() - 1; i >= 0; i--) {
		if (s[i] == 'Z') {
			ed = i;
			break;
		}
	}
	cout << ed - st + 1 << endl;
	return 0;
}

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int N, M;
vector<int> g[MAX + 1];
int nPar[MAX + 1];

int ans[MAX + 1];
queue<int> q;

int main() {
	cin >> N >> M;
	int n1 = N - 1 + M;
	for( int i = 0; i < n1; i++ ) {
		int a, b;
		cin >> a >> b;
		g[a].push_back( b );
		nPar[b]++;
	}

	for( int i = 1; i <= N; i++ ) {
		if( nPar[i] == 0 ) {
			q.push( i );
			break;
		}
	}
	while( !q.empty() ) {
		int n = q.front();
		q.pop();
		for( auto t : g[n] ) {
			nPar[t]--;
			if( nPar[t] ) {
				continue;
			}
			ans[t] = n;
			q.push( t );
		}
	}

	for( int i = 1; i <= N; i++ ) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 7040
from collections import deque
from functools import reduce
import math; floor,ceil = math.floor,math.ceil
import sys; input = lambda: sys.stdin.readline().rstrip()
aint = lambda: int(input()); ints = lambda: list(map(int, input().split()))
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
is_even = lambda x: True if x%2==0 else False
s = lambda x: int(x*(x+1)*0.5)

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    n = aint()
    ans = 0
    for a in range(n):
      for b in range(a,n):
        for c in range(b,n):
          if (a==b and b==c):
            ans += gcd(a+1,b+1,c+1)
          elif (a==b or b==c or c==a):
            ans += gcd(a+1,b+1,c+1)*3
          else:
            ans += gcd(a+1,b+1,c+1)*6
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9636
#include<stdio.h>
int A[45];
int fi(int n){
  if(n==0 || n==1)return A[n]=1;
  if(A[n]!=-1)return A[n];
  return A[n]=fi(n-1)+fi(n-2);
}

int main(){
  int n,i;
  for(i=0;i<45;i++){
    A[i]=-1;
  }
  scanf("%d",&n);
  printf("%d\n",fi(n));
  return 0;
}



Measured memory_bytes: 2104
def main():
    mod = 10**9+7
    n,k = map(int,input().split())
    candies = list(map(int,input().split()))
    dp = [[0 for i in range(k+1)] for j in range(n+1)]
    dp[0][0] = 1
    for pos in range(1,n+1):
        for used in range(k+1):
            a = candies[pos-1]
            start = used
            end = min(start+a+1,k+1)
            dp[pos][start] += dp[pos-1][start]
            if end <= k:
                dp[pos][end] -= dp[pos-1][start]

        for used in range(1,k+1):
            dp[pos][used] += dp[pos][used-1]
            dp[pos][used] %= mod


    print(dp[-1][-1])


main()


Measured memory_bytes: 171656
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>

const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int a[50],b[50],c[50],d[50];
int A[20];

int loop(int id, int n, int m,int q)
{
	int ret=0;
	if (id>n)
	{
		for (int i=0;i<q;i++)
		{
			if (A[b[i]]-A[a[i]]==c[i]) ret+=d[i];
		}
		return ret;
	}


	for (A[id]=A[id-1];A[id]<=m;A[id]++)
	{
		int tmp= loop(id+1,n,m,q);
		if (tmp>ret) ret=tmp;
	}
	return ret;
}



int main(int argc, char *argv[])
{
	int n,m,q;
	A[0]=1;
	cin>>n>>m>>q;
	
	for (int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	int ret=loop(1,n,m,q);

	cout<<ret<<endl;

	return 0;
}



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

 int main() {
   int N,K;
   cin >> N >> K;
   vector<int> h(N);
   for(int i = 0;i < N;i++){
     cin >> h.at(i);
   }
   
  /* cout << N << K <<endl;
    for(int i = 0;i < N;i++){
     cout <<  h.at(i) << endl;
   } */
   int ans = 0;
   for(int i = 0;i< N;i++){
     if(h.at(i) >= K){
       ans++;
     }
   }
   cout << ans << endl;
 }

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=5e5+10;
const ll mod=1e9+7;
int main()
{
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		if(a+b>c+d) puts("Left");
		else if(a+b==c+d) puts("Balanced");
		else puts("Right");
	}
	return 0;
}


Measured memory_bytes: 256
#優先度付きキュー
#値の追加 O(log|Q|)
#値の削除 O(log|Q|)
#最大値の取得 O(1)
#pythonでは 最小値のみしか取得できないため事前に全要素に-1をかけておき最後のまた-1かける

import math
import heapq

N,M = map(int,input().split())

#各要素を-1倍
A = list(map(int,input().split()))
A = list(map(lambda x: x*-1,A))
heapq.heapify(A)

for i in range(M):
    max_A = heapq.heappop(A)
    max_A = max_A * -1
    heapq.heappush(A,-1* (math.floor((max_A) / 2)) )

print(-1 * sum(A))


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

int main(){

    int n;
    map<int,int> ans ;
    cin >> n;


    rep(i,n-1){
        int a;
        cin >> a;
        ans[a] += 1;
    }

    rep(i,n){
        cout << ans[i+1] <<endl;
    }

    return 0;
}


Measured memory_bytes: 12928
#include <iostream>
using namespace std;
int main() {
	int e, y;
	cin >> e >> y;
	if (e == 0) {
		if (y >= 1989) cout << "H" << y - 1988 << endl;
		else if (y >= 1926) cout << "S" << y - 1925 << endl;
		else if (y >= 1912) cout << "T" << y - 1911 << endl;
		else cout << "M" << y - 1867 << endl;
	}
	if (e == 1) {
		cout << y + 1867 << endl;
	}
	if (e == 2) {
		cout << y + 1911 << endl;
	}
	if (e == 3) {
		cout << y + 1925 << endl;
	}
	if (e == 4) {
		cout << y + 1988 << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[5000];
ll const INF = 1001001001;

int main(void) {
  ll n,m; cin >> n >> m;
  ll a[m],b[m];
  ll c[m];
  MEMSET(c,0);

  FOR(i,0,m-1){
    cin >> a[i] >> b[i];
    FOR(j,0,b[i]-1) {
      ll t; cin >> t; --t;
      c[i] += (1<<t);
    }
  }

  FOR(j,0,4999){
    dp[j] = INF;
  }
  dp[0] = 0;

  FOR(i,0,(1<<n)-1){
    FOR(j,0,m-1){
      ll t = i | c[j];
      ll cost = dp[i] + a[j];
      chmin(dp[t],cost); 
    }
  }

  if(dp[(1<<n)-1]==INF) cout << -1 << endl;
  else cout << dp[(1<<n)-1] << endl;
}


Measured memory_bytes: 256
S = list(raw_input())

K = input()

data = []
for i in range(len(S)):
    for j in range(1,K+1):
        if i+j <= len(S):
            sample = ''
            counter = 1
            while counter <= j:
                sample += S[i+counter-1]
                counter += 1
            if sample not in data:
                data.append(sample)
        else:
            break

data.sort()

print data[K-1]

Measured memory_bytes: 3588
def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))
    ans = T
    for i in range(1, N):
        ans += t[i] + T - max(t[i], t[i-1] + T)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 85328
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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




}

Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
template<class T> using V=vector<T>; 
using P=pair<int,int>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
const int MAX_V = 10010;
struct Flow{
//辺の構造体　
struct edge{
    //行き先、容量、逆辺の場所
    ll to,cap,rev;
};
//グラフの隣接リスト
V<edge> G[MAX_V];//vectorの"配列"
//DFSで調べた頂点を記録
bool used[MAX_V];
//辺の情報を代入する関数
void add(ll from,ll to,ll cap){
    G[from].push_back((edge){to,cap,(ll)G[to].size()});
    G[to].push_back((edge){from,0,(ll)G[from].size()-1});
}
//増加パスをDFSで探す
ll dfs(ll v,ll t,ll f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i]; //辺の容量を更新するためのアドレス
        if(!used[e.to]&&e.cap>0){
            ll d=dfs(e.to,t,min<ll>(f,e.cap));
            if(d>0){
                e.cap-=d;//使った分減らす
                G[e.to][e.rev].cap+=d;//使った分逆辺の容量を増やす
                return d;
            }
        }
    }
    return 0;
}
//sからtへの最大流を求める
ll fmax(ll s,ll t){
   ll flow=0;
   while(1){
       for(int i=0;i<MAX_V;i++)used[i]=false;
       ll f=dfs(s,t,10e9);
       if(f==0)return flow;
       flow+=f;
   }
}
};
map<P,bool>mp;
int main(){
int h,w;
cin>>h>>w;
V<string> a(h);
for(int i=0;i<h;i++)cin>>a[i];
Flow mf;
int S=0,T=h+w+2;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
          if(a[i][j]=='o'){
              mf.add(i+1,j+h+1,1);
              mf.add(j+h+1,i+1,1);
          }
          if(a[i][j]=='S'){
              mf.add(S,i+1,1e5);
              mf.add(S,j+h+1,1e5);
          }
          if(a[i][j]=='T'){
              mf.add(i+1,T,1e5);
              mf.add(j+h+1,T,1e5);
          }
    }
}
int ans=mf.fmax(S,T);
if(ans>=1e5)cout<<-1<<endl;
else cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>

typedef struct node{
  double x,y;
}A;

void kock(int n,A p1,A p2){
  A s,t,u;
  double M = M_PI / 3;
  
  if(n == 0) return;

  s.x = (2*p1.x + p2.x)/3;
  s.y = (2*p1.y + p2.y)/3;
  t.x = (p1.x + 2*p2.x)/3;
  t.y = (p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x)*cos(M) - (t.y - s.y)*sin(M) + s.x;
  u.y = (t.x - s.x)*sin(M) + (t.y - s.y)*cos(M) + s.y;

  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1,t,p2);
}

int main(){
  A p1,p2;
  int n;

  scanf("%d",&n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 3005;

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];

    int ruisekiwa[n+2];
    ruisekiwa[0] = 0;
    REP(i,n) ruisekiwa[i+1] = ruisekiwa[i] + A[i];

    int dp[n_max][n_max];
    REP(i,n) dp[i][i] = 0;
    FOR(kukan,1,n+1){
        REP(i,n){
            if(i + kukan > n) break;
            dp[i][i+kukan] = max( - dp[i + 1][i + kukan] , - dp[i][i + kukan - 1]);
            dp[i][i+ kukan] += ruisekiwa[i + kukan] - ruisekiwa[i];
        }
    }
    cout << 2 * dp[0][n] - (ruisekiwa[n]) << endl;
}

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

int N, K, h, sum = 0;
int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
    {
        cin >> h;
        if (h >= K)
        {
            sum++;
        }
        
    }
    cout << sum << endl;

    cin.get();
    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

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

void solve(const vector<int>& a, ll& even, ll& odd) {
	even = odd = 0;
	int n = sz(a);
	vector<int> sum(1 << n);
	int oldest = -1;
	sum[0] = 0;
	even = 1;
	for (int mask = 1; mask < (1 << n); ++mask) {
		if (!(mask & (mask - 1))) {
			++oldest;
		}
		sum[mask] = sum[mask ^ (1 << oldest)];
		sum[mask] ^= (a[oldest] & 1);
		if (sum[mask] == 1) {
			++odd;
		} else {
			++even;
		}
	}
}

int main() {

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

	//ifstream cin("input.txt");

	int n, p;
	cin >> n >> p;

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

	int l = n / 2;
	vector<int> b, c;
	for (int i = 0; i < l; ++i) {
		b.pb(a[i]);
	}
	for (int i = l; i < n; ++i) {
		c.pb(a[i]);
	}

	ll x1, y1, x2, y2;
	solve(b, x1, y1);
	solve(c, x2, y2);

	ll ans;

	if (p == 0) {
		ans = x1 * x2 + y1 * y2;
	} else {
		ans = x1 * y2 + x2 * y1;
	}

	cout << ans << "\n";

}


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

int main(){
  int h,w;
  cin >> h >> w;
  char arr[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> arr[i][j];
    }
  }
  for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<h;i++){
    cout << "#";
    for(int j=0;j<w;j++){
      cout << arr[i][j];
    } 
    cout << "#" << endl;
  }
  for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	in := readLine()
	ins := strings.Split(in, " ")

	n, _ := strconv.Atoi(ins[0])
	d, _ := strconv.Atoi(ins[1])

	var x [][]int

	for i := 0; i < n; i++ {
		xs := strings.Split(readLine(), " ")
		var xi []int
		for _, v := range xs{
			vint, _ := strconv.Atoi(v)
			xi = append(xi, vint)
		}
		x = append(x, xi)
	}

	var count int
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			var a float64
			for k := 0; k < d; k++ {
				a += math.Pow(math.Abs(float64(x[i][k] - x[j][k])), 2)
			}
			b := math.Sqrt(a)
			if math.Mod(b, 1.0) == 0 {
				count++
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 640
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string s,t,u;int a,b;
	cin>>s>>t;cin>>a>>b;cin>>u;
	if(s==u) a--;else b--;
	cout<<a<<' '<<b<<endl;
}


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

def diffculc(st, ed):
    if ed < st:
        tmp = ed
        ed = st
        st = tmp
    if st < 0 and ed < 0:
        diff = abs(st - ed)
    elif -1 < st and ed < 0:
        diff = abs(ed - st)
    elif st < 0 and -1 < ed:
        diff = abs(st - ed)
    elif -1 < st and -1 < ed:
        diff = ed - st
    return diff

xList = [int(x) for x in input().split()]
sortedList = sorted(xList)

# 0番目と1番目の間のdiffはdiffcache[0]
diffcache = {}
diff = 0
for i, x in enumerate(sortedList):
    if i == len(sortedList) - 1:
        break
    diffcache[i] = diffculc(sortedList[i+1], x)

rangeset = []
counter = 0
for k, v in sorted(diffcache.items(), key=lambda x: -x[1]):
    if counter == N - 1:
        break
    diffcache.pop(k)
    counter = counter + 1

result = 0
for k,v in diffcache.items():
    result = result + v
print(result)

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int x,t;
  cin>>x>>t;
  if(t>x)cout<<0<<endl;
  else cout<<x-t<<endl;


return 0;

}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	string s;
	string t;

	cin >> s >> t;

	int n = s.size();
	int m = t.size();

	bool res = false;
	RFOR(i,n-m+1,0){
		if(res) break;
		bool flg = true;
		rep(j,m){
			if(s[i+j] == t[j] || s[i+j] == '?') continue;
			else{
				flg = false;
				break;
			}
		}
		if(flg){
			res = true;
			FOR(j,0,i) cout << (s[j] == '?' ? 'a' : s[j]);
			FOR(j,i,i+m) cout << t[j-i];
			FOR(j,i+m,n) cout << (s[j] == '?' ? 'a' : s[j]);
			cout << endl;
		}
	}

	if(!res) cout << "UNRESTORABLE" << endl;
}

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

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

    set<int> st;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (st.find(a) == st.end()) st.insert(a);
        else st.erase(a);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 4864
using System;
namespace ABC
{
    public class C
    {
        static void Main()
        {
            long N = long.Parse(Console.ReadLine());
            var ans = ToAlphabet(N);
            Console.WriteLine(ans);

            static string ToAlphabet(long n)
            {
                string r = "";
                do
                {
                    long a = (n - 1) % 26;
                    r = (char)('a' + a) + r;
                    n = (n - 1) / 26;
                } while (n > 0);
                return r;
            }

        }
    }
}


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

using namespace std;

int main() {
    stack<int> st;
    string s;
    while (cin >> s) {
        int a, b;
        if (s == "+") {
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a + b);
        } else if (s == "-") {
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a - b);
        } else if (s == "*") {
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a * b);
        } else {
            st.push(stoi(s));
        }
    }
    printf("%d\n", st.top());
}


Measured memory_bytes: 3264
n,m=map(int,input().split())
ab=[]
data=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  ab.append([a,b])
  data[a].append(b)
  data[b].append(a)
flag=[0]*(n+1)
cnt=[0]*(n+1)
for i in range(1, n+1):
  if flag[i]==0:
    cnt[i]+=1
    flag[i]=1
    que=[i]
    while que:
      h=que.pop()
      for u in data[h]:
        if flag[u]==0:
          cnt[i]+=1
          flag[u]=1
          que.append(u)   
print(max(cnt))

Measured memory_bytes: 63092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  ll d=abs(a-b)+abs(b-c);
  ll e=abs(a-c)+abs(b-c);
  ll f=abs(a-c)+abs(a-b);
  cout<<min(d,min(e,f))<<endl;
  return 0;
}


Measured memory_bytes: 3540
a, b = map(int, input().split())
money = 0
if a == 1:
    money += 300000
    if b == 2:
        money  += 200000
    elif b ==3:
        money  += 100000

    elif b == 1:
        money += 700000

elif a == 2:
    money += 200000
    if b == 2:
        money += 200000
    elif b == 3:
        money += 100000
    elif b ==1:
        money += 300000

elif a == 3:
    money += 100000
    if b == 2:
        money += 200000
    elif b == 3:
        money += 100000
    elif b == 1:
        money += 300000

else:
    if b == 2:
        money += 200000
    elif b == 3:
        money += 100000
    elif b == 1:
        money += 300000

print(money)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int[] arr = inputval();
        int N=arr[0];
        int C = arr[1];
        int[][] bangumi = new int[N][3];
        for(int i=0; i<bangumi.length; i++){
            bangumi[i] = inputval();
        }
        int[] tt = new int[100000];
        int[] sm = new int[100000];
        for(int i=0; i<sm.length; i++){
            sm[i] = 0;
        }
        int maxval = 0;
        for(int i=1; i<=C; i++){
            for(int j=0; j<tt.length; j++){
                tt[j] = 0;
            }
            for(int j=0; j<bangumi.length; j++){
                if(bangumi[j][2] == i){
                    if(tt[bangumi[j][0]-1]==0) tt[bangumi[j][0]-1] = -1;
                    for(int k=bangumi[j][0]; k<bangumi[j][1]; k++){
                        tt[k] = 1;
                    }
                }
            }
            for(int j=0; j<tt.length; j++){
                if(tt[j] == -1){
                    if(sm[j] <= 0){
                        sm[j]--;
                    }else{
                        sm[j]++;
                    }
                }else if(tt[j] == 1){
                    if(sm[j] <= 0) {
                        sm[j] = -sm[j];
                    }
                    sm[j]++;
                }
                if(sm[j] > maxval) maxval = sm[j];
            }
        }
        System.out.println(maxval);

    }


















    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 48836
#include <stdio.h>

int main(){

    long long int brpKali;
    int count=0;
    long long int hasil=0;
    int i=1;
    int j=0;
    long long int arrTampungan[1000000];
    scanf("%lld", &brpKali);
    while(i<=brpKali){
        if(i%3==0 && i%5!=0){
            //printf("Fizz");
        }
        else if(i%5==0 && i%3!=0){
            //printf("Buzz");
        }
        else if(i%3==0 && i%5==0){
            //printf("FizzBuzz");
        }
        else{
           // printf("%d", i);
            arrTampungan[j]=i;
           // printf("\n ini array tampungan ke-%d :%d\n",j , arrTampungan[j]);
            count++;
            j++;
        }
        i++;

    }
 for(int k=0;k<count;k++){
    hasil+=arrTampungan[k];
 }
printf("%lld\n", hasil);
 
 
    return 0;
}

Measured memory_bytes: 5808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		
		int red = 0;
		int blue = 0;
		
		String[] ss = s.split("");
		
		for(int i=0; i<n; i++) {
			if(ss[i].equals("R")) {
				red++;
			}else {
				blue++;
			}
		}
		
		if(red>blue) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23508
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();
		int y = sc.nextInt();

		if (x % y == 0) {
			pr.println(-1);
		} else {
			pr.println(x);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21204