akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

const int N=2020;

int n, a[N*2];
int que[N*2], ss, tt;

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

    LL ans=1LL<<60;
    rep(w, 1, n) {
        ss=1, tt=0;
        LL tmp=LL(w-1)*LL(x);
        rep(i, 1, n*2) {
            while(ss<=tt && i-que[ss]>=w) ++ss;
            while(ss<=tt && a[i]<=a[que[tt]]) --tt;
            que[++tt]=i;
            if(i>n) tmp+=a[que[ss]];
        }
        //cout<<w<<": "<<tmp<<endl;
        setmin(ans, tmp);
    }
    cout<<ans<<endl;

    return 0;
}


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

vector<lint> cumsum(string& data, char c) {
    lint n = data.size();
    vector<lint> before(n+1, 0);
    for(lint i=0; i<n; i++) {
        before[i+1] = before[i] + (data[i] == c);
    }
    return before;
}

char the_other(char a, char b) {
    return 'R'^'G'^'B'^a^b;
}

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

    map<char, vector<lint>> cum;
    cum['R'] = cumsum(s, 'R');
    cum['G'] = cumsum(s, 'G');
    cum['B'] = cumsum(s, 'B');

    lint ans = 0;
    for(lint i=0; i<n; i++)
    for(lint j=i+1; j<n; j++) {
        if(s[i] == s[j])  continue;
        char c = the_other(s[i], s[j]);
        ans += cum[c][n] - cum[c][j+1];
        if(2*j-i < n && s[2*j-i] == c)  ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3664
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<s[0];
    cout<<s.size()-2;
    cout<<s.back()<<"\n";
}


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int N, M;
        cin >> N >> M;
        vector<Int> A(M);
        int ki = 0;
        for (int i = 0; i < M; ++i) {
            cin >> A[i];
            if (A[i] % 2) ki++;
        }

        if (ki > 2) {
            cout << "Impossible" << endl;
            return;
        }

        sort(all(A), [](Int a, Int b) {
            return a % 2 > b % 2;
        });


        if (A.size() > 1 && A[1] % 2 == 1) {
            swap(A[1], A.back());
        }
        vector<Int> B = A;
        if (B.size() == 1) {
            B.push_back(1);
            B[0]--;
            if (B[0] == 0) {
                swap(B[0], B[1]);
            }
        }

        B[0]--;
        B.back()++;
        if (B[0] == 0) {
            B.erase(B.begin());
        }
        if (B.back() == 0) {
            B.pop_back();
        }

        for (int i = 0; i < M; ++i) {
            cout << A[i] << " ";
        }
        cout << endl;
        cout << B.size() << endl;
        for (auto e : B) {
            cout << e << " ";
        }
        cout << endl;


    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 384
from collections import Counter
input()
A_list = input().split(" ")
c = Counter(A_list)

even_count = 0
for v in c.values():
    if not (v % 2):
        even_count += 1
        
if even_count % 2:
    print(len(c)-1)
else:
    print(len(c))

Measured memory_bytes: 19820
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

set<char>st[26],x[26];

