akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(a: i64, b: i64, c: i64, x: i64);
    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if x == 500 * i + 100 * j + 50 * k {
                    ans += 1;
                }
            }
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    string s;
    cin >> s;
    
    string hi = "hi";
    string cur = hi;
    while(cur.length() <= 10) {
        if(cur == s) {
            printf("Yes\n");
            return 0;
        }
        cur += hi;
    }
    printf("No\n");

    return 0;
}



Measured memory_bytes: 256
n = int( raw_input() )
   
d = [ 0 for i in range(n) ]
f = [ 0 for i in range(n) ]
G = [ 0 for i in range(n) ]
v = [ [0 for i in range(n) ] for j in range(n) ]
st = [ 0 for i in range(n) ]
tm = [ 0 ]
   
def DFS_visit(s):
  st[ s ] = 1
  tm[ 0 ] += 1
  d[ s ] = tm[ 0 ]
  for e in range(n):
    if v[ s ][ e ] == 1 and st[ e ] == 0:
      DFS_visit(e)
  st[ s ] == 2
  tm[ 0 ] += 1
  f[ s ] = tm[ 0 ]
   
def DFS():
  for s in range(n):
    if st[ s ] == 0:
      DFS_visit(s)
  for s in range(n):
     print'{0} {1} {2}'.format( s+1 , d[ s ] , f[ s ] )
       
for i in range(n):
  G = map( int , raw_input().split() )
  for j in range( G[1] ):
    v[ G[0] -1 ][ G[ 2+j ] -1 ] = 1
   
DFS()

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

int main() {
  int n;
  cin>>n;
  if(n>=15000){
    int count=0;
    for(int i=0;i<=30000;i+=2){
      if(i%3!=0){
        cout<<i<<" ";
        count++;
      }
    }
    for(int i=1;i<=30000;i+=2){
      if(i%6==3){
        cout<<i<<" ";
        count++;
      }
    }
    for(int i=6;i<=30000;i+=2){
      if(count==n){
        break;
      }
      if(i%6==0){
        cout<<i<<" ";
        count++;
      }
    }
    return 0;
  }
  if(n>=6){
    cout<<"2 3 4 6 9 12 ";
    int count=6;
    if((n-6)%2==1){
      cout<<"30000 ";
      count++;
    }
    for(int i=13;i<=30000;i++){
      if(count==n){
        return 0;
      }
      if(i%6==2){
        cout<<i<<" "<<i+2<<" ";
        count+=2;
      }
    }
    for(int i=15;i<=30000;i++){
      if(count==n){
        return 0;
      }
      if(i%6==3){
        cout<<i<<" ";
        count++;
      }
    }
    for(int i=18;i<30000;i++){
      if(count==n){
        return 0;
      }
      if(i%6==0){
        cout<<i<<" ";
        count++;
      }
    }
    return 0;
  }
  if(n==5){
    cout<<"2 5 20 63 12600"<<endl;
  }
  if(n==4){
    cout<<"2 5 20 63"<<endl;
  }
  if(n==3){
    cout<<"2 5 63"<<endl;
  }
}

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

//////全探索したいときに開けよ////////
/*
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}
*/

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n;
  cin >> n;
  vector<pair<int64_t,int64_t>> xl(n);
  rep(i,n) cin >> xl.at(i).first >> xl.at(i).second;
  vector<pair<int64_t,int64_t>> lr(n);
  rep(i,n){
    lr.at(i).first = xl.at(i).first + xl.at(i).second;
    lr.at(i).second = xl.at(i).first - xl.at(i).second;
  }
  sort(lr.begin(),lr.end());
  int64_t yp = 0;
  int64_t pyp = 0;
  int64_t cnt = 1;
  while(true){
    yp++;
    if(yp >= n){
      break;
    }
    if(lr.at(yp).second >= lr.at(pyp).first){
      cnt++;
      pyp = yp;
    }
  }
  cout << cnt << endl;
}

    
    
  
  
  
    



