akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,k;
    cin >> n >> k;
    ld ans = 0;
    repi(i, 1, n + 1){
        intl a = 0;
        intl b = i;
        while(b < k){
            b *= 2;
            a++;
        }
        ans += 1.0L / n * pow(0.5L,a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  string s;
  cin >> s;

  int ans=s.size();

  rep(i,1,s.size())
    if(s[i-1]!=s[i])
      chmin(ans,max(i,(int)s.size()-i));

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


Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }

    static object Solve() {
        var N = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var len = a.Length;
        var i = 1;
        for (int j = 0; j < len; j++) {
            if (a[j] == i) i++;
        }
        return i == 1 ? -1 : N - i + 1;
    }
}

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

namespace AtCoder
{
    class A_Product_086
    {
        public static void Main()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine((inputs[0] * inputs[1]) % 2 == 0 ? "Even" : "Odd");
        }
    }
}


Measured memory_bytes: 13268
//
// Created by maze on 2019/11/03.
//

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

#define INF_LL (int64)le18
#define INF (int32)le9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

int main() {
  int32 r, s, p;
  cin >> r >> s >> p;
  vector<int32> dist(p,0);
  REP(k,p){
    int32 i, j;
    cin >> i >> j;
    dist[k] += r - i + 1;
    if(j <= s){
      dist[k] += s - j + 1;
    }else{
      dist[k] += j - s;
    }
  }
  sort(all(dist));
  int32 ans = 0;
  REP(i,p){
    if(ans >= dist[i]){
      ans++;
    }else{
      ans = dist[i];
    }
  }
  cout << ans << endl;

}


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

typedef struct pair{
  int x,y;
}point;

int compare_pair(const void *a,const void *b){
  if((*(point*)a).y < (*(point*)b).y) return 1;
  return -1;
}

int compare_int(const void *a,const void *b){
  if(*(int*)a > *(int*)b) return 1;
  return -1;
}

int main(void){
  int N,M;
  scanf("%d%d",&N,&M);

  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d",&A[i]);
  }

  qsort(A,N,sizeof(int),compare_int);

  point arr[M];
  for (int i = 0; i < M; i++) {
    scanf("%d%d",&arr[i].x,&arr[i].y);
  }

  qsort(arr,M,sizeof(point),compare_pair);

  int cnt = 0;
  int num = 0;
  for (int i = 0; i < N; i++) {
    if(A[i] < arr[num].y){
      A[i] = arr[num].y;
      cnt++;
      if(cnt+1 > arr[num].x){
        cnt = 0;
        num++;
      }
    }
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }

  printf("%lld\n",ans);

  return 0;
}

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

int dp[400] = {};

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

    int s, l, p;
    for(int i = 1; i <= n; i++){
        cin >> s >> l >> p;
        for(int j = 1; j <= 400; j++){
            for(int k = s; j-k >= 0 && k <= l; k++){
                dp[j] = max(dp[j], dp[j-k]+p);
            }
        }
    }

    int m;
    cin >> m;

    int w;
    vector<int> ans;
    for(int i = 0; i < m; i++){
        cin >> w;
        if(dp[w] == 0){
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(dp[w]);
    }

    for(int x : ans)    cout << x << endl;
    
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint a(n); rep(i,n) cin>>a[i];


    ll ans = a.front() - 1;
    ll maxval = 1;

    repf(i,1,n){
        // cout<<ans<<endl;
        if(a[i] == maxval+1){
            maxval++;
            continue;
        }

        if(a[i] > maxval){
            if(a[i]%(maxval+1) == 0) {a[i] -= maxval + 2; ans++;}
            ans += a[i]/(maxval+1);
        }else{
            continue;
        }

    }
    cout<<ans<<endl;


    return 0;

}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

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

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

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

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

