akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::*;

const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {

    let s: String = read().unwrap();
    let ans: String = s.chars()
        .enumerate()
        .filter(|&(index, _)| index % 2 == 0)
        .map(|tuple| tuple.1)
        .collect();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(43);

int x, a;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> x >> a;
  if(x < a)
    cout << 0;
  else
    cout << 10;
    
	return 0;
}

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


using namespace std;

const int MAXN = 100010;

typedef pair<int, int> pii;

vector<pii> v;
int p[MAXN], q[MAXN];

int main()
{
	int w, h;
	cin >> w >> h;
	for (int i = 0; i < w; i++)
	{
		cin >> p[i];
		v.push_back(pii(p[i], i + 1));
	}
	for (int i = 0; i < h; i++)
	{
		cin >> q[i];
		v.push_back(pii(q[i], -(i + 1)));
	}
	sort(v.begin(), v.end());
	int cntY = h + 1, cntX = w + 1;
	long long res = 0;
	for (int i = 0; i < v.size(); i++)
	{
		int idx;
		if (v[i].second < 0)
		{
			idx = -v[i].second  - 1;
			res += (long long)q[idx] * cntX;
			cntY--;
		}
		else
		{
			idx = v[i].second - 1;
			res += (long long)p[idx] * cntY;
			cntX--;
		}
	}
	cout << res << endl;

}

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

using namespace std;
typedef long long ll;
const int MAXN = 2e3 + 5;
int a[MAXN];
set<int> s;

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    for (int i = a; i <= a + n - 1; i++)
        s.insert(i);
    for (int i = b; i >= b - n + 1; i--)
        s.insert(i);
    for (auto i : s) {
        if (i >= a && i <= b)
            cout << i << endl;
    }
    return 0;
}

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

using namespace std;

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

  int K, A, B;
  cin >> K >> A >> B;
  if (A <= B / K * K)
    cout << "OK" << '\n';
  else
    cout << "NG" << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MEM 1000
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
long long t,n,m;
string s;
int main()
{
    sanic;
    cin >> n >> m;
    for(int i=1; i<=10000; i++){
        int a=i*0.08;
        int b=i*0.1;
        if(n==a && m==b){
            cout << i;
            return 0;
        }
    }
    cout << -1;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h==0 && w==0)    break;
            for(int i=0;i<h;i++){
                if(i==0 || i==h-1){
                    for(int j=0;j<w;j++){
                        System.out.print("#");
                    }
                    System.out.println();
                }else{

                    for(int j=0;j<w;j++){
                        if(j==0 || j==w-1){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }

                    }
                    System.out.println();
                }
            }
            System.out.println();
        }


        sc.close();
    
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int>data(N);
  for(int i=0;i<N;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  cout << data.at(N/2)-data.at(N/2-1) << endl;
}

Measured memory_bytes: 3760
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    s = gets.chomp.chars.sort

    lc = ''
    s.each do |c|
      if c == lc
        puts "no"
        return
      end
      lc = c
    end
    puts "yes"
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

	int n = 5;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

	int idx = 0;
	int mn = 200;
	for(int i = 0; i < n; ++i){
		if(a[i]%10 == 0) continue;
		if(a[i]%10 < mn){
			mn = a[i]%10;
			idx = i;
		}
	}

	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(idx == i) continue;
		ans += (a[i] + 9)/10*10;
	}
	ans += a[idx];
	ppp(ans);


    return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
hate = input().split()

sw = False

while True:
    N_str = str(N)
    
    for i in N_str:
        if i in hate:
            break
    else:
        sw = True
    
    if sw:
        print(N)
        break
    
    N += 1
            