Measured memory_bytes: 3328
s = input()
count = 0
first_half, second_half = s[:len(s)//2], s[(len(s)+1)//2:]
if first_half == reversed(second_half):
    print(count)
else:
    for x in range(len(first_half)):
        if first_half[x] != second_half[len(second_half)-x-1]:
            count += 1
    print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

template <class T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from = -1, int to = -1, T cost = 1) : from(from), to(to), cost(cost){};

    bool operator<(const Edge<T>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<T>& e) const { return this->cost > e.cost; }
};

template <class T = int>
class Graph {
public:
    explicit Graph(int N = 0) : size(N) { path.resize(size); }
    void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(u, v, cost)); }
    std::vector<Edge<T>> operator[](int v) const { return path[v]; }

    int size;
    std::vector<std::vector<Edge<T>>> path;
};

template <class Weight, class Data>
class ReRooting {
    using DataMerger = std::function<Data(Data, Data)>;
    using Promoter = std::function<Data(Data, Edge<Weight>)>;

public:
    Graph<Weight> tree;
    std::vector<Data> data;
    Data id;
    DataMerger merge;
    Promoter promote;

    ReRooting(const Graph<Weight>& tree, Data id, DataMerger merge, Promoter promote)
        : tree(tree), data(tree.size), id(id), merge(merge), promote(promote) {
        dfs(0);
        edfs(0);
    }

    // vを根とする部分木の解でdataを埋める
    Data dfs(int v, int r = -1) {
        data[v] = id;
        for (const auto& e : tree[v]) {
            if (e.to == r) continue;
            data[v] = merge(data[v], promote(dfs(e.to, v), e));
        }
        return data[v];
    }

    // vを根とする木の解を求める
    void edfs(int v, int r = -1, Data par_data = 0) {
        int cnum = tree[v].size();  // vから伸びる辺の数

        std::vector<std::pair<Data, int>> child;
        child.emplace_back(0, 0);  // index合わせ
        for (const auto& e : tree[v]) {
            if (e.to == r) {
                child.emplace_back(promote(par_data, e), e.to);
            } else {
                child.emplace_back(promote(data[e.to], e), e.to);
            }
        }

        std::vector<Data> lacc(cnum + 2), racc(cnum + 2);
        // 左から、右からの累積和
        lacc[0] = 0;
        for (int i = 1; i <= cnum; ++i) {
            lacc[i] = merge(lacc[i - 1], child[i].first);
        }
        racc[child.size()] = 0;
        for (int i = cnum; i >= 1; --i) {
            racc[i] = merge(racc[i + 1], child[i].first);
        }

        data[v] = lacc[cnum];  // 全体の累積和が答え

        for (int i = 1; i <= cnum; ++i) {
            if (child[i].second == r) continue;
            edfs(child[i].second, v, merge(lacc[i - 1], racc[i + 1]));
        }
    }
};

int main() {
    int N;
    std::cin >> N;
    Graph<int> tree(N);
    for (int i = 0; i < N - 1; ++i) {
        int u, v, w;
        std::cin >> u >> v >> w;
        tree.span(u, v, w);
        tree.span(v, u, w);
    }

    // Data    : 最も遠い頂点までの距離
    // Merger  : max (id = 0)
    // Promoter: + cost
    ReRooting<int, int> dp(tree, 0,
                           [](int a, int b) { return std::max(a, b); },
                           [](int a, const Edge<int>& e) { return a + e.cost; });
    for (auto d : dp.data) {
        std::cout << d << std::endl;
    }
    return 0;
}



Measured memory_bytes: 7324
#include "bits/stdc++.h"
using namespace std;
const int N=1e4+20;
int n,a[N],ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			auto k=lower_bound(a+j,a+n,a[i]+a[j])-a;
			k--;
			ans+=k-j;
		}
	}

	cout<<ans;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int ret = 0;
	for(int i=0; i < (N-2)%11; ++i){
		for(int j=0; j<5; ++j){
			if((i*8+j*9+4) % 11 == K){
				++ret;
			}
		}
	}
	ret += ((N-2) / 11) * 5;
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 123, K = 18, MOD = 1e9 + 7;
int n, up[K][N], in[N], out[N], T, h[N];
vector <int> g[N], lvl[N];

