akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for(ll i=0;i<n;i++) 
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(int& a,int b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
 ll n,k ;
 cin>>n >> k;
 vector<ll> A(n) ; 
 rep(i,n) {
   cin>>A[i] ;
   A[i]++ ;
   } ;
  int ans=-INF ;
  int sum=0 ;
  rep(i,k){
   sum+= A[i] ;
  }
  ans=sum ;
  rep(i,n-k){
   sum= sum-A[i]+A[i+k] ;
   chmax(ans,sum) ; 
  }
  double bns=0.0 ;
   bns= (ans+bns)/2 ;
  cout<< fixed<< setprecision(20);
  cout<< bns <<endl ;
  return 0;
  }

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

string solve(string s,string t){
	int n=s.length(),m=t.length();
	int dp[n+1][m+1];
	
	//cout<<n<<" "<<m<<endl;
	
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0 || j==0)
			dp[i][j]=0;
			else if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	/*for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}*/
	
	string lcs="";
	int i=n,j=m;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			lcs=s[i-1]+lcs;
			i--,j--;
		}else{
			if(dp[i-1][j]>dp[i][j-1])
			i--;
			else
			j--;
		}
	}
//	cout<<lcs<<" "<<dp[n][m]<<endl;
	return lcs;
	
}

int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	cout<<solve(s,t);
	return 0;
}


Measured memory_bytes: 38868
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0 ; i < n ; i++) cin >> a[i];
    sort(a, a + n);
    int b = 0;
    for (int i = 0 ; i < n ; i++) if (a[i] != a[i + 1]) b++;
	int c[b] = {}, j = 0;
	for (int i = 0 ; i < n ; i++) {
		c[j]++;
		if (a[i] != a[i + 1]) j++;
	}
	if (b <= k) {
		cout << 0;
		return 0;
	}
	sort(c, c + b);
	int d = 0;
	for (int i = 0 ; i < b - k ; i++) d += c[i];
	cout << d;
}

Measured memory_bytes: 5184
/*input

*/
#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 int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

vector< pair<int,int> > nice;
int n;