void solve(){
	string s,t;
	cin>>s>>t;
	rep(i,sz(t)){
		st[t[i]-'a'].insert(s[i]);
		x[s[i]-'a'].insert(t[i]);
	}
	bool ok=1;
	rep(i,26){
		if(sz(st[i])>1 || sz(x[i])>1){
			cout<<"No";
			return;
			ok=0;
		}
	}
	cout<<"Yes";
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <numeric>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <typename T>
vector<T> apply(vector<T> const & a, vector<int> const & swp) {
    int n = swp.size();
    vector<T> b(n);
    repeat (i,n) b[i] = a[swp[i]];
    return b;
}
int main() {
    int n; cin >> n;
    vector<ll> x(n); repeat (i,n) cin >> x[i];
    int m; ll k; cin >> m >> k;
    vector<int> a(m); repeat (i,m) { cin >> a[i]; -- a[i]; }
    vector<ll> dx(n-1); repeat (i,n-1) dx[i] = x[i+1] - x[i];
    vector<int> swp(n-1); whole(iota, swp, 0);
    repeat (j,m) swap(swp[a[j]-1], swp[a[j]]);
    for (ll i = 1; i <= k; i <<= 1) {
        if (k & i) dx = apply(dx, swp);
        swp = apply(swp, swp);
    }
    vector<ll> y(n);
    y[0] = x[0]; repeat (i,n-1) y[i+1] = y[i] + dx[i];
    repeat (i,n) cout << y[i] << endl;
    return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> s(3);
    REP(i,3){
        cin >> s[i];
    }
    int now=0;
    vector<int> a(3);
    while(1){
        if(a[now]==s[now].size()){
            cout << char(now+'A') << endl;
            return 0;
        }
        int t=a[now];
        a[now]++;
        now=s[now][t]-'a';
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    
    if((A*B)%2==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        
    }
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<char> vc;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
//(a + b ) % m = (a % m + b % m ) %m
//(a - b ) % m = ( ((//(//(a - b ) % m = ( (a % m - b % m ) + m ) %m
// a % m - b % m ) + m ) %m
//(a * b ) % m = (a % m * b % m ) %m
//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)



ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}

void solve(){
	ll i,j,n,k;
	ll a;
	cin>>a;
	cout<<(a+(a*a)+(a*a*a))<<endl;
}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    vec.push_back(num);
  }
  int res = 0;
  int count = 0;
  int prevNum = vec[0];
  for(int i=1; i<n; i++){
    if(vec[i] <= prevNum){
      count++;
      prevNum = vec[i];
    }else{
      prevNum = vec[i];
      if(res < count){
        res = count;
      }
      count = 0;
    }
  }
  if(res < count){
    res = count;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 892
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""




s,t = input().split()

a,b = m()

p = input()[:-1]

if p == s:
    a -= 1
    print("{0} {1}".format(a,b))
else:
    b -= 1
    print("{0} {1}".format(a,b))

Measured memory_bytes: 3436
'''
Date         : 2020-08-09 00:46:52
Author       : ssyze
Description  : 
'''
n, k = map(int, input().split())
a = list(map(int, input().split()))


def check(m):
    sum = 0
    for i in range(len(a)):
        sum += (a[i] - 1) // m
    if sum > k:
        return False
    else:
        return True


l = 1
r = 10**9
ans = 10**9
while l < r:
    mid = (l + r) // 2
    if check(mid) == 1:
        r = mid
        ans = mid
    else:
        l = mid + 1
print(ans)


Measured memory_bytes: 104344
fn main() {
    let v: Vec<i64> = read_vec();
    let n = v[0];
    let a = v[1];
    let b = v[2];

    let x: Vec<i64> = read_vec();
    let mut ans: i64 = 0;

    for i in 1..n {
        let tmp = (x[i as usize] - x[(i - 1) as usize]) * a;
        if tmp > b {
            ans += b;
        } else {
            ans += tmp;
        }
    }

    println!("{}", ans);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
while True:
    n = int(input())
    if n == 0:
        exit()
        
    li = list(map(int,input().split()))
    
    m = sum(li)/len(li)
    ans = 0
    
    for i in li:
        ans += ((i-m)**2)
    ans = ans/n
    ans = ans**0.5
    
    print(ans)


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

const int MAX_N = (int)1e5 + 5;

int dfss[MAX_N];
vector<int> e[MAX_N];
bool used[MAX_N];

int res, i, vc[MAX_N];
void dfs(const int& v) {
    used[v] = true;
    for (int& x : e[v]) 
        if (!used[x]) dfs(x);
    for (int i = 0; i < e[v].size(); i++) vc[i] = dfss[e[v][i]];
    sort(vc, vc + e[v].size());
    for (int i = res = 0; i < e[v].size(); i++) 
        res = max(res, vc[i] + (int)e[v].size() - i - 1);
    dfss[v] = res + 1;
}

int main() {
    int n, a;
    scanf("%d", &n);
    for (int i = 2; i <= n; i++) {
        scanf("%d", &a);
        e[a].push_back(i);
    }
    dfs(1);
    printf("%d", dfss[1] - 1);
}

Measured memory_bytes: 9344
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e9+10,mod=1e9+7;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
long long n,a,b,p;
long long qmod(long long a,long long b)
{
    if(b==0) return 1;
    long long tmp = qmod(a,b/2)%mod;
    long long ans=(tmp*tmp)%mod;
    if(b%2==1)
        ans = ((tmp*tmp)%mod*a)%mod;
    return ans;
}
long long C(long long n,long long a)
{
    a=min(a,n-a);
    long long x=1,y=1;
    for(int i=n,j=1;j<=a;i--,j++)
    {   
        x=(x*i)%mod;
        y=(y*j)%mod;
    }    
    return x*qmod(y,mod-2)%mod;
}
int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n>>a>>b;
    p=qmod(2,n);

    // cout<<p<<" "<<C(n,a)<<" "<<C(n,b)<<endl;
    long long ans=p-1-C(n,a)-C(n,b);
    while(ans<0)
        ans+=mod;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<char> t(q), d(q);
  rep(i, q) cin >> t[i] >> d[i];
  int l = 0, r = n+1;
  while (r-l > 1) {
    int mid = (l+r)/2;
    int p = mid;
    rep(i, q) {
      if (t[i] == s[p-1]) {
        if (d[i] == 'R')
          p++;
        else
          p--;
      }
    }
    if (p)
      r = mid;
    else
      l = mid;
  }
  int res = l;
  l = 0, r = n+1;
  while (r-l > 1) {
    int mid = (l+r)/2;
    int p = mid;
    rep(i, q) {
      if (t[i] == s[p-1]) {
        if (d[i] == 'R')
          p++;
        else
          p--;
      }
    }
    if (p == n+1)
      r = mid;
    else
      l = mid;
  }
  res += n-(r-1);
  int ans = max(n-res, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 976
<?php

fscanf(STDIN, "%d", $x);

while (1) {
    $flg = true;
    $sqrt = sqrt($x);

    for ($i = 2; $i <= $sqrt; ++$i) {
        if ($x % $i === 0) {
            $flg = false;
            break;
        }
    }

    if ($flg) {
        break;
    }

    ++$x;
}

echo $x;



Measured memory_bytes: 4728
#include <iostream>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
    double v;
    while(cin >> v){
        double t = v / 9.8;
        double y = t * t * 4.9;
        int ans = 0;
        rep(i, 1, 600){
            double h = 5 * (i - 1);
            if(h > y){
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string T; cin >> T;
    for (auto &x: T) {
        if (x == '?') x = 'D';
    }
    cout << T << "\n";
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;


int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    rep(i,n-1){
        int a;
        cin >> a;
        a--;
        mp[a]++;
    }
    rep(i,n){
        cout << mp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13012
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

f2 = []
ans = -10**10

for i in f:
    f_tmp = ''
    for j in i:
        f_tmp += str(j)
    f2.append(f_tmp)

li = []

def bfs():
    global li
    if len(li) == 10:
        hantei()
    else:
        li.append(0)
        bfs()
        li.pop(-1)
        li.append(1)
        bfs()
        li.pop(-1)

def hantei():
    global li,ans
    if 1 not in li:
        pass
    else:
        li_tmp = ''
        ans_tmp = 0
        for i in li:
            li_tmp += str(i)
        tmp = format(int(li_tmp, 2) & int(f2[0], 2), 'b')

        for i in range(n):
            tmp = format(int(li_tmp, 2) & int(f2[i], 2), 'b')
            ans_tmp += p[i][tmp.count('1')]

        ans = max(ans, ans_tmp)

bfs()

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std; 
long long arr[100005] , dp[100005];
int main(){
	int n , k;
	cin>>n>>k;
	for(int i = 0; i< n;  i++){
		cin>>arr[i];
		dp[i] = 1e13;
	}
	dp[0] = 0;
	for(int i = 0; i < n ; i++){
		for(int j = i + 1 ;j < n && j <= i + k ; j++)
			dp[j] = min(dp[j] , dp[i] + abs(arr[j] - arr[i]));
	}
	cout<<dp[n-1];
	return 0;
}  


Measured memory_bytes: 1792
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

s = input()

ans = 0
for i in range(len(s)//2):
    if (s[i] != s[len(s) -1 - i]):
        ans += 1
print(ans)


Measured memory_bytes: 8888
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

typedef pair<int, int> P;

struct UF {
	int n;
	vector<int>d;
	UF() {}
	UF(int n) :n(n), d(n, -1) {}

	int root(int v) {
		if (d[v] < 0) { return v; }
		return d[v] = root(d[v]);
	}
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) { return false; }
		if (size(x) < size(y)) { swap(x, y); }
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	int size(int v) { return -d[root(v)]; }
};

int L[100005];
int lang[100005];

int main() {

	int N, M;

	scanf("%d %d", &N, &M);

	int i, j;

	int K;

	UF t(100005);

	for (j = 0; j < N; j++) {

		scanf(" %d", &K);

		for (i = 0; i < K; i++) {
			scanf(" %d", &L[i]);
			lang[L[i]]++;
		}
		for (i = 0; i < K - 1; i++) {
			t.unite(L[i], L[i + 1]);
		}

	}
	int si = 0;
	for (i = 1; i <= 100000; i++) {
		if (lang[i] > 0) {
			si++;
		}
	}
	int flag = 0;
	for (i = 1; i <= 100000; i++) {
		if (lang[i] > 0) {
			if (t.size(i) != si) { 
				flag = 1; 
				break; 
			}
			else {
				break;
			}
		}
	}
	if (flag == 1) { printf("NO\n"); }
	else { printf("YES\n"); }

	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

cond = 0
tmp = A[0]
cnt = 0
for i in range(1,N):
	if cond == 0:
		if A[i] == tmp:
			tmp = A[i]
			continue
		elif A[i] < tmp:
			tmp = A[i]
			cond = -1
			continue
		else:
			tmp = A[i]
			cond = 1
			continue

	elif cond == -1:
		if A[i] > tmp:
			cnt += 1
			cond = 0
			tmp = A[i]
			continue
		else:
			tmp = A[i]
			continue

	else:
		if A[i] < tmp:
			cnt += 1
			cond = 0
			tmp = A[i]
			continue
		else:
			tmp = A[i]
			continue

print(cnt + 1)

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int p,q,r;
    cin>>p>>q>>r;
    int ans = min(p+q,q+r);
    ans=min(ans,r+p);
    cout<<ans;
    return 0;
}

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

#define all(x) (x).begin(),(x).end()
using namespace std;

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

    set<int> a,b,c;
    int n,m;
    int x;

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        a.insert(x);
    }

    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        b.insert(x);
    }

    set_symmetric_difference(all(a),all(b),inserter(c,c.end()));

    for(int i:c)
    {
        cout<<i<<endl;
    }

    return 0;
}





Measured memory_bytes: 40624
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int ans = 0;
    int i = 0;
    if(s.charAt(i) == 'R'){
      ans++;
      if(s.charAt(i + 1) == 'R'){
        ans++;
        if(s.charAt(i + 2) == 'R'){
        	ans++;
          
        }
      }
    }else if(s.charAt(i + 1) == 'R'){
      ans++;
      if(s.charAt(i + 2) == 'R'){
        ans++;
        
      }
    }else{
      if(s.charAt(i + 2) == 'R'){
        ans++;
        
      }
    }
  
System.out.print(ans);
  }
}

Measured memory_bytes: 35632
def piyo():
    n = int(input())
    hoge = n//100
    if int(str(hoge)+str(hoge))>=n%100:
        a = int(str(hoge)+str(hoge)+str(hoge))
    else:
        hoge+=1
        a = int(str(hoge)+str(hoge)+str(hoge))
    print(a)

if __name__ == '__main__':
    piyo()

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

int q;

int main(void) {
    cin >> q;

    for (int i = 0; i < q; ++i) {
        string X;
        string Y;

        cin >> X >> Y;

        int xlen = X.size();
        int ylen = Y.size();

        X = ' ' + X;
        Y = ' ' + Y;

        int lcs[1010][1010] = {};

        lcs[0][0] = 0;

        for (int x = 1; x <= xlen; ++x) {
            for (int y = 1; y <= ylen; ++y) {

                if (X[x] == Y[y]) {
                    lcs[x][y] = lcs[x - 1][y - 1] + 1;
                }
                else {
                    lcs[x][y] = max(lcs[x - 1][y], lcs[x][y - 1]);
                }
            }
        }

        cout << lcs[xlen][ylen] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 7148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
  int n;cin>>n;
  int X[n],Y[n];
  vector<int> zipx,zipy;
  rep(i,n){
    int p,q;cin>>p>>q;
    X[i]=p;Y[i]=q;
    zipx.push_back(p);
    zipy.push_back(q);
  }
  sort(all(zipx));sort(all(zipy));
  zipx.erase(unique(all(zipx)),zipx.end());
  zipy.erase(unique(all(zipy)),zipy.end());
  UnionFind uf(2*n);
  rep(i,n){
    int p,q;
    p=lower_bound(all(zipx),X[i])-zipx.begin();
    q=lower_bound(all(zipy),Y[i])-zipy.begin();
    q+=n;
    uf.unite(p,q);
    //cout<<p<<" "<<q<<endl;
  }
  int x[2*n]={};
  int y[2*n]={};
  //rep(i,2*n)uf.find(i);
  rep(i,2*n){
    int f=uf.find(i);
    //cout<<f<<endl;
    if(i<n)x[f]++;
    else y[f]++;
  }
  ll ans=0;
  rep(i,2*n){
    ans+=1ll*x[i]*y[i];
    //cout<<x[i]<<" "<<y[i]<<endl;
  }
  cout<<ans-n<<endl;
}


Measured memory_bytes: 4340
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication35
{
    class Program
    {
        static void Main()
        {
            int a = int.Parse(Console.ReadLine());int change = 0; 
            while (true)
            {
                int @out = 0, j = 0; bool[] runner = { false, false, false };
                while (true)
                {
                    string y = Console.ReadLine();j++;
                    switch (y[1])
                    {
                        case 'I':runner[2] = runner[1];runner[1] = runner[0];runner[0]=true ; break;
                        case 'U': if (@out++ == 2) { change++; goto q; }; break;
                        case 'O':runner[0] = runner[1] = runner[2] = false; break;
                    }


                }
            q:;int m = 0;foreach (bool u in runner) if (u) m++;
                Console.WriteLine(j-3-m);if (change == a) break;
            }
        }
    }
}

Measured memory_bytes: 9128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod=1e9;
static const ll INF=1LL<<50;
using namespace std;

int main() {
	int r,d;
  	cin>>r>>d;
  	vector<int>x(11);
  	cin>>x[0];
  	for(int i=1;i<11;++i){
    	x[i]=x[i-1]*r-d;
      	cout<<x[i]<<endl;
    }return 0;
}


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

void DFS(int idx, vector<vector<int> >& node, vector<int>& prenum, vector<int>& lowest, vector<int>& parent, int& num){
// cout << "idx = " << idx << endl;
    prenum[idx] = num++;
    lowest[idx] = prenum[idx];
    for (int i = 0; i < node[idx].size(); i++) {
        if (node[idx][i] == parent[idx]) continue;
        int lowest_tmp;
        if (node[idx][i] != 0 && parent[node[idx][i]] == -1) {
            parent[node[idx][i]] = idx;
            DFS(node[idx][i], node, prenum, lowest, parent, num);
            lowest_tmp = lowest[node[idx][i]];
        } else {
            lowest_tmp = prenum[node[idx][i]];
        }
        lowest[idx] = min(lowest[idx], lowest_tmp);
    }
}

void AP(vector<vector<int> >& node, set<int>& ans){
    int size = node.size();
    vector<int> prenum(size, 0);
    vector<int> lowest(size, 0);
    vector<int> parent(size, -1);
    int num = 1;
    DFS(0, node, prenum, lowest, parent, num);
    int n_zero = 0;
    for (int i = 1; i < size; i++) {
        if (parent[i] == 0) n_zero++;
    }
    if (n_zero >= 2) ans.insert(0);
    for (int i = 1; i < size; i++) {
        if (lowest[i] >= prenum[parent[i]] && parent[i] != 0) {
            ans.insert(parent[i]);
        }
    }
// for (int i = 0; i < size; i++) {
//     cout << i << " : " << prenum[i] << " " << lowest[i] << " " << parent[i] << endl;
// }
}

int main(){
    int V, E;
    cin >> V >> E;
    vector<vector<int> > node(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        node[s].push_back(t);
        node[t].push_back(s);
    }

// for (int i = 0; i < V; i++) {
//     for (int j = 0; j < node[i].size(); j++) {
//         cout << node[i][j] << " ";
//     }
//     cout << endl;
// }

    set<int> ans;
    AP(node, ans);
    for (auto it = ans.begin(); it != ans.end(); it++) {
        cout << *it << endl;
    }
    return 0;
}



Measured memory_bytes: 4800
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int r;
	cin >> r;

	cout << r * r * 3 << endl;
}



Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;
int n, m;
int graph[50][50];
int visited[50];
int a[50];
int b[50];

void dfs(int v) {
	rep(i, m) {
		if (!graph[v][i]) continue;
		if (visited[i]) continue;
		visited[i] = 1;
		dfs(i);
	}
}

int main(void) {
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
	}
	int ans = 0;
	rep(i, m) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = 0;
		rep(j, n) visited[j] = 0;
		dfs(0);
		rep(j, n) {
			if (!visited[j]) {
				ans++;
				break;
			}
		}
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, raw_input().split())
mp = [["#"] * (W+2)]
for _ in range(H):
    a = raw_input().split()
    a = ["#"] + a + ["#"]
    mp.append(a)

mp.append(["#"]*(W+2))

for idx in range(H+2):
    print "".join(mp[idx])


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    auto S = accumulate(A.begin(), A.end(), 0L);
    if (n & 1){
        puts(S & 1 ? "First" : "Second");
        return 0;
    }

    auto mi = *min_element(A.begin(), A.end());
    puts(S % 2 != 0 or mi % 2 != 0 ? "First" : "Second");
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    lint N;
    cin >> N;

    V<lint> A(N);
    for(auto &&it : A) {
        cin >> it;
    }

    sort(A.begin(), A.end());
    lint ans = A.back() - A.front();
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int p[n];
    rep(i,n)cin >> p[i];
    int q[n];
    rep(i,n)cin >> q[i];
    int r[n];
    rep(i,n) r[i] = i + 1;

    int a = 1;
    while(true){
        int flag = 1;
        rep(i,n){
            if(r[i] != p[i])flag = 0;
        }
        if(flag)break;
        next_permutation(r, r+n);
        a++;
    }

    rep(i,n) r[i] = i + 1;
    int b = 1;
    while(true){
        int flag = 1;
        rep(i,n){
            if(r[i] != q[i])flag = 0;
        }
        if(flag)break;
        next_permutation(r, r+n);
        b++;
    }

    cout << abs(a - b) << endl;
    return 0;
}
 
 


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

int main() {
        int n, k;
        scanf("%d %d", &n, &k);
        int x = 1;
        for(int i = 0; i < n; i++) {
                x = min(2*x, x+k);
        }
        printf("%d\n", x);
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define CLR(a, b) memset((a), (b), sizeof((a)))
template <typename t> bool ckmin(t& a, const t& b) {return a > b ? a = b, true : false;}
template <typename t> bool ckmax(t& a, const t& b) {return a < b ? a = b, true : false;}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
if (DEBUG) std::cerr

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

    int r;
    cin >> r;

    cout << fixed << setprecision(9) << 2*M_PI*r << endl;
}




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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

ll gcd(ll x, ll y)
{
	ll r;
	if (x<y) swap(x, y);
	while((r = x%y)!=0){
		x = y;
		y = r;
	}
	return y;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	vll a(n);
	rep(i, n) cin >> a[i];
	ll ans = a[0];
	rep(i, n-1){
		ans = gcd(ans, a[i+1]);
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int N,Y;
  cin >> N >> Y;
  int one = -1, two = -1,three = -1;

  for(int i = 0; i <= N; i++){
    for(int j = 0; i+j <= N; j++){
      int k = N - i - j;//1000円札の枚数
      int total = 10000*i + 5000*j + 1000*k;
      if(total == Y){
        one = i;
        two = j;
        three = k;
      }
    }
  }
  cout << one << " " << two << " " << three << endl;

}

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

int n, m, q, a[55], b[55], c[55], d[55], A[11];
int f(int i) {
    int r = 0;
    if(i < n) {
        for(A[i + 1] = A[i]; A[i + 1] <= m; A[i + 1]++)
            r = max(r, f(i + 1));
        return r;
    }
    for(int j = 0; j < q; j++)
        if(A[b[j]] - A[a[j]] == c[j])
            r += d[j];
    return r;
}
int main() {
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    A[0] = 1;
    cout << f(0) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll a,b;
     cin>>a>>b;
     cout<<a*b<<endl;
    return 0;
}




Measured memory_bytes: 3652
fun main() {
    val n = readLine()!!.toInt()
    var numList = readLine()!!.split(" ").map { it.toInt() }
    var a = 0
    var b = 0

    numList = numList.sortedDescending()

    for (i in numList.indices){
        if (i%2==0){
            a += numList[i]
        }else{
            b += numList[i]
        }
    }

    println(a-b)
}

Measured memory_bytes: 39112
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
p = A[P-1]

#X番目の問題に可能性があるかどうか(0-indexed)
def f(X):
    x = A[X]
    if x + M < p: return False
    votes = M*V
    votes -= M * (P-1)
    for i in range(P-1,N):
        votes -= min(M, x + M - A[i])
    return votes <= 0

ok = 0
over = N
while over - ok > 1:
    mid = (over + ok) // 2
    if f(mid): ok = mid
    else: over = mid
print(ok+1)

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

int main() {
  int n;
  cin >> n;
  double pn[n];
  rep(i,n) cin >> pn[i];
  double dp[n+1][n+1];
  rep(i,n+1) rep(j,n+1) dp[i][j] = 0.0;
  dp[0][0] = 1.0;
  
  rep(i,n) dp[i+1][0] = dp[i][0] * (1.0-pn[i]);
  rep(i,n) rep(j,n) {
    dp[i+1][j+1] = dp[i][j] * pn[i] + dp[i][j+1] * (1.0-pn[i]);
  }
  
  double p = 0.0;
  rep(j,n+1) if (j > (n-j)) p+= dp[n][j];
  printf("%.16f", p);
}


Measured memory_bytes: 70528
import sys

N, M = map(int,input().split())
es = []
for _ in range(M):
    e = list(map(int,input().split()))
    e[2] *= -1
    es.append(e)

INF = float('inf')
d = [INF for _ in range(N+1)]
d[1] = 0
negative = [0 for _ in range(N+1)]
for i in range(N):
    for j in range(M):
        e = es[j]
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            if i == N-1:
                negative[e[0]] = 1
                negative[e[1]] = 1
for i in range(M):
    e = es[i]
    if negative[e[0]]:
        negative[e[1]] = 1
if negative[N]:
    print('inf')
else:
    print(-d[N])

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

using namespace std;

#define endl "\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

typedef long long ll;


int main(){
	ios_base::sync_with_stdio(0);
//	cin.tie(0);
	int n;
	cin>>n;
	int tmp=n;
	int sum=0;
	while(tmp){
		sum+=(tmp%10);
		tmp/=10;
	}
	if(n%sum==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    lli num;
    cin >> num;
    vector<long double> vect(num);

    for(lli i=0; i<num; i++){
        cin >> vect.at(i);
    }
    sort(vect.begin(), vect.end());
    // for(auto x: vect)
    //     cout << x << " ";
    long double v = vect[0];
    for(lli i=1; i<num; i++){
        v = (v+vect[i])/2;
    }
    cout << (long double)(v) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b,k;
    cin>>a>>b>>k;
    ll temp = k;
    temp-=a;
    if(a+b==0) return cout<<0<<" "<<0, 0;
    if(temp>0)
    {
        cout<<0<<" ";
        cout<<max(0ll,b-temp);
    }
    else{
        cout<<a-k<<" "<<b;
    }
 
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
// #include <prettyprint.hpp>
using namespace std;
typedef long long llong;
static const int max_n = 210;
// static const int max_e = 2010;
static const llong max_cost = 2000000000000000;
static const string negative_cicle = "NEGATIVE CIRCLE";
// vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
vector<vector<llong>> adj_matrix(10, vector<llong>(10, max_cost));
struct Edge{
    int from;
    int to;
    llong cost;
};
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<vector<llong>> distance_table(max_n, vector<llong>(max_n, max_cost));
vector<vector<int>> wall(max_n, vector<int>(max_n));
// vector<Edge> edge_list(max_e);
// vector<pair<llong, int>> points_sort_y;

int H, W;


void warshall_floyd(){
    for(int i=0;i<10;i++){
        // distance_table[i][i] = 0;
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                adj_matrix[j][k] = min(adj_matrix[j][k], adj_matrix[j][i]+adj_matrix[i][k]);
            }
        }
    }
}

int main(){
    int u, v;
    // bool updated = false;
    llong cost;
    // printf("ok3\n");

    // S = 0;
    scanf("%d %d", &H, &W);
    // vector<llong> ans(N);
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            scanf("%lld ", &cost);
            adj_matrix[i][j] = cost;
        }
    }
    warshall_floyd();

    llong ans = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf("%d", &u);
            if(u==-1) continue;
            ans += adj_matrix[u][1];
        }
    }


    // for(int i=0;i<N;i++){
    //     printf("i = %d [", i);
    //     for(int j=0;j<N;j++){
    //         printf("%lld ,", adj_matrix[i][j]);
    //     }
    //     printf("] \n");

    // }

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

    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <string> 