void dfs(int v, int p) {
	lvl[h[v]].pb(v);
	in[v] = ++T;
	up[0][v] = p;
	for (int i = 1; i < K; i++)
		up[i][v] = up[i - 1][up[i - 1][v]];
	for (int to : g[v]) {
		h[to] = h[v] + 1;
		dfs(to, v);
	}
	out[v] = T;
}

bool upper(int x, int y) {
	return in[x] <= in[y] && out[y] <= out[x];
}

int lca(int x, int y) {
	if (upper(x, y)) return x;
	if (upper(y, x)) return y;
	for (int i = K - 1; i >= 0; i--)
		if (!upper(up[i][x], y))
			x = up[i][x];
	return up[0][x];
}

bool cmp(const int & x, const int & y) {
	return in[x] < in[y];
}

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1)
			res = (ll)res * x % MOD;
		x = (ll)x * x % MOD;
		y /= 2;
	}
	return res;
}

void add(int & x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
}

struct VT {
	vector <int> g[N], v;
	int dp[2][N], sz[N];
	int root = 0;
	void build(vector <int> vec = {}) {
		if (vec.empty()) return;
		v = vec;
		sort(all(v), cmp);
		int n = v.size();
		for (int i = 0; i < n - 1; i++)
			v.pb(lca(v[i], v[i + 1]));
		sort(all(v), cmp);
		v.erase(unique(all(v)), v.end());
		n = v.size();
		vector <int> ch;
		ch.pb(v[0]);
		for (int i = 1; i < n; i++) {
			while ((int)ch.size() > 1 && !upper(ch.back(), v[i])) {
				g[ch[(int)ch.size() - 2]].pb(ch.back());
				ch.pop_back();
			}
			ch.pb(v[i]);
		}
		while ((int)ch.size() > 1) {
			g[ch[(int)ch.size() - 2]].pb(ch.back());
			ch.pop_back();
		}
		root = ch.back();
	}
	void clear() {
		for (int i : v)
			g[i].clear();
		root = 0;
	}
	void dfs(int v) {
		if (g[v].empty()) {
			dp[0][v] = dp[1][v] = 1;
			sz[v] = 1;
			return;
		}
		dp[1][v] = 0, sz[v] = 0;
		int res = 1;
		for (int to : g[v]) {
			dfs(to);
			sz[v] += sz[to];
			res = (ll)res * dp[0][to] % MOD;
		}
		for (int to : g[v])
			add(dp[1][v], ((ll)res * bp(dp[0][to], MOD - 2) % MOD) * dp[1][to] % MOD);
		dp[0][v] = (bp(2, sz[v]) - dp[1][v] + MOD) % MOD;
	}
};
VT cur;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		g[x].pb(i);
	}
	dfs(0, 0);
	int res = 0;
	for (int i = 0; i <= n; i++) {
		if (lvl[i].empty()) break;
		cur.build(lvl[i]);
		cur.dfs(cur.root);
		add(res, (ll)cur.dp[1][cur.root] * bp(2, n + 1 - (int)lvl[i].size()) % MOD);
		cur.clear();
	}
	cout << res;
}


Measured memory_bytes: 58252
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int n, a, b;
std::vector<int>h;

bool check(ll x)
{
     ll res = 0;
     for(int i=0; i<n; i++)
     {
          ll foo = (ll)h[i] - b*x;
          if (foo > 0) res+=ceil((double)foo/(a-b));
     }
     return res <= x;
}

int main() {
    
    cin>>n>>a>>b;
    h.resize(n);
    for(int i = 0; i < n; i++) cin>>h[i];
    
    ll lb = -1, ub = 1e9;
    while(ub-lb > 1)
    {
         ll mid = (lb+ub)/2;
         if (check(mid)) ub = mid;
         else lb = mid;
    }
    
    cout<<ub;
    
    return 0;
}

Measured memory_bytes: 768
#include <iostream> pre processor directive
#include <string>
#include <iomanip>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int r,D;
    long long X;
    cin>>r>>D>>X;
    for (int i=0;i<10;i++){
        X=(r*X)-D;
        cout<<X<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b) {
    if (a>b) return b;
    else return a;
}