void solve() {
    int n, k;
    sc(n, k);
    ll ans = 0;
    fr(b, k + 1, n) {
        for(int m = 0; m * b <= n; m++) {
            int lm = m * b + k;
            int rm = m * b + b - 1;
            rm = min(rm, n);
            lm = max(lm, 1);
            if(lm <= rm) ans += rm - lm + 1;
        }
    }
    cout << ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;

bool check(string s, int k){
    if(s.empty()) return false;
    int l = s.size();
    if(k >= 0 && k < l-1 && s[k] == '(' && s[k+1] == ')') return true;
    else return false;
}

int main(){
    int n; cin >> n;
    string s,t; cin >> s;
    t = s;
    
    while(true){
        bool deleted = false;
        rep(i, (int)t.size()){
            if(check(t, i)){
                t.erase(i, 2);
                deleted = true;
                break;
            }
        }
        if(!deleted) break;
    }

    int cnt1 = 0, cnt2 = 0;
    rep(i,(int)t.size()){
        if(t[i] == '(') cnt1++;
        else cnt2++;
    }

    rep(i, cnt1){
        s += ")";
    }
    rep(i,cnt2){
        s = "(" + s;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

struct UnionFind {
  vector<ll> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<ll> siz;

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

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

  void unite(ll x, ll y) {  // xとyの木を併合
    ll rx = root(x);         // xの根をrx
    ll ry = root(y);         // yの根をry
    if (rx == ry) {
      return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    } else {
      if (size(rx) < size(ry)) swap(rx, ry);
      par[ry] =
          rx;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
      siz[rx] += siz[ry];  // 大きさを付け換える
    }
  }

  bool same(ll x, ll y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    ll rx = root(x);
    ll ry = root(y);
    return rx == ry;
  }
  ll size(ll x) { return siz[root(x)]; }
};
int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n,m; cin >> n >> m;
  UnionFind u(n);
  rep(i,m){
    ll x, y, z; cin >> x>> y >>z;
    x--; y--;
    u.unite(x,y);
  }
  set<ll> parent;
  rep(i,n){
    parent.insert(u.root(i));
  }
  cout << SIZE(parent) << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    map<int, int> mp;
    rep(i, N)
    {
        if (mp.count(a[i]))
        {
            mp[a[i]] += 1;
        }
        else
        {
            mp[a[i]] = 1;
        }
    }
    int ans = 0;
    for (auto x : mp)
    {
        if (x.first > x.second)
        {
            ans += x.second;
        }
        else if (x.first < x.second)
        {
            ans += x.second - x.first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5120
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int powm(int a, int b, const int &m) {
  int c = 1;
  while (b) {
    if (odd(b)) c = (c * a) % m;
    b >>= 1;
    a = (a * a) % m;
  }
  return c;
}

void solve() {
  int n;
  cin >> n;
  vi t(n);
  rep(i, n) {
    int a;
    cin >> a;
    t[a]++;
  }
  if (any_of(all(t), [](int x) { return x > 2; }) || t[0] > 1) {
    cout << 0 << endl;
    return;
  }
  cout << powm(2, n / 2, MOD) << endl;
}


Measured memory_bytes: 1024
require 'prime'
require 'set'
a, b = gets.split.map(&:to_i)

mods_a = Set.new
mods_b = Set.new

2.upto( Math.sqrt(a) ) do |i|
  if a % i == 0
    mods_a.add(i)
    a = a / i while a % i == 0
  end
  if b % i == 0
    mods_b.add(i)
    b = b / i while b % i == 0
  end
end
if a.prime?
  mods_a.add(a) 
end
if b.prime?
  mods_b.add(b)
end

puts (mods_a & mods_b).size + 1

Measured memory_bytes: 4220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			Rectangle rect = new Rectangle(Integer.parseInt(tmpArray[0]),
					Integer.parseInt(tmpArray[1]));
			System.out.println(rect.getArea() + " " + rect.getPerimeter());

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
class Rectangle {

	private int vertical = 0;
	private int side = 0;

	public Rectangle(int v, int s) {
		vertical = v;
		side = s;
	}

	public int getArea() {
		return vertical * side;
	}

	public int getPerimeter() {
		return (vertical + side) * 2;
	}
}


Measured memory_bytes: 26068
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;

  vector<ll> a(n);
  vector<ll> a_sum(n + 1);
  a_sum[0] = 0;
  REP(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  REP(i, n) a_sum[i + 1] = a_sum[i] + a[i];

  ll l = a[0] + a[0] - 1, r = a[n - 1] + a[n - 1] + 1;

  while(r - 1 > l) {
    ll mid = (l + r) / 2;
    auto f = [&] {
      ll sum = 0;
      REP(i, n) {
        ll t = mid - a[i];
        auto it = lower_bound(a.begin(), a.end(), t);
        if(it != a.end()) sum += a.end() - it;
      }
      return sum >= m;
    };
    if(f()) l = mid;
    else r = mid;
  }

  r = r - 1;

  ll ans = 0, c = 0;
  REP(i, n) {
    ll t = r - a[i];
    auto it = lower_bound(a.begin(), a.end(), t);
    if(it != a.end()) {
      ans += a_sum[n] - a_sum[it - a.begin()] + a[i] * (a.end() - it);
      c += a.end() - it;
    }
  }

  cout << (ans - r * (c - m)) << endl;
}


Measured memory_bytes: 4764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u =sc.next();

        if(u.equals(s))a--;
        else b--;

        System.out.println(a+" "+b);

        

    }

}




Measured memory_bytes: 21844
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner Sc=new Scanner(System.in);
    int n=Sc.nextInt();
    int[] arr=new int[n];
    for(int i=0;i<n-1;i++)
      arr[Sc.nextInt()-1]++;
    for(int i=0;i<n;i++)
      System.out.println(arr[i]);
  }
}


Measured memory_bytes: 60740
import sys
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

b=bfs(0)
ct0=0;ct1=0
for i in range(n):
  b[i]%=2
  if b[i]==0:
    ct0+=1
  else:
    ct1+=1

ans=[0]*n
x1=1;x2=2;x3=3

if ct0>=n//3+1 and ct1>=n//3+1:
  for i in range(n):
    if b[i]==0:
      if x1<=n:
        ans[i]=x1
        x1+=3
      else:
        ans[i]=x3
        x3+=3
    else:
      if x2<=n:
        ans[i]=x2
        x2+=3
      else:
        ans[i]=x3
        x3+=3

elif ct0<=n//3:
  for i in range(n):
    if b[i]==0:
      ans[i]=x3
      x3+=3
    else:
      if x1<=n:
        ans[i]=x1
        x1+=3
      elif x2<=n:
        ans[i]=x2
        x2+=3
      else:
        ans[i]=x3
        x3+=3

elif ct1<=n//3:
  for i in range(n):
    if b[i]==1:
      ans[i]=x3
      x3+=3
    else:
      if x1<=n:
        ans[i]=x1
        x1+=3
      elif x2<=n:
        ans[i]=x2
        x2+=3
      else:
        ans[i]=x3
        x3+=3

for i in range(n):
  ans[i]=str(ans[i])
print(' '.join(ans))

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DFaceProducesUnhappiness {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        string s;
        cin >> s;
        char prev = s[0];
        int res = 0;
        FOR(i, 1, N - 1) {
            char c = s[i];
            if (c == prev) {
                res++;
            }
            prev = s[i];
        }
        res += K * 2;
        res = min(N - 1, res);
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DFaceProducesUnhappiness solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;
  vector<int> pos {0,4,6,8};
  REP(i,pos.size()) {
    if (pos[i] > S.size()) break;
    if (S[pos[i]] != 'A') S.insert(pos[i],"A");
  }
  if (S == "AKIHABARA") cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
Scanner sc = new Scanner(System.in);
int i, j;
// 最初の文字の固まりを整数値と想定して読み込む 
while (true) {
int H = sc.nextInt();
int W= sc.nextInt();
if (H == 0 && W == 0) {
	break; }
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if((i+j)%2 == 0){
					System.out.printf("#");
				}else {
					System.out.printf(".");
				}
			}
			System.out.println();
		}
	System.out.println();
}
sc.close(); }
}


