akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
    int R, G, B, N;
    std::cin >> R >> G >> B >> N;
    int a, b, c;
    std::vector<int> x;
    x.push_back(R);
    x.push_back(G);
    x.push_back(B);
    std::sort(x.begin(), x.end(), std::greater<int>());

    int Ri = 0, Gi = 0, Bi = 0;
    int sum = 0;

    for (int i = 0; i <= (N / x[0]); i++)
    {
        for (int j = 0; j <= (N - (i * x[0])) / x[1]; j++)
        {

            if ((N - (i * x[0] + j * x[1])) % x[2] == 0)
            {
                sum++;
            }
        }
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll a, b, c, d;

ll gcd(ll x, ll y) {
	if(x % y == 0) return y;
	else return gcd(y, x % y);
}

bool chk(ll A, ll B, ll C, ll D) {
	if(D < B || A < B) return 0;
	if(C >= B  -1) return 1;
	ll tmp = gcd(B, D);
	A %= tmp;
	return B - tmp + A <= C;
}

int main() {
	cin >> n;
	while(n--) {
		cin >> a >> b >> c >> d;
		if(chk(a, b, c, d)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

int N;
vector<int> P;
vector<int> Q;
vector<int> X;
int cp=0;
int cq=0;
int c=0;



int main(){
    cin>>N;
    int a;
    rep(i,N){
        cin>>a;
        P.pb(a);
    }
    rep(i,N){
        cin>>a;
        Q.pb(a);
    }
    rep(i,N){
        X.pb(i+1);
    }
    do{
        c++;
        if(X==P){
            cp=c;
        }
        if(X==Q){
            cq=c;
        }
    }while(next_permutation(X.begin(),X.end()));
    
    cout<<abs(cp-cq)<<endl;

    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 300005
#define maxa 2000005
#define MOD    100000000  //1000000007 //998244353
#define INF 1000000000000000000
#define ll unsigned long long

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << " "; cout << endl;}


void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

vector<ll> no;
ll n, m, q, ans = 0;
ll qq[55][4];

void solve2(ll p){  //cout << p << " ";
    if(p == n){
        ll tmp = 0;
        rep(i, q)
        {
            ll a = qq[i][0]-1, b = qq[i][1]-1, c = qq[i][2], d = qq[i][3];
            if(no[b]-no[a] == c) tmp += d;
        }
        ans = max(ans, tmp);
        return;
    }

    ll l = 1;
    if(p!=0) l = no[p-1];
    for(ll i = l; i <= m; i++){
        no.pb(i);
        solve2(p+1);
        no.erase(no.end()-1);
    }

}
void solve(){
    cin >> n >> m >> q;
    rep(i, q)
    cin >> qq[i][0] >> qq[i][1] >> qq[i][2] >> qq[i][3];
    solve2(0);
    cout << ans;

}

int main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);
	
	while (n != 0) {
		int a_score = 0;
		int b_score = 0;
		
		int i;
		for (i = 0; i < n; i++) {
			int a;
			int b;
			scanf("%d %d", &a, &b);
			
			*(a >= b ? &a_score : &b_score) += a;
			*(b >= a ? &b_score : &a_score) += b;
		}
		
		printf("%d %d\n", a_score, b_score);
		
		scanf("%d", &n);
	}
	
	return 0;
}

Measured memory_bytes: 596
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,M,K = map(int,input().split())

U = UnionFind(N+1)
frendlist = [0]*(N+1)
blocklist = [0]*(N+1)
for _ in range(M):
    A, B = map(int,input().split())
    frendlist[A] +=1
    frendlist[B] +=1
    U.union(A,B)

for _ in range(K):
    C, D = map(int,input().split())
    if U.same(C,D):
        blocklist[C] +=1
        blocklist[D] +=1

for i in range(1,N+1):
    print(U.size(i)-1 -frendlist[i]-blocklist[i],end=" ")
    
    

    



Measured memory_bytes: 9372
# https://atcoder.jp/contests/abc174/submissions/15768313 さんの回答、参照

K = int(input())
num = 0
if K%2 == 0:
    print(-1)
else:
    for i in range(1, 1000000):
        num = num*10 + 7
        num %= K
        if num == 0:
            print(i)
            break
    else:
        print(-1)

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> inline void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  vector<vector<P>> v(n,vector<P>(0));
  rep(i,0,n){
    int a;cin>>a;
    rep(j,0,a){
      int x,y;cin>>x>>y;
      x--;
      v[i].pb({x,y});
    }
  }

  int ans=0;
  rep(l,0,mpow(2,n)){//
    int x=l,cnt=0,num=0;
    vector<bool> hon(n,false);
    while(x>0){
      if(x%2){
        hon[cnt]=true;
        num++;
      }
      x/=2;
      cnt++;
    }

    bool ok=true;
    rep(i,0,n){
      if(!hon[i])continue;
      rep(j,0,siz(v[i])){
        int per=v[i][j].fs;
        if(hon[per]!=v[i][j].sc){
          ok=false;
        }
      }
    }
    if(ok){
      chmax(ans,num);
    }
  }
  cout<<ans<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n;
ll ans=1,a[1<<17];
long double tot;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",a+i);
		if(a[i]==0)puts("0"),exit(0);
		tot+=log10(a[i]);
	}
	if(tot>18.1)puts("-1"),exit(0);
	for(int i=1;i<=n;i++)ans*=a[i];
	if(ans<=1e18l)printf("%lld\n",ans);
	else puts("-1");
	return 0;
}

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


