akhauriyash/Code-Regression huggingface dataset:
n, m, x, y = gets.split(" ").map(&:to_i)
xs = gets.split(" ").map(&:to_i)
ys = gets.split(" ").map(&:to_i)

if [xs.max, x].max < [ys.min, y].min
  puts "No War"
else
  puts "War"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);	
}
int main() {
	//fopen();
	int x,y;
	cin>>x>>y;
	map<int,int>m;
	m.insert({1,300000});
	m.insert({2,200000});
	m.insert({3,100000});
	if(x==1 && y==1)
		{cout<<1000000;}
	else{
		cout<<m[x]+m[y];
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <complex>


using namespace std;
typedef long long ll;


int main() {
	int N, K; cin >> N >> K;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	ll ans = 0;
	sort(v.begin(), v.end());

	for (int i = 0; i < N - K; i++) {
		ans += (ll)v[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int dt[105][10];

void left( int dt[] ) {
    int x = dt[1];
    dt[1] = dt[3];
    dt[3] = dt[6];
    dt[6] = dt[4];
    dt[4] = x;
}

void right( int dt[] ) {
    int x = dt[1];
    dt[1] = dt[4];
    dt[4] = dt[6];
    dt[6] = dt[3];
    dt[3] = x;
}

void up( int dt[] ) {
    int x = dt[1];
    dt[1] = dt[2];
    dt[2] = dt[6];
    dt[6] = dt[5];
    dt[5] = x;
}

void down( int dt[] ) {
    int x = dt[1];
    dt[1] = dt[5];
    dt[5] = dt[6];
    dt[6] = dt[2];
    dt[2] = x;
}

bool ok( int a[], int b[] ) {
    for( int i = 1; i <= 6; ++i ) if( a[i] != b[i] ) return false;
    return true;
}

bool check( int dt1[], int dt2[] ) {
    for( int i = 0; i < 4; ++i ) {
        left( dt1 );
        for( int j = 0; j < 4; ++j ) {
            up( dt1 );
            for( int k = 0; k < 4; ++k ) {
                left( dt1 );
                if( ok( dt1, dt2 ) ) return true;
            }
        }
    }
    return false;
}



int main( void ) {
    ios::sync_with_stdio( false );
    int n;
    cin >> n;
    bool flag = true;
    for( int i = 0; i < n; ++i ) {
        for( int j = 1; j <= 6; ++j ) cin >> dt[i][j];
    }
    for( int i = 0; i < n; ++i ) {
        for( int j = i + 1; j < n; ++j ) {
            if( check( dt[i], dt[j] ) ) flag = false;
        }
    }
    if( flag ) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}



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

vector<bool> diff;
vector<vector<pair<ll, ll>>> net;
vector<bool> visited;
vector<ll> used;

bool dfs(ll cur){
    visited.at(cur) = true;
    ll tmp = 0;
    for(const auto edge : net.at(cur)){
        const ll nxt = edge.first;
        const ll eid = edge.second;
        if(visited.at(nxt)){ continue; }
        if(dfs(nxt)){
            used.push_back(eid);
            tmp += 1;
        }
    }
    return (diff.at(cur) + tmp) % 2;
}

int main(){
    ll n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> ab;
    ab.emplace_back(0, 0);
    REP(i, n){
        ll ai, bi;
        cin >> ai >> bi;
        ab.emplace_back(ai, bi);
    }
    ab.emplace_back(ll(1e9) + 1, 0);
    assert(ab.size() == n + 2);
    sort(ab.begin(), ab.end());

    diff.resize(n + 1);
    REP(i, n + 1){
        if(ab.at(i).second != ab.at(i + 1).second){
            diff.at(i) = true;
        }else{
            diff.at(i) = false;
        }
    }

    net.resize(n + 1);
    REP(i, m){
        ll li, ri;
        cin >> li >> ri;
        ll lidx = lower_bound(
            ab.begin(), ab.end(), make_pair(li, 0LL)) - ab.begin();
        ll ridx = upper_bound(
            ab.begin(), ab.end(), make_pair(ri, 1LL)) - ab.begin();
        assert(lidx <= ridx);
        assert(ridx <= n + 1);
        assert(lidx >= 1);
        lidx--; ridx--;
        net.at(lidx).emplace_back(ridx, i);
        net.at(ridx).emplace_back(lidx, i);
    }

    visited.resize(diff.size());
    fill(visited.begin(), visited.end(), false);
    used.clear();
    REP(i, n + 1){
        if(visited.at(i)){ continue; }
        if(dfs(i)){
            cout << -1 << endl;
            return 0;
        }
    }
    sort(used.begin(), used.end());

    cout << used.size() << endl;
    REP(i, used.size()){
        cout << used.at(i) + 1;
        if(i + 1 < used.size()){
            cout << ' ';
        }else{
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21488
n = gets.to_i

all_cards = []
["S", "H", "C", "D"].each do |mark|
    (1..13).each do |num|
        all_cards.push("#{mark} #{num}")
    end
end
n.times do
    s = gets.chomp
    all_cards.delete(s)
end

if !all_cards.empty?
    puts all_cards.join("\n")
end



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)



int main(){
	string S; cin >> S;	
	int n = S.size();
	LL ans = 0;
	LL b = 0;
	for(auto c : S){
		if(c == 'B') ++b;
		else ans += b;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <bits/stdc++.h>
#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int
     
     
using namespace std;
     
int n, m;
     
void init()
{
    si2(n, m);
    int A[1234];
    int  a[123], b[123];
    for (int i = 0; i < m; ++i)
    {
    	si(a[i]);
    	si(b[i]);
    }
    for (int i = 0; i < n; ++i)
    {
    	A[i] = 0;
    }
    //memset()
    for (int i = 0; i < m; ++i)
    {
    	A[a[i] - 1] += 1;
    	A[b[i] - 1] += 1;
    }
    for (int i = 0; i < n; ++i)
    {
    	printf("%d\n", A[i]);
    }
}
int main()
{
   
    init();
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from functools import reduce

def segfunc(a,b):
    if a == 0 or b == 0:
        return max(a, b)
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return segfunc(b, r)

def gcd_list(numbers):
    return reduce(segfunc, numbers)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res


n = ii()
#A = sorted(li())
A = li()

#####単位元######
'''
if n == 2:
    print(max(A))
    exit()
elif n == 3:
    ide_ele = max(segfunc(A[0], A[1]), segfunc(A[1], A[2]), segfunc(A[0], A[2]))
else:
    #ide_ele = max(segfunc(A[-1], A[-2]), segfunc(A[-3], A[-4]))
    ide_ele = max(segfunc(A[0], A[1]), segfunc(A[2], A[3]))
    print(segfunc(A[0], A[1]), segfunc(A[2], A[3]))
'''
ide_ele = 0
#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init(A)
ans = 0

#ans = max(query(1, n), ans)
#for i in range(1, n-1):
for i in range(n):
    #print(i, query(0, i), query(i+1, n))
    ans = max(segfunc(query(0, i), query(i+1, n)), ans)
#ans = max(query(0, n-1), ans)

print(ans)

Measured memory_bytes: 14632
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


template <typename T>
vector<pair<int, T>> rle(vector<T> a)
{
	int n = (int)a.size();
	vector<pair<int, T>> res;
	if (n == 0)
	{
		return res;
	}
	T now = a[0];
	int con = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] == now)
		{
			con++;
		} else
		{
			res.push_back(pair<int, T>(con, now));
			now = a[i];
			con = 1;
		}
	}
	res.push_back(pair<int, T>(con, now));
	return res;
}

int main() {
	IOS;
	ll n, m, v, p;
	cin >> n >> m >> v >> p;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(all(a), greater<ll>());
	vector<ll> s(n + 1, 0);
	REP(i, n) {
		s[i + 1] = s[i] + a[i];
	}
	ll res = 0;
	//auto rl = rle(a);
	REP(i, n) {
		if (a[i] >= a[p-1]) {
			res++;
		} else {
			ll k = p - 1 + n - 1 - i;
			if (k >= v - 1) {
				if (a[p - 1] <= a[i] + m) {
					res++;
				}
			} else {
				if (a[p - 1] <= a[i] + m) {
					ll t = v - 1 - k;
					ll t2 = (a[i] + m) * (i - (p - 1));
					ll t3 = s[i] - s[p - 1];
					ll t4 = t2 - t3;
					if (t4 >= t * m) {
						res++;
					}
				}
			}
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 1920
import itertools
n, m, r = map(int, input().split())
R = [int(x) for x in input().split()]
inf = pow(10, 9)+7

roads = [[inf]*n for _ in range(n)]
for i in range(m):
  a, b, c = map(int, input().split())
  roads[a-1][b-1] = c
  roads[b-1][a-1] = c

for k in range(n):
  for i in range(n):
    for j in range(n):
      if roads[i][j] > roads[i][k]+roads[k][j]:
        roads[i][j] = roads[i][k]+roads[k][j]

ans = inf
for value in itertools.permutations(R):
  sub = 0
  for k in range(r-1):
    sub += roads[value[k]-1][value[k+1]-1]
  if ans > sub:
    ans = sub

print(ans)

Measured memory_bytes: 46552
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int M = sc.nextInt();
    int bridge[][] = new int[M][2];
    for(int i=0; i<M; i++){
      bridge[i][0] = sc.nextInt();
      bridge[i][1] = sc.nextInt();
    }
    Arrays.sort(bridge, (a,b) -> Integer.compare(a[0],b[0]) );
    int ans = 0;
    int border = 0;
    for(int i=0; i<M; i++){
      if(bridge[i][0] > border){
        ans++;
        border = bridge[i][1] - 1;
      }else{
        border = Math.min(bridge[i][1] - 1, border);
      }
    }
    out.println(ans);
  }

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

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

int main(){

    int n;
    string s;
    cin >> n >> s;

    int r=0,b=0;

    rep(i,n){
        if(s[i]=='R'){
            r++;
        }else{
            b++;
        }
    }

    if(r>b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  int h,w,k; cin>>h>>w>>k;
  vector<string> s(h);
  for(int i=0;i<h;i++){
    cin>>s[i];
  }
  vector<vector<int>> num(h,vector<int>(w,0));
  int now=1,okheight;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#') break;
      if(j==w-1){
        for(int k=0;k<w;k++){
          num[i][k]=-1;
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(num[i][j]==-1) break;
      okheight=i;
      while(s[i][j]=='.' && j<w){
        num[i][j]=now;
        j++;
      }
      if(j!=w && s[i][j]=='#'){
        num[i][j]=now;
        j++;
      }
      while(s[i][j]=='.' && j<w){
        num[i][j]=now;
        j++;
      }j--;
      now++;
    }
  }
  int count=1;
  while(count>0){
    count=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(num[i][j]!=-1) break;
      count++;
      if(i<okheight){
        num[i][j]=num[i+1][j];
      }else{
        num[i][j]=num[i-1][j];
      }
    }
  }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      cout<<num[i][j]<<' ';
    }cout<<num[i][w-1]<<endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int 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 sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
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; }

char t;
string c[4][13];

int func(char c) {
	if (c == 'T')return 10;
	else if (c == 'J')return 11;
	else if (c == 'Q')return 12;
	else if (c == 'K')return 13;
	else if (c == 'A')return 14;
	return c - '0';
}

int main() {
	while (cin >> t&&t != '#') {
		rep(i, 4)rep(j, 13)cin >> c[i][j];
		int cnt[2] = {};
		int w = 0;
		rep(i, 13) {
			bool f = 0;
			int MAX = func(c[w][i][0]);
			char s = c[w][i][1];
			rep(j, 4) {
				if (c[j][i][1] == s) {
					if (!f || s == t) {
						if (MAX < func(c[j][i][0])) {
							w = j;
							MAX = func(c[j][i][0]);
						}
					}
				}
				else if (c[j][i][1] == t) {
					if (f) {
						if (MAX < func(c[j][i][0])) {
							w = j;
							MAX = func(c[j][i][0]);
						}
					}
					else {
						f = 1;
						w = j;
						MAX = func(c[j][i][0]);
					}
				}
			}
			cnt[w % 2]++;
		}
		if (cnt[0] > cnt[1])cout << "NS " << cnt[0] - 6 << endl;
		else cout << "EW " << cnt[1] - 6 << endl;
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	for(int i = 0; ;i++){
		if(i * a - i + 1 >= b){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
    ll r=a%b; 
    while(r!=0){ 
      a=b; 
      b=r; 
      r=a%b; 
    }
    return b;
}
ll koubai(ll a,ll b){
  return (a/gcd(a,b)*b); 
}
int main(){
  ll n;cin>>n;
  vector<ll>num(n);

  ll mae=num[0];
  ll ans=0;
  for(int i=0;i<n;i++){
    cin>>num[i];
    ans+=num[i]-1;
  }

  cout<<ans<<endl;
  return 0;
}


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

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

	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	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; i++) cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long ans = 0;
	for (const auto &mid: b) {
		auto it1 = upper_bound(c.begin(), c.end(), mid);
		if (it1 == c.end()) continue;
		auto it2 = lower_bound(a.begin(), a.end(), mid);
		ans += (c.end()-it1) * (it2-a.begin());
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
N=int(input())
Index=[]
S=[]
P=[]
for i in range(N):
  Index.append(i+1)
  s,p=input().split()
  S.append(s)
  P.append(int(p))
#print(S)
#print(P)

for i in range(N):
  deleteIndex=0
  outputIndex=Index[0]
  minS=S[0]
  maxP=P[0]
  for j in range(1,N-i):
    if (S[j] < minS) or ((S[j] == minS) and (P[j] > maxP)):
      deleteIndex=j
      outputIndex=Index[j]
      minS=S[j]
      maxP=P[j]
  print(outputIndex)
  del Index[deleteIndex]
  del S[deleteIndex]
  del P[deleteIndex]


Measured memory_bytes: 3064
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
using pii =pair<int,int>;

int n;
int v;
priority_queue<double,vector<double>,greater<double>> q;
void input(){
    cin>>n;
    rep(i,n){
        cin>>v;
        q.push((double)v);
    }
}
void src(){
    rep(c,n-1){
        double v1=q.top();q.pop();
        double v2=q.top();q.pop();
        q.push((v1+v2)/2.0);
    }
    cout<<setprecision(6)<<fixed<<q.top();
    return;
}

int main(int argc,char* argv[]){
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using namespace std;

bool is_kaibun(string a) {
	for (int i = 0; i < (a.size() + 1) / 2; i++) {
		if (a[i] != a[a.size() - 1 - i])return false;
	}
	return true;
}

int main() {
	string s;
	cin >> s;
	if (is_kaibun(s) && 
		is_kaibun(s.substr(0, (s.size() - 1) / 2)) && 
		is_kaibun(s.substr((s.size() + 3) / 2 - 1, (s.size() - 1) / 2)))
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = -2LL<<62;
  maxs(ans,b*d);
  maxs(ans,a*c);
  maxs(ans,a*d);
  maxs(ans,b*c);
  if(a<=0 and b>=0) max(ans,0LL);
  if(c<=0 and d>=0) max(ans,0LL);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x;
    ll h=0;
    cin>>x;
    ll a=x/500;
    ll b=x%500;
    b=b/5;
    h=h+a*1000+b*5;
    cout<<h<<"\n";
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    ll res = 0;
    int l = s.size();
    rep (bit, 1 << l - 1) {
        ll tmp = 0;
        rep (i, l) {
            tmp *= 10;
            tmp += s[i] - '0';
            if (bit & (1 << i)) {
                res += tmp;
                tmp = 0;
            }
        }
        res += tmp;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
#!/use/bin/env python3

(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

like = []

ans = n
b = n
while (1):

    c = True
    b = n
    while (b != 0):
        d = b % 10
        b = b // 10

        if d in a:
            c = False
            break

    if (c):
        ans = n
        break
    n += 1

print(ans)


Measured memory_bytes: 3064
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,a,b=n1()

def comb(n,k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk

MOD = 10**9+7
a1=comb(n, a)
b1=comb(n, b)
ans=pow(2,n,MOD)-a1-b1-1
print(ans%MOD)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 2e5 + 5;

int arr [MAX_N];
int last [MAX_N];

Modint idp [MAX_N];
Modint edp [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }

  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      idp[i] = Modint(0);
      edp[i] = Modint(1);
    } else if (last[arr[i]] == 0 || last[arr[i]] == i - 1) {
      idp[i] = Modint(0);
      edp[i] = edp[i - 1] + idp[i - 1];
    } else {
      idp[i] = idp[last[arr[i]]] + edp[last[arr[i]]];
      edp[i] = edp[i - 1] + idp[i - 1];
    }
    last[arr[i]] = i;
  }

  cout << idp[n] + edp[n] << endl;
}


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

extern inline unsigned int xor128(void){
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123; 
  unsigned int t=x^(x<<11);
  x=y; y=z; z=w;
  return w=(w^(w>>19))^(t^(t>>8)); 
}

template <typename T>
class Treap{
public:
  Treap* l;
  Treap* r;
  int cnt;
  int pri;
  T value;
  Treap(){
  }
  Treap(T v){
    value=v;
    cnt=1;
    pri=xor128();
    l=r=NULL;
  }
};

template <typename T >
class Vectree{
private:

  int count(Treap<T>* t){ return !t ? 0:t->cnt; }

  Treap<T>* update(Treap<T>* t){
    t->cnt = count(t->l) + count(t->r) + 1;
    return t;
  }

  
  Treap<T>* merge(Treap<T>* l,Treap<T>* r){
    if( !l || !r ) return !l ? r : l;
    if( l->pri > r ->pri ){
      l->r = merge(l->r,r);
      return update(l);
    } else {
      r->l = merge(l,r->l);
      return update(r);
    }
  }

  typedef pair< Treap<T>* , Treap<T>* > pnn;
  pnn split(Treap<T>* t,int k){
    if( !t ) return pnn(NULL,NULL);
    if( k <= count(t->l) ){
      pnn s = split(t->l,k);
      t->l = s.second;
      return make_pair(s.first,update(t));
    } else {
      pnn s = split(t->r,k - count(t->l) - 1);
      t->r = s.first;
      return make_pair(update(t),s.second);
    }
  }
  
  int size_num;
  Treap<T> *root;
  
  int poolc;
  Treap<T> pool[20000];
  
public:
  Vectree(){
    size_num=0;
    poolc=0;
    root=NULL;
  }
  
  int size();
  void push_back(T);
  void pop_back();
  void insert(int,T);
  void erase(int);
  T& operator [] (int x);
};


template <typename T>
int Vectree <T> :: size(){
  return size_num;
}

template <typename T>
void Vectree <T> :: erase(int index){
  auto p=split( root, index + 1 );
  auto q=split( p.first, index);
  root = merge(q.first,p.second);
  size_num--;
}

template <typename T>
void Vectree <T> :: insert(int index,T v){
  auto p=split( root, index );
  pool[ poolc ] = Treap<T>(v);
  p.first = merge( p.first, &pool[poolc] );
  poolc++;
  root = merge( p.first, p.second );
  size_num++;
}

template <typename T>
void Vectree <T> :: push_back(T v){
  insert( size_num, v );
}

template <typename T>
void Vectree <T> :: pop_back(){
  erase( size_num );
}

template <typename T>

T& Vectree<T> :: operator [] (int x){
  auto p=split(root,x);
  auto q=split(p.second,1);
  root=merge(p.first, merge(q.first,q.second) );
  return q.first->value;
}

int main(){
  Vectree<int> t;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    t.push_back(a);
  }

  int ans=0;
  int m;
  cin>>m;
  
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    for(int j=0;j<n;j++)
      if(t[j]==a){
        ans++;
        break;
      }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  
  long N,A,B,C,D;
  cin >> N;
  
  A = N*(N+1)/2;
  
  B = (N/3)*(1+N/3)/2;
  
  C = (N/5)*(1+N/5)/2;
  
  D = (N/15)*(1+N/15)/2;
  
  cout << A-3*B-5*C+15*D <<endl;
    
  
}


Measured memory_bytes: 3620
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut a = sc.read_vec::<usize>(n);

    a.sort();
    let mut dp = vec![true; 100_0001];
    let mut prev = 0;
    for &x in a.iter() {
        if x == prev {
            dp[x] = false;
            continue;
        }
        prev = x;

        let mut fac = 2;
        loop {
            if x * fac > a[n - 1] {
                break;
            }
            dp[x * fac] = false;
            fac += 1;
        }
    }

    let mut ans = 0;
    for a in a.into_iter() {
        if dp[a] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cerr << "[" << #x << " " << x << "]\n";
// #define int ll

ll power(ll x, ll y) {
     ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*================================================================*/




int R[4005], B[4005], G[4005];
void solve() {
    string s;int n;
    cin >> n >> s;
    repc(i, n-1, -1, -1){
        R[i] += R[i+1] + (s[i] == 'R');
        G[i] += G[i+1] + (s[i] == 'G');
        B[i] += B[i+1] + (s[i] == 'B');
    }
    ll r = 0, b = 0, g = 0, ans = 0;
    rep(i, 0, n){
        if(s[i] == 'R')ans += b*G[i+1] + g*B[i+1], r++;
        else if(s[i] == 'G')ans += b*R[i+1] + r*B[i+1], g++;
        else ans += r*G[i+1] + g*R[i+1], b++;
        int j = 1;
        while(i-j >= 0 and j + i < n){
            ans -= (s[i-j] != s[i] and s[j+i] != s[i] and s[i-j] != s[i+j]);
           j++;
        }
    }
    cout << ans;
}

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


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

using namespace std;

void solve()
{
	vector<int> Vec(10);
	for(int i = 0; i < 10; ++i)
	{
		cin >> Vec[i];
	}
	sort(Vec.begin(), Vec.end());
	for(int i = 9; i > 6; --i)
	{
		cout << Vec[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)

time_all.append(time.time()-start)

#print(time_all)


Measured memory_bytes: 114000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(long long N, long long M, std::vector<long long> A){
    sort(A.begin(),A.end());
    ll sum[N+1];
    sum[0] = 0;
    for(int i=0;i<N;i++){
        sum[i+1] = sum[i] + A[i];
    }
    ll l =0;
    ll r = 1e7;
    while(l+1<r){
        ll mid = (l+r)/2;
        ll temp = 0;
        for(int i=0;i<N;i++){
            ll remain = mid -A[i];
            auto itr = lower_bound(A.begin(),A.end(),remain);
            ll p =itr -A.begin();
            temp += (N-p);
        }
        if(temp>=M){
            l = mid;
        }else{
            r = mid;
        }
    }
    // cerr <<"l=" << l << endl;
    ll ans =0;
    for(int i=0;i<N;i++){
        ll remain = r -A[i];
        auto itr = lower_bound(A.begin(),A.end(),remain);
        ll p =itr -A.begin();
        M -= (N-p);
        ans += ((sum[N]-sum[p])+A[i]*(N-p));
    }
    ans += (l*M);
    cout << ans << endl;
            

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

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

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t a,b,c,k;
  cin >> a >> b >> c >> k;
  int64_t sum = 0;
  if(k<=a) cout << k << endl;
  else if(k<=a+b) cout << a << endl;
  else cout << a - (k-a-b) << endl;
  
  return 0;
}

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

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

  int n; cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;
  
  map<int, int> cnt[2];
  for (int i = 0; i < n; i++) {
    cnt[i & 1][a[i]]++;
  }
  vector<pair<int, int>> odd, even;
  for (auto& x : cnt[0]) {
    odd.push_back({ x.second, x.first });
  }
  for (auto& x : cnt[1]) {
    even.push_back({ x.second, x.first });
  }
  sort(odd.rbegin(), odd.rend());
  sort(even.rbegin(), even.rend());
  odd.push_back({ 0, -1 }), even.push_back({ 0, -2 });

  if (odd[0].second != even[0].second) {
    cout << n - odd[0].first - even[0].first << "\n";
  } else {
    cout << min(n - odd[0].first - even[1].first, n - odd[1].first - even[0].first) << "\n";
  }
}

Measured memory_bytes: 6524
#include<stdio.h>
#include<math.h>

const double PI = 3.14159265359;

int main(){
    int a,b,C;
    scanf("%d%d%d",&a,&b,&C);
    
    double rad = PI * C / 180;
    double S = a*b*sin(rad)/2;
    double d = sqrt(a*a+b*b-2*a*b*cos(rad));
    double L = a+b+d;
    double h = b*sin(rad);
    
    printf("%.6lf\n",S);
    printf("%.6lf\n",L);
    printf("%.6lf\n",h);
    
    return 0;
}


Measured memory_bytes: 2104
N,M = map(int,input().split())
INF = 10**8
N_dp = 2**N
DP = [INF] * (N_dp)
DP[0] = 0

for i in range(M):
    a,b = map(int,input().split())
    C = [int(i) for i in input().split()]
    c_bit = sum(2**(c-1) for c in C)
    for i in range(N_dp):
        DP[c_bit | i] = DP[i] + a if(DP[i]+a < DP[c_bit | i]) else DP[c_bit | i]
if(DP[-1] == INF):
    DP[-1] = -1
print(DP[-1])

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int a, b, k; cin >> a >> b >> k;

	vector <int> p;

	for(int i = 1; i <= min(a, b); i++){
		if(a % i == 0 and b % i == 0){
			p.push_back(i);
		}
	}



	cout << p[p.size() - k] << endl;


	return 0;
}

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


int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<int> H;
	H.resize(N);

	for (int i = 0; i != N; ++i)
	{
		int tmp = 0;
		std::cin >> tmp;
		H[i] = tmp;
	}

	for (int i = N - 1; i > 0; --i)
	{
		if (H.at(i) >= H.at(i - 1))
		{
			continue;
		}
		else
		{
			if (H.at(i) >= H.at(i - 1) - 1)
			{
				H[i - 1] = H[i - 1] - 1;
			}
			else
			{
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}

	std::cout << "Yes" << std::endl;

	return 0;
}

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

int main(){
    string s;
    cin>>s;
    
    rep(i,(int)(s.length())) cout<<'x';
    
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<int>dp;
vector<vector<int> > chi,par;
int find(int i){
    int len=0;
    if(dp[i]!=-1)return dp[i];
    for(auto x:chi[i]){
        len=max(len,find(x)+1);
    }
    dp[i]=len;
    return dp[i];
}
int main(){
    int n, m ;
    cin>>n>>m;
    chi.resize(n+1);
    par.resize(n+1);
    dp.resize(n+1,-1);
    for(int i = 0 ; i < m ; i ++ ) {
        int a, b;
        cin>>a>>b;
        chi[a].push_back(b);
        par[b].push_back(a);
    }int ans=0;
    for(int i = 1 ; i <= n ; i++ ){
        if(par[i].size()==0){
            dp[i]=find(i);
            ans=max(ans,dp[i]);
        }
    }
    cout<<ans<<endl;
}


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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

string t;

cin>>t;
int i;
bool n=0,s=0,w=0,e=0;

for(i=0;i<t.size();i++)
	{
	if(t[i]=='N') n = 1;	
	
	if(t[i]=='S') s = 1;
	
	if(t[i]=='W') w = 1;	
	
	if(t[i]=='E') e = 1;
	}

//cout<<n<<s<<w<<e<<endl;

if((n+s)==1 || (w+e)==1)
	cout<<"No"<<endl;
else 
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 200005;
const int mod = (int) 1e9 + 7;

int n;
int fac[N];
int arr[N];
int res[N];

int fp(int a, int b) {
  int ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (1ll * ans * a) % mod;
    }
    b >>= 1;
    a = (1ll * a * a) % mod;
  }
  return ans;
}

int inv(int n) {
  return fp(n, mod - 2);
}

int comb(int n, int k) {
  int ans = (1ll * fac[n] * inv(fac[k])) % mod;
  ans = (1ll * ans * inv(fac[n - k])) % mod;
  return ans;
}

int main() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = (1ll * fac[i - 1] * i) % mod;
  }
  scanf("%d", &n);
  int r, l;
  map <int, int> cnt;
  for (int i = 1; i <= n + 1; i++) {
    scanf("%d", arr + i);
    cnt[arr[i]]++;
    if (cnt[arr[i]] > 1) {
      r = i;
    }
  }
  for (int i = 1; i <= n + 1; i++) {
    if (cnt[arr[i]] > 1) {
      l = i;
      break;
    }
  }
  for (int i = 1; i <= n + 1; i++) {
    res[i] = comb(n + 1, i);
  }
  l--;
  r = n + 1 - r;
  res[1] = (res[1] - 1) % mod;
  for (int i = 1; i <= l + r; i++) {
    res[i + 1] = (res[i + 1] - comb(l + r, i)) % mod;
  }
  for (int i = 1; i <= n + 1; i++) {
    printf("%d\n", (res[i] + mod) % mod);
  }
  return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int w = tx-sx;
    int h = ty-sy;

    for(int i=0; i<w; i++) cout << "R";
    for(int i=0; i<h; i++) cout << "U";
    for(int i=0; i<w; i++) cout << "L";
    for(int i=0; i<h; i++) cout << "D";
    cout << "D";
    for(int i=0; i<w+1; i++) cout << "R";
    for(int i=0; i<h+1; i++) cout << "U";
    cout << "L";
    cout << "U";
    for(int i=0; i<w+1; i++) cout << "L";
    for(int i=0; i<h+1; i++) cout << "D";
    cout << "R";
    cout << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a = sorted([i//400 for i in a])
min_a = 0
max_a = 0
flag = -1
for i in range(n):
  if a[i] >= 8:
    max_a += 1
  elif flag != a[i]:
    min_a += 1
    max_a += 1
  flag = a[i]
print(max(1,min_a),max_a)

Measured memory_bytes: 38384