Measured memory_bytes: 58764
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  vc S;

  if(N == 0){
    cout << 0 << endl;
    return 0;
  }
  
  while(N != 0){
    if(N % (-2) == 0){
      S.push_back('0');
    } else{
      S.push_back('1');
      N--;
    }

    N /= -2;
  }

  rep_inv(i, S.size() - 1, -1) cout << S[i];

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


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,u,v,ans=0;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        ans+=(i*(n-i+1));
    }
    for(ll i=0;i<n-1;i++)
    {
        cin>>u>>v;
        if(u>v)swap(u,v);
        ans-=(u*(n-v+1));
    }
    cout<<ans;

}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b)
    for (int i = 0; i < b; i++) {
      cout << a;
    }
  else
    for (int i = 0; i < a; i++) {
      cout << b;
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int i = scanner.nextInt();
    scanner.nextInt();
    int i1 = scanner.nextInt();
    scanner.nextInt();

    if (i != i1) {
      System.out.println(1);
    } else {
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21972
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;


int n, k;
int v[210000];
int s[210000];

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

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

    for (int j = 0; j < min(1000,k); j++) {
        for (int i = 0; i < n; i++) s[i] = 0;
        
        for (int i = 0; i < n; i++) {
            int l = max(0, i - v[i]);
            int r = min(n-1, i + v[i]);
            s[l]++;
            s[r+1]--;
        }

        v[0] = s[0];
        for (int i = 1; i < n; i++) {
            v[i] = v[i-1] + s[i];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << v[i];
        if (i != n-1) cout << " ";
    }
    cout << endl;
    // cin >> n >> k >> tgt_and >> tgt_or;

    // for (int i = 0; i < n; i++) {
    //     cin >> v[i];
    //     if ( (v[i] & tgt_and) != tgt_and || (v[i] | tgt_or) != tgt_or) v[i] = -1;
    // }

    // int or_zeros = (~tgt_or) & ((1<<18)-1);
    // int and_zeros = (~tgt_and) & ((1<<18)-1);

    // if (tgt_and & or_zeros) {
    //     cout << 0 << endl;
    //     return 0;
    // } 

    // int relevant = (tgt_and | or_zeros); 

    // for (int i = 0; i < n; i++) if (v[i] != -1) {
    //     dp[i][1][relevant] = 1;

    //     for (int pck = 2; pck <= k; pck++) {
    //         for (int j = i+1; j < n; j++) if (v[j] != -1) {
    //             dp[j][pck][]
    //         }
    //     }
    // }
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> x;
    x.push_back(a);
    x.push_back(b);
    x.push_back(c);
    sort(x.begin(), x.end());
    cout << x[0]+x[1];
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n;
string s;
 
int main(int argc, char **argv) {
	cin >> n >> s;
	int r = 0, st = 0;
	REP(i, n) {
		if (s[i] == '(') ++st;
		else if (st == 0) ++r;
		else --st;
	}
	REP(i, r) cout << '(';
	cout << s;
	REP(i, st) cout << ')';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c && a%2 == 0) cout << -1 << endl;
	else{
		int ans = 0;
		while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
			ll na = (b + c) / 2;
			ll nb = (a + c) / 2;
			ll nc = (a + b) / 2;
			a = na;
			b = nb;
			c = nc;
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;int main(){int n,y;cin>>n>>y;for(int i=0;i<=n;i++)for(int j=0;j<=n-i;j++)if(i*10000+j*5000+(n-i-j)*1000==y)cout<<i<<' '<<j<<' '<<n-i-j<<'\n',exit(0);cout<<"-1 -1 -1\n";return 0;}

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

const long INF = 10e10;

int main() {
    long n; cin >> n;
    vector<long> a(n+1);
    for(int i = 0; i < n; i ++) cin >> a[i];
    a[n] = INF;
    sort(a.begin(), a.end());
    long cnt = 0;
    long eo;
    for(int i = 0; i < n; i ++) {
        eo ++;
        if(a[i] != a[i+1]) {
            if(eo%2==1) cnt ++;
            eo = 0L;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;


inline bool eq(double a, double b) { return fabs(b - a) < EPS;}

struct p_t{
  double x;
  double y;
  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }
};
struct l_t{
	p_t a, b;
};

double cross(p_t p,p_t q);
p_t line(p_t p,p_t q);

bool asc(p_t left,p_t right) {
    return left.x == right.x ? left.y < right.y : left.x < right.x;
}
p_t Crosspoint(l_t l,l_t m);

int main(){
  int n;
  cin>>n;
  vector<p_t> a;
  p_t z;
  for(int i=0;i<n;i++){
    cin>>z.x>>z.y;
    a.push_back(z);
  }
  if((n&1)==0){
    z.x=(a[0].x+a[n/2].x)/2;
    z.y=(a[0].y+a[n/2].y)/2;
    int i;
    for(i=2;i<n/2;i++){
      if(eq(z.x,(a[i].x+a[i+n/2].x)/2)==0) break;
      if(eq(z.y,(a[i].y+a[i+n/2].y)/2)==0) break;
    }
    if(i==n/2){
      cout<<fixed<<z.x<<" "<<fixed<<z.y<<endl;
      return 0;
    }
  }
  cout<<"NA"<<endl;
  return 0;
}


p_t line(p_t p,p_t q){
  p_t z;
  z.x=q.x-p.x;
  z.y=q.y-p.y;
  return z;
}


double cross(p_t p,p_t q){
  return p.x*q.y-p.y*q.x;
}

p_t Crosspoint(l_t l,l_t m){
  p_t aa,bb,cc,dd,ee;
  aa.x=l.b.x-l.a.x;
  aa.y=l.b.y-l.a.y;
  bb.x=m.b.x-m.a.x;
  bb.y=m.b.y-m.a.y;
  cc=aa;
  dd.x=l.b.x-m.a.x;
  dd.y=l.b.y-m.a.y;
	double A = cross(aa,bb);
	double B = cross(cc,dd);
	if (abs(A) < EPS && abs(B) < EPS) return m.a;
  ee.x=m.a.x+(m.b.x-m.a.x)*B/A;
  ee.y=m.a.y+(m.b.y-m.a.y)*B/A;
	return ee;
}



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


int main(){

    int h,n,sum =0;
    cin >> h >> n;
    while(n--){
        int a;
        cin >> a;
        sum += a;

    }
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))
    if X not in p:
        print(X)
        return
    for i in range(1, 101):
        if X - i not in p:
            print(X - i)
            return
        if X + i not in p:
            print(X + i)
            return

if __name__ == "__main__":
    main()

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

bool judge( char a, char b, char c )
{
    if( a == b && b == c && a != '+' )
        return true;
    return false;
}

int main()
{
    char c[3][3];

    while( cin >> c[0][0] )
    {
        if( c[0][0] == '0' )
            break;
        
        cin >> c[0][1] >> c[0][2];
        for( int i = 1; i < 3; i++ )
            for( int j = 0; j < 3; j++ )
                cin >> c[i][j];

        bool na = true, one = true;
        for( int i = 0; i < 3; i++ )
            if( judge( c[i][0], c[i][1], c[i][2] ) || judge( c[0][i], c[1][i], c[2][i] ) )
            {
                cout << c[i][i] << endl;
                na = false;
                one = false;
                break;
            }

        if( judge( c[0][0], c[1][1], c[2][2] ) || judge( c[0][2], c[1][1], c[2][0] ) && one )
        {
            cout << c[1][1] << endl;
            na = false;
        }
        if( na )
            cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
	int N; cin >> N;
	vector<int> A(N);
	vector<vector<int> > X(N), Y(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
		X[i].resize(A[i]);
		Y[i].resize(A[i]);
		for(int j = 0; j < A[i]; ++j){
			int x, y;
			cin >> x >> y; x--;
			X[i][j] = x; Y[i][j] = y;
		}
	}

	vector<int> ans(N, 0);
	int maxcnt = 0;

	// 全探索
	for(int i = 0; i < pow(2, N); ++i){
		int sht = i;
		int cnt = 0;
		vector<int> digit(N);
		for(int j = 0; j < N; ++j){
			ans[j] = (sht & 0x01);
			digit[j] = ans[j];
			sht = sht >> 1;
			// cout << ans[j] << " ";
		}
		// cout << "-> ";

		int flag = 1;
		// iの各桁に対して
		for(int j = 0; j < N; ++j){
			if(digit[j] == 0) continue;
			for(int k = 0; k < A[j]; ++k){
				if(digit[X[j][k]] != Y[j][k]) flag = 0;
				// cout << X[j][k] << " " << Y[j][k] << " : ";
			}
		}

		if(flag){
			for(int j = 0; j < N; ++j){
				cnt += ans[j];
			}
		} else {
			cnt = 0;
		}

		// cout << cnt << endl;
		if(cnt > maxcnt) maxcnt = cnt;
	}

	cout << maxcnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
#define MN 200000
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 n,m,A,B;ll ans=1e18;
struct Tree{int l,r;ll val,x,mn1,mn2;}T[MN*4+5];
void Build(int x,int l,int r)
{
	if((T[x].l=l)==(T[x].r=r))
	{
		T[x].x=l==B?0:1e18;
		T[x].mn1=T[x].x+l;
		T[x].mn2=T[x].x-l;
		return;
	}
	int mid=l+r>>1;
	Build(x<<1,l,mid);Build(x<<1|1,mid+1,r);
	T[x].mn1=min(T[x<<1].mn1,T[x<<1|1].mn1);
	T[x].mn2=min(T[x<<1].mn2,T[x<<1|1].mn2);
}
inline void Mark(int x,ll v){T[x].val+=v;T[x].mn1+=v;T[x].mn2+=v;T[x].x+=v;}
inline void pushdown(int x){Mark(x<<1,T[x].val);Mark(x<<1|1,T[x].val);T[x].val=0;}
void Modify(int x,int k,ll v)
{
	if(T[x].l==T[x].r)
	{
		T[x].x=min(T[x].x,v);
		T[x].mn1=T[x].x+T[x].l;
		T[x].mn2=T[x].x-T[x].l;
		return;
	}
	int mid=T[x].l+T[x].r>>1;if(T[x].val)pushdown(x);
	Modify(x<<1|(k>mid),k,v);
	T[x].mn1=min(T[x<<1].mn1,T[x<<1|1].mn1);
	T[x].mn2=min(T[x<<1].mn2,T[x<<1|1].mn2);
}
pair<ll,ll> operator + (pair<ll,ll> a,pair<ll,ll> b){return make_pair(min(a.first,b.first),min(a.second,b.second));}
pair<ll,ll> Query(int x,int l,int r)
{
	if(T[x].l==l&&T[x].r==r) return make_pair(T[x].mn1,T[x].mn2);
	if(T[x].val) pushdown(x);int mid=T[x].l+T[x].r>>1;
	if(r<=mid) return Query(x<<1,l,r);
	else if(l>mid) return Query(x<<1|1,l,r); 
	else return Query(x<<1,l,mid)+Query(x<<1|1,mid+1,r);
}
inline int Abs(int x){return x<0?-x:x;}
int main()
{
	n=read();m=read();A=read();B=read();Build(1,1,n);
	for(int i=1,last=A;i<=m;++i)
	{
		int x=read();
		ll val=min(Query(1,1,x).second+x,Query(1,x,n).first-x);
		Mark(1,Abs(x-last));Modify(1,last,val);last=x;
	}
	for(int i=1;i<=MN*4;++i) 
	{
		if(T[i].l&&T[i].l==T[i].r) ans=min(ans,T[i].x);
		else if(T[i].val) pushdown(i);
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 22784
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

int main()
{
  int x[5];
  int index;

  for (int i = 0; i < 5; i++)
  {
    cin >> x[i];
    if (x[i] == 0)
    {
      index = i;
    }
  }
  if (index > 0)
  {
    cout << x[index - 1] + 1 << "\n";
  }
  else
  {
    cout << x[index + 1] - 1 << "\n";
  }

  return 0;
}


Measured memory_bytes: 3592
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    A = [int(i) for i in input().split()]
    sum = 0
    for j in range(M):
        sum += A[j]*B[j]
    sum += C
    if sum > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

ll X[200002], pre[200002], erp[200002];

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int L, N; cin >> L >> N;
    for (int i = 1; i <= N; ++i) cin >> X[i];
    for (int i = 1; i <= N; ++i) pre[i] = X[i]+pre[i-1];
    for (int i = N; i > 0; --i) erp[i] = L-X[i]+erp[i+1];

    ll ans = max(X[N], L-X[1]), dist;
    for (int i = 1; i < N; ++i) {
        int j = N-i;
        if (i < j) dist = max(2*pre[i]+2*(erp[i+1]-erp[2*i+1])-min(X[i], L-X[i+1]), 2*pre[i]+2*(erp[i+2]-erp[2*i+2])+L-X[i+1]);
        else if (i == j) dist = 2*pre[i]+2*erp[i+1]-min(X[i], L-X[i+1]);
        else dist = max(2*(pre[i]-pre[i-j])+2*erp[i+1]-min(X[i], L-X[i+1]), 2*(pre[i-1]-pre[i-j-1])+2*erp[i+1]+X[i]);
        ans = max(dist, ans);
    }
    cout << ans;
}

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

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

Measured memory_bytes: 256
s = input()
t = input()
counts = []
for i in range(len(s)):
    count = 0
    if len(s[i:]) < len(t):
        break
    tmp = s[i:]
    for j in range(len(t)):
        if tmp[j] != t[j]:
            count += 1
    counts.append(count)

print(min(counts))

Measured memory_bytes: 9036
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
double dist(double x1,double y1,double x2, double y2){
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

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

    int N;
    cin >> N;
    vector<double> x(N),y(N);
    rep(i,0,N){
        cin >> x[i] >> y[i];
    }
    double R = 1e11;
    double pi = M_PI;
    int num = 2000000;
    vector<int> ans(N);

    for(int i = 0; i < num; i++){
        double X = R * cos(i * 2 * pi / num);
        double Y = R * sin(i * 2 * pi / num);
        double min_d = dist(X,Y,x[0],y[0]);
//        if(i % 10000 == 0){
//            cout << X << " " << Y << endl;
//        }
        int min_k = 0;

        rep(j,1,N){
            double tmp = dist(X,Y,x[j],y[j]);
            if(tmp < min_d){
                min_d = tmp;
                min_k = j;
            }
        }
        ans[min_k]++;
    }
    rep(i,0,N){
        printf("%.6f\n",1.0 * ans[i] / num);
    }


    return 0;
}


Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[110];
int k;
vector<pair<int,int> > v;
int main()
{
	scanf("%s%d",s+1,&k);
	int len=strlen(s+1);
	bool flag=1;
	for(int i=2;i<=len;i++)flag&=(s[i]==s[1]);
	if(flag==1)
	{
		printf("%lld\n",1ll*k*len/2);
		return 0;
	}
	int st=-1,cur=0;
	long long ans=0;
	for(int i=1;i<=len;i++)
	{
		if(s[i]!=cur)
		{
			if(st!=-1)
			{
				v.push_back(make_pair(cur,i-st));
			}	
			st=i;cur=s[i];
		}
	}
	v.push_back(make_pair(cur,len-st+1));
	for(auto &x:v)ans+=(x.second/2);
	ll out=ans*k;
	if(v.begin()->first==v.back().first)
	{
		out-=1ll*(k-1)*(v.begin()->second/2+v.back().second/2);
		out+=1ll*(k-1)*((v.begin()->second+v.back().second)/2);
	}
	printf("%lld\n",out);
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = list(map(int, input().split()))
    Ai = sum(A)
    B = list(map(int, input().split()))
    for i in range(n):
        b = B[i]
        if b > A[i]:
            b -= A[i]
            A[i] = 0
            if b > A[i + 1]:
                b -= A[i + 1]
                A[i + 1] = 0
            else:
                A[i + 1] -= b
        else:
            A[i] -= b
    Af = sum(A)
    print(Ai - Af)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t h, w; cin >> h >> w;
	if(h == 1 or w == 1) {
		cout << 1 << '\n';
		return 0;
	}
	cout << (h * w + 1) / 2 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <math.h>

#define REP(i, n) for (int i = 0; i < n; i++)

typedef int long long ill;
typedef int long il;

using namespace std;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a;
    cin>>a;
    if(a=="SAT"){
        cout<<"1\n";
    }else if(a=="FRI"){
        cout<<"2\n";
    }else if(a=="THU"){
        cout<<"3\n";
    }else if(a=="WED"){
        cout<<"4\n";
    }else if(a=="TUE"){
        cout<<"5\n";
    }else if(a=="MON"){
        cout<<"6\n";
    }else if(a=="SUN"){
        cout<<"7\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;

vector<vector<long>> stat(501, vector<long>(4, 0));
int main(){
    int n;
    cin >> n ;

    for(int i=0; i<n-1; i++){
        cin >> stat[i][0] >> stat[i][1] >> stat[i][2];
    }
    for(int i=0; i<n-1; i++){
        long cost=stat[i][0]+stat[i][1];
        for(int j=i+1; j<n-1; j++){
            //cout << i << ", " << j << ", " << stat[j][2] << endl;
            if( cost <= stat[j][1] ) cost = stat[j][1]+stat[j][0];
            else if ( cost%stat[j][2]==0 ) cost += stat[j][0];
            else cost += stat[j][2]-cost%stat[j][2] + stat[j][0];
        }
        cout << cost << endl;
    }
    cout << 0 << endl;
    return 0;
}



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

const int N = 500000;

int bit[N + 1][26], n;

int sum(int i, int j) {
  int s = 0;
  while (i > 0) {
    s += bit[i][j];
    i -= i & -i;
  }
  return s;
}

void add(int i, int j, int x) {
  while (i <= n) {
    bit[i][j] += x;
    i += i & -i;
  }
}

int main() {
  int q;
  string s;
  cin >> n >> s >> q;

  rep(i, n+1) rep(j, 26) bit[i][j] = 0;
  rep(i, n) {
    int j = (int)(s[i] - 'a');
    add(i+1, j, 1);
  }

  rep(qi, q) {
    int t;
    cin >> t;
    if (t == 1) {
      int i;
      char c;
      cin >> i >> c;
      int j0 = (int)(s[i-1] - 'a');
      int j1 = (int)(c - 'a');
      add(i, j0, -1);
      add(i, j1, 1);
      s[i-1] = c;
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      int ans = 0;
      rep(j, 26) if (sum(l, j) < sum(r, j)) ans++;
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 54700