int main(void) {
    int H, W, x, y, C[105][105], i, j;
    char S[105][105];
    scanf("%d%d", &H, &W);
    for (i=0; i<H; i++) scanf("%s", S[i]);
    for (i=0; i<H; i++) {
        for (j=0; j<W; j++) C[i][j]=0;
    }
    if (S[0][0]=='.') C[0][0]=0;
    else C[0][0]=1;
    for (i=1; i<H; i++) {
        if (S[i][0]=='#' && S[i-1][0]=='.') x=1;
        else x=0;
        C[i][0]=C[i-1][0]+x;
    }
    for (i=1; i<W; i++) {
        if (S[0][i]=='#' && S[0][i-1]=='.') x=1;
        else x=0;
        C[0][i]=C[0][i-1]+x;
    }
    for (i=1; i<H; i++) {
        for (j=1; j<W; j++) {
            if (S[i][j]=='#' && S[i-1][j]=='.') x=1;
            else x=0;
            if (S[i][j]=='#' && S[i][j-1]=='.') y=1;
            else y=0;
            C[i][j]=min(C[i-1][j]+x, C[i][j-1]+y);
        }
    }
    /*
    for (i=0; i<H; i++) {
        for (j=0; j<W; j++) {
            printf("%d ", C[i][j]);
        }
        printf("\n");
    }
    */
    printf("%d", C[H-1][W-1]);
    return 0;
}


Measured memory_bytes: 256
A,B = list(map(int,input().split()))
found = False
for i in range(1010):
    A_tax = int(i * 0.08)
    B_tax = int(i * 0.10)
    if A == A_tax and B == B_tax:
        print(i)
        found = True
        break
