akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e12;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll dp[3010][3010];

ll score(ll xy, ll p, ll l, ll r, vl& v){
    if(l>r) return xy;
    if(dp[l][r] != LINF) return xy + dp[l][r];
    
    if(p == 0){
        ll s1 = score(xy+v[l], 1-p, l+1, r, v);
        ll s2 = score(xy+v[r], 1-p, l, r-1, v);
        dp[l][r] = max(s1,s2) - xy;
        return max(s1, s2);
    }
    else{
        ll s1 = score(xy-v[l], 1-p, l+1, r, v);
        ll s2 = score(xy-v[r], 1-p, l, r-1, v);
        dp[l][r] = min(s1,s2) - xy;
        return min(s1, s2);
    }
}

int main(){
    ll N; cin >> N;
    vl a(N); REP(i, N) cin >> a[i];
    REP(i, 3010) REP(j, 3010) dp[i][j] = LINF;
    ll ans = score(0, 0, 0, N-1, a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<long long int,long long int>> pairs(n);
  int a,b;
  for(int i=0;i<n;i++){
    cin >> a>> b;
    pairs.at(i) = make_pair(a,b);
  }
  sort(pairs.begin(),pairs.end());
  
  long long int ans = 0;
  for(int i=0;i<n;i++){
    if (m > pairs.at(i).second){
      m -= pairs.at(i).second;
      ans += pairs.at(i).first * pairs.at(i).second;
    }
    else{
      ans += pairs.at(i).first*m;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin>>N>>S;
  for(int X=0;X<S.size();X++){
    if(((int)S[X])+N>(int)'Z'){
      S[X]=(char)((int)S[X]+N-26);
    }
    else{
      S[X]=(char)((int)S[X]+N);
    }
  }
  cout<<S<<endl;
}

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

int main() {
  int n,k,ans;
  cin >> n >> k;
  vector<int> h(n);
  ans = 0;
  for(int i = 0;i < n;i++){
    cin >> h.at(i);
    if(h.at(i) >= k){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans;
  int N;
  cin >> N;
  vector<int> d(N);
  FOR(i, 0, N) { cin >> d[i]; }

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

  int half = N / 2;
  ans = d[half] - d[half - 1];

  cout << ans << '\n';

  return 0;
}

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

int main() {
  string n;
  cin >> n;
  
  rep(i, 3) {
    if(n[i] == '1') cout << 9;
    else cout << 1;
  }
  
  cout << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
import numpy as np

def buy_stock(have_money, have_stock, have_stock_valuation, stock_price):
    stock_num = have_money // stock_price
    have_money -= stock_num * stock_price
    have_stock += stock_num
    have_stock_valuation += stock_num * stock_price

    return have_money, have_stock, have_stock_valuation

def sell_stock(have_money, have_stock, have_stock_valuation, stock_price):
    have_money += have_stock * stock_price
    have_stock = 0
    have_stock_valuation = 0

    return have_money, have_stock, have_stock_valuation

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    A = np.array(A)
    have_money = 1000
    have_stock = 0
    have_stock_valuation = 0
    call_status = True

    for i in range(N):

            if call_status:
                if i == N - 1:
                    continue
                if A[i] < A[i+1]:
                    have_money, have_stock, have_stock_valuation = buy_stock(have_money, have_stock, have_stock_valuation, A[i])
                    call_status = False
                if not call_status:
                    if have_stock_valuation / have_stock < A[i]:
                        have_money, have_stock, have_stock_valuation = sell_stock(have_money, have_stock, have_stock_valuation,  A[i])
                        call_status = True
            else:
                if have_stock_valuation / have_stock < A[i]:
                    have_money, have_stock, have_stock_valuation = sell_stock(have_money, have_stock, have_stock_valuation,  A[i])
                    call_status = True
                if call_status:
                    if i == N - 1:
                        continue
                    if A[i] < A[i+1] and call_status:
                        have_money, have_stock, have_stock_valuation = buy_stock(have_money, have_stock, have_stock_valuation, A[i])
                        call_status = False
            
    print(have_money)

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
	ll n, m, k;
	cin >> n >> m >> k;
	ll a[n + 1], b[m + 1];
	a[0] = b[0] = 0;
	ll dp[m + 1];
	dp[0] = 0;
	ll dp2[n + 1];
	dp2[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		dp2[i] = dp2[i - 1] + a[i];
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		dp[i] = dp[i - 1] + b[i];
	}
	ll sum = 0;
	ll ans = 0, temp;
	for (int i = 1; i <= n; i++) {
		sum += a[i];
		if (sum > k)
			break;
		temp = i;
		ll lo = 0, hi = m;
		while (hi - lo > 1) {
			ll md = (hi + lo) / 2;
			if (dp[md] + sum <= k)
				lo = md;
			else 
				hi = md; 
		}
		if (dp[hi] + sum <= k)
			temp += hi;
		else 
			temp += lo;
		ans = max(ans, temp);
	}
	sum = 0;
	for (int i = 1; i <= m; i++) {
		sum += b[i];
		if (sum > k)
			break;
		ll lo = 0, hi = n;
		temp = i;
		while (hi - lo > 1) {
			ll md = (hi + lo) / 2;
			if (dp2[md] + sum < k)
				lo = md;
			else 
				hi = md;
		}
		if (dp2[hi] + sum <= k)
			temp += hi;
		else
			temp += lo;
		ans = max(ans, temp);
	}
	cout << ans << "\n";
 	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  if (N%2 == 1) {
    cout << 1.0 * (1 + N/2) / N << endl;
  }
  else {
    cout << 1.0 / 2.0 << endl;
  }
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll K = 0;
string s;
ll tmp;
ll ret = 0;
vector<ll> v;

void input() {
  IN(N);
  IN(K);
  IN(s);
}

void solve() {
  ll cnt = 0;
  char target = '1';
  if (s[0] == '0') {
    v.pb(0);
    target = '0';
  }
  REP(i, N) {
    if (s[i] == target) {
      cnt++;
    } else {
      v.pb(cnt);
      cnt = 1;
      target = (target == '0')?'1':'0';
    }
  }
  v.pb(cnt);
  if (target == '0') v.pb(0);

  ll sum = 0;
  ll begin = 0;
  ll end = 0;
  while(end < v.size() && end < 2*K+1) {
    sum += v[end];
    end++;
  }
  ret = sum;
  // DEBUG(begin);
  // DEBUG(end-1);
  // DEBUG("=>");
  // DEBUG(sum);
  // LN();
  while(end < v.size()) {
    sum -= v[begin];
    sum -= v[begin+1];
    sum += v[end];
    sum += v[end+1];

    begin += 2;
    end += 2;

    // DEBUG(begin);
    // DEBUG(end-1);
    // DEBUG("=>");
    // DEBUG(sum);
    // LN();
    ret = max(ret, sum);

    
  }

  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 1528
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

#define LEN 1024

void convert(char num[LEN], int a[LEN]);
void add(int a[LEN], int b[LEN], int c[LEN]);
void printLDV(int c[LEN]);

int main()
{
	int i, n, a[LEN], b[LEN], c[LEN];
	char num1[LEN], num2[LEN];

	scanf("%d", &n);

	for(i=0; i<n; i++){
		
		scanf("%s", num1);
		scanf("%s", num2);

		convert(num1, a);
		convert(num2, b);

		add(a, b, c);

		printLDV(c);

	}
	return 0;
}

void convert(char num[LEN], int x[LEN])
{
	int i;

	for(i=0; i<LEN; i++)
		x[i] = 0;

	for(i=strlen(num)-1; i>=0; i--){
		x[LEN+i-(strlen(num)-1)-1] = num[i] - '0';
	}

	return;
}

void add(int a[LEN], int b[LEN], int c[LEN])
{
	int i;

	for(i=0; i<LEN; i++)
		c[i] = 0;

	for(i=LEN-1; i>=1; i--){
		c[i] += a[i] + b[i];
		if(c[i] >= 10){
			c[i] = c[i] % 10;
			c[i-1] = 1;
		}
	}

	return;
}

void printLDV(int c[LEN])
{
	int i, flag=0;

	for(i=0; i<LEN; i++){
		if(i <= LEN-81){
			if(c[i] != 0){
				printf("overflow");
				flag = 1;
				break;
			}
		} else {
			if(c[i] != 0)
				flag = 1;
			if(flag == 1)
				printf("%d", c[i]);
		}
	}
	if(flag == 0)
		printf("0");
	printf("\n");
}

Measured memory_bytes: 620
use std::collections::{BinaryHeap, HashMap};
use std::io::Read;
use std::cmp::{min,max};
fn belmanford_trial(dist: &mut Vec<i64>, edges: & Vec<(usize, usize, i64)>){
    for &(a, b, c) in edges{
        dist[b] = min(dist[b], dist[a] + c);
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let p: i64 = iter.next().unwrap().parse().unwrap();
    let mut dists = vec![1<<60;n];
    let mut distg = vec![1<<60;n];
    let mut edges = vec![];
    let mut redges = vec![];
    for _ in 0..m{    
        let a:usize = iter.next().unwrap().parse().unwrap();
        let b:usize = iter.next().unwrap().parse().unwrap();
        let c:i64 = iter.next().unwrap().parse().unwrap();
        edges.push((a-1, b-1, p-c));
        redges.push((b-1, a-1, p-c));
    }
    dists[0] = 0;
    distg[n-1] = 0;
    for _ in 0..n+10{
        belmanford_trial(&mut dists, &edges);
    }
    for _ in 0..n+10{
        belmanford_trial(&mut distg, &redges);
    }
    
    let mut ans = vec![];
    for v in 0..n{
        ans.push(dists[v] + distg[v]);
    }
    
    for _ in 0..n+10{
        belmanford_trial(&mut dists, &edges);
    }
    for _ in 0..n+10{
        belmanford_trial(&mut distg, &redges);
    }

    for v in 0..n{
        if ans[v] != dists[v] + distg[v] && dists[v] < 1000000007 && distg[v] < 1000000007{
            println!("-1");
            return;
        }
    }    
    println!("{}", max(-ans[0], 0));
    
}


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

using namespace std;
using ll=long long;

int main()
{
    int n;cin >>n;
    vector<int>p;
    int sum=0;
    for(int i=0;i<n;i++){
        int s;
        cin >>s;
        sum+=s;
        if(s%10!=0)p.push_back(s);
    }
    bool flg=true;
    if(p.empty())flg=false;
    if(flg)sort(p.begin(),p.end());
    if(sum%10==0&&!flg)cout << 0 << endl;
    else if(sum%10==0&&flg)cout <<sum-p[0]<<endl;
    else cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1000000];
int main(){
  int K;
  cin >> K;
  a[0]=7%K;
  for(int i=1;i<K;i++)a[i]=(a[i-1]*10+7)%K;

  for(int i=0;i<K;i++)if(a[i]==0){
      cout << i+1 << endl;
      return 0;
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 7476
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int k, s;
	scanf("%d %d", &k, &s);
	int ans;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			if (s - (x + y) >= 0 && s - (x + y) <= k) {
				ans += 1;
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

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

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> mat_mul(const vector<int>& a, const vector<int>& b, int& n) {
  vector<int> ret(n+1);
  for(int i=1; i<=n; i++) {
    ret[i] = a[b[i]];
  }
  return ret;
}

vector<int> mat_pow(vector<int>& mat, int n, int& size) {
  vector<int> res(size+1);
  vector<int> a = mat;
  for(int i=1; i<=size; i++) {
    res[i] = i;
  }
  while(n > 0) {
    if (n&1) {
      res = mat_mul(res, a, size);
    }
    a = mat_mul(a, a, size); n >>= 1;
  }
  return res;
}

vector<int> mat_inv(const vector<int>& a, const int& n) {
  vector<int> ret(n+1);
  for(int i=1; i<=n; i++) {
    ret[a[i]] = i;
  }
  return ret;
}

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

  int n, k; cin >> n >> k;
  vector<int> p(n+1);
  vector<int> q(n+1);
  for(int i=1; i<=n; i++) {
    cin >> p[i];
  }
  for(int i=1; i<=n; i++) {
    cin >> q[i];
  }
  vector<int> ip = mat_inv(p, n);
  vector<int> iq = mat_inv(q, n);

  k--;
  vector<int> A = mat_mul(q, ip, n);
  A = mat_mul(A, iq, n);
  A = mat_mul(A, p, n);
  A = mat_pow(A, k/6, n);
  vector<int> IA = mat_inv(A, n);

  k = k%6;
  vector<int> ans;
  if (k==0) {
    ans = p;
  } else if (k==1) {
    ans = q;
  } else {
    k--;
    while(k--) {
      ans = mat_mul(q, mat_inv(p, n), n);
      p = q;
      q = ans;
    }
  }

  ans = mat_mul(A, ans, n);
  ans = mat_mul(ans, IA, n);

  for(int i=1; i<=n; i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <random>
#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;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

int intpow(int a,int b){
  int out=1;
  rep(i,b){
    out*=a;
  }
  return out;
}

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> c(1);
  ll ans=0;
  rep(i,n){
    cin>>a[i];
  }

  sort(a.begin(),a.end(),greater<ll>());
  c[0]=a[0];
  for(int i=1;i<n;i++){
    c.insert(c.end(),a[i]);
    c.insert(c.end(),a[i]);
    ans+=c[i-1];
  }







  cout<<ans<<endl;


}


Measured memory_bytes: 9024
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X, Y, Z = get_ints

puts "#{Z} #{X} #{Y}"


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

ll p5(ll x) { return x * x * x * x * x; }

bool solve(ll mid, ll key) {
    if (mid <= -6200) return true;
    if (mid >= 6200) return false;
    return (mid * mid * mid * mid * mid <= key);
}

ll binary_search(ll ok, ll ng, ll key) {
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (solve(mid, key)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}


int main() {
    ll X;
    cin >> X;
    for (ll y = -6200; y <= 6200; y++) {
        ll y5 = p5(y);
        ll b5, a5;

        a5 = y5;
        b5 = y5 - X;
        
        ll a, b;
        a = binary_search(-6300ll, 6300ll, a5);
        b = binary_search(-6300ll, 6300ll, b5);
        if (p5(a) == a5 && p5(b) == b5) {
            cout << a << " " << b << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-5;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

const int MAX_J = 5001;

int X,Y,Z;
int V[4];
int event[51];
int event_A[51];
double dp[51][MAX_J];

int main(){
    while(1){
        scanf("%d%d%d",&X,&Y,&Z);
        if(!X)break;

        for(int i=0;i<X;i++){
            scanf("%d",&V[i]);
        }
        fill(event,event+Y+1,0);
        for(int i=0;i<Z;i++){
            int N,E,A;
            scanf("%d%d%d",&N,&E,&A);
            event[N] = E;
            event_A[N] = A;
        }
        for(int i=0;i<Y+1;i++){
            for(int j=0;j<MAX_J;j++){
                dp[i][j] = 0;
            }
        }

        dp[0][0] = 1;
        for(int i=0;i<Y;i++){
            for(int j=0;j<MAX_J;j++){
                for(int k=0;k<X;k++){
                    int ni = min(Y, i+V[k]), nj = j;
                    if(event[ni]==1){
                        ni = min(Y, ni+event_A[ni]);
                    }else if(event[ni]==2){
                        nj += event_A[ni];
                    }else if(event[ni]==3){
                        nj = max(0, j-event_A[ni]);
                    }
                    dp[ni][nj] += dp[i][j] / X;
                }
            }
        }
        double ans = 0;
        for(int j=1;j<MAX_J;j++){
            ans += j*dp[Y][j];
        }
        printf("%d\n", (int)(ans+EPS));

        //break;
    }

    return 0;
}

Measured memory_bytes: 3180
a,b,c,x,y = map(int, input().split())

cost = 0

while x>0 or y>0:
  
  if a+b>=2*c:
    while x>0 and y>0:
      cost += 2*c
      x -= 1
      y -= 1
      
  if x>0:
    if a>=2*c:
      cost += 2*c
    else:
      cost += a
    x -= 1
  elif y>0:
    if b>=2*c:
      cost += 2*c
    else:
      cost += b
    y -= 1
    
print(cost)
    

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll N = s.size();
    if(N == 2 && s[0] == s[1]){
        print("1 2");
        return 0;
    }
    rep(i,0,N-1){
        if(s[i] == s[i+1]){
            if(i == N-2){
                cout << N-2 << " " << N << endl;
                return 0;
            }else{
                cout << i+1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }
    rep(i,0,N-2){
        if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    print("-1 -1");

}


Measured memory_bytes: 512
import java.util.Scanner;

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

    		int N = sc.nextInt();
    		int T = sc.nextInt();
    		int min = 10000000;
    		while(N-->0) {
    			int c = sc.nextInt();
    			int t = sc.nextInt();
    			if(t<=T && c<min) {
    				min = c;
    			}
    		}
    		System.out.println(min==10000000? "TLE" : min);

    	}
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    string s;
    int a,b,c,d;
    cin >> a >> b;

    if(a<=8 && b<= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    //cout <<  << endl;


    return 0;
}

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

int main(){
  int N, T;
  cin >> N >> T;
  vector<long long> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  map<long long, long long> mp;
  long long maxA = A[N-1];
  long long maxdif = 0;
  int count = 0;
  for (int i=N-2; i>=0; i--){
    if (maxdif==maxA-A[i]){
      count++;
    } else if (maxdif < maxA-A[i]){
      count = 1;
      maxdif = maxA-A[i];
    }
    maxA = max(maxA, A[i]);
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func floatSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, k := iScan(), iScan()
	h := iSScan(n)
	p := make([]float64, n)
	for i, v := range h {
		p[i] = float64(v+1) / 2
	}
	x := floatSum(p[:k])
	ans := x
	for i := k; i < n; i++ {
		x -= p[i-k]
		x += p[i]
		if ans < x {
			ans = x
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,m;
  cin>>n>>m;
  ll sum=0;
  for(ll i=0;i<m;i++){
  	ll k;
    cin>>k;
    sum += k;
  }
  if(sum>n){
    cout<<"-1\n";}
  else{
  cout<<n-sum<<"\n";}
}

Measured memory_bytes: 3564
using System;

    class Program
    {
        static void Main(string[] args)
        {
            var b = Console.ReadLine();
            if (b == "A")
            {
                Console.WriteLine("T");
                return;
            }
            if (b == "C")
            {
                Console.WriteLine("G");
                return;
            }
            if (b == "G")
            {
                Console.WriteLine("C");
                return;
            }
            if (b == "T")
            {
                Console.WriteLine("A");
                return;
            }
        }
    }

Measured memory_bytes: 11092
N, Y = map(int, input().split())

for i in range(N+1): # 1万円札
  for j in range(N-i+1): # 5千円札
    k = N - i - j
    price = i * 10000 + j * 5000 + k * 1000
    if price == Y:
      print(i, j, k)
      exit()

print('-1 -1 -1')



Measured memory_bytes: 2940
const long long c{(long long)1e9+7};
#include<bits/stdc++.h>
using namespace std;
int main(){
	int row,col;
	cin>>row>>col;
	vector<vector<char>> g(row,vector<char>(col));
	for(int i{};i<row;i++){
		string a;
		cin>>a;
		for(int j{};j<col;j++){
			g[i][j]=a[j];
		}
	}	
	vector<vector<int>> dp(row+1,vector<int>(col+1));
	dp[0][1]=1;
	for(int i{};i<row;i++){
		for(int j{};j<col;j++){
			if(g[i][j]=='#'){
				dp[i+1][j+1]=0;
			}
			else dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1];
			
			if(dp[i+1][j+1]>c){
				dp[i+1][j+1]-=c;
			}
		}
	}
	cout<<dp[row][col];
}

Measured memory_bytes: 8544
n,m=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
b=[0]*(m-1)
b=b.map.with_index{|n,i| (a[i]-a[i+1]).abs}.sort
if b.empty? or m-n<=0
    p 0
else
    p b[0,m-n].inject(:+)
end

Measured memory_bytes: 12016
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

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

const int maxn = 1e5 + 5;

int n;
int a[maxn], b[maxn];

lli x[maxn];

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i] >> b[i];
}

void solve()
{
    for(int i = 1; i <= n; ++i)
    {
        x[i] = a[i] % b[i];
        if(x[i] > 0) x[i] = b[i] - x[i];
    }
    for(int i = n - 1; i > 0; --i)
    {
        if(x[i] >= x[i + 1]) continue;
        lli k = (x[i + 1] - x[i] + b[i] - 1) / b[i];
        x[i] += k * b[i];
    }
    lli ans = 0;
    for(int i = n; i > 1; --i)
    {
        x[i] -= ans;
        x[i] += (x[i - 1] - ans - x[i]) / b[i];
        ans += x[i];
    }
    ans += (x[1] - ans);
    cout << ans << '\n';
}

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



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); 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 ld long 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;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    if (n==0){
        cout<<0<<endl;
        return 0;
    }
    ll m=1;
    vi ans;
    while(n){
        if (n&1){
            ans.pb(1);
            n-=m;
        }else{
            ans.pb(0);
        }
        n/=2;
        m*=-1;
    }
    reverse(all(ans));
    rep(i,ans.size()){
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}


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

const int N_MAX = 20;
int n, m;
double l[N_MAX], a[N_MAX], b[N_MAX];
vector<int> selected;
double result;

void combinations(int c) {
	if (c == 0) {
		double sum = 0;
		for (int i = 0; i < m; i++) {
			for (int j = i + 1; j < m; j++) {
				int s = selected[i];
				int t = selected[j];
				double x = l[s] - l[t];
				double y = a[s] - a[t];
				double z = b[s] - b[t];
				sum += x * x + y * y + z * z;
			}
		}
		result = max(result, sum);
	}
	else {
		int start = 0;
		if (c != m) {
			start = selected.back() + 1;
		}
		for (int i = start; i < n; i++) {
			selected.push_back(i);
			combinations(c - 1);
			selected.pop_back();
		}
	}
}

int main () {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> l[i] >> a[i] >> b[i];
	}
	result = 0.;
	combinations(m);
	printf("%.6lf\n", result);
	return 0;
}

Measured memory_bytes: 1264
#include <stdio.h>

int main(void){
        int n, i, max, min;
        int a[100];
        scanf("%d", &n);
        for(i=0; i<n; i++){
                scanf("%d", &a[i]);
        }
        max = a[0];
        min = a[0];
        for(i=1; i<n; i++){
                if(max < a[i])  max = a[i];
                else if(min > a[i])     min = a[i];
        }
        printf("%d\n", max - min);

        return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#define elif else if
int main(void) {

  int c[3][3];
  rep(i,3){
    rep(j,3) cin>> c[i][j];
  }

  int a[3];
  int b[3];
  string is_ok = "No";
  for(int p=0;p<=c[0][0];p++){
    a[0] = p;
    b[0] = c[0][0] -a[0];

    //予測を求める

   	if(b[0]<0){
        break;
      }
    bool is_minus = false;
    for(int j=1;j<3;j++){
      a[j] = c[j][0]-b[0];
      b[j] = c[0][j]-p;
      //cout<<a[j]<<" "<<b[j]<<endl;

      if(a[j]<0 ||b[j]<0){
        is_minus = true;
        continue;
      }
    }
    //負の値が生まれたら終わり
    if(is_minus)continue;

    int count = 0;
    for(int k=1;k<3;k++){
      for(int l=1;l<3;l++){
        if(c[k][l]==a[k]+b[l] )count++;
      }
    }
    if(count==4){
      is_ok = "Yes";
      break;
    }
  }


  cout<<is_ok<<endl;

  return 0;
}


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

using namespace std;

const int N = 200'009;

int x[N];
int h[N];
int o[N];
long long w[N];

int main() {
  int n, d, a;
  scanf("%d%d%d", &n, &d, &a);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, h + i);
    o[i] = i;
    w[i] = -1;
  }
  sort(o, o + n, [](int i, int j) {
    return x[i] < x[j];
  });
  long long sum = 0;
  for (int i = 0, j = -1; i < n; ++i) {
    if (w[o[i]] == -1) {
      w[o[i]] = sum;
    }
    long long rem = (w[o[i]] - sum) * a + h[o[i]];
    if (rem <= 0) {
      continue;
    }
    j = max(j, i);
    while (j < n && abs(x[o[i]] + d - x[o[j]]) <= d) {
      w[o[j]] = sum;
      ++j;
    }
    sum += (rem + a - 1) / a;
  }
  printf("%lld\n", sum);
}


Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  int t[N];
  for(int i=0;i<N;i++) cin >> t[i];
  int M;
  cin >> M;
  int p[M],x[M];
  for(int i=0;i<M;i++){
     cin >> p[i] >> x[i];
     p[i]--;
  }

  for(int i=0;i<M;i++){
    int ans = 0;
    for(int j=0;j<N;j++){
      if(j == p[i]) ans += x[i];
      else ans += t[j];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/// Swift5 -> Swift2.2
extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}
/// end

let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let W = input[1]

var dp = Array(repeating: 0, count: W + 1)

for _ in 0 ..< N {
    let knapsack = readLine()!.split(separator: " ").map { Int($0)! }
    let weight = knapsack[0]
    let value = knapsack[1]

    let tmp = Array(weight ... W)
    for i in stride(from: W, through: weight, by: -1) {
        dp[i] = max(dp[i], dp[i - weight] + value)
    }
}

print(dp.last!)


Measured memory_bytes: 4208
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;

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

const int INF = 2000000000; //2e9
const long long INF2 = 1000000000000000000; //1e18
const long double pi = acos(-1);

const int MOD = 1000000007; //1e9 + 7
//const int MOD = 1000000009; //1e9 + 9
//const int MOD = 998244353;




//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}

ll my_pow(ll N, ll a) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2);
			return (tempo * tempo);
		}
		else {
			tempo = my_pow(N, a - 1);
			return (tempo * N);
		}
	}
}


signed main() {
	int N; cin >> N;

	vector<int> X(N), Y(N), P(N);
	rep(i, N) cin >> X[i] >> Y[i] >> P[i];

	vector<ll> res(N + 1, INF2);
	res[N] = 0;

	int M = my_pow(2, N);
	vector<vector<int>> memox(M, vector<int>(N, -1));
	vector<vector<int>> memoy(M, vector<int>(N, -1));


	//前計算
	rep(j, M) {
		vector<int> Ys, Xs;
		Xs.push_back(0); Ys.push_back(0);
		rep(k, N) {
			if (j & (1LL << k)) Xs.push_back(X[k]);
			if (j & (1LL << k)) Ys.push_back(Y[k]);
		}
		
		rep(k, N) {
			int tempo1 = INF2;
			rep(l, (int)Xs.size()) {
				tempo1 = min(tempo1, abs(X[k] - Xs[l]));
			}
			memox[j][k] = tempo1;

			tempo1 = INF2;
			rep(l, (int)Ys.size()) {
				tempo1 = min(tempo1, abs(Y[k] - Ys[l]));
			}
			memoy[j][k] = tempo1;
		}
	}
	//前計算終わり

	rep(j, M) {
		rep(j2, M) {
			if (j & j2) continue;
			int i = __builtin_popcountll(j) + __builtin_popcountll(j2);
			ll tempo0 = 0;
			rep(k, N) tempo0 += (ll)min(memox[j][k], memoy[j2][k]) * (ll)P[k];
			res[i] = min(res[i], tempo0);
		}
	}

	rep(i, N + 1) {
		cout << res[i] << endl;
	}


}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A <= B) {
        if (C >= A && C <= B) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        if (C <= A && C >= B) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


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

int main(){
	int n; cin>>n;
	ll ans=1;
	bool flg=false;
	ll lmt=1e18;
	rep(i,n){
		ll a; cin>>a;
		if(a==0){
			cout << 0 << endl;
			return 0;
		}
		if(flg||lmt/ans<a){
			flg=true;
		}
		ans*=a;
	}
	if(flg) cout << "-1" << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 3640
from collections import deque
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
cntW=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      cntW+=1
dist=[[-1]*w for i in range(h)]
dist[0][0]=0
q=[(0,0)]
q=deque(q)
dx=[1,0,-1,0]
dy=[0,1,0,-1]
while q:
  y,x=q.pop()
  for i in range(4):
    ny,nx=y+dy[i],x+dx[i]
    if 0<=ny<h and 0<=nx<w and dist[ny][nx]==-1 and s[ny][nx]=='.':
      dist[ny][nx]=dist[y][x]+1
      q.appendleft((ny,nx))
if dist[-1][-1]==-1:
  print(-1)
else:
  print(cntW-dist[-1][-1]-1)

Measured memory_bytes: 3444
N = int(input())
d = dict()
m = 0
for i in range(N):
    w = input()
    if w in d:
        d[w] += 1
        m = max(d[w], m)
    else:
        d[w] = 1
        m = max(d[w], m)
res_list = []

for w, n in d.items():
    if (n == m):
        res_list.append(w)

for w in sorted(res_list):
    print(w)


Measured memory_bytes: 33072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e9 + 7;
ll n;

int main() {
	// your code goes here
	cin >> n;
    ll U=1;;
    ll A = 1;
    ll A_B= 1;
    for(int i=0;i<n;i++){
        U = (U%M*10%M)%M;
        A=(A%M*9%M)%M;   // is B
        A_B=(A_B%M*8%M)%M;

    }
   
    ll unio = ((2*A - A_B)%M+M)%M;
    cout <<  ((U-unio)%M+M)%M;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

ll N,C,K;

int main()
{
  cin >> N >> C >> K;
  std::vector<ll> T(N,0);
  REP(i,N) cin >> T[i];
  std::sort(T.begin(),T.end());
  ll ans = 0, id = 0, tmp = 0, start = 0;
  while(true) {
    if(id == N) break;
    start = T[id] + K;
    while(tmp < C && id < N && T[id] <= start && start <= T[id] + K) {
      tmp++;
      id++;
    }
    if(tmp > 0) {
      ans++;
      tmp = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int m = 1 << n;
    vector<int> a(m);
    rep(i, 0, m){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    vector<int> b;
    b.push_back(a[0]);
    multiset<int> s;
    rep(i, 1, m) s.insert(a[i]);
    bool f = true;
    rep(i, 0, n){
        int l = 1 << i;
        rep(j, 0, l){
            // b[j]より小さい数のうち最大のものを追加する
            auto it = s.lower_bound(b[j]);
            // cout << i << ' ' << j << " " << b[j] << " " << *it << endl;
            if(it == s.begin()){
                f = false;
                break;
            }
            it--;
            // cout << " " << *it << endl;
            b.push_back(*it);
            s.erase(it);
        }
        if(!f) break;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 16764
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //偶数球
        int m = sc.nextInt(); //奇数球
        System.out.println(choose(n, 2) + choose(m, 2));

    }

    static int choose (int n, int k){
        int ret = 1;
        if(n == k) {
            return 1;
        }else {
            for(int i = 0; i < k; i++){
                ret = ret * (n-i) / (i + 1);
            }
        return ret;}
    }
}

Measured memory_bytes: 23764
using System;

namespace Sample101
{
    class Program
    {
        static void call(int n)
        {
            for (int i = 1; i <= n; ++i)
            {

                int x = i;
                if (x % 3 == 0)
                {
                    Console.Write(" " + i);
                    continue;
                }
                do
                {
                    if (x % 10 == 3)
                    {
                        Console.Write(" " + i);
                        break;
                    }
                    x /= 10;
                } while (x != 0);
            }
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            call(n);
        }
    }
}


Measured memory_bytes: 17988
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long l[n];
    int i, j, k;
    int count=0;
    for(i=0;i<n;i++){
        cin >> l[i];
    }
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if((l[i]!=l[j])&&(l[i]!=l[k])&&(l[k]!=l[j])&&(l[i]+l[j]>l[k])&&(l[i]+l[k]>l[j])&&(l[k]+l[j]>l[i])){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    vector<int> t(M);
    for (int i = 0; i < A; i++) cin >> a[i];
    for (int i = 0; i < B; i++) cin >> b[i];
    for (int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        t[i] = a[x - 1] + b[y - 1] - c;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int minv = a[0] + b[0];
    for (int i = 0; i < M; i++)
    {
        minv = min(minv, t[i]);
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int n, q;
int sum[202020], ans[202020];
bool visited[202020];
vector<vector<int>> vvi(202020);
int main() {
    cin>>n>>q;
    REP(i, 0, n-1){
        int a, b;
        cin>>a>>b;
        vvi[a-1].emplace_back(b-1);
    }
    REP(i, 0, q){
        int p, x;
        cin>>p>>x;
        sum[p-1]+=x;
    }

    stack<pair<int, int>> stk;
    stk.push(make_pair(0, 0));
    while(!stk.empty()){
        pair<int, int> p=stk.top();
        stk.pop();
        int node=p.first;
        int cur=p.second;

        if(visited[node]) continue;

        visited[node]=true;
        ans[node]=cur+sum[node];
        REP(j, 0, vvi[node].size()){
            stk.push(make_pair(vvi[node][j], ans[node]));
        }
    }

    REP(i, 0, n-1) cout<<ans[i]<<" ";
    cout<<ans[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int calc(int x, int n) {
    string s = to_string(x);
    while (s.size() < n) {
        s += "0";
    }
    sort(all(s));
    int b = stoi(s);
    reverse(all(s));
    int a = stoi(s);

    return a - b;
}

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

    int x, n;
    while (cin >> x >> n, n) {
        set<int> st;
        vector<int> v;
        int i;
        for (i = 0; st.count(x) == 0; i++) {
            st.insert(x);
            v.emplace_back(x);
            x = calc(x, n);
        }
        int j;
        for (j = 0; v[j] != x; j++)
            ;
        cout << j << " " << x << " " << i - j << endl;
    }
}

Measured memory_bytes: 3304
/*
AizuOnline A1509
Title Rental DVD Shop NEO
WA 5/11
*/
#include <stdio.h>
#define min(x,y) (((x)<(y))?(x):(y))
//Global data section
int a,b,c,d,e;
int na,nb,nc;
//
int rent_fee(int an,int bn,int cn)
{
  if(cn==0)
    return(an*a+bn*b);
  if(an + bn + cn <= d)
    return(min(an*a+bn*b+cn*c,d*e));
  if(cn >= d)
    return(cn*e+rent_fee(an,bn,0));
  if(bn+cn >= d)
    {
    return(min(a*an+b*bn+c*cn,d*e+rent_fee(an,bn-(d-cn),0)));
    }
  else
    {
    return(min(an*a+bn*b+c*cn,(d*e+rent_fee(an-(d-bn-cn),0,0))));
    }
}

main()
{
  int ret;

  while(EOF!=scanf("%d %d %d %d %d",&a,&b,&c,&d,&e) && (a||b||c||d||e))
    {
      scanf("%d %d %d",&na,&nb,&nc);
      ret=rent_fee(na,nb,nc);
      printf("%d\n",ret);
    }

return(0);
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void){
    int h, w;
    int i, j;

    while(1){
        scanf("%d %d", &h, &w);
        if(h + w == 0)
            break;
        for(i = 0; i < h; i++){
            for(j = 0; j < w; j++){
                if((j + i) % 2 == 0)
                    putchar('#');
                else
                    putchar('.');
            }
            puts("");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 588
import sys
sys.setrecursionlimit(10000000)
MOD = 998244353
INF = 10 ** 15

def main():
    N,S = map(int,input().split())
    A = list(map(int,input().split()))

    dp = [0] * (1 + S)
    dp[0] = pow(2,N,MOD)
    inv2 = pow(2,MOD - 2,MOD)
    for a in A:
        for s in range(S,a - 1,-1):
            dp[s] = (dp[s] + dp[s - a] * inv2)%MOD
    print(dp[S])
if __name__ == '__main__':
    main()

Measured memory_bytes: 9252
import java.util.*;

public class Main {
	
    public static void main(String[]args){
        Scanner cin=new Scanner(System.in);
        int left = cin.nextInt();
        int center = cin.nextInt();
        int right = cin.nextInt();
        String result = "NO";
        
        if(center-left==right-center){
        	result = "YES";
        }
        
        System.out.println(result);
        
    }
}


Measured memory_bytes: 21844