int main(){
    std::string Input;
    int i = 0;
    //Input = "fAIr, TE";
    //std::cin >> Input;
    std::getline(std::cin, Input);
    while (Input[i] != '\0'){
        if((Input[i] >= 'A') && (Input[i] <= 'Z')){
            Input[i] += 0x20;
        }else if ((Input[i] >= 'a') && (Input[i] <= 'z')){
            Input[i] -= 0x20;
        }
        i++;
    }
    
    std::cout << Input << std::endl;
    return 0;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	vector<int>v ;
	vector<int>p , q ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x ;
		cin>>x ;
		p.push_back(x) ;
	}
	for(int i = 0 ; i < n ; ++i)
	{
		int x ;
		cin>>x ;
		q.push_back(x) ;
	}
	int cnt = 0 , a = 0 , b = 0 ;
	for(int i = 1 ; i <= n ; ++i)
		v.push_back(i) ;
	do
	{
		cnt++ ;
		if(v == p)
			a = cnt ;
		if(v == q)
			b = cnt ;
	}while(next_permutation(v.begin() , v.end())) ;
	return cout<<abs(a - b)<<"\n" , 0 ;
}		

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


int main(){
  int n;
  int score;
  while(cin >> n && n){
    int lc = 1000;
    int uc = 0;
    score = 0;
    for(int i = 0; i < n; i++){
      int num;
      cin >> num;
      score += num;
      lc = min(lc, num);
      uc = max(uc, num);
    }
    cout << (score - uc - lc) / (n - 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
list_A = list(map(int, input().split()))
l, r = 0, max(list_A)

while l + 1 < r:
    m, cnt = (r + l) // 2, 0

    for a in list_A:
        cnt += (a-1)//m

    if cnt > k:
        l = m
    else:
        r = m

print(r)

Measured memory_bytes: 30620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    
    priority_queue<double, vector<double>, greater<double> > q;
    rep(i, n) {
        double v;
        cin >> v;
        q.push(v);
    }
    
    rep(i, n - 1) {
        double a = q.top();
        q.pop();
        double b = q.top();
        q.pop();
        double c = (a + b) / 2;
        q.push(c);
    }
    out(FIX(6) << q.top());
}


Measured memory_bytes: 256