if not found:
    print("-1")

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    for (int i = k; i < n; i++)
    {
        if (s[i - k] < s[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch[200010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll sum[200010]={};
	for(ll i=0;i<n;i++){
		sum[i+1]=sum[i]+ch[i];
		sum[i+1]%=inf;
		//cout << sum[i+1]<<endl;
	}
	ll ans=0;
	for(ll i=1;i<n;i++){
		ll now=ch[i]*sum[i];
		now%=inf;
		ans+=now;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 6760
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  
  int n; cin >> n;
  std::vector<long long> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];
  std::sort(l.begin(), l.end()); 
  
  int ans = 0;
  for(int i = 0; i < n; i++)
  {
    for(int j = i+1; j < n; j++)
    {
      int k = std::distance(l.begin(),std::lower_bound(l.begin(), l.end(), l[i]+l[j]));
      
      ans += std::max(k-(j+1),0);
    }
  }
  std::cout << ans << std::endl;
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    // X以上のものだけを使ったときの個数がM以下か
    auto check = [&](ll X){
        ll cnt = 0;
        rep(i,N){
            int add = A.end() - lower_bound(all(A), X - A[i]);
            cnt += add;
        }
        return cnt <= M;
    };
    ll ng = 0;
    ll ok = INFLL;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    cerr << ng << " " << ok << endl;
    //累積和で高速化パート
    vec<ll> cum(N+1, 0);
    rep(i, N)cum[i+1] = cum[i] + A[i];
    //ok以上のものだけ使えばM個以内に収まる
    //ngを何個か入れることを考える
    //ngが入る余地があるときがある
    //ok以上でM以下だが、Mピッタリとは限らない
    //ngにすると超えるということである。
    //余りがあるはずなので、それを加えよう。
    ll ans = 0;
    rep(i,N){
        int idx = lower_bound(all(A), ok - A[i]) - A.begin();
        int cnt = N - idx;
        ans += cum[N] - cum[idx] + A[i] * cnt;
        M -= cnt;
    }
    ans += M * (ok - 1);
    cout << ans << endl;
}

Measured memory_bytes: 1920
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int hikaku = Integer.MAX_VALUE;
        List<Integer> point = new ArrayList<>();
        for(int i = 0;i < n;i++){
            point.add(sc.nextInt());
        }
        Collections.sort(point);

        for(int i = 1;i <= point.get(n-1);i++){
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21460
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

int numstone[151];
pair<int,int> stones[151][11];
int memo[151][151][11]; //memo[ツ甘敖つゥツづァツづ個仰猟猟」][ツ氾イツづ篠つオツ氾イツづ堕づーツつオツつスツ嘉アツ青脳[ツ債。ツづ個暗環置]
int n,m;

int solve(int i,int j,int k) {
  if(memo[i][j][k] != -1) return memo[i][j][k];
  if(i >= n-1 || (j < m && i == n-2)) return 0;

  int l,ret = 1<<29;
  if(j < m) {
    rep(l,numstone[i+2]) {
      int cc = stones[i][k].second+stones[i+2][l].second;
      ret = min(ret, solve(i+2, j+1, l)
		+ cc*abs(stones[i][k].first-stones[i+2][l].first));
    }
  }

  rep(l, numstone[i+1]) {
    int cc = stones[i][k].second+stones[i+1][l].second;
    ret = min(ret, solve(i+1, j, l)
	      + cc*abs(stones[i][k].first-stones[i+1][l].first));
  }
  //printf("row: %d double: %d nowpos: %d ret: %d\n", i,j,k,ret);
  return memo[i][j][k] = ret;
}

int main() {
  int k,i,j;
  while(scanf("%d%d", &n, &m), n|m) {
    memset(memo, -1, sizeof(memo));

    rep(i,151) rep(j,151) rep(k,11) memo[i][j][k] = -1;
    rep(i,n) {
      scanf("%d", &k);
      numstone[i] = k;
      rep(j,k) {
	pair<int,int> p;
	scanf("%d%d", &(p.first), &(p.second));
	stones[i][j] = p;
      }
    }

    int ans = 1<<29;
    rep(i, numstone[0]) {
      ans = min(ans, solve(0,0,i));
    }
    if(m >= 1) {
      rep(i, numstone[1]) {
	ans = min(ans, solve(1,1,i));
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 1764
#include <stdio.h>
#include <string.h>

const int inf=1<<30;
int memo[16][1<<16], t[17][17], n;

#define min(x, y) ((x)<(y)?(x):(y))

int func(int S, int k)
{
    int i, j, res=memo[k][S];
    if (S==(1<<n)-1) return 0;
    if (res) return res;

    res=inf;
    for(i=0;i<n;++i) if (!(S&(1<<i))) {
        int minT=t[i+1][0];
        for(j=0;j<n;++j) if (j!=i && (S&(1<<j))) minT=min(minT, t[i+1][j+1]);
        res=min(res, func(S|(1<<i), i)+minT);
    }
    return memo[k][S]=res;
}

int main(void)
{
    while (scanf("%d", &n), n) {
        int i, j, res;
        for(i=1;i<=n;++i) for(j=0;j<=n;++j) scanf("%d", &t[i][j]);
        res=inf;
        memset(memo, 0, sizeof(memo));
        res=min(res, func(0, 0));
        printf("%d\n", res);
    }
    return 0;
}

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

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, 0, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 1e18;
    rep(i, 0, n - k + 1){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  char key[] = {'R', 'G', 'B'};
  int S[4040];
  long long num[3][4040];
  for (int i = 0; i < 3; i ++) {
    for (int j = 0; j <= N; j ++) {
      num[i][j] = 0;
    }
  }
  for (int i = 0; i < N; i ++) {
    char c;
    cin >> c;
    for (int j = 0; j < 3; j ++) {
      if (i > 0) num[j][i] = num[j][i - 1];
      if (c == key[j]) {
        S[i] = j;
        num[j][i] ++;
      }
    }
  }
  //cout << num[0] << num[1] << num[2] << endl;
  long long ans = 0ll;
  for (int i = 2; i < N; i ++) {
    for (int j = 1; j < i; j ++) {
      if (S[i] != S[j]) {
        int kj = 3 - S[i] - S[j];
        long long ku = num[kj][j];
        int a = 2 * j - i;
        if (a >= 0 && a < N) {
          if (S[a] == kj) {
            ku --;
          }
        }
        ans += ku;
        //cout << ans << endl;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int N,a,b,c;
	std::cin >> N;
	while(std::cin >> a >> b >> c){
		std::vector<int> vec;
		vec.push_back(a);
		vec.push_back(b);
		vec.push_back(c);
		std::sort(vec.begin(), vec.end());
		if(vec.at(0) * vec.at(0) + vec.at(1) * vec.at(1) == vec.at(2) * vec.at(2))
			std::cout << "YES" <<std::endl;
		else
			std::cout << "NO" <<std::endl;
	}

	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, s, res = linf;

ll f(ll b, ll n) {
	if (n<b) return n;
	return f(b,n/b) + n%b;
}

int main() {
	cin >> n >> s;
	if (n==s) return cout << n+1, 0;
	for (ll b=2; b*b<=n; ++b) if (f(b,n)==s) return cout << b, 0;
	for (ll p=1; p*p<=n-s; ++p) {
		if ((n-s)%p) continue;
		ll b = (n-s)/p + 1;
		if (f(b,n)==s) chmin(res, b);
	}
	cout << (res==linf ? -1 : res);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

ll gcd(ll a, ll b) {
return b ? gcd(b, a%b) : a;
}

int main(){
    int x,y;
    cin >> x >> y;
    cout << gcd(x,y) << endl;
}


Measured memory_bytes: 3112
### coding: UTF-8
 
#import math
#import random as rd
#import numpy as np
 
 
n=int(input())
line=list(map(int,input().split( )))
 
line=sorted(line)
 
#print(line)
 
s=sum([line[-(i+1)] for i in range(n) if i%2==0])-sum([line[-(i+1)] for i in range(n) if i%2!=0])
 
print(s)
 

Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<random>
#include<bitset>
#include <queue>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;


const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//正剰余
long long mod(long long a, long long b)
{
    return a - (long long)std::floor((double)a / (double)b) * b;
}

int main() {
    COMinit();
    int n, k;
    cin >> n >> k;
    vector <ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        ret += (a[i] - a[n - 1 - i]) * COM(n - i - 1, k - 1);
        ret = mod(ret, MOD);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 24448
n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
if idx == 0:
    print(-(-len(a[(idx + 1):]) // (k - 1)))
elif idx == (n - 1):
    print(-(-len(a[:idx]) // (k - 1)))
else:
    print(-(-(n - 1) // (k - 1)))


Measured memory_bytes: 52476
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>


#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n)

using namespace std;

int main()
{
	string s;
	cin>>s;
	
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		if(i==3)cout<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc122/tasks/abc122_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

string S;

int main() {
    
    cin >> S;

    int counter = 0;
    int ans = 0;
    for(int i=0; i<S.size();i++) {
        if(S[i]=='A' || S[i]=='C' || S[i]=='T' || S[i]=='G') {
            counter++;
        } else {
            counter = 0;
        }
        ans = max(ans, counter);
    }
    cout << ans << endl;
    return 0;
}


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


int time_count(int x) {
  int re = 1;
  while (x) {
    int y = x;
    int cnt_one = 0;
    while (y) {
      if (y % 2) cnt_one++;
      y = y >> 1;
    }
    x %= cnt_one;
    re++;
  }
  return re;
}

int MOD(int base, int mod) {
  if (base < 0) {
    for (int i = 1; ; i++) {
      base += i * mod;
      if (base >= 0) {
        break;
      }
    }
  }
  return base % mod;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  assert((int) s.size() == n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') cnt++;
  }
  if (cnt == 0) {
    for (int i = 0; i < n; i++) {
      cout << 1 << '\n';
    }
    return 0;
  }
  if (cnt == 1) {
    if (s[n - 1] == '1') {
      for (int i = 0; i < n - 1; i++) {
        cout << 2 << '\n';
      }
      cout << 0 << '\n';
    } else {
      for (int i = 0; i < n - 1; i++) {
        if (s[i] == '1') {
          cout << 0 << '\n';
        } else  {
          cout << 1 << '\n';
        }
      }
      cout << 2 << '\n';
    }
    return 0;
  }
  int ans1 = 0;
  for (int i = 0; i < n; i++) {
    ans1 *= 2;
    ans1 += s[i] - '0';
    ans1 %= cnt - 1;
  }
  int ans2 = 0;
  for (int i = 0; i < n; i++) {
    ans2 *= 2;
    ans2 += s[i] - '0';
    ans2 %= cnt + 1;
  }
  vector<int> va(n, 0);
  va[n - 1] = 1 % (cnt - 1);
  for (int i = n - 1; i >= 1; i--) {
    va[i - 1] = va[i] * 2 % (cnt - 1);
  } 
  vector<int> vb(n, 0);
  vb[n - 1] = 1 % (cnt + 1);
  for (int i = n - 1; i >= 1; i--) {
    vb[i - 1] = vb[i] * 2 % (cnt + 1);
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      ans[i] = time_count(MOD(ans1 - va[i], cnt - 1));
    } else {
      ans[i] = time_count(MOD(ans2 + vb[i], cnt + 1));
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 5932
#include <stdio.h>

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

    if (N%10 == 7)
    {
        printf("Yes");
    }

    else if ((N/10)%10 == 7)
    {
        printf("Yes");
    }

    else if ((N/100)%10 == 7)
    {
        printf("Yes");
    }

    else
    {
        printf("No");
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll X, K, D;
    cin>>X>>K>>D;
    ll mi=(X%D+D)%D;
    //cout<<mi<<endl;
    ll kai=(X-mi)/D;
    //cout<<abs(kai)<<endl;
    if(abs(kai)>K){
        if(X>0) cout<<abs(X-K*D)<<endl;
        else cout<<abs(X+K*D)<<endl;
    }
    else{
        //cout<<"#$"<<endl;
        if(abs(kai)%2==K%2) cout<<mi<<endl;
        else cout<<D-mi<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  int col[9]={};
  for(int i=0,a;i<n;++i){
    cin>>a;
    if(a<3200) col[a/400]++;
    else col[8]++;
  }
  int maxn=0, minn=0;
  for(int i=0;i<8;++i)
    if(col[i]) minn++;
  maxn = minn;
  maxn += col[8];
  cout<<max(minn,1)<<" "<<maxn<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k,s;cin>>n>>k>>s;
    ll ans[n];
    
    if(s<1000000000){
        rep(i,0,k)ans[i]=s;
        rep(i,k,n)ans[i]=s+1;
        rep(i,0,n)cout<<ans[i]<<" ";
        cout<<endl;
    }
    else{
        rep(i,0,k)cout<<1000000000<<" ";
        rep(i,k,n)cout<<1<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf = (ll) 1e9;

int main(){
  ll s; cin >> s;
  if(s%inf)
    cout << 0 << ' ' << 0 << ' ' << inf << ' ' << 1 << ' '
      << inf - (s%inf) << ' ' << s/inf + 1;
  else
    cout << 0 << ' ' << 0 << ' ' << inf << ' ' << 1 << ' '
      << 0 << ' ' << s/inf;
}

Measured memory_bytes: 256
S = input()
N = len(S)
MOD = 10 ** 9 + 7

# dp[i][j] := i文字目までみた時に13で割ってj余るような数の通り数
dp = [[0] * 13 for i in range(N + 1)]
dp[0][0] = 1

for i, s in enumerate(S):
    for j in range(13):
        if s != '?':
            dp[i + 1][((j * 10) + int(s)) % 13] += dp[i][j]
            dp[i + 1][((j * 10) + int(s)) % 13] %= MOD
        else:
            for k in range(10):
                dp[i + 1][((j * 10) + k) % 13] += dp[i][j]
                dp[i + 1][((j * 10) + k) % 13] %= MOD

print(dp[-1][5] % MOD)


Measured memory_bytes: 64036
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

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

  if(a == b && b == c && c == a) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int main(){
  
  int n;
  cin >> n;
  
  vector<int> sticks(n);
  
  for(int i=0; i<n; i++){
    cin >> sticks.at(i);
  }
  
  sort(sticks.begin(),sticks.end());
  
  int answer = 0;
  
  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if(sticks.at(k) < sticks.at(i) + sticks.at(j)){
          answer += 1;
        }
      }
    }
  }
  
  cout << answer << endl;
  
}

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

typedef long long int ll;

vector <ll> h;
vector <ll> dp(100005);

bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

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

    ll i,j,k,l,m,n;

    cin >> n >> m;

    for(i=0;i<n;i++)
    {
        cin >> k;

        h.push_back(k);
    }

    if(n==2)
    {
        cout << abs(h[0]-h[1]) << '\n';
        return 0;
    }

    dp[1] = abs(h[0]-h[1]);

    // cout << dp[0] << '\n';
    // cout << dp[1] << '\n';
    ll maximum = 1000000000;
    for(i=2;i<n;i++)
    {
        maximum = 1000000000;

        // dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        for(j=1;j<=m && (i-j)>=0;j++)
        {
            maximum = min(maximum,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i] = maximum;
        // cout << dp[i] << '\n';
    }

    cout << dp[n-1] << '\n';





}

Measured memory_bytes: 2168
a,b,c,d = gets.split.map(&:to_i)
arry = Array.new(101,0)
arry[a] += 1
arry[b] -= 1
arry[c] += 1
arry[d] -= 1
(0 .. 100).inject(0) do |s,i|
    arry[i] = s + arry[i]
end
puts arry.count(2)

Measured memory_bytes: 1788
#include <stdio.h>

int main(void)
{
  int n, sum, min;
  int x[100];

  scanf("%d", &n);  
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);

  min = n * 100 * 100;

  for (int i = 1; i <= 100; i++){
    sum = 0;
    for (int j = 0; j < n; j++) sum += (x[j] - i) * (x[j] - i);
    if (min > sum) min = sum;
  }

  printf("%d", min);

  return 0;
}

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

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		TreeSet<Integer> set=new TreeSet();
		while(n-->0)
			set.add(sc.nextInt());
		System.out.println(set.size());
	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
}


Measured memory_bytes: 20948
def counter(x):
    if x==0:
        return 0
    return counter(x >> 1) + (x & 1)
N=int(input())
A=[[]]
X=[[]]
Y=[[]]
for i in range(1,N+1):
    a=int(input())
    A.append(a)
    x=[[]]
    y=[[]]
    for j in range(a):
        b=list(map(int,input().split()))
        x.append(b[0])
        y.append(b[1])
    X.append(x)
    Y.append(y)
ans=0
for bits in range(1 << N):
    #print(bin(bits))
    ok=True
    for i in range(1,N+1):
        if not (bits & (1<<i-1)):
            continue
        for j in range(1,A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]):
                ok = False
        
    if ok:
#        print(ok,bin(bits))
        ans = max(ans, counter(bits))
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		char[] bus = scan.nextLine().toCharArray();
		if(bus[0] == bus[1] && bus[1] == bus[2]) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

using namespace std;

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

	string str;
	cin>>str;

	char ch=str.back();
	if(ch=='2' || ch=='4' || ch=='5' || ch=='7' || ch=='9')
		cout<<"hon\n";
	else if(ch=='0' || ch=='1' || ch=='6' || ch=='8')
		cout<<"pon\n";
	else
		cout<<"bon\n";
}


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

int main(){
    int n, w, h;
    cin >> n >> w >> h;

    int width[w+1], height[h+1];
    memset(height, 0, sizeof(height));
    memset(width, 0, sizeof(width));

    int x, y, a;
    for(int i = 0; i < n; i++){
        cin >> x >> y >> a;
        width[max(0, x-a)]++;
        width[min(w, x+a)]--;
        height[max(0, y-a)]++;
        height[min(h, y+a)]--;
    }

    bool judgew = true, judgeh = true;
    
    int acc = 0;
    for(int i = 0; i < w; i++){
        acc += width[i];
        if(acc <= 0)    judgew = false;
    }

    acc = 0;
    for(int i = 0; i < h; i++){
        acc += height[i];
        if(acc <= 0)    judgeh = false;
    }

    if(judgew || judgeh)    cout << "Yes" << endl;
    else                    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3884
S=int(input())
a=S//100
b=S%100
if 0<a<13 and 0<b<13:
    print('AMBIGUOUS')
elif 0<a<13 and 12<b<100:
    print("MMYY")
elif 12<a<100 and 0<b<13:
    print("YYMM")
elif 0<a<13 and b==0:
    print('MMYY')
elif a==0 and 0<b<13:
    print("YYMM")
else:
    print("NA")

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

int main(){
  int n;
  cin >> n;
  int a[n];
  int ans=0;
  for(int i=0;i<n;i++) cin >> a[i];
  
  for(int i=0;i<n;i++){
    int num=1;
    while(a[i]==a[i+num]){
    	num++;
    }
    ans+=num/2;
    i+=num-1;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256