int main()
{
    int n;
    cin >> n;
    long long a[n+1];
    for( int i = 1; i<=n; i++) cin >> a[i];

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

    long long ans;
    ans = 1;
    long long comp, d;
    comp = 1000000000000000000;
    for( int i = 1; i<=n; i++){
        ans = ans * a[i];
	if( i != n ){
	  d = comp/a[i+1];
	}
	else if ( i == n ){
	  d = comp;
	}
	if(ans>d){
		cout << "-1" << endl;
		return 0;
	}
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4416
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main(){
    int n,m; cin >> n >> m;
    priority_queue<int> price;
    rep(i,n) {
        int tmp;
        cin >> tmp;
        price.push(tmp);
    }
    

    rep(i,m){
        int tmp2 = price.top();
        //cout << tmp2 << endl;
        price.pop();
        price.push(tmp2/2);
        
    }
    long sum = 0;
    //rep(i,n) cout << price[i] << endl;
    rep(i,n) {
        sum+=price.top();
        price.pop();
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 892
H, W = [int(i) for i in input().split()]

masu_sum = H * W

if H == 1 or W == 1:
    ans = 1
elif masu_sum % 2 == 0:
    ans = masu_sum // 2
else:
    ans = masu_sum // 2 + 1

print(ans)

Measured memory_bytes: 3060
class LazySegmentTree
  def initialize(arr, l = 0, r = arr.size - 1)
    @l, @r = l, r
    @lazy = nil
    if l == r
      @agg = arr[l]
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @agg = aggregate(@left_child.agg, @right_child.agg)
    end
  end

  attr_reader :agg, :l, :r

  def update(l, r, x)
    if @l == @r
      @agg += x
    elsif l == @l && r == @r
      if @lazy
        @lazy += x
      else
        @lazy = x
      end
    else
      force
      @agg += x * (r - l + 1)
      if r <= @left_child.r
        @left_child.update(l, r, x)
      elsif @right_child.l <= l
        @left_child.update(l, r, x)
      else
        @left_child.update(l, @left_child.r, x)
        @right_child.update(@right_child.l, r, x)
      end
    end
  end

  attr_reader :lazy, :left_child, :right_child

  def force
    return if !@lazy
    x = @lazy
    @lazy = nil
    @agg += x * (@r - @l + 1)
    @left_child.update(@left_child.l, @left_child.r, x)
    @right_child.update(@right_child.l, @right_child.r, x)
  end

  def query(l, r)
    force
    return @agg if l == @l && r == @r
    if r <= @left_child.r
      return @left_child.query(l, r)
    elsif @right_child.l <= l
      return @right_child.query(l, r)
    else
      aggl = @left_child.query(l, @left_child.r)
      aggr = @right_child.query(@right_child.l, r)
      return aggregate(aggl, aggr)
    end
  end

  def aggregate(x, y)
    x + y
  end
end

n = gets.to_i
tree = Hash[(0..n-1).map {|i| [i, {}] }]
tree_inv = Hash[(0..n-1).map {|i| [i, nil] }]
out_degree = Hash[(0..n-1).map {|i| [i, 0] }]
n.times do |i|
  k, *neighbours = gets.split.map(&:to_i)
  neighbours.each do |j|
    tree[i][j] = 0
    out_degree[i] += 1
    tree_inv[j] = i
  end
end

subtree_size = Hash[(0..n-1).map {|i| [i, 1] }]
queue = []
out_degree.each do |i, k|
  if k == 0
    queue << i
  end
end
until queue.empty?
  i = queue.shift
  tree[i].each_key do |j|
    subtree_size[i] += subtree_size[j]
  end
  j = tree_inv[i]
  if j
    out_degree[j] -= 1
    queue << j if out_degree[j] == 0
  end
end

# Heavy-Light Decomposition
queue = [0]
position = {}
path_head = {}
until queue.empty?
  i = queue.shift
  path = [i]
  loop do
    heavy = true
    tree[i].each_key.sort_by {|j| -subtree_size[j]}.each do |j|
      if heavy
        path << j
        i = j
        heavy = false
      else
        queue << j
      end
    end
    break if heavy
  end
  path.unshift tree_inv[path[0]] if tree_inv[path[0]]
  weights = path.each_cons(2).map {|i, j| tree[i][j] }
  seg = LazySegmentTree.new(weights)
  (1..path.size - 1).each do |i|
    position[path[i]] = [seg, i - 1]
    path_head[path[i]] = path[0]
  end
end

q = gets.to_i
q.times do
  t, i, w = gets.split.map(&:to_i)
  if t == 1
    sum = 0
    loop do
      seg, j = position[i]
      break if !seg
      sum += seg.query(0, j)
      i = path_head[i]
    end
    p sum
  else
    loop do
      seg, j = position[i]
      break if !seg
      seg.update(0, j, w)
      i = path_head[i]
    end
  end
end



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

#define watch(x) cout<<#x<<" -> "<<x<<endl
#define ALL(x) x.begin() , x.end()
#define INF 100000
typedef long long ll;
using namespace std;
vector<long long> q[200002];
long long used[200002] = {0};
int cnt = 0;
void dfs(int x){
    cnt++;
    used[x] = 1;
    for (int i = 0 ;i < q[x].size(); i++){
        if (!used[q[x][i]])
            dfs(q[x][i]);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n , m;
    cin>>n>>m;
    while (m--){
        int x , y;
        cin>>x>>y;
        q[x].push_back(y);
        q[y].push_back(x);
    }
    int mx = 0;
    for (int i = 1; i<=n; i++){
        if (!used[i]){
            dfs(i);
            mx = max(cnt , mx);
            cnt = 0;
        }
    }
    cout<<mx<<endl;
}

Measured memory_bytes: 22296
a,b = map(int,input().split())
xy = [map(int, input().split()) for _ in range(a)]
x, y = [list(i) for i in zip(*xy)]
c = 0

for j in range(a):
  if (x[j])**2 + (y[j])**2 <= b**2:
    c += 1
print(str(c))

Measured memory_bytes: 116640
#include <bits/stdc++.h>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie
using namespace std;

int FE[100002];

void FuncionError(string &t){	
	FE[0] = -1;
	for(int i = 0; i < t.size();){
		int pos = FE[i];
		while(pos >= 0 && t[pos] != t[i])
			pos = FE[pos];
		FE[++i] = ++pos;
	}
}

void Aparece(string &s, string &t){
	int pos = 0;
	for(int i = 0; i < s.size(); i++){
		while(pos >= 0 && s[i] != t[pos] )
			pos = FE[pos];
		pos++;
		if(pos == t.size()){
			cout << i - t.size() + 1 << '\n';
			pos = FE[pos];
		}
	}
}

int main(){

	string s,t;


	optimizar_io(0);

	cin >> s >> t;

	FuncionError(t);
	Aparece(s,t);

	return 0;
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int fact[MAX];

void factorial(){
    fact[0] = 1;
    for (int i = 1; i < MAX; ++i) {
        fact[i] = (fact[i-1] * i )% MOD;
    }
}
int exp(int base, int e , int mod){
    int result = 1;
    base %= mod;
    while(e){
        if(e & 1 )
        result =  result  * base % mod;

            base = base * base % mod;
            e >>=1 ;
    }
    return result;
}
void solve() {
    factorial();
    int h , w , a , b;
    cin>>h>>w>>a>>b;
    vi x1;
    for(int j = b + 1 ; j <= w ; j++){
        int i = h - a;
        int term = fact[i - 1 + j - 1] *  (exp(fact[i-1] , MOD -2 , MOD)  *  exp(fact[j - 1] , MOD - 2 , MOD ) % MOD) % MOD;
        x1.push_back(term);
    }
    vi x2;
    for(int j = b + 1 ; j <= w ; j++){
        int ii = a;
        int jj = w - j + 1 ;
        int term = fact[ii - 1 + jj -1 ] * (exp(fact[ii - 1] , MOD - 2 , MOD ) * exp(fact[jj - 1] , MOD -2 , MOD) % MOD) % MOD;
        x2.push_back(term);
    }
    int ans = 0;
    for(int i = 0 ; i < x1.size() ; i++){
        ans += x1[i] * x2[i] % MOD;
        if(ans >= MOD)
            ans -= MOD;
    }
    cout<<ans<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4084
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

const int mxsz = 3e3 + 5;

double v[mxsz];

double dp[mxsz][mxsz];
bool vis[mxsz][mxsz];

int N;
double d(int n, int hd)
{
	if (n<0) return hd > (N-hd);
	if (vis[n][hd]) return dp[n][hd];
	
	vis[n][hd] = 1;
	return dp[n][hd] = v[n]*d(n-1, hd+1) + (1-v[n])*d(n-1, hd);
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	int n; cin>>n, N = n;
	for (int i=0;i<n;i++) cin>>v[i];
	
	cout<<fixed<<setprecision(10)<<d(n-1, 0)<<'\n';
}

Measured memory_bytes: 78592
#include <iostream>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <utility>



void fastio(){std::ios_base::sync_with_stdio(false);std::cin.tie(0);}

using std::string;using std::cin;using std::cout;using std::vector;using std::map;using std::set;using std::pair;using std::max;using std::min;

template<class T> int sz(T x){return (int)x.size();};

using ll=long long;

#define f first
#define s second

int main(){
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    ll max_v=2000 * n;
    vector<ll> dp(max_v+1, 1e18);
    //dp[i] is the min weight to achieve value i
    dp[0]=0;
    for(int i = 0; i < n; i++) {
        for(int j = max_v; j >= v[i]; j--){
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }
    for(ll i = max_v; i >= 0; i--){
        if(dp[i] <= W){
            cout << i << "\n";
            return 0;
        }
    }
    assert(false);
    return 0;
}



Measured memory_bytes: 4840
#pragma GCC optimize(3,"Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2e5+5;
int n,m,ans,pn,p[N];

struct dislike{
	int l,r;
	inline bool operator < (const dislike &nt) const {
		if(l==nt.l) return r>nt.r;
		return l<nt.l;
	}
}a[N];

priority_queue<int,vector<int>,greater<int> > q;

signed main(){
	read(n);read(m);
	for(int i=1;i<=n;i++) read(a[i].l),read(a[i].r);
	sort(a+1,a+1+n);
	int l=1,r=m;
	for(int i=1;i<=n;i++){
		q.push(a[i].r);
		if(l<=r&&l<=a[i].l) l++;
		else{
			p[++pn]=q.top();
			q.pop();
		}
	}
	sort(p+1,p+1+pn,greater<int>());
	for(int i=1;i<=pn;i++){
		if(l<=r&&p[i]<=r) r--;
		else ans++;
	}
	write(ans);
}

Measured memory_bytes: 3192
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

#include <boost/range/adaptors.hpp>

using namespace std;


/** 約数計算
 */
std::set<int64_t> divisors(int64_t n)
{
    std::set<int64_t> ret;
    for (int64_t i = 1; i*i <= n; ++i) {
        if (n % i == 0) {
            ret.insert(i);
            if (i != 1 && i * i != n) {
                ret.insert(n/i);
            }
        }
    }
    return ret;
}


int main()
{
    int64_t N, M;
    std::cin >> N >> M;

    auto mm = divisors(M);
    mm.insert(1);
    mm.insert(M);

    for (auto m: mm) {
        if (m >= N) {
            std::cout << M / m  << std::endl;
            return 0;
        }
    }
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int n;  // nは100<n<999
    cin >> n;

    // 処理
    // 出力
    if (n <= 111) {
        cout << "111" << endl;
    } else if (n <= 222) {
        cout << "222" << endl;
    } else if (n <= 333) {
        cout << "333" << endl;
    } else if (n <= 444) {
        cout << "444" << endl;
    } else if (n <= 555) {
        cout << "555" << endl;
    } else if (n <= 666) {
        cout << "666" << endl;
    } else if (n <= 777) {
        cout << "777" << endl;
    } else if (n <= 888) {
        cout << "888" << endl;
    } else {
        cout << "999" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,n=0;
	char s[5];
	scanf("%s",s);
	for(i=0;i<4;i++){
		if(s[i]=='+')
			n++;
		else
			n--;
	}
	printf("%d",n);
	return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;



int main(void){
	int N;
	cin>>N;
	vector<vector<int>> G(N);
	vector<pair<int, int>> vp;
	for (int i = 1; i < N; i++) {
		int a, b;
		cin>>a>>b;
		a--; b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
		vp.emplace_back(a, b);
	}

	int K = 0;
	map<pair<int, int>, int> I;
	vector<int> cs(N, 0);

	vector<int> used(N, 0);
	queue<int> que;
	used[0] = 1;
	que.emplace(0);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		if (K < (int)G[v].size()) K = G[v].size();
		int cur = 1;
		for (int u : G[v]) {
			if (used[u]) continue;
			if (cur == cs[v]) cur++;
			cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
			used[u] = 1;
			que.emplace(u);
		}
	}

	cout<< K <<endl;
	for (auto p : vp) cout<< I[p] <<endl;
	
	return 0;
}

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

int main() {
    int n, k; cin >>n >>k;
    vector<int> h;
    for (int i = 0; i < n; i++) {
        int tmp; cin >>tmp;
        h.push_back(tmp);
    }
    sort(h.begin(), h.end());
    int ret = 1000000001;
    for (int i = 0; i <= h.size() - k; i++) {
        ret = min(ret, h.at(i+k-1) - h.at(i));
    }
    cout << ret << endl;
    return 0;
}

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

int round(double x){
	if(x>=0){
		return x+0.5;
	}else{
		return x-0.5;
	}
}


int main(){

	int a,b,c,d,e,f;
	double x,y;

	while(cin>>a>>b>>c>>d>>e>>f){
		x = (c*e - b*f)/(double)(a*e - b*d);
		y = (c*d - a*f)/(double)(b*d - a*e);

		int o,p;
		o = round(x*1000);
		p = round(y*1000);


		printf("%.3lf %.3lf\n",(double)o/1000,(double)p/1000);
	}
	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set> 
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int a,b;
 cin>>a>>b;
 if (a+b==15)
 cout<<'+';
 if (a*b==15)
 cout<<'*';
 if (a+b!=15 and a*b!=15)
 cout<<'x'; 
 system("pause");
 return 0; 
 }

Measured memory_bytes: 504
#include <iostream>

using namespace std;

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

int a, b, c, x;

int main() {
    cin >> a >> b >> c >> x;
    
    int cnt = 0;

    rep(i, a + 1) {
        rep(j, b + 1) {
            rep(k, c + 1) {
                if((500 * i) + (100 * j) + (50 * k) == x) {
                    cnt++;
                }
            }
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;
set<string> que;
int n;
void f(string s,int k){
    if(k==n){
        cout<<s<<'\n';
        //que.insert(s);
        return;
    }
    set<char> st;
    rep(i,k) st.insert(s[i]);
    int c=*rbegin(st)-'a';
    rep(i,26){
        if(i<=c+1){
            string u=s;
            u+=i+'a';
            f(u,k+1);
        }
    }
}

void solve(){
    
    string s="a";
    
    f(s,1);
}

signed main(){
    cin>>n;
    f("a",1);
    // que.push(s);
    // rep(i,n-1){
    //     string t;
    //     rep(j,i) t+='a';
    //     rep(j,n-i) t+='b';
    //     que.push(t);
    // }
    
    // solve();
    // while(!que.empty()){
    //     string t=*begin(que);
    //     cout<<t<<endl;
    //     que.erase(t);
    // }
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

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

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b; cin >>a >>b;
	cout <<a*b;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3672
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int[][] dp = new int[S.length() + 1][T.length() + 1];
    for (int i = 1; i <= S.length(); i++) {
      for (int j = 1; j <= T.length(); j++) {
		if (S.charAt(i - 1) == T.charAt(j - 1)) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
        }
      }
    }
    int length = dp[S.length()][T.length()];
    char[] ans = new char[length];
    for (int i = S.length(), j = T.length(), k = length - 1; i > 0 && j > 0;) {
      if (S.charAt(i - 1) == T.charAt(j - 1)) {
        ans[k--] = S.charAt(i - 1);
        i--;
        j--;
      } else if (dp[i - 1][j] > dp[i][j - 1]) {
        i--;
      } else {
        j--;
      }
    }
    for (int i = 0; i < length; i++) System.out.print(ans[i]);
    System.out.println();
  }
}

Measured memory_bytes: 83148
n, k = map(int, input().split())
a = list(map(int, input().split()))
import collections
count_dict = collections.Counter(a)
# print(count_dict.most_common())
ans = 0
unique = count_dict.most_common()
for i in range(len(count_dict) - k):
    ans += unique[len(count_dict)-i-1][1]
print(ans)


Measured memory_bytes: 39348
#include<iostream>
using namespace std;
int main(){
int n,i,d[101],e[101];
  cin >> n;
  int ans=0;
  for(i=0;i<n;i++){
  cin >> d[i] >> e[i];
    if(d[i] == e[i]){
    ans++;
    }else{
    ans=0;
    }
    if(ans==3){
    cout << "Yes" << endl;
    return 0;
    }
  }
  cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;

bool check(string t){
    rep(i,t.size()-1){
        if(t[i] != t[i+1])return false;
    }
    return true;
}

int main(){
    cin >> s;
    ll ans = INF;
    rep(i,26){
        char c = (char)('a'+i);
        string t = s;
        while(!check(t)){
            // cout << t << endl;
            string buf = "";
            rep(i,t.size() - 1){
                if(t[i] == c || t[i+1] == c)buf += c;
                else buf += t[i];
            }
            t = buf;
        }
        // cout << c << " " << t << endl;
        ans = min(ans,(ll)(s.size() - t.size()));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <math.h>
#include <iostream>

using namespace std;

int main()
{
  string s;
  cin >> s;
  int sum = 0;
  if (s[0] == 'C')
    sum = sum + 1;
  if (s[1] == 'O')
    sum = sum + 1;
  if (s[2] == 'D')
    sum = sum + 1;
  if (s[3] == 'E')
    sum = sum + 1;
  if (s[4] == 'F')
    sum = sum + 1;
  if (s[5] == 'E')
    sum = sum + 1;
  if (s[6] == 'S')
    sum = sum + 1;
  if (s[7] == 'T')
    sum = sum + 1;
  if (s[8] == 'I')
    sum = sum + 1;
  if (s[9] == 'V')
    sum = sum + 1;
  if (s[10] == 'A')
    sum = sum + 1;
  if (s[11] == 'L')
    sum = sum + 1;
  if (s[12] == '2')
    sum = sum + 1;
  if (s[13] == '0')
    sum = sum + 1;
  if (s[14] == '1')
    sum = sum + 1;
  if (s[15] == '6')
    sum = sum + 1;
  cout << 16 - sum;
}

Measured memory_bytes: 3616
use std::cmp;

fn main(){
  let inf: u32 = 2000000000;
  let nm: Vec<usize> = read_vec();
  let n = nm[0];
  let m = nm[1];

  let mut dv: Vec<u32> = Vec::new();

  for _ in 0 .. n {
    dv.push(read());
  }

  let mut dp: Vec<u32> = vec![inf; n+1];
  dp[0] = 0;

  for _ in 0 .. m {
    let c: u32 = read();

    let mut ndp: Vec<u32> = vec![0; n+1];
    
    for i in 1 .. n+1 {
      ndp[i] = cmp::min(dp[i], dp[i-1] + c * dv[i-1]);
    }
    
    dp = ndp;
    
  }
  
  println!("{:?}", dp[n]);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,i,n,a,b,k1;
    cin>>k>>a>>b;
    i=1;
    k1=k;
    while(k<=b){
        k=i*k1;
        if(k>=a&&k<=b){
            cout<<"OK"<<endl;
            return 0;
        }
        i++;
    }
    cout<<"NG"<<endl;
    return 0;
}

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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    deque<bool> deq(26);
    for(auto c: s){
        deq[(int)(c-'a')] = !deq[(int)(c-'a')];
    }
    for(auto e: deq){
        if(e){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	vector<vector<int>> memo(8);
	rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        rep(j,2){
            rep(k,2){
                rep(l,2){
                    int it=0;
                    if(j)it+=a;
                    else it-=a;
                    if(k)it+=b;
                    else it-=b;
                    if(l)it+=c;
                    else it-=c;
                    memo[j*4+k*2+l].push_back(it);
                }
            }
        }
	}
	int ans=0;
    rep(j,2){
        rep(k,2){
            rep(l,2){
                sort(memo[j*4+k*2+l].begin(),memo[j*4+k*2+l].end(),greater<>());
                int it=0;
                rep(i,m)it+=memo[j*4+k*2+l][i];
                ans=max(ans,it);
            }
        }
    }
	cout<<ans<<endl;
}


Measured memory_bytes: 384
# Problem A - ><

S = input()
N = len(S) + 1

num_list = [0]*N
ans_sum = 0

# < process
for i in range(len(S)):
    s = S[i]
    if s=="<":
        num_list[i+1] = num_list[i] + 1

# > process
for i in range(len(S)-1, -1, -1):
    s = S[i]
    if s==">":
        num_list[i] = max(num_list[i], num_list[i+1]+1)

# sum process
for i in range(N):
    ans_sum = ans_sum + num_list[i]

print(ans_sum)


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	998244353;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, q, x, K;
string s,t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,x;
	cin>>x>>a>>b;
	if(abs(x-a) < abs(x-b)) cout<<"A";
	else cout<<"B";
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	bool a;
	bool b;
} P;
int main( void ){
	int N; cin >> N;
	int prev_input, input, cnt = 2, ans = 1; cin >> prev_input >> input;
	while(input == prev_input && cnt < N){
		cin >> input;
		cnt++;
	}
	bool is_inc = input >= prev_input;
	rep( i, 0, N - cnt ){
		prev_input = input;
		cin >> input;
		if (input == prev_input);
		else if (input >= prev_input ^ is_inc){
			if (i + cnt + 1 <  N){
				prev_input = input;
				cin >> input; cnt++;
				while(input == prev_input & i + cnt + 1 <  N){
					cin >> input;
					cnt++;
				}
				is_inc = input >= prev_input;
			}
			// is_inc = input >= prev_input;
			ans++;
		}
	}
	cout << ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main()
{
	ull q,h,s,d;
	cin>>q>>h>>s>>d;
	h=min(h,2*q);
	s=min(s,2*h);
	d=min(d,2*s);
	ull n;
	cin>>n;
	cout<<(ull)(n/2)*d+(n%2)*s<<endl;
	return 0;

}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] KX = Console.ReadLine().Split(' ');
            int K = int.Parse(KX[0]);
            int X = int.Parse(KX[1]);
            List<int> ans = new List<int>();
            for(int i = X - K + 1; i < X + K; i++)
            {
                ans.Add(i);
            }
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 27764
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int r;
    cin >> r;
    cout << pow(r,2) << endl;
    return 0;
  } 

Measured memory_bytes: 256
from collections import  Counter

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

S = [0 for _ in range(N+1)]
for i in range(N):
    S[i+1] = S[i] + A[i]
S = Counter(S)

ans = 0
for v in S.values():
    ans += v*(v-1)//2
    
print(ans)

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

int main() {
  int N,A=-1;
  cin>>N;
  vector<int64_t> p(N+2);
  p[0]=300,p[N+1]=0;
  for(int i=1;i<=N;i++){
    cin>>p[i];
  }
  int64_t Z=1000,K=0;
  for(int i=1;i<N+1;i++){
    if(A==-1&&p[i-1]>=p[i]&&p[i]<p[i+1]){
      A*=-1;
      K=Z/p[i];
      Z-=K*p[i];
    }
    else if(A==1&&p[i-1]<=p[i]&&p[i]>p[i+1]){
      A*=-1;
      Z+=K*p[i];
      K=0;
    }
  }
  cout<<Z<<endl;
  
  
}



Measured memory_bytes: 3624
from collections import deque

MOD = 10**9 + 7
H, W = map(int, input().split())
G = [input() for _ in range(H)]


def main():
    dp = [[0] * W for _ in range(H)]
    for i in range(H):
        if G[i][0] == '#':
            break
        dp[i][0] = 1
    for i in range(W):
        if G[0][i] == '#':
            break
        dp[0][i] = 1

    que = deque([(0, 0)])

    while que:
        h, w = que.popleft()
        for dh, dw in ((1, 0), (0, 1)):
            nh = h + dh
            nw = w + dw
            if nh < 0 or nw < 0 or nh >= H or nw >= W:
                continue
            if G[nh][nw] == '#':
                continue
            if nh > 0 and nw > 0:
                if dp[nh][nw]:
                    continue
                dp[nh][nw] = (dp[nh - 1][nw] + dp[nh][nw - 1]) % MOD
            que.append((nh, nw))

    print(dp[H - 1][W - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 86624
'''
Accepted    　:No
difficult   　:
ペナルティ　  　:5分
実際の回答時間  :分
WAの回数　     :回
合計時間　　  　:分
'''


def myAnswer(N: int, M: int, K: int) -> int:
   ans = set([0])
   for i in range(M):
      ans.add(N * (i + 1))
      ans.add(M - (i + 1) + (N - 1) * (i + 1))
   for i in range(N):
      ans.add(M * (i + 1))
      ans.add(N - (i + 1) + (M - 1) * (i + 1))
   print(ans)
   return "Yes" if K in ans else "No"

def modelAnswer(N,M,K):
   for k in range(N + 1):
      for l in range(M + 1):
         if k * (M - l) + l * (N - k) == K:
            return "Yes"
   return "No"
def main():
   N, M, K=map(int, input().split())
   print(modelAnswer(N, M, K))
if __name__ == '__main__':
   main()


Measured memory_bytes: 9132
x,K,D = list(map(int, input().split()))

if x < 0 :
  x = -x

l = x // D

if K > l:
  K = K - l
  if (K % 2) == 0:
    print(abs(x-D*l))
  else:
    print(abs(x-D*(l+1)))
else:
  print(abs(x - D*K))


Measured memory_bytes: 9164
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	static void run() {
		new Main().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), e = sc.nextInt(), t = sc.nextInt() - 1;
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
		}
		int[] g = new int[e];
		int[] c = new int[e];
		int[][] s = new int[e][];
		for (int i = 0; i < e; i++) {
			g[i] = sc.nextInt() - 1;
			c[i] = sc.nextInt();
			s[i] = new int[c[i]];
			for (int j = 0; j < c[i]; j++) {
				s[i][j] = sc.nextInt() - 1;
			}
		}
		long[] F = new long[n];
		Arrays.fill(F, 1L << 30);
		for (int i = 0; i < n; i++) {
			if (w[i] == 1) {
				F[i] = 1;
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < e; j++) {
				ArrayList<Long> v = new ArrayList<>();
				for (int k = 0; k < s[j].length; k++) {
					v.add(F[s[j][k]]);
				}
				v.sort(new Comparator<Long>() {
					@Override
					public int compare(Long o1, Long o2) {
						return -Long.compare(o1, o2);
					}
				});
				long d = 1;
				for (int k = 0; k < s[j].length; k++) {
					if (d < v.get(k) + k) {
						d = k + v.get(k);
					}
				}
				if (F[g[j]] > d) {
					F[g[j]] = d;
				}
			}
		}
		if (F[t] >= (1L << 30))
			System.out.println(-1);
		else
			System.out.println(F[t]);
	}
}

Measured memory_bytes: 64288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		if(s.equals("Sunny")) {
			System.out.println("Cloudy");
		}else if(s.equals("Cloudy")) {
			System.out.println("Rainy");
		}else if(s.equals("Rainy")) {
			System.out.println("Sunny");
		}
	}
}

Measured memory_bytes: 21204
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A,B=map(int,input().split())
    X=list(map(int,input().split()))
    z=B//A
    ans=0
    for i in range(N-1):
        if X[i+1]-X[i]>z:
            ans+=B
        else:
            ans+=(X[i+1]-X[i])*A
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62704
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################

#####ide_ele#####
ide_ele = float('-inf')
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

N, K = map(int,input().split())
a = [0] * 300001
seg = SegTree(a, segfunc, ide_ele)
ans = 0
for _ in range(N):
    A = int(input())
    x = seg.query(max(0, A - K), min(300001, A + K + 1))
    seg.update(A, x + 1)
    ans = max(ans, x + 1)
print(ans)

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

#include <iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s[0] != s[1] || s[1] != s[2] || s[2] != s[0]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256