akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using pii = pair<int,int>;
int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> task(M);
    rep(i,N){
        int a,b; cin >> a >> b;
        if(a > M) continue;
        task[M-a].push_back(b);
    }

    priority_queue<int> que;
    ll ans = 0;
    for(int i = M-1; i >= 0; i--){
        for(int t : task[i]) que.push(t);
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
use strict;
sub func {
  my($n) = shift;

  my($s, $k);
  my(%h) = ();
  my($c) = 0;
  for(my$i=0; $i<$n; $i++) {
  	$s = <>; chomp($s);
  	$k = join('', sort split("", $s));
    $h{"$k"}++;
    $c += ($h{"$k"}-1);
  }
  return $c;
}

if ($0 eq __FILE__) {
  my($n) = split(" ", <>);
  print func($n);
}


Measured memory_bytes: 13440
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int n;

int main(){
	cin >> n;
	
	bool ans = 0;
	for(int i = 1; i < 10; i++){
		for(int j = i; j < 10; j++){
			if(i*j == n) ans=1;
		}
	}
	
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int fac[1000005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i*i<=n;i++)
	{
		fac[i*i]++;
		for(int j=i*i+i;j<=n;j+=i)
		{
			fac[j]+=2;	
		}
	}
	long long ans=0;
	for(int i=1;i<n;i++)
	{
		ans+=fac[i];
		//cout<<i<<": "<<fac[i]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[50], b[50], c[50][51], d[51];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { cin >> b[i]; }
	
	incII(j, 0, 50) { d[j] = 1; }
	
	decII(l, 0, 50) {
		inc(i, n) {
			incII(j, 0, 50) { c[i][j] = 0; }
			c[i][a[i]] = 1;
		}
		
		d[l] = 0;
		bool f = true;
		inc(i, n) {
			decII(k, 1, 50) {
				if(d[k] == 0) { continue; }
				decII(j, 0, 50) { if(c[i][j]) { c[i][j % k] = 1; } }
			}
			if(c[i][b[i]] == 0) { f = false; }
		}
		if(! f) { d[l] = 1; }
	}
	
	LL ans = 0;
	if(d[50]) { ans = -1; } else { incII(j, 0, 50) { ans += ((d[j] ? 1LL : 0LL) << j); } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n, m, x, y = map(int,input().split())
xx = list(map(int,input().split()))
yy = list(map(int,input().split()))

xx.sort()
yy.sort()
for i in range(x+1,y+1):
    if xx[-1] < i and yy[0] >= i:
        print('No War')
        quit()
print('War')

Measured memory_bytes: 38256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

#define fir first
#define sec second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v)
    is >> x;
  return is;
}

ostream &operator<<(ostream &os, const pair<char, int> &unit) {
  return os << unit.first << "^" << unit.second;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 5010, P = 1000000007;

int f[N][N], g[N][N], pw[N];
int rsum[N];

int norm(int x) { return x >= P ? x - P : x; }

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

void sub(int &x, int y) {
  if ((x -= y) < 0)
    x += P;
}

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, a, b;
  cin >> n >> a >> b;
  pw[0] = 1;
  for (int i = 1; i <= n; ++i) pw[i] = norm(pw[i - 1] << 1);
  if (a < b) swap(a, b);
  f[0][a] = 1;
  for (int i = 0; i <= n; ++i) {
    if (i)
      add(rsum[i], rsum[i - 1]);
    add(f[i][a - 1], rsum[i]);
    if (i)
      for (int j = 0; j <= a; ++j) {
        add(g[i][j], g[i - 1][j + 1]);
        add(f[i][j], g[i][j]);
      }
    for (int j = 1; j <= a; ++j) {
      if (!f[i][j]) continue;
      add(f[i + 1][j - 1], f[i][j]);

      add(rsum[i + 2], f[i][j]);
      if (i + b + 1 <= n)
        sub(rsum[i + b + 1], f[i][j]);

      if (j > b) {
        if (i + j <= n)
          add(f[i + j][0], f[i][j]);
      } else {
        if (i + b <= n)
          add(f[i + b][0], f[i][j]);
      }
      if (i + b + 1 <= n && j - b - 1 >= 0) {
        add(g[i + b + 1][j - b - 1], f[i][j]);
      }

    }
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    ans = (ans + f[i][0] * (ll) pw[n - i]) % P;
  }
  cout << ans << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
    fast;
    ll n, k;
    cin >> n >> k;
    vector<ll> arr(n);
    for (ll i = 0; i < n; i++)
        cin >> arr[i];
    vector<ll> res(n, INT64_MAX);
    res[n-1] = 0;
    for (ll i = n-1; i > 0; i--) {
        for (ll j = 1; j <= k; j++) {
            if (i < j)
                break;
            res[i-j] = min(res[i-j], res[i] + abs(arr[i] - arr[i-j]));
        }
    }
    cout << res[0] << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func first_pos(l []int)int{
	total := 0
	count := 0
	for idx,value := range l {
		total += value
		if idx%2 == 1{
			if total >= 0{
				count+=(total+1)
				total = -1
			}
		}else{
			if total <= 0{
				count+=(1-total)
				total = 1
			}
		}
	}
	return count
}

func first_min(l []int)int{
	total := 0
	count := 0
	for idx,value := range l {
		total += value
		if idx%2 == 0{
			if total >= 0{
				count+=(total+1)
				total = -1
			}
		}else{
			if total <= 0{
				count+=(1-total)
				total = 1
			}
		}
	}
	return count
}

func main(){
	var n,temp int
	var a []int
	fmt.Scan(&n)
	for i:=0;i < n;i++{
		fmt.Scan(&temp)
		a = append(a,temp)
	}
	if first_min(a) > first_pos(a){
		fmt.Println(first_pos(a))
	}else{
		fmt.Println(first_min(a))
	}
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,t,p;
	cin>>a>>b;
	if (b<10){
		t=a*10+b;
	}
	else if (b<100){
		t=a*100+b;
	}
	else {
		t=a*1000+b;
	}
	p=sqrt(t);
	if (p*p==t){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

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

int main(void) {
  	string s;
  	cin >> s;
  	int year=0,month=0,day=0;
  	year  = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    month = (s[5] - '0') * 10 + (s[6] - '0');
    day   = (s[8] - '0') * 10 + (s[9] - '0');
	if (month <= 4) {
		cout << "Heisei" << endl;
    } else {
		cout << "TBD" << endl;
    }
  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++)

long long int h;
long long int res = 0;

int main(){
  cin >> h;
  long long int sum = 0;
  while(h){
    h /= 2;
    sum++;
  }
  res = pow(2, sum) - 1;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int main() {

//  freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

  string s;
  cin>>s;
  cout<<s[0]<<s[1]<<s[2]<<endl;


  return 0;
}


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

using namespace std;

#define kill asdjskdlj
#define left asdjkal
int const N = 1234567;
vector<int> edges[N];
int k;
int kill[N], left[N], a[N];

static void dfs(int v) {
    kill[v] = 0;
    left[v] = 0;
    for (int to : edges[v]) {
        dfs(to);
        kill[v] += kill[to];
        if (left[to] == k - 1 && v != 0) {
            kill[v]++;
        } else {
            left[v] = std::max(left[v], left[to] + 1);
        }
    }
}

int main() {
    int n;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        --a[i];
    }
    int ans = 0;
    if (a[0] != 0) {
        a[0] = 0;
        ans++;
    }
    for (int i = 1; i < n; i++) {
        edges[a[i]].push_back(i);
    }
    dfs(0);
    printf("%d\n", kill[0] + ans);
}


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

bool shift(vector<int> &vec) {
  for (int i = 0; i < (int)vec.size(); i++) {
    if (vec.at(i) % 2 == 1)
      return false;
    vec.at(i) = vec.at(i) / 2;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);

  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }

  int counter = 0;
  while (shift(vec))
    counter++;

  cout << counter << endl;
}


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

int main()
{
  	int n;
	cin >> n;
  
  	int x, y, z = 1;
  	int count = 0;
  	int x2 = 0;
  	int y2= 0;
  	int xy =0;
  
  	for (int i=1; i<=n; ++i) {
      	while(true) {
          	x2 = x*x;
        	while(true) {
              	y2 = y*y;
              	xy = x*y;
          		while(true) {
                  	int test = x2 + y2 + z*z + xy + x*z + y*z;
                  	if ( test == i ){
                      	++count;
                      	z = 1;
                      	break;
                    }
                  	else if (test > i){
                      	z = 1;
                      	break;
                    }
                  	++z;
          		}
            	if ( y*y >= i ) {
                	y = 1;
                	break;
              	}
              	++y;
        	}
        	if ( x*x >= i ) {
            	x = 1;
                break;
          	}
          	++x;
      	}
      	cout << count << endl;
      	count = 0;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c=0,d=0;
    cin>>a>>b;
    if(a%b!=0)
        c=1;
    d=a/b;
    c+=d;
    if(b>=a)
        c=1;
    cout<<c<<endl;

    return 0;


}


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
const int M = 1e9 + 7;

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}


int modpow(int x, int p) {
    if (!p) return 1;
    int val = modpow(x, p / 2);
    val = (val * val) % M;
    if (p & 1) val = (val * x) % M;
    return val;
}

int inverse(int x) {
    return modpow(x, M - 2);
}

void solve() {
    int n;
    read(n);
    int ans = 0;
    FOR(n) {
        int l, r;
        read(l, r);
        ans += r - l + 1;
    }
    print(ans);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;

int main()
{
    //freopen("input.txt","r",stdin);
    int r;
    cin>>r;
    cout<<r*r*3;

	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;


const int MAX = 510000;
const int MOD = 1000000007;

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

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

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

int main(){

  int n,m;cin>>n>>m;

  if(abs(n-m)>=2)out(0);
  else{
    COMinit();

    out((fac[n]*fac[m]%mod)*((abs(n-m))?1:2)%mod);
  }

  return 0;
}


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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if(abs(a-b) <= t*(v-w))
        pri("YES");
    else
        pri("NO");
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 2000;

int b[N][N],w[N][N],lb[N],rb[N],lw[N],rw[N];

int main() {
	int n,k;cin>>n>>k;
	rep(i,2*k) rep(j,2*k) {b[i][j]=0;w[i][j]=0;}
	rep(i,n) {
		int x,y;char c;cin>>x>>y>>c;
		if(c=='B') b[y%(2*k)][x%(2*k)]++;
		else w[y%(2*k)][x%(2*k)]++;
	}
	rep(i,2*k) {
		lb[i]=0;rb[i]=0;lw[i]=0;rw[i]=0;
		rep(j,k) {
			lb[i]+=b[i][j];
			rb[i]+=b[i][j+k];
			lw[i]+=w[i][j];
			rw[i]+=w[i][j+k];
		}
	}
	int ans=0,lb_sum,rb_sum,lw_sum,rw_sum;
	rep(j,2*k) {
		if(j>0) {
			rep(i,2*k) {
				lb[i]+=-b[i][j-1]+b[i][(j-1+k)%(2*k)];
				rb[i]+= b[i][j-1]-b[i][(j-1+k)%(2*k)];
				lw[i]+=-w[i][j-1]+w[i][(j-1+k)%(2*k)];
				rw[i]+= w[i][j-1]-w[i][(j-1+k)%(2*k)];
			}
		}
		lb_sum=0;rb_sum=0;lw_sum=0;rw_sum=0;
		rep(i,k) {
			lb_sum+=lb[i];
			rb_sum+=rb[i+k];
			lw_sum+=lw[i+k];
			rw_sum+=rw[i];
		}
		ans=max(ans,lb_sum+rb_sum+lw_sum+rw_sum);
		rep(i,2*k-1) {
			lb_sum+=-lb[i]+lb[(i+k)%(2*k)];
			rb_sum+= rb[i]-rb[(i+k)%(2*k)];
			lw_sum+= lw[i]-lw[(i+k)%(2*k)];
			rw_sum+=-rw[i]+rw[(i+k)%(2*k)];
			ans=max(ans,lb_sum+rb_sum+lw_sum+rw_sum);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 31488
/**
 *  Author: Wasi Ur Rahman
 *  FROM RMSTU
**/
#include<bits/stdc++.h>
#define  fast   ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
#define  min3(a,b,c) min(a,min(b,c))
int main()
{
    fast;
    map<string,int> mp;
    int large = 0;
    int n;
    cin >> n;
    for(int i = 0;i<n;i++){
        string str;
        cin >> str;

        mp[str]++;

        large = max(large,mp[str]);
    }

    std::map<string,int>::iterator it;

    for(it = mp.begin(); it != mp.end(); ++it){
        if(mp[it->first] == large)
            cout << it->first << endl;
        //<< it->second << endl;
    }
    return 0;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n, T;
    cin2(n, T);
    lli t[n+1];
    ncin1(n, t);
    t[n] = t[n-1] + T;

    lli ans = 0;
    //lli start_time = 0;
    //bool flowing = false;
    //REP(i, 0, n) {
    //    lli cur = t[i];
    //    lli finish_time = t[i] + T;
    //    lli next = t[i+1];
    //    if (!flowing) {
    //        flowing = true;
    //        start_time = cur;
    //    }
    //    if (next >=  finish_time) {
    //        ans += finish_time - start_time;
    //        flowing = false;
    //    }
    //}


    REP(i, 0, n) {
        ans += min(t[i+1]-t[i], T);
    }

    cout << ans << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
	int n,k;
	cin >> n>>k;
	ll a[n+1];
	ll sum[n+1]={0};
	sum[0]=0;
	for(int i=1;i<=n;i++) {
		cin >> a[i];
		sum[i]=sum[i-1]+a[i];
	}
	
	//sort(a,a+n);
	
	ll x=0;
	for(int i=1;i<=n-k+1;i++) {
		x=max(x,sum[i+k-1]-sum[i-1]);
	}
	double ans =  (double)(x+k)/2;

	
	cout << fixed<<setprecision(12)<<ans << endl;

}

signed main() {
	boost;
	solve();
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
signed main()
{
    int a, b, q;
    cin >> a >> b >> q;
    vi s(a);
    vi t(b);
    rep(i, a)
    {
        cin >> s[i];
    }
    rep(i, b)
    {
        cin >> t[i];
    }
    s.pb(INF);
    s.pb(-INF);
    t.pb(INF);
    t.pb(-INF);
    sort(all(s));
    sort(all(t));
    rep(i, q)
    {
        int x;
        cin >> x;
        int b = lower_bound(all(s), x) - s.begin();
        int d = lower_bound(all(t), x) - t.begin();
        int a = b - 1;
        int c = d - 1;
        vi shine;
        vi temple;
        shine.pb(s[a]);
        shine.pb(s[b]);
        temple.pb(t[c]);
        temple.pb(t[d]);
        int ans = LLONG_MAX;
        rep(i, 2)
        {
            rep(j, 2)
            {
                int cc = min(abs(x - shine[i]) + abs(temple[j] - shine[i]), abs(x - temple[j]) + abs(shine[i] - temple[j]));
                ans = min(cc, ans);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2912
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map>  
#include<stack>
using namespace std;

double a, b;
int main()
{
	cin >> a >> b;
	if (a == b)
	{
		cout << "EQUAL" << endl;
	}
	else if (a > b)
	{
		cout << "GREATER" << endl;
	}
	else
	{
		cout << "LESS" << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
   
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
         return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
  
     public static int digit(long x)
    {
        int d = 0;
        if (x == 0)
            return 1;
        else
        {
            while (x > 0)
            {
                x /= 10;
                d++;
            }
            return d;
        }
    }
    public static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var input = Reads();
        var n = input[0];
        var m = input[1];
        
        var s = new long[m];
        var c = new long[m];
        for(int i = 0; i < m; i++)
        {
            input = Reads();
            s[i] = input[0];
            c[i] = input[1];
        }
        bool g = false;
        long anwer = 0;
        var d = new long[n];
        for (long i =0; i < (long)Math.Pow(10, n); i++)
        {
            int count = 0;
            for (int j = 0; j < m; j++)
            {
                if (c[j] == i / (long)Math.Pow(10, n-s[j]) % 10)
                    count++;                       
            }
            if (count == m&&n==digit(i))
            {        
                g = true;
                anwer = i;
                break;
            }        
        }
        if (g)
            Console.WriteLine(anwer);
        else
            Console.WriteLine(-1) ;

      
        Console.Out.Flush();

    }
}

Measured memory_bytes: 13396
def main(argv)
  (m, d) = gets.chomp.split(' ').map(&:to_i)
  cnt = 0
  (1..m).each do |x|
    (1..d).each do |y|
      y10 = y / 10
      y01 = y % 10
      
      next if ((y01 <= 1) || (y10 <= 1))
      
      if (y10 * y01) == x then
        cnt += 1
      end
    end
  end
  puts cnt.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int main(void){
  int X = 0;
  int N = 0;
  int display = 0;
  int i = 0;
  int j = 0;
  int k = 0;
  int a = 0;
  int flag = 0;
  
  cin >> X >> N;
  
  int p[N];
  
  for(i=0;i<N;i++){
    cin >> p[i];
  }

  while(j!=X+1){
    for(i=1;i>-2;i=i-2){
      a = X + j * i;
      for(k=0;k<N;k++){
        if(p[k] == a){
          flag = 1;
        }
      }
      if(flag == 0){
        if((a < 102) && (a >= 0)){
          display = a;
        }
      }
      flag = 0;
    }
    //flag = 0;
    if(display != 0){
      break;
    }
    j++;
  }

  cout << display << endl;
  
  return 0;
}


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


using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

const int N = 100007;
const int M = 1000000007;


LL dp[N][2];
vector <int> V[N];

void DFS(int v, int ojciec){
    dp[v][0] = 1;
    dp[v][1] = 1;
    for(auto u: V[v]){
        if(u != ojciec){
            DFS(u, v);
            dp[v][0] *= (dp[u][0]+dp[u][1]);
            dp[v][1] *= dp[u][0];
            dp[v][0] %= M;
            dp[v][1] %= M;
        }
    }
}

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    DFS(1, 0);
    cout << (dp[1][0]+dp[1][1])%M << '\n';
    
    
    return 0;
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t = 1;
const ll inf=hell, N=3005;
ll dp[3005][3005];
inline ll mult(ll x,ll y){return (x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n, s, res=0;
	cin>>n>>s;
	memset(dp,0,sizeof dp);
	vector<ll> v(n+1,0);
	rep(i,1,n+1){
		cin>>v[i];
		dp[i][v[i]]=i;
	}
	rep(i,1,n+1){
		rep(j,0,s+1)
			if(j>=v[i])
				dp[i][j]=add(dp[i][j],dp[i-1][j-v[i]]);
		res=add(res,mult(n-i+1,dp[i][s]));
		rep(j,0,s+1)
			dp[i][j]=add(dp[i][j],dp[i-1][j]);
	}
	cout<<res<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, k;
	cin >> n >> k;
	vector <int> A(n);
	int p = -1;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if(A[i] == 1) {
			p = i;
		}
	}
	int ans = MOD;
	for (int i = 0; i < k; i++) {
		ans = min(ans, (max(p + 1 - i - 1, 0) + k - 2) / (k - 1) + 
							(max(n - (p + 1 + k - i - 1), 0) + k - 2) / (k - 1) + 1);
	}
	cout << ans;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

typedef long long ll;

ll dfs(ll h) {
    if (h == 1)
        return 1;
    
    return 2*dfs(h/2)+1;
}

int main() {
    ll h;   cin >> h;
    cout << dfs(h) << endl;

    return 0;
}

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

struct color {
    double l, a, b;
};

double power(double a) {
    return a * a;
}

int main() {
    int n, m;
    cin >> n >> m;
    color c[n];
    for (int i = 0; i < n; i++) {
        cin >> c[i].l >> c[i].a >> c[i].b;
    }

    double ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        vector<int> v;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                 v.push_back(j);
            }
        }
        if (v.size() != m) continue;
        double sum = 0;
        for (int i = 0; i < v.size(); i++) {
            for (int j = i + 1; j < v.size(); j++) {
                sum += power(fabs(c[v[i]].l - c[v[j]].l)) + power(fabs(c[v[i]].a - c[v[j]].a)) + power(fabs(c[v[i]].b - c[v[j]].b));
            }
        }
        ans = max(ans, sum);
    }
    printf("%.6lf\n", ans);
    return 0;
}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
int an[100005];
bool v[100005];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>an[i];
v[1]=1;
int cns=0;
int op=1;
bool ok=1;
while(1)
{
	if(cns>10*n){
		ok=0;
		break;
	}
	if(op==2)
	break;
	if(op==an[op]){
		ok=0;
		break;
	}
	v[op]=0;
	v[an[op]]=1;
	op=an[op];
	cns++;
}
	if(ok){
		cout<<cns<<endl;
		
	}
	else
	cout<<-1<<endl;
	return 0;
} 

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

int main(){
	int n,m; cin>>n>>m;
	vector<pair<int,char>> vp(m);
	for(int i=0; i<m; i++){
		int a; char b; cin>>a>>b;
		vp[i]=make_pair(a-1,b);
	}
	int low, lim;
	if(n==1) low=0, lim=10;
	else if(n==2) low=10, lim=100;
	else low=100, lim=1000;
	for(int i=low; i<lim; i++){
		bool flg=true;
		string s=to_string(i);
		for(int j=0; j<m; j++){
			if(s[vp[j].first]!=vp[j].second) flg=false;
		}
		if(flg) {cout<<i<<endl; return 0;}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 3696
dream, erase = "dream erase".split()

s = input().strip()
while 1:
  if s.startswith(dream):
     s = s[5:]
     if s.startswith("er") and not s.startswith("era"):
       s = s[2:]
  elif s.startswith(erase):
    s = s[5:]
    if s.startswith('r'):
      s = s[1:]
  else:
    break
print("NO" if s else "YES")


Measured memory_bytes: 3316
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
half = flip div 2
aliq = ((0==).).mod
isqrt = truncate.sqrt.fromIntegral

main = do
 [n,d] <- readLnInt
 inputs <- replicateM n readLnInt
 print $ solve inputs

solve s@(as:bs:xs) = count s + (null xs)?(0,solve (tail s))

count s@(as:bs:xs) = judge?(1,0) + (null xs)?(0,count (as:xs)) where
  judge = issq $ sum $ zipWith calc as bs

calc a b = (a-b)^2

issq n = n == (isqrt n)^2


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  if (h % 3 == 0 || w % 3 == 0) cout << 0 << endl;
  else {
    ll ans = min(h, w);
    FOR(i, 1, w) {
      vector<ll> s(3);
      s[0] = h / 2 * i;
      s[1] = (h - h / 2) * i;
      s[2] = h * (w - i);
      sort(s.begin(), s.end());
      ans = min(ans, s[2] - s[0]);
    }

    FOR(i, 1, h) {
      vector<ll> s(3);
      s[0] = w / 2 * i;
      s[1] = (w - w / 2) * i;
      s[2] = w * (h - i);
      sort(s.begin(), s.end());
      ans = min(ans, s[2] - s[0]);
    }
    cout << ans << endl;
  }


  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>
#include<iomanip>
#include<bitset>

using namespace std;

/************************************************/

int main(void) {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		ans = min(ans * 2, ans + k);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define forj(j,n) for(int j=n; j>=0; j--)
#define forx(x,v) for(auto &x:v)
#define sz(v) (int)(v).size()
#define rz(n) resize(n)
#define vec(x) vector < x >
#define vvim(n,m,v) vvi v(n, vi(m))
using int64 = long long;
using vi = vector < int >;
using vi64 = vector < int64 >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "Yes\n", no = "No\n";


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int k;
	cin >> k;
	for0(i, k) {
		cout << "ACL";
	}






	return 0;
}



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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

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

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

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

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

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

int n, s, a[11], c[11], dp[11][1010];

signed main() {
	cin >> n >> s;
	rep(i,n) cin >> a[i] >> c[i];
	memset(dp,-1,sizeof(dp));
	dp[0][0] = 0;
	rep(i,n) rep(j,1010) if (dp[i][j]!=-1) rep(k,a[i]+1)
		chmax(dp[i+1][j+k], dp[i][j] + k*(i+1)*100 + (k==a[i] ? c[i] : 0));
	rep(i,1010) if (dp[n][i]>=s) return cout << i << ln, 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MAX 200000

int main()
{
	int N, A[MAX], ans;
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	std::sort(A, A+N);
	N = N/2;
	ans = A[N] - A[N-1];
	printf("%d\n", ans);
	return 0;
}

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

void comb(vector<vector <uint64_t> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
            
      v[k][j] =v[k][j] % (1000000000+7);
      
    }
  }
}

int main(){
    int N,K;
    cin >> N >>K;
    vector<vector<uint64_t> > v(N+1,vector<uint64_t>(N+1,0));
    comb(v);

    int i=0;
    uint64_t outnum =0;
    for(i=0;i<K;i++){
        if(i <= N-K){
            uint64_t divN = v[N-K+1][i+1];
            divN = divN % (1000000000+7);

            uint64_t divK = v[K-1][i];
            divK = divK %(1000000000+7);
            outnum = divN * divK;
            outnum = outnum % (1000000000+7);

            cout <<outnum<<endl;
        }
        else{
            outnum=0;
            cout<< outnum<<endl;
        }
    }

}



Measured memory_bytes: 31616
#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; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        cin>>n;
        
        vll pre(1e5+6);
        vll suff(1e5+7);
        
        for(i=1;i<=n;i++){
                cin>>x;
                pre[x]++;
                suff[x]++;
        }
        for(i=1;i<=1e5;i++){
                pre[i]+=pre[i-1];
        }
        for(i=1e5;i>=1;i--){
                suff[i]+=suff[i+1];
        }
        ll ans=0;
        for(i=1;i<=1e5;i++){
                if(pre[i-1]==suff[i])ans++;
        }
        cout<<ans<<endl;
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

int main() {
	int a, b;
	cin >> a >> b;
	
	cout << max(a - 2 * b, 0)  << endl;
	
	return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <stdio.h>
# include <cmath>
# include <iomanip>
// # include <cstring>
// # include <string>
// # include <cctype>
// # include <algorithm> //transformの関数はaslgorithmライブラリに入っているみたい。
using namespace std;
class dice{
public:
  int label[6];
  void roll(char);
};
void dice::roll(char direction){
  int temp;
  if(direction == 'E'){
    temp = label[2];
    label[2] = label[0];
    label[0] = label[3];
    label[3] = label[5];
    label[5] = temp;
  }else if(direction == 'N'){
    temp = label[4];
    label[4] = label[0];
    label[0] = label[1];
    label[1] = label[5];
    label[5] = temp;
  }else if(direction == 'S'){
    temp = label[1];
    label[1] = label[0];
    label[0] = label[4];
    label[4] = label[5];
    label[5] = temp;
  }else if(direction == 'W'){
    temp = label[3];
    label[3] = label[0];
    label[0] = label[2];
    label[2] = label[5];
    label[5] = temp;
  }
}
int main(){
  dice d1;
  string order;
  for(int i = 0;i<6;i++){
    cin >> d1.label[i];
  }
  cin >> order;
  for(int j =0;j<order.size();j++){
    d1.roll(order[j]);
  }
  cout << d1.label[0] << endl;
  return 0;
}


Measured memory_bytes: 3168
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt
    val con = Array.fill[ArrayBuffer[Int]](n)(new ArrayBuffer[Int]())
    for (i <- 0 until m) {
      val a = sc.nextInt - 1
      val b = sc.nextInt - 1
      con(a).append(b)
      con(b).append(a)
    }

    val destNum = n - 1
    var ans = false
    for (num <- con(0)) {
      if (con(num).contains(destNum)) {
        ans = true
      }
    }

    println(if (ans) "POSSIBLE" else "IMPOSSIBLE")

  }
}


Measured memory_bytes: 141112