void solve(){
    cin >> n;
    if(n%2 == 0){
      RE(i,n){
        RE(j,i-1){
          if(i+j == n+1)continue;
          nice.pb({i,j});
        }
      }
      cout << nice.size() << endl;
      for(auto it:nice){
        cout << it.f << " " << it.s << endl;
      }
      return;
    }
    for(int i = 1;i < n;i++){
      nice.pb({i,n});
    }
    for(int i = 1;i <= n-1;i++){
      for(int j = i+1;j <= n-1;j++){
        if(i+j == n)continue;
        nice.pb({i,j});
      }
    }
    cout << nice.size() << endl;
    for(auto it:nice){
      cout << it.f << " " << it.s << endl;
    }
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

using namespace std;
long long n,ans=1,mod=1000000007;
int main()
{
 cin>>n;
 for(int i=2;i<=n;i++)
 {
  ans*=i;
  ans%=mod;
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string s;cin >> s;
    map<char,int> m;
    rep(i,s.size())m[s[i]]++;

    if(m.size() == 3)cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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

using namespace std;

void solve()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        vector<int> dp(n);
        for (int l = 0; l + i < n; l++)
        {
            if (s[l] == s[l + i])
            {
                dp[l + i] = dp[l + i - 1] + 1;
            }
        }
        ans = max(ans, min(i, *max_element(dp.begin(), dp.end())));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
(defun tap-dance ()
  (let* ((input (read))
         (s (symbol-name input)))
    (dotimes (i (length s))
      (if (= (mod (1+ i) 2) 0)
          (when (string-equal (elt s i) "R") (format t "~a" "No") (return-from tap-dance))
          (when (string-equal (elt s i) "L")(format t "~a" "No") (return-from tap-dance))))
    (format t "~a" "Yes")))

(tap-dance)

Measured memory_bytes: 17248
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]

uf = UnionFind(N)
for a,b in AB:
    uf.union(a-1,b-1)

print(uf.group_count() - 1)

Measured memory_bytes: 29416
f=lambda:map(int,input().split())
n,m=f()
g=[[] for _ in range(n)]
for _ in range(m):
  a,b=f()
  g[a-1]+=[b-1]
  g[b-1]+=[a-1]
p=[0]*n
from collections import*
q=deque([0])
while q:
  v=q.popleft()
  for c in g[v]:
    if p[c]<1: p[c]=v+1; q.append(c)
if 0 in p: print('No')
else: print('Yes',*p[1:],sep='\n')

Measured memory_bytes: 38936
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

using namespace std;


int main() {
	speed;
	int n, x;
	int L[110];
	cin >> n >> x;
	for (int i = 1; i < n+1; i++) {
		cin >> L[i];

	}
	int d[110];
	int ans = 2;
	d[1] = 0;
	for (int i = 2; i < n+2; i++) {
		d[i] = d[i - 1] + L[i - 1];

		if (d[i] > x) {
			ans = i;
			break;
		}
		if (i==n+1&&d[i] <= x)ans = n + 2;

	}
	cout << ans-1;
	ed;
	return 0;
}


Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.09.09 16:50:34
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (ll i = 0; i < x; i++)
#define rep1(i, x) for (ll i = 1; i <= x; i++)
#define rrep(i, x) for (ll i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (ll i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

ll n, a[100010], b[100010];

int main() {
    scanf("%lld", &n);
    rep(i, n + 1) {
        scanf("%lld", &a[i]);
    }
    rep(i, n) {
        scanf("%lld", &b[i]);
    }

    ll cnt = 0;
    rep(i, n) {
        if (a[i] > b[i]) {
            cnt += b[i];
        } else {
            cnt += a[i];
            if (a[i + 1] < b[i] - a[i]) {
                cnt += a[i + 1];
                a[i + 1] = 0;
            } else {
                cnt += b[i] - a[i];
                a[i + 1] -= b[i] - a[i];
            }
        }
    }

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

    /* --------------------------------- */
    return 0;
}

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

const int N = 100 * 1000 + 5;

int a[N];
int b[N];
int dif[N];
int main() {
	int n, ans = 0;
	long long s = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		dif[i] = a[i] - b[i];
	}
	sort(dif, dif + n);
	for (int i = 0; dif[i] < 0; i++) {
		s += dif[i];
		ans++;
	}
	for (int i = n - 1; i >= 0 && s < 0; i--) {
		s += dif[i];
		ans++;
	}
	if (s < 0)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if(n > k){
    int sum = k*x + (n-k)*y;
    cout << sum;
  }
  if(n <= k){
    int sum = n*x;
    cout << sum;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string str; cin >> str;
	int l = 0;
	int r = 0;
	for( int i = 0; i < n; ++i ){
		if( str[i] == '(') { // 右で ( の数だけ閉じる
			++r;
		} else if ( r != 0 ){ // 右で閉じすぎているので消す
			--r;
		} else { // ')' かつ r > 0，) の数だけ左で閉じる
			++l;
		}
	}
	for( int i = 0; i < l; ++i ) cout << '(';
	cout << str;
	for( int i = 0; i < r; ++i ) cout << ')';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(dead_code)]
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)*}
    };

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

#[allow(dead_code)]
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
    }
    let result = if a <= 5 {
        0
    } else if a <= 12 {
        b / 2
    } else {
        b
    };
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,k;
  cin>>n>>k;
  double res=0;
  	for(ll i=1;i<=n;i++)
    {
		ll j=i;
      ll count=0;
     
      while(j<k)
      {
			j*=2;
        	count++;
      }
      res+=1/((double)pow(2,count)*n);
    
   }
    cout<<fixed<<setprecision(10);
  	cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return ((power(x,y/2)%Mod)*(power(x,y/2)%Mod))%Mod; 
    else
        return (((x%Mod)*(power(x,y/2)%Mod)%Mod)*(power(x,y/2)%Mod)%Mod); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll powerm(ll x,unsigned ll y,ll p)  
{  
    ll res=1;
    x=x%p;   
    if (x==0) return 0;
    while(y>0)  
    {  
        if(y&1)  
            res=(res*x)%p;  
        y=y>>1;
        x=(x*x)%p;  
    }  
    return res;  
}
vector <ll> dp;
ll f(ll sum)
{
    if(sum<0)
     return 0;
    if(sum==0)
     return 1;
    ll &ans=dp[sum];
    if(ans!=-1)
     return ans;
    ans=0; 
    for(ll i=3;i<=sum;i++)
      ans+=f(sum-i),ans%=Mod;
    return ans;  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       ll s;
       cin>>s;
       dp.resize(2005,-1);
       cout<<f(s);
   }
}

