akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def prime_factorize(n):
    f = defaultdict(lambda: 0)
    f[2] = len(bin(n & -n)) - 3
    i = 3
    k = n >> f[2]
    while k > 1:
        while True:
            d, m = divmod(k, i)
            if m == 0:
                f[i] += 1
                k = d
            else:
                break
        i += 2
    return f


MOD = 1000000007
n, m = map(int, input().split())
pf = prime_factorize(m)
mx = max(pf.values())
f, r = prepare(n + mx, MOD)
ans = 1
for p, e in pf.items():
    ans *= f[n + e - 1] * r[n - 1]
    ans %= MOD
    ans *= r[e]
    ans %= MOD
print(ans)


Measured memory_bytes: 46320
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int bit_count(int n){
    int count = 0;
    while(n > 0){
        if(n&1) count++;
        n >>= 1;
    }
    return count;
}

int main(){
    int n, i, j, k, a, x, y, flag, res = 0;
    cin >> n;
    int b[n][n] = {};
    for(i=0; i<n; i++){
        cin >> a;
        for(j=0; j<a; j++){
            cin >> x >> y;
            if(y == 1){
                b[i][x-1] = 1;
            }else{
                b[i][x-1] = -1;
            }
        }
    }
    for(i=1; i<(1<<n); i++){
        flag = 1;
        for(j=0; j<n; j++){
            if(i & (1 << j)){
                for(k=0; k<n; k++){
                    if(b[j][k] == 1){
                        if((~i) & (1 << k)) flag = 0;
                    }else if(b[j][k] == -1){
                        if(i & (1 << k)) flag = 0;
                    }
                }
            }
        }
        if(flag) res = max(res, bit_count(i));
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
a = int(input())
s = list(map(int,input().split()))
T = [i for i in range(1,a)]
result = []
for i in T:
    s_1 = s[0:i+1]
    s_2 = s[i+1:]
    s_1_sum = 0
    s_2_sum = 0
    for i in range(len(s_1)):
        s_1_sum += s_1[i]
    for j in range(len(s_2)):
        s_2_sum += s_2[j]
    if s_1 == [] or s_2 == []:
        pass
    else:
        result.append(abs(s_1_sum - s_2_sum))
print(min(result))

Measured memory_bytes: 3064
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;  
/*  
    time : 10 : 14    
    date : 24.02.2020
*/   
// int L,R,mid,target,idx ;
int tests() 
{
    int i ; 
    int c= 0,n ;
    cin >> n ; 
    vector <int> d(n) ;
    for(auto &it :d)
        cin >> it ; 
    int j = 0 ; 
    sort(all(d));  
            
    cout << d[n/2]-d[n/2-1] << '\n' ;     
    return 0;
}
int main(){
    I__O ;  
    int cases = 1 ; 
    //cin >> cases;  
    while(cases--)
      tests(); 
  return 0 ; 
}

Measured memory_bytes: 640
def floor_sum(n,m,a,b):  # sum([(a*i+b)//m for i in range(n)])
    res = 0
    res += (a//m)*n*(n-1)//2 + (b//m)*n
    a %= m
    b %= m
    y_max = (a*n+b)//m
    if y_max == 0:
        return res
    x_max = m*y_max-b
    res += (n+(-x_max)//a)*y_max
    res += floor_sum(y_max,a,m,(x_max+a-1)//a*a-x_max)
    return res

import sys
input = sys.stdin.readline
t=int(input())
for i in range(t):
    n,m,a,b=map(int, input().split())
    print(floor_sum(n,m,a,b))

Measured memory_bytes: 78480
N = int(input())

n1 = 8*N+1
a = int(n1**0.5)

if N==1:
    print("Yes")
    print(2)
    print(1, 1)
    print(1, 1)
elif n1==a**2:
    n = (-3+a)//2
    d = [[0]*(n+1) for _ in range(n+2)]
    d[0][0] = 1
    d[0][1] = 2
    d[1][0] = 2
    d[1][1] = 3
    d[2][0] = 3
    d[2][1] = 1
    for i in range(1, n):
        v = 4+((i-1)*(i+4)//2)
        c = 2+i

        for j in range(c):
            d[c][j] = v+j
            d[j][c-1] = v+j

    print("Yes")
    print(n+2)
    for i in range(n+2):
        print(n+1, *d[i], sep=" ")
else:
    print("No")

Measured memory_bytes: 12376
a,b,c=sorted(map(int,input().split()))
count=0
A,B=(c-a)//2,(c-b)//2
a+=A*2
b+=B*2
count+=A+B
if a==b==c:
    print(count)
elif a==b:
    print(count+1)
else:
    print(count+2)

Measured memory_bytes: 3064
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var h = o.l();
  if(n <= k + 1)return Math.abs(h[n-1] - h[0]);
  var dp = [0];
  for(var i = 1; i <= k; i++)dp[i] = Math.abs(h[i] - h[0]);
  for(i = k+1; i < n; i++){
    var t = 9e99;
    for(var j = 1; j <= k; j++){
      var t2 = dp[i-j] + Math.abs(h[i] - h[i-j]);
      if(t > t2)t = t2;
    }
    dp[i] = t;
  }
  return dp[n-1];
}

Measured memory_bytes: 27724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

using vec = vector<ll>;
using mat = vector<vec>;

mat mat_mul(mat A, mat B){
    //A(l×m行列)、 B(m×n行列)
    int l = sz(A), m = sz(B), n = sz(B[0]);
    //C(l×n行列)
    mat C(l, vec(n, 0));
    rep(i, l){
        rep(k, m){
            rep(j, n){
                C[i][j] += A[i][k]*B[k][j];
                C[i][j] %= MOD;
            }
        }
    }
    return C;
}

mat mat_pow(mat A, ll k){
    //A(n次正方行列)
    int n = sz(A);
    //B(n次正方行列)
    mat B(n, vec(n, 0));
    rep(i, n) B[i][i] = 1;
    while(k > 0){
        if(k%2) B = mat_mul(B, A);
        A = mat_mul(A, A);
        k /= 2;
    }
    return B;
}

using vec2 = vector<ld>;
using mat2 = vector<vec2>;

//AをO(m*n^2)で行標準化し、rankを出力する
int standard_mat(mat2 &A){
    int m = sz(A), n = sz(A[0]);
    //今どの行を埋めていきたいか
    int now = 0, ret = 0;
    rep(j, n){
        int pivot = now;
        rep2(i, now, m-1){
            if(abs(A[i][j]) > abs(A[pivot][j])) pivot = i;
        }
        swap(A[now], A[pivot]);
        if(abs(A[now][j]) < EPS) continue;
        ret++;
        rep2(k, j+1, n-1) A[now][k] /= A[now][j];
        A[now][j] = 1;
        rep(i, m){
            if(i == now) continue;
            rep2(k, j+1, n-1) A[i][k] -= A[i][j]*A[now][k];
            A[i][j] = 0;
        }
        now++;
        if(now == m) break;
    }
    return ret;
}

//n元連立一次方程式Ax=bをO(n^3)で解く(解がないまたは一意に定まらない場合は空の配列を出力)
vec2 gausiann_elimination(mat2 A, vec2 b){
    int n = sz(A);
    mat2 B(n, vec2(n+1));
    rep(i, n){
        rep(j, n) B[i][j] = A[i][j];
        B[i][n] = b[i];
    }
    standard_mat(B);
    vec2 x(n);
    rep(i, n){
        if(abs(B[i][i]) < EPS) return vec2(0);
        x[i] = B[i][n];
    }
    return x;
}

int main(){
    int N; ll K;
    cin >> N >> K;
    mat A(N, vec(N));
    rep(i, N) rep(j, N) cin >> A[i][j];
    A = mat_pow(A, K);
    ll ans = 0;
    rep(i, N) rep(j, N) ans += A[i][j], ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
      string s,t; int ct=9999;
      cin>>s>>t;
      int l=t.length();

       for(int i=0;i<s.length()-l+1;i++){
              int j=i,min=0;

            for(int k=0;k<l;k++){
                  if(s[j]!=t[k]) min++;
                  j++;

            }

               if(ct>min)ct=min;


       }


       cout<<ct<<endl;

}


Measured memory_bytes: 3644
use std::io;
use std::str::FromStr;

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let mut n = input_vec();
    n.sort();
    println!("{}", n[2] * 10 + n[1] + n[0]);
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll x;

int main(){
FLASH;
cin>>x;
cout<<1-x<<endl;






return 0;
} 


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

int main () {
  LL N;
  cin >> N;
  string str;
  for (int i = 0; i < 100; i++) {
    N -= 1;
    str += (char)(N%26 + 97);
    N /= 26;
    if (N == 0)
      break;
  }
  
  for (int i = 1; i <= str.size(); i++)
    cout << str.at(str.size()-i);
    
  cout << endl;
}


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

const ll INF = 1e15;
vector<pll> g[1010];

//return: pair< min_cost, max_path >
pll rec(int v, int prv, ll cost){
  pll res = pll(cost,0);

  bool f = false;
  rep(i,g[v].size()){
    int d = g[v][i].fs, to = g[v][i].sc;
    if(to == prv)continue;

    f = true;
    pll tmp = rec(to,v,d);
    res.fs += tmp.fs;
    res.sc = max(res.sc, tmp.sc);
  }

  if(!f)return res;
  return pll(res.fs + 2*cost, res.sc+cost);
}

int main(){
  int n;
  while(cin >> n, n){
    vector<int> p(n-1),d(n-1);
    rep(i,n-1)cin >> p[i];
    rep(i,n-1)cin >> d[i];

    rep(i,n)g[i].clear();

    rep(i,n-1){
      g[i+1].push_back(pll(d[i],p[i]-1));
      g[p[i]-1].push_back(pll(d[i],i+1));
    }

    ll ans = INF;
    rep(i,n){
      pll tmp = rec(i,-1,0);
      ans = min(ans, tmp.fs - tmp.sc);
    }
    cout << ans << endl;
  }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e13 + 5);

ll n;

int main(void) {
  // Here your code !
  scanf("%lld", &n);

  ll ans = INF;

  for (ll i = 1L; i * i <= n; ++i) {
    if (n % i != 0) continue;

    ll other = n / i;

    ans = min(ans, i - 1 + other - 1);
  }
  
  printf("%lld\n", ans);

  return 0;
}


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

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    string s, t;
    cin >> s >> t;

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

    string u;
    cin >> u;

    if(s == u){
        cout << a - 1 << " " << b << endl;
    }else{
        cout << a << " " << b - 1 << endl;
    }

    return 0;
}


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

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;

int q(vector<vector<int>>& values)
{
    auto A = values[1][0];
    auto B = values[1][1];
    auto Ps = values[2];

    vector<int> q_count(3);
    for (auto P : Ps) {
        if (P <= A) {++q_count[0];} 
        else if (P <= B) {++q_count[1];} 
        else {++q_count[2];}
    }

    return *min_element(q_count.begin(), q_count.end());
}

int main(int argc, char* argv[])
{
  	int N, A, B;
  	cin >> N >> A >> B;
  	
    int P;	
    vector<int> q_count(3, 0);
    for (int i = 0; i < N; ++i) {
      	cin >> P;
        if (P <= A) {++q_count[0];} 
        else if (P <= B) {++q_count[1];} 
        else {++q_count[2];}
    }

    cout << *min_element(q_count.begin(), q_count.end()) << endl;

  	return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
//typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (s.back() == '1') {
        cout << -1 << endl;
        ret();
    }
    if (s.front() == '0') {
        cout << -1 << endl;
        ret();
    }
    for (int i = 1; i <= n - 1; i++) {
        if (s[i - 1] != s[n - 1 - i]) {
            cout << -1 << endl;
            ret();
        }
    }

    s[n - 1] = '1';
    int pre = n;
    for (int i = n - 1; i >= 1; i--) {
        cout << i << ' ' << pre << ' ' << endl;
        if (s[i - 1] == '1') pre = i;
    }

}


Measured memory_bytes: 1792
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp(" %s = %s\n", #x, to_string(x).data())
/* ==================== */ 
ll Mod = (ll)1e9 + 7;
const int N = 100010;
ll fact[N], n, m;

ll solve() {
	if (abs(n - m) > 1) return 0;
	if (n == m) return (fact[n] * fact[m] * 2) % Mod;
	return (fact[n] * fact[m]) % Mod;
}

int main() {
	fact[0] = 1;
	for (int i = 1; i < N; i++)
		fact[i] = (i * fact[i - 1]) % Mod;
	scanf("%lld%lld", &n, &m);
	printf("%lld\n", solve());
}


Measured memory_bytes: 1024
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    zeros = []
    incs = []
    decs = []
    s = [None] * N

    for i in range(N):
        s[i] = S()
        cur = 0
        mn = 0
        for c in s[i]:
            if c == '(':
                cur += 1
            else:
                cur -= 1
            mn = min(mn, cur)
        end = cur

        if end == 0:
            zeros.append((mn, end, i))
        elif end > 0:
            incs.append((mn, end, i))
            # heappush(incs, (-mn, end))
        else:
            decs.append((mn - end, end, i))
            # heappush(decs, (mn, end))

    incs.sort(reverse=True)
    decs.sort()

    ans = []
    for mn, end, idx in incs:
        ans.append(s[idx])

    for mn, end, idx in zeros:
        ans.append(s[idx])

    for mn, end, idx in decs:
        ans.append(s[idx])

    now = 0
    for i in range(len(ans)):
        for c in ans[i]:
            if c == '(':
                now += 1
            else:
                now -= 1
            if now < 0:
                print("No")
                return

    print(yn[now == 0])

    # now = 0
    # for mn, end, idx in incs:
    #     if now + mn < 0:
    #         print('No')
    #         return
    #     now += end

    # for mn, end, idx in zeros:
    #     if now + mn < 0:
    #         print('No')
    #         return
    #     now += end

    # for mn, end, idx in decs:
    #     if now + mn < 0:
    #         print('No')
    #         return
    #     now += end

    # print(yn[now == 0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 332584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;
}

int main()
{
    ll n,w; cin >> n >> w;
    vector<ll> weight(n),value(n);
    for(int i=0;i<n;i++)cin >> weight[i] >> value[i];

    //dp[価値][種類]を達成する重さの最小値
    vector<vector<ll> > dp(100010,vector<ll>(n+1,INF));
    dp[0][0]=0;
    for(int i=0;i<=100000;i++){
        for(int j=1;j<=n;j++){
            if(i - value[j-1] >= 0)
                chmin(dp[i][j],dp[i-value[j-1]][j-1]+weight[j-1]);
            chmin(dp[i][j],dp[i][j-1]);
        }
    }
    ll res = 0;
    for(int i=0;i<=100000;i++){
        if(dp[i][n] <= w)
            res = i;
    }
    cout << res << endl;
}
    

Measured memory_bytes: 82432
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 2005;
vector<int> a;
int n,k;

int count(long double x){
	int cnt = 0;
	rep(i,n){
		if(a[i] * a[i] <= x)	cnt--;

		if(a[i] == 0 && x >= 0)	cnt += n;
		else if(a[i] < 0){
			cnt += n - (lower_bound(a.begin(), a.end(), x / a[i]) - a.begin());
		}
		else if(a[i] > 0){
			int pos = upper_bound(a.begin(), a.end(), x / a[i]) - a.begin();
			cnt += pos;
		}
		// cout << cnt << ' ';
	}
	// cout << endl << x << ' ' << cnt << endl;

	return cnt / 2;
}

signed main(){
	IOS
	cin >> n >> k;
	rep(i,n){
		int b;	cin >> b;
		a.pb(b);
	}
	sort(a.begin(), a.end());
	int l = -1e18+7, r = 1e18+7;
	while(r-l > 1){
		int mid = (l+r) / 2;
		if(count(mid) < k)	l = mid;
		else		r = mid;
	}
	cout << r << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vvi;
typedef vector <ll> vl;
typedef vector <vector <ll>> vvl;
typedef vector <bool> vb;
typedef vector <vector <bool>> vvb;

//const int kINF = INT_MAX;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

template <typename type>
ostream &operator<<(ostream &out, const vector <type> &massive) {
    for (const type &i : massive) {
        out << i << ' ';
    }
    return out;
}

template <typename type>
void print(const vector <type> &massive, const string &sep, const string &end) {
    if (!massive.empty()) {
        cout << massive[0];
        for (int i = 1; i < massive.size(); ++i) {
            cout << sep << massive[i];
        }
    }
    cout << end;
}

template <typename type>
void print(const vector <type> &massive) {
    print(massive, " ", "\n");
}

template <typename type>
void print(const type &element, const string &end) {
    cout << element << end;
}

template <typename type>
void print(const type &element) {
    print(element, "\n");
}

int main() {
    fast();

    //freopen("../input.txt", "r", stdin);

    int x;
    cin >> x;
    cout << 8 - ((x - 400) / 200);


    return 0;
}


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

using namespace std;

typedef long long ll;

void solve(){
    int n;
    cin >> n;
    cout << (n * (n + 1)) / 2 << "\n";
 }

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
ml = len(bin(max(a)))-2
ans = 0
for i in range(ml):
  x = sum([1 for j in a if ((j>>i) & 1)])
  ans += x*(n-x)*(2**i)
  ans %= mod
print(ans)

Measured memory_bytes: 42156
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        int sum = a1 + a2 + a3;
        String res = "win";
        if(sum>21){
            res = "bust";
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 22228
fun c111(args: Array<String>) {
    val numList = args[1].split(" ").map { it.toInt() }
    val firstList = numList.filterIndexed { index, num -> index % 2 == 0 }
    val secondList = numList.filterIndexed { index, num -> index % 2 == 1 }

    var firstMap = mutableMapOf(0 to 0)
    firstList.forEach {
        if (!firstMap.containsKey(it)) {
            firstMap.put(it, 0)
        }
        firstMap.put(it, firstMap[it]!! + 1)
    }

    var secondMap = mutableMapOf(0 to 0)
    secondList.forEach {
        if (!secondMap.containsKey(it)) {
            secondMap.put(it, 0)
        }
        secondMap.put(it, secondMap[it]!! + 1)
    }

    val sortedFirstMap = firstMap.entries.sortedByDescending { it -> it.value }
    val sortedSecondMap = secondMap.entries.sortedByDescending { it -> it.value }

    if (sortedFirstMap[0].key != sortedSecondMap[0].key) {
        println((firstList.size - sortedFirstMap[0].value) + (secondList.size - sortedSecondMap[0].value))
    } else {
        val res = Math.min(
                ((firstList.size - sortedFirstMap[1].value) + (secondList.size - sortedSecondMap[0].value)),
                ((firstList.size - sortedFirstMap[0].value) + (secondList.size - sortedSecondMap[1].value))
        )
        println(res)
    }

}

fun main(args: Array<String>) {
    c111(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 61656
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<cstdint>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
int main(){
      ll N;
      cin>>N;
      ll A[N];
      rep0(i,N)cin>>A[i];
      sort(A,A+N);
      ll cnt=1;
      ll S=A[0];
      rep0(i,N-1){
            if(2*S>=A[i+1]){
                  cnt++;
            }
            else{
                  cnt=1;
            }
            S+=A[i+1];
      }
      cout<<cnt<<endl;


      return 0;
}

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

using namespace std;

bool check(const vector<string>& v) {
  vector<string> before;
  int i = 0;
  for (auto s : v) {
    for (auto b : before) {
      if (b == s) return false;
    }
    if (i > 0) {
      string bSay = before.at(i - 1);
      if (bSay[bSay.length() - 1] != s[0]) return false;
    }
    before.push_back(s);
    i++;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  cout << (check(v) ? "Yes" : "No") << endl;

  return 0;
}

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

int A, B, C, D, L, R;
int main()
{
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R)
  {
    cout << "Left" << endl;
  }
  else if (L < R){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;

  cin >> n >> a >> b;

  cout << min(a * n, b);

}



Measured memory_bytes: 256
dat = [0] * 400000
m = 0

def init():
    global dat, m
    for i in range(2 * m - 1):
        dat[i] = 0

def add(i, x):
    global dat, m
    i += m - 1
    dat[i] += x
    while i > 0:
        i = (i - 1) // 2
        dat[i] = dat[2 * i + 1] + dat[2 * i + 2]

def getSum(a, b, k, l, r):
    global dat, m
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return dat[k]
    else:
        vl = getSum(a, b, 2 * k + 1, l, (l + r) // 2)
        vr = getSum(a, b, 2 * k + 2, (l + r) // 2, r)
        return vl + vr

n, q = map(int, input().split())
m = 1
while m < n:
    m *= 2

for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        add(x - 1, y)
    else:
        print(getSum(x - 1, y, 0, 0, m))


Measured memory_bytes: 11816
#include <iostream>

using namespace std;


int main()
{
    int n;
    cin >> n;
    n = n % 10;
    if( n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ){
        cout << "hon";
    }
    else if( n == 3 ){
        cout << "bon";
    }
    else{
        cout << "pon";
    }
}

Measured memory_bytes: 3624
p = 10**9 + 7

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

ok = [True]*(N+1)
for i in range(M):
  a = int(input())
  ok[a] = False
  
dp = [0]*(N+1)
dp[0] = 1

for i in range(N):
  for j in range(i+1,min(N,i+2)+1):
    if ok[j]:
      dp[j] += dp[i]
      dp[j] %= p
      
print(dp[N]%p)

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m,k;
	cin >>n >>m >>k;
	
	if(k > n*m){ puts("No"); return 0;}
	if(n<m) swap(n,m);
	vector<bool> s(n*m+5,false);
	rep(i,n) s[m*i]  =true;
	rep(i,m) s[n*i]  =true;
	
	rep(i,n) rep(j,m){
		s[i*j + (n-i)*(m-j)] =true;
		s[(n-i)*j + i*(m-j)] =true;
	}
	cout << (s[k]? "Yes":"No") <<endl;
	
	return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	for(int i=s.size()-t.size();i>=0;i--){
		bool ok=true;
		for(int j=0;j<t.size();j++){
			if(s[i+j]!='?'&&t[j]!=s[i+j]){
				ok=false;
			}
		}
		if(ok){
			for(int j=0;j<s.size();j++){
				if(i<=j&&j<i+t.size())cout<<t[j-i];
				else if(s[j]=='?')cout<<'a';
				else cout<<s[j];
			}
			cout<<endl;
			return 0;
		}
	}
	cout<<"UNRESTORABLE"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD1		1000000007
#define MOD2		998244353
#define BOOST		ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

ll n;
ll MAX = 4500000000;
set<ll> s;

void backtrack(ll no)
{
    if(s.find(no) != s.end())
        return;
    if(no >= MAX)
        return;
    s.insert(no);
    if(no == 0)
    {
        for(int i = 1; i <= 9; i++)
            backtrack(i);
    }
    else
    {
        int lst = no % 10;
        if(lst > 0)
            backtrack(no*10 + lst-1);
        backtrack(no*10 + lst);
        if(lst < 9)
            backtrack(no*10 + lst+1);
    }
}

void solve()
{
   cin >> n;
   backtrack(0);

   ll ind = 0;
   while(ind < n)
   {
        s.erase(*s.begin());
        ind++;
   }
   cout << *s.begin();
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    ll t = 1;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int N, A, B, C;
vector<int> l(10), id(10);
int min_mp(vector<int> id, int left) {
    if (left == N) {
        int mp = 0;
        int a, b, c, ac, bc, cc;
        a = b = c = ac = bc = cc = 0;
        REP(i, N) {
            if (id[i] == 1) {
                a += l[i];
                ac++;
                if (ac > 1) {
                    mp += 10;
                }
            } else if (id[i] == 2) {
                b += l[i];
                bc++;
                if (bc > 1) {
                    mp += 10;
                }
            } else if (id[i] == 3) {
                c += l[i];
                cc++;
                if (cc > 1) {
                    mp += 10;
                }
            }
        }
        mp += abs(A - a) + abs(B - b) + abs(C - c);
        if (ac >= 1 && bc >= 1 && cc >= 1) {
            return mp;
        } else {
            return INF;
        }

    } else {
        int ans = INF;
        REP(i, 4) {
            id[left] = i;
            ans = min(ans, min_mp(id, left + 1));
        }
        return ans;
    }
}

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

    cin >> N >> A >> B >> C;

    l.resize(N, 0);
    id.resize(N, 0);
    REP(i, N) { cin >> l.at(i); }

    cout << min_mp(id, 0) << endl;

    return 0;
}


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

int main(void)
{
    int n,x,t;
    cin>>n>>x>>t;
    int ans=n/x*t;
    if(n%x!=0) ans+=t;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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


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

  for (int i = 0; i < n; i++) {
    long long curr = 0;
    for (int j = i; j < n - 1; j++) {
      int k = max<int>(0, (curr - s[j] + f[j] - 1) / f[j]);
      curr = s[j] + f[j] * k + c[j];
    }
    cout << curr << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n, d, kansi, ans;
    cin >> n >> d;
    kansi=1+2*d;
    if(n%kansi==0) ans=n/kansi;
    else ans=(n/kansi)+1;
    cout << ans <<endl;
    return 0;
}


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

double l2(int a, int b, double th) {
  return a * a + b * b - 2 * a * b * cos(th);
}

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  
  double pi = 3.141592653589793238462643383279;
  double c =  30 * H - 5.5 * M;
  double r = c / 180 * pi;
  
  //cout << c << endl;
  //cout << r << endl;
  cout << fixed << setprecision(20);
  cout << sqrt(l2(A, B, r)) << endl;
  //cout << cos(r) << endl;
}


Measured memory_bytes: 4144
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GET_BIT(n, i) (((n) & (1LL << ((i)-1))) >> ((i)-1)) // i start from 1
#define SET_BIT(n, i) ((n) | (1LL << ((i)-1)))
#define CLR_BIT(n, i) ((n) & ~(1LL << ((i)-1)))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
void myInit();
int mpow(int base, int exp);
void ipgraph(int n, int m);
// void dfs(int u, int par);
const int MOD = 1000000007;
const int N = 3e5, M = N;
//=========TQR==============
vi g[N];
vector<bool> vis(N, false);
int ans = 0;
void dfs(int u, int &len) {
	vis[u] = true;
	ans = max(ans, len);
	for (int v : g[u]) {
		if (vis[v])
			continue;
		dfs(v, ++len);
	}
}

int main() {
	myInit();
	FIO;
	int i, n, m;
	cin >> n >> m;
	ipgraph(n , m);
	fo(i, n) {
		int len = 1;
		if (!vis[i]) {
			dfs(i, len);
		}
	}
	cout << ans << endl;
	return 0;
}

void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp) {
	base %= MOD;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % MOD;
		base = ((ll)base * base) % MOD;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}


Measured memory_bytes: 26304
from operator import sub,add
tmp = input()
A = int(tmp[0])
B = int(tmp[1])
C = int(tmp[2])
D = int(tmp[3])
dic = {0:sub,1:add}
ansdic = {0:"-",1:"+"}
ans = []
for i in [0,1]:
    for j in [0,1]:
        for k in [0,1]:
            tmp1 = dic[i](A,B)
            tmp2 = dic[j](tmp1,C)
            tmp3 = dic[k](tmp2,D)
            if tmp3 == 7:
                ans = [i,j,k]
                break
print(str(A)+ansdic[ans[0]]+str(B)+ansdic[ans[1]]+str(C)+ansdic[ans[2]]+str(D)+"=7")

Measured memory_bytes: 3188
class Main{
    public static void main(String[] a){
			int[] num = {1,2,3,4,5,6,7,8,9};
			for (int x: num){
				for (int y: num){
					int z = x * y;
					System.out.println(String.valueOf(x)+'x'+String.valueOf(y)+'='+String.valueOf(z));
				}
			}
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  vector <int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    if(vec.at(i) * 4 * M >= sum) {
      count++;
    }
  }
  
  if (count >= M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,q = readInts()
    S = [-float("inf")] + [int(input()) for _ in range(a)] + [float("inf")]
    #S = sorted(S)
    T = [-float("inf")] + [int(input()) for _ in range(b)] + [float("inf")]
    for i in range(q):
        ans = float("inf")
        x = int(input())
        Sl = bisect.bisect_left(S,x)
        Tl = bisect.bisect_left(T,x)
        # 4通り試して一番小さいもの!!
        for s in (S[Sl-1],S[Sl]):
            for t in (T[Tl-1],T[Tl]):
                # 最小値、いったんsに行ってs-t, いったんtに行ってt-s で最小値を求める
                ans = min(ans,abs(s-x) + abs(s-t),abs(t-x)+abs(s-t))
        print(ans)
    # print(ans)
    #T = sorted(T)
    # for i in range(q):
    #     x = int(input())
    #     ans = 0
    #     now = x
    #     Sa = float("inf")
    #     Ta = float("inf")
    #     Sidx = bisect.bisect_right(S,x)
    #     Tidx = bisect.bisect_right(T,x)
    #     #print("-!-",x,Sidx,S)
    #     #print("-?-",x,Tidx,T)
    #     # ------------------------------------
    #     if Sidx < len(S):
    #         Sa = abs(S[Sidx] - x)
    #         Si = Sidx
    #     if Sidx - 1 >= 0:
    #         if Sa > abs(S[Sidx-1] - x):
    #             Sa = abs(S[Sidx-1] - x)
    #             Si = Sidx - 1
    #     # ------------------------------------
    #     if Tidx < len(T):
    #         if Ta > abs(T[Tidx] - x):
    #             Ta = abs(T[Tidx] - x)
    #             Ti = Tidx
    #     if Tidx - 1 >= 0:
    #         if Ta > abs(T[Tidx-1] - x):
    #             Ta = abs(T[Tidx-1] - x)
    #             Ti = Tidx - 1
    #     # ------------------------------------
    #     print(S,S[Si])
    #     print(T,T[Ti])
    #     mid = abs((S[Si] - T[Ti]))
    #     if abs(mid + Sa) < abs(mid + Ta):
    #         now = S[Si]
    #         ans += Sa
    #         jin = False
    #     else:
    #         print('?')
    #         if Ti - 1 >= 0:
    #             t =
    #             now = T[Ti]
    #             ans += Ta
    #             jin = True
    #     mi_ = float("inf")
    #     if jin:# 次神社を調べろ
    #         Sidx = bisect.bisect_right(S,now)
    #         if Sidx < len(S):
    #             mi_ = abs(now - S[Sidx])
    #         if Sidx - 1 >= 0:
    #             mi_ = min(mi_, abs(now - S[Sidx-1]))
    #         ans += mi_
    #     else:
    #         Tidx = bisect.bisect_right(T,now)
    #         if Tidx < len(T):
    #             mi_ = abs(now - T[Tidx])
    #         if Tidx - 1 >= 0:
    #             mi_ = min(mi_, abs(now - T[Tidx-1]))
    #         ans += mi_
    #     print(ans)
    #     print("--next--")

if __name__ == '__main__':
  main()


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

bool isPrime[1000001];

int main() {
    isPrime[0] = isPrime[1] = false;
    for(int i=2; i<=1000000; ++i) {
        isPrime[i] = true;
    }
    for(int i=2; i<=1000000; ++i) {
        if(isPrime[i]) {
            for(int j=i+i; j<=1000000; j+=i) {
                isPrime[j] = false;
            }
        }
    }
    int a, d, n;
    while(cin >> a >> d >> n, n) {
        int cnt=0;
        int ret=0;
        while(cnt != n) {
            if(isPrime[a]) {
                ret = a;
                cnt++;
            }
            a += d;
        }
        cout << ret << endl;
    }
}


Measured memory_bytes: 3996
#include <iostream>

int main() {
  int n, c, tmp;
  int sum = 0;

  std::cin >> n >> c;

  for (int i = 0; i < c; ++i) {
    std::cin >> tmp;
    sum += tmp;
  }

  if (sum % (n + 1) == 0) {
    std::cout << sum / (n + 1) << std::endl;
  } else {
    std::cout << 1 + sum / (n + 1) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

int val[128];

string ln;
int pos;

int fm();

int eq(){
	int A = fm();
	assert(ln[pos] == '=');
	pos++;
	int B = fm();
	return A == B;
}
int fm(){
	//cout << ln[pos] << endl;
	if( ln[pos] == 'T'){ pos++; return 1; }
	if( ln[pos] == 'F'){ pos++; return 0; }
	if( 'a' <= ln[pos] && ln[pos] <= 'k'){ pos++; return val[ln[pos-1]]; }
	if( ln[pos] == '-' ){ pos++;return !fm(); }
	if( ln[pos] == '('){
		pos++;
		int A = fm();
		if( ln[pos] == '*'){pos++; A = A & fm();}
		else if(ln[pos] == '+'){pos++; A = A | fm();}
		else if(ln[pos] == '-'){
			pos += 2;
			A = !A | fm();
		}else{
			assert(0);
		}
		pos++;
		return A;
	}
}


int main(){
	while(cin >> ln && ln != "#" ){
		int ok = 1;
		for(int i = 0 ; i < (1<<11) ; i++){
			for(int j = 0 ; j < 11 ; j++) val[j+'a'] = i>>j&1;
			pos = 0;
			ok &= eq();
		}
		cout << (ok?"YES":"NO") << endl;
	}
}

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

int main() {
  LL n, m;
  cin >> n >> m;

  LL ans = 0;
  if (m >= n * 2) {
    ans += n;
    ans += (m - n * 2) / 4;
  } else {
    ans += m / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
S = input()

if S == 'SUN':
    print('7')
if S == 'MON':
    print('6')
if S == 'TUE':
    print('5')
if S == 'WED':
    print('4')
if S == 'THU':
    print('3')
if S == 'FRI':
    print('2')
if S == 'SAT':
    print('1')


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    ll n ;
    cin >> n ;

    if ( n%2 ) { cout << 0 ; line ; R ; }

    n >>= 1 ;
    ll f =  5 ;
    ll ans = 0 ;

    while ( true )
    {
        ans += n/f ;
        f *= 5 ;

        if ( n/f == 0 )
            break ;
    }

    cout << ans ; line

}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define M 205
vector<int> g[N];
bool vis[N],chk[N];
int du[N];//outd - ind
void addedge(int f,int t){
    f+=M,t+=M;
    chk[f]=chk[t]=true;
    g[f].push_back(t);
    g[t].push_back(f);
    du[f]++,du[t]--;
}
bool DFS(int u){
    bool ret= du[u]!=0 ;vis[u]=true;
    for(int i:g[u])  
        if(!vis[i]) ret|=DFS(i);
    return ret;
}
int n,h;
int main(){
    scanf("%d%d",&n,&h);
    for(int i=1,a,b,c,d;i<=n;i++){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        addedge((c==0? a:-c),(d==0? -b:d) );
    }
    for(int i=-h;i<=h;i++)
        if(i!=0&&i*du[i+M]<0)
            return puts("NO"),0;
    for(int i=-h;i<=h;i++)
        if(chk[i+M]&&i!=0&&!vis[i+M]&&!DFS(i+M))
            return puts("NO"),0;
    return puts("YES"),0;
}

Measured memory_bytes: 4096
n, l = map(int, input().split())
sum = 0

if l > 0:
    for i in range(l + 1, n + l):
        sum += i
elif n + l - 1 < 0:
    for i in range(l, n + l - 1):
        sum += i
else:
    for i in range(l, n + l):
        sum += i
print(sum)


Measured memory_bytes: 2940