Measured memory_bytes: 3060
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
	string S;
	cin >> S;
	int ans = 1;
	string now = "";
	string before = S.substr(0,1);
	FOR(i, 1, S.length()){
		now += S[i];
		if(before!=now){
			ans++;
			before = now;
			now = "";
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
  long long int n;
  cin>>n;
  int s_n=0;
  string s=to_string(n);
  for(int i=0;s[i]!='\0';i++){
    s_n+=(s[i]-'0');
  }
  if(n%s_n ==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define H_MAX 250

int parent(int i){
  return (int)i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}

int main(){
  int H[H_MAX], heap_size, i;

  scanf("%d",&heap_size);
  for(i = 1; i < heap_size+1; i++){
    scanf("%d",&H[i]);
  }

  for(i = 1; i < heap_size+1; i++){
    printf("node %d: key = %d, ",i,H[i]);
    if( i != 1 ) printf("parent key = %d, ",H[parent(i)] );
    if( left(i) <= heap_size ) printf("left key = %d, ",H[left(i)] );
    if( right(i) <= heap_size ) printf("right key = %d, ",H[right(i)] );
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>

using namespace std;

struct kasi {
	int n, p, q, r;
};

int cal(kasi k) {
	return (k.p + k.r) * 4 + k.q * 9;
}

kasi make_kasi(int n, int p, int q, int r) {
	kasi ret;

	ret.n = n;
	ret.p = p;
	ret.q = q;
	ret.r = r;

	return ret;
}

int main() {
	int n;

	while (cin >> n, n) {
		vector<kasi> kasis;
		for (int i = 0; i < n; ++i) {
			int i, p, q, r; cin >> i >> p >> q >> r;
			kasis.push_back( make_kasi(i, p, q, r) );
		}

		int P, Q, R, C; cin >> P >> Q >> R >> C;

		bool flag = false;
		for (int i = 0; i < n; ++i) {
			kasi k = kasis[i];
			if ( k.p <= P && k.q <= Q && k.r <= R && cal(k) <= C) {
				cout << k.n << endl;
				flag = true;
			}
		}

		if (!flag) cout << "NA" << endl;
	}
}

Measured memory_bytes: 940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<set>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
multiset<string>s;
multiset<string>::iterator it1,it2;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	REP(i,1,a)s.insert("a");
	REP(i,1,b)s.insert("b");
	REP(i,1,c)s.insert("c");
	REP(i,1,a+b+c-1){
		it1=s.begin();
		it2=s.end(),--it2;
		s.insert(*it1+*it2);
		s.erase(it1);
		s.erase(it2);
	}
	cout<<*s.begin()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> color(210); // R : 0, B : 1
vector<int> ans(210);
int n = 0;
void pcolor(int pos)
{
    string out;
    out.append("? ");
    for(int i = pos; i < pos+n; i++)
    {
        out.append(to_string(i) + " ");
    }
    cout << out << endl << flush;
    string c;
    cin >> c;
    if(c == "Red") color[pos] = 0;
    else color[pos] = 1;
}
void detcolor(int cand, int pos)
{
    string out;
    out.append("? ");
    for(int i = pos; i < pos+n-1; i++)
    {
        out.append(to_string(i) + " ");
    }
    out.append(to_string(cand));
    cout << out << endl << flush;
    string c;
    cin >> c;
    if(c == "Red") ans[cand] = 0;
    else ans[cand] = 1;
}
void detcolor(int cand, int pos1, int pos2)
{
    string out;
    out.append("? ");
    for(int i = 1; i <= pos1; i++)
    {
        out.append(to_string(i) + " ");
    }
    for(int i = pos2; i <= 2*n; i++)
    {
        out.append(to_string(i) + " ");
    }
    out.append(to_string(cand));
    cout << out << endl << flush;
    string c;
    cin >> c;
    if(c == "Red") ans[cand] = 0;
    else ans[cand] = 1;
}

int main()
{
    cin >> n;
    int h = n+1;
    int l = 1;
    pcolor(l);
    pcolor(h);
    while(h - l > 1)
    {
        int m = (h+l) >> 1;
        pcolor(m);
        if(color[m] == color[h]) h = m;
        else l = m;
    }
    ans[l] = color[l];
    ans[l+n] = color[h];

    for(int i = 1; i < l; i++)
    {
        detcolor(i, l+1);
    }
    for(int i = l+n+1; i <= 2*n; i++)
    {
        detcolor(i, l+1);
    }
    for(int i = l+1; i < l+n; i++)
    {
        detcolor(i, l-1, l+n+1);
    }
    string out;
    out.append("! ");
    for(int i = 1; i <= 2*n; i++)
    {
        if(ans[i] == 0) out.append("R");
        else out.append("B");
    }
    cout << out << endl << flush;
    return 0;
}

Measured memory_bytes: 724
#include <iostream>

using namespace std;

int main(){
  int time[5];

  for(int i = 0; i < 5; i++) cin >> time[i];

  int min_1digit = 0;
  int endind = 0;

  for(int i = 0; i < 5 ; i++){
    if(time[i] % 10 == 0) continue;
    if(min_1digit < 10 - time[i] % 10){
      min_1digit = 10 - time[i] % 10;
      endind = i;
    }
  }

  int ans = 0;
  for(int i = 0; i < 5; i++){
    if(endind == i) continue;
    if(time[i] % 10 == 0){
      ans += time[i];
    }
    else{
      ans += time[i] + (10 - time[i] % 10);
    }
  }
  ans += time[endind];

  cout << ans << endl;
}
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int count = s.substring(1).replaceAll("W", "").length();
		int min = count;
		for(int i = 1; i < n; i++) {
			if(s.charAt(i-1) == 'W')
				count++;
			if(s.charAt(i) == 'E')
				count--;
			if(min > count) {
				min = count;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 45196
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define INF 1e9+7
#define N 200005
#define il inline
#define re register
#define tie0 cin.tie(0),cout.tie(0)
#define fastio ios::sync_with_stdio(false)
#define File(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout)
using namespace std;
typedef long long ll;

template <typename T> inline void read(T &x) {
	T f = 1; x = 0; char c;
    for (c = getchar(); !isdigit(c); c = getchar()) if (c == '-') f = -1;
    for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x *= f;
}

struct Ball {
	ll x, y;
	bool operator < (const Ball &k) const {return x < k.x;}
} ball[N];

int n;
ll rmx, rmn, bmx, bmn, ans, res, ret;
ll x[N], y[N], mx[N], mn[N];

int main() {
	read(n);
	rmn = bmn = ret = INF;
	for (int i = 1; i <= n; ++i) {
		read(x[i]), read(y[i]);
		if (x[i] > y[i]) swap(x[i], y[i]);
		ball[i].x = x[i], ball[i].y = y[i];
		rmx = max(rmx, x[i]), rmn = min(rmn, x[i]);
		bmx = max(bmx, y[i]), bmn = min(bmn, y[i]);
	}
	res = (rmx - rmn) * (bmx - bmn);
	sort(ball + 1, ball + 1 + n);
	mx[1] = mn[1] = ball[1].y; bmn = rmn;
	for (int i = 2; i <= n; ++i) {
		mx[i] = max(mx[i-1], ball[i].y);
		mn[i] = min(mn[i-1], ball[i].y);
		if (i != n) ret = min(ret, max(mx[i], ball[n].x) - min(mn[i], ball[i+1].x));
	}
	ret *= (bmx - bmn);
	ans = min(ret, res);
	printf("%lld", ans);
	return 0;
}


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

bool rose(const vector<string>& g,int i,int j)
{
	return 0<=i && i<g.size() && 0<=j && j<g[0].size() && g[i][j]=='#';
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vector<string> g(h);
		for(int i=0;i<h;i++) cin>>g[i];
		reverse(begin(g),end(g));
		
		vector<tuple<int,int,int>> ts;
		for(int i=0;i<=h;i++) for(int j=0;j<=w;j++){
			int a=rose(g,i-1,j-1),b=rose(g,i-1,j),c=rose(g,i,j-1),d=rose(g,i,j);
			if(a==b && a==d && a!=c) ts.emplace_back(i,j,1);
			if(a==c && a==d && a!=b) ts.emplace_back(i,j,-1);
		}
		sort(begin(ts),end(ts),[&](tuple<int,int,int> a,tuple<int,int,int> b){
			int i1,j1,x1,i2,j2,x2; tie(i1,j1,x1,i2,j2,x2)=tuple_cat(a,b);
			return i1*(i2+j2)!=i2*(i1+j1)?i1*(i2+j2)<i2*(i1+j1):x1<x2;
		});
		
		int res=0,cnt=1;
		for(auto t:ts) res=max(res,cnt+=get<2>(t));
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b==c || a+c==b || b+c==a){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    rep(i,n){
        cin>>a[i];
        --a[i];
    }
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    ll ans = 0;
    rep(i,n){
        ans += b[a[i]];
        if(i+1<n&&a[i]+1==a[i+1])ans+=c[a[i]];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int A[N];
    rep(i, N) cin >> A[i];
    rep2(i, K, N-1){
        if(A[i] > A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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;

int N, M;
vector<int> g[100010];
int dp[100010];
bool seen[100010];

// 深さ優先探索
int dfs(int i) {
    // 訪問済みの場合は何もしない
    if (seen[i]) {
        return dp[i];
    }

    seen[i] = true;
    int res = 0;
    for (const auto next: g[i]) {
        //cout << "g[" << i << "]=" << next << endl;
        chmax(res, dfs(next) + 1);
    }
    dp[i] = res;
    return dp[i];
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        g[x-1].emplace_back(y-1);
    }
    // for (const auto &x: g[1]) cout << x << endl;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        chmax(ans, dfs(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 8192
#include<stdio.h>

int main(){
    int a,b,c,d,sum1,sum2;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);

    if(a<11 && b<11 && c<11 && d<11 && a>0 && b>0 && c>0 && d>0){
        sum1=a+b;
        sum2=c+d;

        if(sum1>sum2){
            printf("Left");
        }
        else if(sum1<sum2){
            printf("Right");
        }
        else if(sum1=sum2){
            printf("Balanced");
        }
    }

return 0;
}


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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

const int INF = (1 << 25);

int main(int argc, char *argv[]) {
    int n = 1000000;
    vector<int> f(n, INF);
    vector<int> z(n);

    f[0] = 0;

    int d, g;
    cin >> d >> g;
    g /= 100;

    for (int i = 1; i <= d; i++) {
      int p, c;
      cin >> p >> c;
      c /= 100;

      copy(ALL(f), z.begin());
      for (int k = 0; k < n; k++) {
        for (int j = 1; j <= p; j++) {
          int s = i * j;
          if (j == p) s += c;
          if (k - s >= 0) {
            if (f[k] > f[k - s] + j) {
              z[k] = f[k - s] + j;
            }
          }
        }
      }
      copy(ALL(z), f.begin());
    }



    int ans = INF;
    for (int i = g; i < n; i++) {
      if (f[i] < ans) ans = f[i];
    }

    cout << ans << endl;

    return 0;
}


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

ll N, L, A[100000];

int main(void) {
  cin >> N >> L;
  REP(i, 0, N) cin >> A[i];

  ll last = 0;
  REP(i, 0, N - 1) if(last == 0 && A[i] + A[i + 1] >= L) last = i + 1;

  if(last > 0) {
    cout << "Possible" << endl;
    REP(i, 1, last) cout << i << endl;
    for(ll i = N - 1; i > last; i--) cout << i << endl;
    cout << last << endl;
  } else {
    cout << "Impossible" << endl;
  }
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

ll N, K;
ll ret;

int main() {
	cin >> N >> K;
	ll t = N / K;
	ret = t * t * t;

	if (K % 2 == 0) {
		ll u = N / (K / 2) - N / K;
		ret += u * u * u;
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=210000;
int n,ans,vi[N];
char s[N];
bool check(int i){return((s[i]=='B')&(s[i+1]=='C'))|(vi[i]);}
signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int cnt=0;
	for (int i=n-1;i>=1;)
	{
		if (check(i))
		{
			cnt++;
			int j=i-1;
			while (s[j]=='A' && j>0) ans+=cnt,j--;
			i=j-1;
		}
		else cnt=0,i--;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3996
#include <stdio.h>
int main(void){
    int n,i,j,ans=0;
    char s[101];
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<n;i++){
        int cnt=0;
        int x[26]={0};
        int y[26]={0};
        for(j=0;j<n;j++){
            if(i>j) x[s[j]-'a']=1;
            else y[s[j]-'a']=1;
        }
        for(j=0;j<26;j++){
            if(x[j]==1 && x[j]==y[j]) cnt++;
        }
        if(cnt>ans) ans=cnt;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

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

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


void dodecagon()
{
  int r;
  cin >> r;

  cout << 3 * r * r << "\n";
}


void harmony()
{
  int a, b;
  cin >> a >> b;

  if (a % 2 == b % 2) cout << (a + b) / 2 << "\n";
  else cout << "IMPOSSIBLE\n";
}


void transfer()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c - (a - b)) << "\n";
}


void A_137()
{
  int a, b;
  cin >> a >> b;

  cout << max(a + b, max(a - b, a * b)) << "\n";
}


void red_or_not()
{
  int a;
  cin >> a;
  string s;
  cin >> s;

  if (a >= 3200) cout << s << "\n";
  else cout << "red\n";
}


void tenki()
{
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  for (int i = 0; i < 3; ++i)
  {
    if (s[i] == t[i]) ++cnt;
  }
  cout << cnt << "\n";
}


void password()
{
  int n;
  cin >> n;

  cout << pow(n, 3) << "\n";
}







void resistors_in_parallel()
{
  int n;
  cin >> n;
  vector<float> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  float ans = 0.0;
  for (int i = 0; i < n; ++i) ans += 1.0 / a[i];
  cout << 1.0 / ans << "\n";
}


void power_socket()
{
  int a, b;
  cin >> a >> b;

  if (b == 1) cout << 0 << "\n";

  int cnt = 1, tap = (a - 1) * cnt + 1;
  while (tap < b)
  {
    ++cnt;
    tap += a - 1;
  }
  
  cout << cnt << "\n";
}


void buffet()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n - 1; ++i) cin >> c[i];

  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += b[a[i] - 1];
    if (i > 0 && a[i - 1] + 1 == a[i]) ans += c[a[i - 1] - 1];
  }
  cout << ans << "\n";
}




int main()
{
  //security();
  //fifty_fify();
  //dodecagon();
  //harmony();
  //transfer();
  //A_137();
  //red_or_not();
  //tenki();
  //password();

  //resistors_in_parallel();
  //power_socket();
  //buffet();
  resistors_in_parallel();


}

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

int main() {
  long A,B,M;
  cin >> A >> B >> M;
  vector<double> a(A);
  vector<double> b(B);
  for(long i = 0; i < A; i++){
    cin >> a.at(i);
  }
  for(long j = 0; j < B; j++){
    cin >> b.at(j);
  }
  
  double min,cmin;
  long min_cmin;
  vector<vector<int>> c(M, vector<int>(3));
  for(long k = 0; k < M; k++){
    for(long l = 0; l < 3; l++){
      cin >> c.at(k).at(l);
    }
      cmin = a.at(c.at(k).at(0)-1) + b.at(c.at(k).at(1)-1) - c.at(k).at(2);
      if(k == 0){
        min_cmin = cmin;
        continue;
      }else if(min_cmin > cmin){
        min_cmin = cmin;
      }
  }
  min = *min_element(a.begin(),a.end()) + *min_element(b.begin(),b.end()); 
  if(min < min_cmin){
    cout << min << endl;
  }else{
    cout << min_cmin << endl;
  }
}
  

Measured memory_bytes: 7296
s = input()
gcount = 0
pcount = 0
vcount = 0
for i in s:
    if i == "p":
        if pcount < gcount:
            pcount+=1
        else:
            gcount+=1
            vcount-=1
    else:
        if pcount < gcount:
            pcount+=1
            vcount+=1
        else:
            gcount+=1
print(vcount)

Measured memory_bytes: 3316
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var s = int.Parse(line[1]);
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line2, int.Parse);
        Console.WriteLine( GetL(a, n, s));
    }
    public static int GetL (int[] a  , int n , int s)
    {
        var start = 0;  var t = 0;    var sum = 0;
        var ans = 999999;
        while (true)
        {
            while(t < n && sum < s)
            {
                sum += a[t++];
            }
            if (sum < s) break;
            ans = Math.Min(ans, t - start);
            sum -= a[start++];
        }
        if (ans == 999999) return 0;
        else return ans;
    }
}

Measured memory_bytes: 15316
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        string s;
        cin>>s;
        fori(i,s.size()) {
            if(s[i] == '?') s[i] = 'D';
        }
        cout<<s;
    }
    
    return 0;
}

Measured memory_bytes: 3736
from math import ceil


N, K = map(int, input().split())
A = list(map(int, input().split()))

def f(x):
    cnt = 0
    for a in A:
        cnt += ceil(a / x) - 1
    return True if cnt <= K else False

OK, NG = 10**9, 0
while OK - NG > 1:
    mid = (OK + NG) // 2
    if f(mid):
        OK = mid
    else:
        NG = mid

print(OK)


Measured memory_bytes: 30916
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M
using namespace std;
LL read(){
	LL nm=0,fh=1;char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
LL n,m;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	LL a=read(),b=read(),c=read(); swap(a,b);
	printf("%lld\n",a+min(a+b+1,c)); 
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int ai[10005];
#define N 1000000
int main()
{
    int a=0,b,c;
    char n[4];
    scanf("%s",n);
    for(int i=0;i<4;i++)
    {
        if(n[i]=='o')
            a++;
    }
    printf("%d\n",700+100*a);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

#define mod 1000000007
#define limit 200001
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i = 0; i < n; i++)
#define max(a,b) {if(a>b){return a;}return b;}
#define min(a,b) {if(a<b){return a;}return b;}
int up_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
int up_char(const void *left, const void *right) {return strcmp((char *)left,(char *)right);}

int main(){
    ll x;
    ll count = 1;
    ll value = 100;
    scanf("%lld",&x);
    
    while(1){
        value *= 1.01;
        if(value >= x) break;
        count++;
    }
    printf("%lld\n",count);
    return 0;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    vector<ll> V(N);
    rep(i,N) cin >> V[i];
    ll val,ans;
    ans=0;
    
    rep(i,min(N,K)+1){
        rep(l,i+1){
            int r=i-l;
            priority_queue<int, vector<int>, greater<int> > que;
            
            rep(j,l) que.push(V[j]);
            rep(j,r) que.push(V[N-1-j]);
            rep(j,K-i){
                if(que.empty()) break;
                val=que.top();

                if(val<0){
                    que.pop();
                }else{
                    break;
                }
            }
            ll tot=0;
            while(!que.empty()){
                tot+=que.top();
                que.pop();
            }

            ans = max(ans,tot);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in() + 1;
  int m = in();
  string str;
  in(str);
  foreach(i,str)i-='0';
  vector<int> dp(n,-1);
  dp[0]=0;
  multiset<int> s;
  s.insert(0);
  rep(i,1,n){
    if(s.empty())break;
    if(!str[i]){
      dp[i] = *s.rbegin()+1;
      s.insert(dp[i]);
    }
    if(i>=m and dp[i-m]!=-1)s.erase(s.find(dp[i-m]));
  }
  if(dp[n-1]==-1){
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  int pos = n-1;
  while(pos){
    rep(i,max(0,pos-m),n){
      if(dp[i]!=-1){
        ans.push_back(pos-i);
        pos = i;
        break;
      }
    }
  }
  reverse(all(ans));
  foreach(i,ans)output(i);
  outendl();
  return 0;
}


Measured memory_bytes: 3328
a = input().split(' ')
a = [int(s) for s in a]

b = input().split(' ')
b = [int(s) for s in b]

l = []
for i in range(a[1]):
    if i == 0:
        l.append(b[a[1] - 1] - b[i])
    else:
        l.append((a[0] - b[i]) + b[i - 1])
print(min(l))

Measured memory_bytes: 24948
#include<iostream>
using namespace std;
#define int long long int
bool prime(int x)
{
	if(x==2||x==3||x==5)
	    return true;
	if(x%2==0||x%3==0||x%5==0)
	    return false;
	for(int i=7;i*i<=x;i++)
	{
		if(x%i==0)
		    return false;
	}
	return true;
}
int32_t main()
{
	int n;
	cin>>n;
	int j;
	for(j=7;j;j++)
	{
		if(prime(j)&&j%5==2)
		{
			cout<<j<<" ";
			n--;
			if(n==0)
			   break;
		}
	}
	cout<<endl;
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  long long Ans1;
  long long Ans2;
  long long N;
  long long  K;
  cin>>N>>K;
  Ans2=N%K;
  Ans1=K-Ans2;
  if(Ans2>Ans1){
    cout<<Ans1<<endl;
     return 0;
  }
  if(Ans1>Ans2){
cout<<Ans2<<endl;
    return 0;
  }
  cout<<Ans2<<endl;
   return 0;
}

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

vector<vector<int>> s;
vector<int> c, t;
vector<pair<int, int>> last;
vector<int64_t> b_score;
vector<vector<int64_t>> c_score;

int64_t calc_score() {
    last.assign(26, {0, 0});
    for (auto i = 0; i < (int)t.size(); i++) {
        if(i != 0) {
            b_score[i] = b_score[i - 1];
            c_score[i] = c_score[i - 1];
        } else {
            b_score[i] = 0;
            c_score[i].assign(26, 0);
        }
        b_score[i] += s[i][t[i]];
        last[t[i]] = {i + 1, last[t[i]].first};
        for (auto j = 0; j < 26; j++) {
            c_score[i][j] -= c[j] * (i + 1 - last[j].first);
        }
    }

    int64_t ret = b_score.back();
    for (auto i = 0; i < 26; i++) ret += c_score[(int)t.size() - 1][i];
    return ret;
}

int64_t calc_score(pair<int, int> q) {
    last.assign(26, {0, 0});
    for (auto i = 0; i < (int)t.size(); i++) {
        if(i != 0) {
            b_score[i] = b_score[i - 1];
            c_score[i][q.first] = c_score[i - 1][q.first];
            c_score[i][q.second] = c_score[i - 1][q.second];
        } else {
            b_score[i] = 0;
            c_score[i][q.first] = 0;
            c_score[i][q.second] = 0;
        }
        last[t[i]] = {i + 1, last[t[i]].first};
        b_score[i] += s[i][t[i]];
        c_score[i][q.first] -= c[q.first] * (i + 1 - last[q.first].first);
        c_score[i][q.second] -= c[q.second] * (i + 1 - last[q.second].first);
    }

    int64_t ret = b_score.back();
    for (auto i = 0; i < 26; i++) ret += c_score[(int)t.size() - 1][i];
    return ret;
}

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

    c.resize(26);
    for (auto i = 0; i < 26; i++) cin >> c[i];

    s.assign(d, vector<int>(26));
    for (auto i = 0; i < d; i++) {
        for (auto j = 0; j < 26; j++) cin >> s[i][j];
    }

    int64_t ans = 0;
    int index = 0;
    for (auto i = 0; i < d; i++) {
        t.resize(i + 1);
        for (auto j = 0; j < 26; j++) {
            t[i] = j;
            b_score.assign(t.size(), 0);
            c_score.assign(t.size(), vector<int64_t>(26, 0));
            auto tmp = calc_score();
            if(tmp > ans) {
                ans = tmp; index = j;
            }
        }
        t[i] = index;
    }

    auto now = chrono::system_clock::now();
    auto end = chrono::system_clock::now() + chrono::milliseconds(1800);
    random_device seed;
    default_random_engine engine(seed());
    uniform_int_distribution<> day_dist(0, d - 1);
    uniform_int_distribution<> contest_dist(0, 25);
    b_score.assign(t.size(), 0);
    c_score.assign(t.size(), vector<int64_t>(26, 0));
    int64_t score = calc_score();
    while(now < end) {
        int day = day_dist(engine);
        int contest = contest_dist(engine);
        int prev = t[day];
        t[day] = contest;
        auto tmp = calc_score(make_pair(prev, contest));
        if(score < tmp) score = tmp;
        else {
            t[day] = prev;
            calc_score(make_pair(contest, prev));
        }
        now = chrono::system_clock::now();
    }

    for (auto & elm : t) cout << elm + 1 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int al = 0;
    for(auto &x: A) {
        cin >> x;
        al += x;
    }

    int cnt = 0;
    for(auto x: A) {
        if(4 * M * x >= al)
            cnt++;
    }
    if(cnt < M) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
nlist = [a, b, c]

if nlist.count(a) == 3:
    a = str(a)
    fst = a + a
    print(int(fst) + int(a))
else:
    maxn = max(nlist)
    minn = min(nlist)

    if nlist.count(maxn) > 1:
        maxn = str(maxn)
        fst = maxn + maxn
        print(int(fst) + minn)
    elif nlist.count(minn) > 1:
        minn = str(minn)
        maxn = str(maxn)
        fst = maxn + minn
        print(int(fst) + int(minn))
    else:
       nlist.pop(nlist.index(maxn))
       nlist.pop(nlist.index(minn))
       fst = str(maxn) + str(nlist[0])
       print(int(fst) + minn)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp> //__gnu_pbds::priority_queue
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int mo = 1e9 + 7;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

int a, b, c, d;
inline void add(int& x, int y) {
    x += y;
    if(x >= mo) x -= mo;
}

int ans;
void solve() {
    ans = 1ll * std::min(a, d + 1) 
              * std::min(b, d + 1) % mo
              * std::min(c, d + 1) % mo;

    for(int i = 0; i < 3; ++i) {
        int x = 1, lim = a - d - 1;
        while(x <= lim) {
            int nxt_x = lim + 1; 
            int y = 1ll * x * b / a;
            int z = 1ll * x * c / a;

            int len0 = std::min(y + d, b - 1) - std::max(y - d, 0) + 1;
            int len1 = std::min(z + d, c - 1) - std::max(z - d, 0) + 1;

            if(y + d <= b - 1 && y - d >= 0) {
                chkmin(nxt_x, int((1ll * (b - d) * a + b - 1) / b));
            }else {
                chkmin(nxt_x, int((1ll * (y + 1) * a + b - 1) / b));
            }

            if(z + d <= c - 1 && z - d >= 0) {
                chkmin(nxt_x, int((1ll * (c - d) * a + c - 1) / c));
            }else {
                chkmin(nxt_x, int((1ll * (z + 1) * a + c - 1) / c));
            }

            add(ans, 1ll * len0 * len1 % mo * (nxt_x - x) % mo);
            x = nxt_x;
        }
        std::swap(a, b);
        std::swap(b, c);
    }
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    read(a), read(b);
    read(c), read(d);

    solve();
    printf("%d\n", ans);

    return 0;
}


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

int main() {
  int n, x, ans = 0, min = 10000;
  vector<int> m(1001);

  cin >> n >> x;

  for (int i = 0; i < n; i++) {
    cin >> m.at(i);
    x -= m.at(i);
    ans++;
    if (m.at(i) < min) min = m.at(i);
  }

  while (x >= min) {
    ans++;
    x -= min;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
tp = 0
hp = 0

for i in range(n):
    l = input().split()
    if l[0] == l[1]:
        tp += 1
        hp += 1

    elif l[0] > l[1]:
        tp += 3

    elif l[0] < l[1]:
        hp += 3

print(f"{tp} {hp}")


Measured memory_bytes: 5608
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		Arrays.sort(H);
		long sum = 0;
		for (int i = 0; i < H.length - K; i++) {
			sum += H[i];
		}
		System.out.print(sum);
	}
}

Measured memory_bytes: 64840
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  string s;
  cin >> s;
  s.replace(0,4,"2018");
  cout << s << endl;
  return 0;
}


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

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> is(26);
  rep(i, n) is[s[i] - 'a'].insert(i);
  rep(qi, q){
    int t;
    cin >> t;
    if(t ==1){
      int i;
      char c;
      cin >> i >> c;
      i--;
      is[s[i] - 'a'].erase(i);
      s[i] = c;
      is[s[i] - 'a'].insert(i);
    }else {
      int l, r;
      cin >> l >> r;
      l--;
      int ans = 0;
      rep(i,26){
        auto it = is[i].lower_bound(l);
        if(it != is[i].end() && *it < r)ans++;
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 24324
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)



int main() {
    int n, a[100000], b[100000];
    map<int, int> m;
    
    cin >> n;
    REP(i, n){
        cin >> a[i];
        b[i] = a[i];
    }
    
    sort(b, b + n);
    REP(i, n){
        m[b[i]] = i;
    }
    
    int ans = 0;
    REP(i, n){
        if(i % 2 != m[a[i]] % 2){
            ans++;
        }
    }
    
    cout << ans / 2 << endl;
}


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

int main(){
  int A;
  int N;
  int S;
  
  cin>>N;
  cin>>A;
  
  S=N%500;
  
  if(S<=A){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#define MOD (int)(1e9+7)
using namespace std;
typedef pair<int, int> P;
struct edge {
    int to, cost;
};

class dijkstra {
private:
    int V;
    int d[100002];
    priority_queue<P, vector<P>, greater<>> que;

public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

    int find(int e) {
        return d[e];
    }
};

int gcd(int a, int b) {
    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

bool prime(int a) {
    if (a == 1)
        return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)
            return false;
    }
    return true;
}

class Union_Find {
private:
    vector<int> t, s;

public:
    Union_Find(int max_length) {
        rep(i, max_length + 1) {
            t.push_back(i);
            s.push_back(1);
        }
    }

    void Union(int x, int y) {
        if (same(x, y))
            return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        } else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        } else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        } else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }

    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }

    bool same(int x, int y) {
        return Find(x) == Find(y);
    }

    int get_Size(int a) {
        return s[a];
    }
};

vector<int> primeFactorization(int n) {
    vector<int> re;
    int cnt = 2;
    while (n != 1) {
        if (n % cnt != 0) {
            cnt++;
            continue;
        }
        n /= cnt;
        re.push_back(cnt);
    }
    return re;
}

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
#ifdef DEBUG
    cout<<1<<endl;
#endif
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;
int A[10];
int match[] = {0, 2,5,5,4,5,6,3,7,6};
int dp[11000];
int N, M;
int main() {
  
  
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> A[i];
  }
  sort(A, A + M);
  fill(dp, dp + N + 5, INT_MIN);
  
  dp[0] = 0;
  
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < M; j++) {
      if (i - match[A[j]] >= 0 && dp[i - match[A[j]]] != INT_MIN) {
        dp[i] = max(dp[i], dp[i - match[A[j]]] + 1);
      }
    }
  }
  
  int remain = N;
  for (int i = 0; i < dp[N]; i++) {
    for (int j = M - 1; j >= 0; j--) {
      if (remain - match[A[j]] >= 0 && dp[remain - match[A[j]]] + 1 == dp[remain]) {
        cout << A[j];
        remain -= match[A[j]];
        break;
      }
    }
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256