Measured memory_bytes: 3672
#include <iostream>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a < b && b < c)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3108
import Control.Applicative
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IM

main :: IO ()
main = solve <$> readLn >>= print

solve :: Int -> Int
solve s = f IM.empty 1 s
  where
    f mp i n = let n' = if even n then n `div` 2 else n * 3 + 1
               in case IM.lookup n mp of
                   Nothing -> f (IM.insert n i mp) (i + 1) n'
                   Just _ -> i


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

int main()
{
    string year, month, day;
    string s; cin >> s;

    year = s.substr(0, 4);
    month = s.substr(5, 2);
    day = s.substr(8, 2);
    if((year >= "2019") && (month >= "05")){
        cout << "TBD";
    }
    else{
        cout << "Heisei";
    }
    cout << "\n";
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    int n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) sum ^= a[i];
    rep(i,n){
        cout <<(sum ^ a[i])<< ' ';
    }
}


Measured memory_bytes: 5192
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> G;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int i,j,H,W,wh=0,bl=0,ans;

int d[59][59];
string s[59];
	
int bfs() {
	queue<P> que;
	d[0][0] = 0;
	que.push(P(0,0));
	
	while ( que.size() ) {
		P p = que.front();que.pop();
		if (p.first == (H-1) && p.second == (W-1)) return d[H-1][W-1];
		REPI(0,4) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if (
				0<=nx && nx<H && 0<=ny && ny<W
				&& s[nx][ny] == '.'
				&& d[nx][ny] < 0
			) {
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return -1;
}

int main() {
	cin >> H >> W;
	
	REPI(0,H) {
		cin >> s[i];
		REPJ(0,W) if (s[i][j] == '#') bl++;
					else  wh++;
	}
	
	REPI(0,50) REPJ(0,50) d[i][j] = -1;
	
	ans = bfs();
	ans = (ans < 0)? -1 : wh - (ans+1);
	cout << ans;
	
	return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

lint dp[3005][3005], dp2[3005][3005];

int main(){
    lint n, s; cin >> n >> s;
    rep(i, n){
        dp[i][0] = (i+1)*(i+2)/2 - i - 1;
        dp2[i][0] = i + 2;

        dp[i][0] %= MOD9;
    }

    rep(i, n){
        lint a; cin >> a;
        if(i == 0){
            dp[0][a] = 1; dp2[0][a] = 1;
        }
        else{
            repn(w, s){
                dp[i][w] = dp[i-1][w] + dp2[i-1][w];
                dp2[i][w] = dp2[i-1][w];
                if(w >= a) dp2[i][w] += dp2[i-1][w-a];

                dp[i][w] %= MOD9; dp2[i][w] %= MOD9;
            }
        }
    }

    out((dp[n-1][s] + dp2[n-1][s]) % MOD9);
}

Measured memory_bytes: 141184
a,b,k=map(int,input().split())
L=[]
for i in range(a,a+k):
    if i<=b:
        L.append(i)
for i in range(b+1-k,b+1):
    if i>=a:
        L.append(i)
for l in sorted(set(L)):
    print(l)

Measured memory_bytes: 3060
from decimal import Decimal
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = LI()

bunbo = sum([Decimal(str(1 / i)) for i in a])
ans = Decimal(str(1 / bunbo))
print(float(ans))


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

int main() {
	int k; cin >> k;
	int64_t a[k]; for(int i = 0; i < k; ++i) cin >> a[i];
	int64_t l, r;
	{
		int64_t ok = 0, ng = 1e18;
		while(abs(ok - ng) > 1) {
			int64_t mid = (ok + ng) / 2;
			int64_t n = mid;
			for(int i = 0; i < k; ++i) {
				n = (n / a[i]) * a[i];
			}
			if(n < 2) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		l = ng;
	}
	{
		int64_t ok = 0, ng = 1e18;
		while(abs(ok - ng) > 1) {
			int64_t mid = (ok + ng) / 2;
			int64_t n = mid;
			for(int i = 0; i < k; ++i) {
				n = (n / a[i]) * a[i];
			}
			if(n <= 2) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		r = ok;
	}
	if(l > r) {
		cout << -1 << '\n';
	} else {
		cout << l << " " << r << '\n';
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> tasks;

	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		tasks.emplace_back(b, a);
	}

	int value = 0;
	string ans = "Yes";

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

	for (int i = 0; i < n; i++)
	{
		value += tasks[i].second;
		if (value > tasks[i].first)
		{
			ans = "No";
			break;
		}
	}

	cout << ans << endl;
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;
#define vv vector

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

#define isIn(x,y) 0<=x&&x<H&&0<=y&&y<W

ll N,N3;
ll A[303030];
ll i, j, k;

void mxin(ll& a,ll b){
    if(a<b)
        a = b;
}


void dpcalc(vv<vv<pair<ll, pll>>>& dp,vv<ll>& odp2,vv<ll>& av,ll& odpmx,ll I){
    ll i, j, k;
    vv<ll> dp2 = odp2;
    ll dpmx = odpmx;

    auto gtdp = [&](ll a, ll b) {
        if(a>b)
            swap(a, b);
        if(dp[a][b].se.fi!=I)
            dp[a][b].se = {I, dp[a][b].fi};
        return dp[a][b].se.se;
    };
    auto stdp = [&](ll a, ll b, ll n) {
        if(a>b)
            swap(a, b);
        if(dp[a][b].se.fi!=I)
            dp[a][b].se = {I, dp[a][b].fi};
        
        mxin(dp[a][b].fi, n);
        mxin(dp2[a], n);
        mxin(dp2[b], n);
        mxin(dpmx, n);
    };
    
    

    rep(i,0,3){
        vv<ll> bv;
        rep(j,0,3){
            if(i!=j)
                bv.push_back(av[j]);
        }
        stdp(bv[0], bv[1], odpmx);
        stdp(bv[0], bv[1], gtdp(av[i], av[i]) + 1);

        
        rep(j,1,N+1){
            stdp(av[i], j, odp2[j]);
            if(bv[0]==bv[1])
                stdp(av[i], j, gtdp(bv[0], j) + 1);
        }
    }
    odp2 = dp2;
    odpmx = dpmx;
}

int main(){
    scanf("%lld", &N);
    N3 = N * 3;
    rep(i,0,N3){
        scanf("%lld", &A[i]);
    }
    vv<ll> Av;
    Av.push_back(A[0]);
    Av.push_back(A[1]);
    rep(i,1,N){
        //cout << A[i * 3 - 1] << A[i * 3] << A[i * 3 + 1] << endl;
        if(A[i*3-1]==A[i*3]&&A[i*3]==A[i*3+1])
            continue;
        rep(j,-1,2){
            Av.push_back(A[i * 3 + j]);
        }
    }
    Av.push_back(A[N3 - 1]);

    vv<vv<pair<ll, pll>>> dp(N + 3, vv<pair<ll, pll>>(N + 3, {-1e15, {0, -1e15}}));
    vv<ll> dp2(N + 3, -1e15);
    ll dpmx = 0;
    if (Av[0] > Av[1])
        swap(Av[0], Av[1]);
    dp[Av[0]][Av[1]] = {N - Av.size() / 3, {0, 0}};
    dpmx = dp2[Av[0]] = dp2[Av[1]] = dp[Av[0]][Av[1]].fi;

    rep(i,2,Av.size()){
        /*
        rep(j,1,N+1){
            rep(k,j,N+1){
                printf("%lld,%lld:%lld\n", j, k, dp[j][k].fi);
            }
        }*/
        if(i+3>Av.size())
            break;
        vv<ll> bv;
        rep(j,0,3){
            bv.push_back(Av[i + j]);
        }
        dpcalc(dp, dp2, bv, dpmx, i);
        i += 2;
        
    }
    ll ln = Av[i];
    ll ans = max(dpmx,dp[ln][ln].fi+1);

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

    return 0;
}

Measured memory_bytes: 97512
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

int main() {
	int x;
	cin >> x;
	/*
	1 = 1;
	2 = 2;
	3 = 1 + 2;
	4 = 1 + 3;
	5 = 2 + 3;
	6 = 1 + 2 + 3;
	7 = 3 + 4;
	8 = 1 + 3 + 4;
	9 = 2 + 3 + 4;
	10 = 1 + 2 + 3 + 4;
	*/
	int ans = 0;
	for (int i = 1; i < 1000000000; i++) {
		ans += i;
		if (x <= ans) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 384
#! /usr/bin/python
# -*- coding: utf-8 -*-

from bisect import *

while 1:
    (N, M) = map(int, raw_input().split())
    if N == 0: break
    r = int(raw_input())
    used = [0]*(N+1)
    imos = [[0]*1301 for i in range(M+1)]
    for i in range(r):
        (t, n, m, s) = map(int, raw_input().split())
        if s == 1 and used[n] == 0:
            used[n] = m
            imos[m][t] += 1
        if s == 0 and used[n] == m:
            used[n] = 0
            imos[m][t] -= 1
            #if imos[m][t] > 0:
            #    imos[m][t] -= 1
            #else:
            #    imos[m][t] = -1

    q = int(raw_input())
    for i in range(q):
        (qs, qe, user) = map(int, raw_input().split())
        tmp = 0
        ans = 0
        for j in range(540, 1261):
            #if imos[user][j] == 1:
            #    tmp += 1
            if tmp > 0 and j > qs and j <= qe:
                ans += 1
            tmp += imos[user][j]
            #if imos[user][j] == -1:
            #    tmp -= 1
        print ans
                

Measured memory_bytes: 166364
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        String s = sc.next();

        if(a>=3200){
            System.out.println(s);
        }
        else if(a<3200){
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 21844
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn = 2e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

vector<int> v[maxn], g[maxn];

bool good[maxn];

int h[maxn], pr[maxn];

void dfs1(int u, int par = 0){
    h[u] = h[par] + 1;
    pr[u] = par;
    for(int y : g[u]){
	if(y != par)
	    dfs1(y, u);
    }
}

vector<int> vec;

void dfs2(int u, int H = 1, int par = 0){
    if(H >= h[u])
	return;
    vec.PB(u);
    for(int y : v[u]){
	if(y != par)
	    dfs2(y, H+1, u);
    }
}

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

    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < n-1; i++){
	int a, b;
	cin >> a >> b;
	v[a].PB(b);
	v[b].PB(a);
    }
    for(int i = 0; i < n-1; i++){
	int a, b;
	cin >> a >> b;
	g[a].PB(b);
	g[b].PB(a);
    }
    dfs1(b);
    for(int i = 1; i <= n; i++){
	for(int j : v[i]){
	    if(pr[i] != j && pr[j] != i && pr[i] != pr[j] && pr[pr[i]] != j && pr[pr[j]] != i)
		good[i] = good[j] = 1;
	}
    }
    dfs2(a);

    int ans = 0;
    for(int u : vec){
	if(good[u])
	    return cout << -1 << endl, 0;
	ans = max(ans, h[u]);
    }
    return cout << 2 * (ans-1) << endl, 0;
}


Measured memory_bytes: 33148
from collections import Counter
N = int(input())
S = []
for i in range(N):
    S.append(input())
A = []
d = Counter(S)
md = d.most_common(1)[0][1]

for key, value in d.items():
    if value == md:
        A.append(key)

As = sorted(A)
for a in As:
    print(a)


Measured memory_bytes: 35572
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
// #define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/

void solve(){
    rep(i, 0, 5){
        int a;
        cin >>a;
        if(a == 0){
            cout << i+1;return;
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, C, P[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> C;
    rep(i, 0, C) cin >> P[i];

    int sm = 0;
    rep(i, 0, C) sm += P[i];

    int ans = (sm + N) / (N + 1);
    cout << ans << endl;
}



Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s; cin >> s;
	int cnt = 0;
	if (s[0] == 'o')cnt++;
	if (s[1] == 'o')cnt++;
	if (s[2] == 'o')cnt++;
	cout << 700 + cnt * 100 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define ll long long
#define i1 int128_t
#define vi vector<long long>
#define st set<long long>
#define uset unordered_set<long long>
#define si set<long long>:: iterator
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(long long i=a; i<b; i++)
#define fs(i,a,s) for(long long i=a; s[i]!='\0'; i++)
#define endl "\n"

int main(){


	ll n;
	cin>>n;

	if(n%1000)
		cout<<1000-n%1000;
	else
		cout<<0;
	
}

Measured memory_bytes: 3628
# 2019/09/11

s=list(input())
n=len(s)

if n<3:
    print(*[1,2] if len(set(s))<2 else [-1,-1])

    exit()

ans=(-1,-1)
for i in range(1,n-1):
    if len(set(s[i]+s[i-1]+s[i+1]))<3:
        ans=(i,i+2)
        break
print(*ans)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
 
using namespace std;
 
vector <int> prime;
void eratos(void)
{
	bool isprime[1000001];
	memset(isprime,true,sizeof(isprime));
	for(int i=2;i<=1000000;i++)
	{
		if(isprime[i])
		{
			prime.push_back(i);
			for(int j=2*i;j<=1000000;j+=i)
			{
				isprime[j] = false;
			}
		}
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 	
 	long long int n;

 	cin >> n;

 	eratos();

 	map <long long int,long long int> cnt;
 	for(int i=0;i<prime.size();i++)
 	{
 		if(n==1)
 		{
 			break;
 		}
 		while(1)
 		{
 			if(n%prime[i]!=0)
 			{
 				break;
 			}
 			n/=prime[i];
 			cnt[prime[i]]+=1;
 		}
 	}
 	if(n>1)
 	{
 		cnt[n]++;
 	}

 	long long int res = 0;
 	for(auto it : cnt)
 	{
 		long long int num = it.second;
 		long long int val = 0;
 		if(num==0)
 		{
 			continue;
 		}
 		for(int i=1; ;i++)
 		{
 			if(val + i > num)
 			{
 				break;
 			}
 			val += i;
 			res++;
 		}
 	}

 	cout << res << '\n';

    return 0;
}

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

int main() {
  int n, x;
  while (true) {
    cin >> n >> x;
    if (n == 0 && x == 0) break;
    int count = 0;
    for (int i = 1; i < n - 1; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if ((x - i - j) > j && (x - i - j) <= n) count++;
      }
    }
    cout << count << endl;
  }

  return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

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

        int max = x / 100;
        int diff = x % 100;

        if (diff <= max * 5) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 22996
#include<stdio.h>
#include<stdlib.h>
 
typedef struct{
    long long st;
    long long fi;
    long long kr;
}rs;
 
typedef struct{
    long long st;
    long long kz;
}mkj;
 
int sortfnc(const void *a,const void *b){
if(((rs*)a)->st == ((rs*)b)->st){return 0;}
if(((rs*)a)->st < ((rs*)b)->st){return -1;}
return 1;
}
 
void makemkj(rs g[],mkj x[],long long n){
    long long i,ms=0,nst=g[0].st;
    for(i=1;i<n;i++){
        if(g[i].st!=g[i-1].st){
            x[nst].kz=i-ms;
            x[nst].st=ms;
            nst=g[i].st;ms=i;
        }
    }
    x[nst].kz=n-ms;
    x[nst].st=ms;
}
 
void calcdif(rs g[],mkj x[],long long nc,long long ndif,long long dif[]){
    long long i;
    for(i=x[nc].st;i<x[nc].st+x[nc].kz;i++){
        if(dif[g[i].fi] != -1){continue;}
        dif[g[i].fi]=ndif+g[i].kr;
        calcdif(g,x,g[i].fi,dif[g[i].fi],dif);
    }
}
 
int main(void){
    long long n,a[131072],b[131072],c[131072],i;
    long long q,k;
    long long z[131072],y[131072];
    long long dif[131072];
    rs g[262144];
    mkj x[131072];
    scanf("%lld",&n);
    for(i=0;i<n-1;i++){
        scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
        g[2*i].st=a[i];g[2*i].fi=b[i];g[2*i].kr=c[i];
        g[2*i+1].st=b[i];g[2*i+1].fi=a[i];g[2*i+1].kr=c[i];
    }
    qsort(g,2*n,sizeof(rs),sortfnc);
    makemkj(g,x,2*n);
    scanf("%lld%lld",&q,&k);
    for(i=0;i<=131071;i++){dif[i]=-1;}
    dif[k]=0;
    calcdif(g,x,k,0,dif);
    for(i=1;i<=q;i++){
        scanf("%lld%lld",&z[i],&y[i]);
        printf("%lld\n",dif[z[i]]+dif[y[i]]);
    }
    return 0;
}

Measured memory_bytes: 23396
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
using namespace boost::multiprecision;

int main(){

    int h,n;
    cin >> h >> n;

    int sum = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        sum += tmp;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  ll n; cin >> n;
  int ans = 99;

  for(ll i=1; i*i<=n; i++) {
    if (n%i == 0) {
      ll b = n/i;
      int tmp = 0;
      //debug(b);
      while(b != 0) {
        b/=10;
        tmp++;
      }
      //debugln(tmp);
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;

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

  ll n, K;
  cin >> n >> K;
  vector < pair < ll, ll > > pts;
  for(int i = 0; i < n; i++){
    ll x, y;
    cin >> x >> y;
    pts.push_back({x, y});
  }

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

  ll area = LLONG_MAX;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      if(j - i + 1 < K) continue;
      vector < ll > v;
      for(int k = i; k <= j; k++) v.push_back(pts[k].second);
      sort(v.begin(), v.end());
      ll mi = LLONG_MAX;
      for(int k = 0; k < v.size() && K + k - 1 < v.size(); k++){
        mi = min(mi, v[K - 1 + k] - v[k]);
      }
      ll tmp_area = mi;
      tmp_area *= (pts[j].first - pts[i].first);
      area = min(area, tmp_area);
    }
  }

  for(int i = 0; i < n; i++) swap(pts[i].first, pts[i].second);

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

  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      if(j - i + 1 < K) continue;
      vector < ll > v;
      for(int k = i; k <= j; k++) v.push_back(pts[k].second);
      sort(v.begin(), v.end());
      ll mi = LLONG_MAX;
      for(int k = 0; k < v.size() && K + k - 1 < v.size(); k++){
        mi = min(mi, v[K - 1 + k] - v[k]);
      }
      ll tmp_area = mi;
      tmp_area *= (pts[j].first - pts[i].first);
      area = min(area, tmp_area);
    }
  }

  cout << area << '\n';
}


Measured memory_bytes: 3660
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    int ans = n / 2;
    if (n % 2) ans++;
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n,m,k;std::cin>>n>>m>>k;
    std::vector<std::vector<int>>g(n);
    while(m--){
        int u,v;std::cin>>u>>v;u--,v--;
        g.at(u).push_back(v);
        g.at(v).push_back(u);
    }
    std::vector<int>cmp(n,-1);
    std::vector<int>sz;
    for(int i=0;i<n;i++){
        if(cmp.at(i)!=-1)continue;
        std::vector<int>que;
        que.push_back(i);
        cmp.at(i)=sz.size();
        sz.push_back(1);
        for(int j=0;j<(int)que.size();j++){
            int x=que.at(j);
            for(int y:g.at(x)){
                if(cmp.at(y)!=-1)continue;
                cmp.at(y)=cmp.at(x);
                que.push_back(y);
                sz.back()++;
            }
        }
    }
    std::vector<int>ans(n);
    for(int i=0;i<n;i++){
        ans.at(i)=sz.at(cmp.at(i))-g.at(i).size()-1;
    }
    while(k--){
        int u,v;std::cin>>u>>v;u--,v--;
        if(cmp.at(u)==cmp.at(v)){
            ans.at(u)--;
            ans.at(v)--;
        }
    }
    for(int i=0;i<n;i++){
        std::cout<<(i?" ":"")<<ans.at(i);
    }
    std::cout<<'\n';
}


Measured memory_bytes: 7536
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    print!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<isize> = vec![0; h + 1];
    for i in 1..h + 1 {
        a[i] = iterator.next().unwrap().parse().unwrap();
    }

    let mut result = String::new();
    for i in 1..h + 1 {
        result.push_str(&format!("node {}: key = {}, ", i, a[i]));

        let pk = i / 2;
        if pk >= 1 && pk <= h {
            result.push_str(&format!("parent key = {}, ", a[pk]));
        }

        let lk = 2 * i;
        if lk >= 1 && lk <= h {
            result.push_str(&format!("left key = {}, ", a[lk]));
        }

        let rk = 2 * i + 1;
        if rk >= 1 && rk <= h {
            result.push_str(&format!("right key = {}, ", a[rk]));
        }

        result.push('\n');
    }

    return result;
}



Measured memory_bytes: 5036
from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input().rstrip())

def sinput():
	return input().rstrip().split()

def intsput():
	return map(int, sinput())

def main():
	n, r = intsput()
	if n >= 10:
		print(r)
	else:
		print(r+(100*(10-n)))



if __name__ == '__main__':
	main()

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

int main(void){
    int a, b, c, d, e, k;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
    if(e-a > k){
        printf(":(");
    }else{
        printf("Yay!");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int H=sc.nextInt(),W=sc.nextInt(),S[][]=new int[H][W];
        for(int i=0;i<H;i++){
            String t=sc.next();
            for(int j=0;j<W;j++){
                if (t.charAt(j)=='#'){
                    S[i][j]=-1;
                }else{
                    S[i][j]=0;
                }
            }
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(S[i][j]==-1){
                    for(int k=-1;k<2;k++){
                        for(int l=-1;l<2;l++){
                            if(k+i>=0&&j+l>=0&&k+i<H&&j+l<W){
                                if(S[i+k][j+l]!=-1) S[i+k][j+l]++;
                            }
                        }
                    }
                }
            }
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(S[i][j]==-1){
                    System.out.print("#");
                }else{
                    System.out.print(S[i][j]);
                }
            }
            System.out.println();
        }
        System.out.println();
    }
}

Measured memory_bytes: 36436
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int K = sc.nextInt();

		char x = S.charAt(K-1);
		List<String> list = new ArrayList<String>();
		for (int i=0;i<N;i++) {
			if (S.charAt(i)!=x) {
				list.add("*");
			} else  {
				list.add(String.valueOf(x));
			}
		}
		for (int i=0;i<N;i++) {
			System.out.print(list.get(i));
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
char buf[214514];

int main() {
  scanf("%d %s", &N, buf);
  int ans = N+10;
  int cnt = 0;
  rep(i, N) {
    if (buf[i] == '.') cnt++;
  }
  MN(ans, cnt);
  rep(i, N) {
    if (buf[i] == '#') cnt++;
    else if (buf[i] == '.') cnt--;
    MN(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
n,l=map(int,input().split())
T=[]
for i in range(n):
  t=int(abs(l+i))
  T.append(t)
#print(T)
eat=T.index(min(T))+1
#print(eat)
print(int(n*l+n*(n-1)/2-(l+eat-1)))

Measured memory_bytes: 2940