akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60]={0};
           signed main(){
        string s;
           	cin>>s;
           	
           	for(auto c:s)a[c-'a']++;
           	for(int i=0;i<26;i++)if(a[i]==0){
           		cout<<(char)('a'+i)<<endl;
           		return 0;
           	
           	}cout<<"None"<<endl;
           	
           	return 0;
           	
           	
           }
             

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define MAXN 200005
const int INF = 1000 * 1000 * 1000;
using namespace std;
vector<int> A , B , C;
int N;
int main()
{
	scanf("%d" , &N);
	for(int i = 0; i < N; i++)
	{
		int x;
		scanf("%d" , &x);
		A.pb(-x);
	}
	for(int i = 0; i < N; i++)
	{
		int x;
		scanf("%d" , &x);
		B.pb(x);
	}
	for(int i = 0; i < N; i++)
	{
		int x;
		scanf("%d" , &x);
		C.pb(x);
	}
	sort(A.begin() , A.end());
	sort(C.begin() , C.end());
	ll ans = 0;
	for(int i = 0; i < N; i++)
	{
		auto it1 = upper_bound(A.begin() , A.end() , -B[i]);
		auto it2 = upper_bound(C.begin() , C.end() , B[i]);
		ll r1 = A.end() - it1;
		ll r2 = C.end() - it2;
		ans += r1 * r2;
	}
	cout << ans;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n, k;
    int d[100] = {0};
    int A[100][100] = {{0}, {0}};
    int children[100] = {0};
    
    cin >> n >> k;
    
    for(int i=0; i<k; i++){
        cin >> d[i];
        //cout << "d:" << i << " = " << d[i] << endl;
        for(int j=0; j<d[i]; j++){
            cin >> A[i][j];
            //cout << "A[i][j] = " << A[i][j] << endl;
            //cout << children[A[i][j]-1] << endl;
            if(children[A[i][j]-1] == 0) children[A[i][j]-1] = 1;
            //cout << children[A[i][j]-1] << endl;
        }
    }
    
    int ans = 0;
    for(int i=0; i<n; i++){
        if(children[i] == 0) ans++;
    }
    
    cout << ans;
    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>h(n);
  rep(i,0,n)cin>>h[i];
  vector<ll>dp(n,INF);
  dp[0]=0;
  rep(i,0,n-1){
    rep(j,1,k+1){
      if(i+j>=n)continue;
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

bool check[100000];
long tall[100000];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> tall[i];
		check[i] = true;
	}
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		if (tall[a - 1] > tall[b - 1])
		{
			check[b - 1] = false;
		}
		else if(tall[a - 1] < tall[b - 1])
		{
			check[a - 1] = false;
		}
		else
		{
			check[a - 1] = false;
			check[b - 1] = false;
		}
	}
	long count = 0;
	for (int i = 0; i < n; i++)
	{
		if (check[i])
		{
			count++;
		}
	}
	cout << count;
}



Measured memory_bytes: 35468
a=int(input())
b=list(map(int,input().split()))
c=1
b.sort()
if b[0]==0:
  print(0)
else:
  for i in range(a):
    c=c*b[-i]
    if c>1000000000000000000:
      break
  if c>1000000000000000000:
    print(-1)
  else:
    print(c)

Measured memory_bytes: 21752
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    set<int> st;
    rep(i, 0, n){
        int a;
        cin >> a;
        if(st.count(a)) st.erase(a);
        else st.insert(a);
    } 
    cout << st.size() << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<ll> r(n+1),g(n+1),b(n+1);
    r[0]=0;g[0]=0;b[0]=0;
    for(int i=0; i<n; i++){
        r[i+1]=r[i];
        g[i+1]=g[i];
        b[i+1]=b[i];
        if(s[i]=='R') r[i+1]++;
        else if(s[i]=='G') g[i+1]++;
        else b[i+1]++;
    }
    ll ans=0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R') ){
                //B
                ans+=b[n]-b[j];
                if(b[n]-b[j]>0&&j+(j-i)<n&&s[j+(j-i)]=='B') ans--;
                
            }else if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R') ){
                //G
                ans+=g[n]-g[j];
                if(g[n]-g[j]>0&&j+(j-i)<n&&s[j+(j-i)]=='G') ans--;

            }else if((s[i]=='G'&&s[j]=='B')||(s[i]=='B'&&s[j]=='G')){
                //R
                ans+=r[n]-r[j];
                if(r[n]-r[j]>0&&j+(j-i)<n&&s[j+(j-i)]=='R') ans--;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h> 
#define ll long long int
#define push_back pb

using namespace std; 
 
int main() 
{
    int x,y;
    cin>>x>>y;

    int ans = 0;
    if(x==1) ans=300000;
    else if(x==2) ans=200000;
    else if(x==3) ans=100000;

    if(y==1) ans+=300000;
    else if(y==2) ans+=200000;
    else if(y==3) ans+=100000;

    if(x==1 && y==1) ans+=400000;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
local mab = math.abs
local n = io.read("*n", "*l")
local str = io.read()
local a = {}
for v in str:gmatch("%-?%d+") do
  table.insert(a, tonumber(v))
end
local sum = mab(a[1]) + mab(a[n])
for i = 1, n - 1 do
  sum = sum + mab(a[i] - a[i + 1])
end
print(sum - mab(a[1]) - mab(a[1] - a[2]) + mab(a[2]))
for i = 2, n - 1 do
  print(sum - mab(a[i] - a[i - 1]) - mab(a[i] - a[i + 1]) + mab(a[i - 1] - a[i + 1]))
end
print(sum - mab(a[n]) - mab(a[n] - a[n - 1]) + mab(a[n - 1]))


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

int main(){
int A, B;
cin >> A >> B;
if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 ==0) {
    cout << "Possible" << endl;
}
else {
    cout << "Impossible" << endl;
}
}

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

int main(){
    int n;
    cin >> n;
    deque<int> deq;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        if(i%2 == 0)deq.push_back(a);
        else deq.push_front(a);
    }

    if(n%2 != 0)reverse(deq.begin(), deq.end());
    for(int i=0;i<n;++i){
        cout << deq.front();
        deq.pop_front();
        if(i == n-1)cout << endl;
        else cout << " ";
    }

    return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();
    
    ss[3] = '8';
    	 System.out.println(String.valueOf(ss));
    }
}

Measured memory_bytes: 35620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	int n; cin >> n;
	vector<ll> a(n + 1), s(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
	vector<ll> cand;
	ll ans = 2e18;
	for (int t = 2; t <= n - 2; t++) {
		cand.clear();
		ll tg = s[t] / 2;
		int lo = 1, hi = t - 1;
		while (hi - lo > 1) {
			int mid = lo + (hi - lo) / 2;
			if (s[mid] > tg) hi = mid;
			else lo = mid;
		}
		if (abs(s[t] - 2 * s[lo]) < abs(s[t] - 2 * s[hi])) {
			cand.push_back(s[lo]);
			cand.push_back(s[t] - s[lo]);
		}
		else {
			cand.push_back(s[hi]);
			cand.push_back(s[t] - s[hi]);
		}

		tg = (s[n] - s[t]) / 2;
		lo = t + 1, hi = n - 1;
		while (hi - lo > 1) {
			int mid = lo + (hi - lo) / 2;
			if (s[mid] - s[t] > tg) hi = mid;
			else lo = mid;
		}
		if (abs(s[n] - 2 * s[lo] + s[t]) < abs(s[n] - 2 * s[hi] + s[t])) {
			cand.push_back(s[n] - s[lo]);
			cand.push_back(s[lo] - s[t]);
		}
		else {
			cand.push_back(s[n] - s[hi]);
			cand.push_back(s[hi] - s[t]);
		}
		sort(cand.begin(), cand.end());
		ans = min(ans, cand[3] - cand[0]);
	}
	cout << ans << endl;
	return 0;
}


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

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int used[405][405];

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S[i];

  long ans = 0;
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      if (used[h][w]) continue;
      used[h][w] = 1;

      long nb = 0, nw = 0;
      queue<pair<int, int>> Q;
      Q.push(make_pair(h, w));
      while (Q.size()) {
        auto p = Q.front(); Q.pop();
        int h1 = p.first, w1 = p.second;
        if (S[h1][w1] == '.') nw++;
        else nb++;
        for (int i = 0; i < 4; i++) {
          int h2 = h1 + dy[i], w2 = w1 + dx[i];
          if (h2 < 0 || h2 == H || w2 < 0 || w2 == W || S[h2][w2] == S[h1][w1] || used[h2][w2]) continue;
          Q.push(make_pair(h2, w2));
          used[h2][w2] = 1;
        }
      }
      ans += nb * nw;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define LL long long
#define pb push_back
#define mp make_pair
#define M 1000000007
#define y1 fwfwkpoe
 
#define K 200001

int n;
int a[K];

int main() {
	scanf("%d", &n);
	
	FOE(i, 1, n) scanf("%d", &a[i]);
	
	sort(a + 1, a + n + 1);
	
	if (a[n] - a[1] >= 2) {
		puts("No"); return 0;	
	}
	
	if (a[n] == a[1]) {
		if (a[n] == n - 1) {
			puts("Yes"); return 0;	
		}
		
		int maxpairs = n / 2;
		
		if (a[n] <= maxpairs) {
			puts("Yes"); return 0;	
		}
		
		puts("No"); return 0;
	}
	
	int low = 0, high = 0;
	
	FOE(i, 1, n) {
		if (a[i] == a[1]) low++;
		if (a[i] == a[n]) high++;	
	}
	
	int maxpairs = high / 2;
	
	if (high == 1) {
		puts("No"); return 0;	
	}
	
	if (a[n] > low + maxpairs) {
		puts("No"); return 0;	
	}
	
	if (a[1] == 1 && low >= 2) {
		puts("No"); return 0;	
	}
	
	puts("Yes"); return 0;
}


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

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

  vector<int> v;
  for(int i = 0;i < N;i++){
    int l;
    cin >> l;
    v.push_back(l);
  }

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

  // for(int i = 0;i < N;i++){
  //   std::cout << v[i] << " ";
  // }
  // std::cout << std::endl;

  int count = 0;
  for(int i = 0;i < N - 2;i++){
    for(int j = i + 1;j < N - 1;j++){
      auto it0 = upper_bound(v.begin() + j + 1, v.end(), v[j] - v[i]);
      auto it1 = lower_bound(v.begin() + j + 1, v.end(), v[i] + v[j]);
      count += (it1 - it0);
      // std::cout << v[i] << " " << v[j] << " " << (it0 - v.begin()) << " " << *it0 << " " << (it1 - v.begin()) << " " << *it1 << " " << (it1 - it0) << std::endl;
    }
  }

  std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
typedef pair<int, int> P;
vector<P> G[100000];
int color[100000];
void dfs(int v, int p, int c) {
	color[v] = c;
	for (P e : G[v]) {
		if (e.first == p) continue;
		if (e.second % 2 == 0) {
			dfs(e.first, v, c);
		}
		else {
			dfs(e.first, v, c ^ 1);
		}
	}
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		G[u].emplace_back(v, w);
		G[v].emplace_back(u, w);
	}
	dfs(0, -1, 0);
	for (int i = 0; i < N; i++) {
		cout << color[i] << endl;
	}
}


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	vector<int> A,B;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		A.push_back(a);
		B.push_back(b);
	}
	long long ans=0;
	for(int i=N-1;i>=0;i--){
		if ((ans+A[i])%B[i]!=0){
			int d=(B[i]-((ans+A[i])%B[i]));
			ans+=d;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 102;

string s;
int n, k;
ll dp[N][3][2];

ll calc(int idx, int cnt, bool f) {
	if (cnt == k)
		return 1;
	if (idx == n)
		return 0;
	ll &ret = dp[idx][cnt][f];
	if (ret != -1)
		return ret;
	ret = 0;
	if (f) {
		for (int i = 0; i <= s[idx] - '0'; i++) {
			ret += calc(idx + 1, cnt + bool(i), i == s[idx] - '0');
		}
	} else {
		for (int i = 0; i < 10; i++) {
			ret += calc(idx + 1, cnt + bool(i), 0);
		}
	}
	return ret;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> s >> k;
	n = SZ(s);
	MMS(dp, -1);
	cout << calc(0, 0, 1) << endl;
	return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
int D[MAX_N];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> D[n];
  }

  sort(D, D+N);

  cout << D[N/2] - D[N/2-1] << endl;


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  string s;
  cin >> s;
  i64 ans[2] = {};
  i64 size = s.size();
  for (i64 i = 0; i < size; i++)
    if (i % 2 == 0)
    {
      if (s[i] == '0')
        ans[0]++;
      else
        ans[1]++;
    }
    else
    {
      if (s[i] == '0')
        ans[1]++;
      else
        ans[0]++;
    }
  cout << min(ans[0], ans[1]) << endl;

  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Christmas Eve
            var line = ReadLine();
            int n = line[0];
            int k = line[1];

            var trees = ReadLines(n).ToList();

            //木の高さ順にソート
            trees = trees.OrderByDescending(x => x).ToList();

            //木の高さの差分を記憶するための変数
            int minDiff = trees[0];

            for(int i = 0; i <= n - k; i++)
            {
                int minIndex = i + k - 1;
                int diff = trees[i] - trees[minIndex];

                if (diff < minDiff)
                {
                    minDiff = diff;
                }
            }

            Console.WriteLine(minDiff);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }

        static IEnumerable<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }

            for (int i = 0; i < count; i++)
            {
                string s = Console.ReadLine().TrimEnd();
                yield return int.Parse(s);
            }
        }
    }
}

Measured memory_bytes: 20572
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 2e6 + 7;
inline int add(int x, int y) {int res = x + y; if (res >= mod) res -= mod; return res;}
inline int sub(int x, int y) {int res = x - y; if (res < 0) res += mod; return res;}
inline int mul(int x, int y) {ll res = (ll)x * y; res -= res / mod * mod; return res;}
int ksm(int a, int b)
{
    int res = 1;
    while (b)
    {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
int fac[MAXN], inv[MAXN];
inline int C(int n, int m) {return mul(fac[n], mul(inv[m], inv[n - m]));}
int main()
{
    int N = 2e6 + 2;
    fac[0] = 1; for (int i = 1; i <= N; i++) fac[i] = mul(fac[i - 1], i);
    inv[N] = ksm(fac[N], mod - 2); for (int i = N; i >= 1; --i) inv[i - 1] = mul(inv[i], i);
    int r1, c1, r2, c2; scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    int ans = 0;
    for (int i = c1; i <= c2; i++) 
        ans = add(ans, sub(C(r2 + i + 1, i + 1), C(r1 + i, i + 1)));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
void dprintf(const char *format, ...) {
  va_list arg;
  va_start (arg, format);
  vfprintf(stderr, format, arg);
  va_end(arg);
}
#define debug(arg) cerr << #arg << " = " << arg << endl;
#else
#define dprintf(...)
#define debug(x)
#endif
using ll = long long;

const int MAX_N = 200000;

ll AIB[1 + MAX_N];

void update(int index, ll newValue) {
  //printf("%d %lld\n", index, newValue);
  for (int i = index; i <= MAX_N; i += i & -i) {
    AIB[i] = max(AIB[i], newValue);
  }
}

ll query(int index) {
  long long answer = 0;
  for (int i = index; i > 0; i -= i & -i) {
    answer = max(answer, AIB[i]);
  }
  return answer;
}

int main() {
  int n;
  scanf("%d", &n);
  int h[1 + n];
  int pozH[1 + n];
  int a[1 + n];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &h[i]);
    pozH[h[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    update(pozH[i], query(pozH[i]) + a[pozH[i]]);
  }
  ll answer = query(n);
  printf("%lld\n", answer);
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define MOD 1000000007
double probs[3000];

double recur(int i, int n, int heads, int tails, double sa)
{
	if (i == n)
	{
		if (heads > tails)
			return sa;
		else
			return 0;
	}

	double a = recur(i + 1, n, heads + 1, tails, (double)sa * probs[i]);
	double b = recur(i + 1, n, heads, tails + 1, (double)sa * (1 - probs[i]));
	return a + b;
}



int main()
{

	ll n;
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> probs[i];

	double dp[n + 1][n + 1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if (i == 0 && j == 0)
				dp[i][j] = 1;

			if (i + j > n)
				break;
			if (j > i)
				dp[i][j] = 0;
			if (j - 1 >= 0)
				dp[i][j] += dp[i][j - 1] * (probs[i + j - 1]);

			if (i - 1 >= 0)
				dp[i][j] += dp[i - 1][j] * (1 - probs[i + j - 1]);
		}
	}
	double ans = 0;
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if ((i + j == n) && (j > i))
				ans += dp[i][j];
		}
	}





	cout << setprecision(10) << ans << endl;
}













Measured memory_bytes: 70528
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

D = abs(B - A)
S = abs(V - W)

if V <= W:
    print('NO')
else:
    X = S*T
    if X >= D:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9192
#include <stdio.h>
 
int main(void)
{
    int m, n, a[100][100], b,i,j;
 
    scanf("%d %d\n", &n, &m);
 
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++) {
            if (j < m - 1)
                scanf("%d ", &a[i][j]);
            else
                scanf("%d\n", &a[i][j]);
        }
 
    for (j = 0; j < m; j++) {
        scanf("%d", &b);
        for (i = 0; i < n; i++)
            a[i][j] *= b;
    }
 
    for (i = 0; i < n; i++) {
        b = 0;
        for (j = 0; j < m; j++)
            b += a[i][j];
        printf("%d\n", b);
    }
 
    return 0;
}

Measured memory_bytes: 640
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  Printf.printf "\n";
  preorder (fun e -> print_string " "; print_int e) t;
  Printf.printf "\n"

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let delete x t =
  let rec min_val = function
    | Nil -> assert false
    | Node (x, Nil, _) -> x
    | Node (_, l, _) -> min_val l in
  let rec remove_min = function
    | Nil -> assert false
    | Node (_, Nil, r) -> r
    | Node (x, l, r) -> Node (x, remove_min l, r) in
  let rec doit = function
    | Nil -> assert false
    | Node (y, l, r) ->
      if x = y then
        if l = Nil then r
        else if r = Nil then l
        else Node (min_val r, l, remove_min r)
      else if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | ["delete"; n] -> t := delete (int_of_string n) !t
    | _ -> print !t
  done

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

long long MOD = 1e9 + 7;


int main() {
    string L; cin >> L;
    int bit_size = L.size();

    long long dp[bit_size + 1][2];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 0; i < bit_size; i++) {
        int l = L[i] - '0';
        for (int j = 0; j < 2; j++){
            if (l == 1) dp[i + 1][1] += dp[i][j] % MOD;
            else dp[i + 1][j] += dp[i][j] % MOD;
 
            if(!(l == 0 && j == 0)) dp[i + 1][j] += dp[i][j] * 2 % MOD;
        }
    }

    long long ans = dp[bit_size][0] + dp[bit_size][1];
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 2048
use std::cmp::min;


fn main() {
    let (n, x, y) = read_tuple::<i64>();
    let (x, y) = (x - 1, y - 1);

    let mut counter = vec![0; n as usize];
    for s in 0..(n - 1) {
        for t in (s+1)..n {
            let min_dist = min(t - s, i64::abs(x - s) + 1 + i64::abs(t - y));
            counter[min_dist as usize] += 1;
            // println!("({}, {}) => {}", s, t, min_dist);
        }
    }
    for c in counter.iter().skip(1) {
        println!("{:?}", c);
    }

}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T, T) {
    let temp = read_vec();
    (temp[0], temp[1], temp[2])
}



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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  rep(i, m) { cin >> v[i]; }

  int sum = accumulate(all(v), 0LL);

  if (n - sum >= 0) {
    cout << n - sum << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/

const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(){
	ll d, t, s;
	cin >> d >> t >> s;
	ll time = 0;
	if (d % s == 0)
	{
		time = d / s;
	}
	else{
		time = d / s + 1;
	}

	if(t>=time){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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



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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
int possible[8][8];

void update(int x, int y){
    REP(i, 8) possible[x][i] = 0;
    REP(i, 8) possible[i][y] = 0;
    REP(i, 8) {
        if(x+i < 8){
            if(y+i < 8)
                possible[x+i][y+i] = 0;
            if(y-i >= 0)
                possible[x+i][y-i] = 0;
        }
        if(x-i >= 0){
            if(y+i < 8)
                possible[x-i][y+i] = 0;
            if(y-i >= 0)
                possible[x-i][y-i] = 0;
        }
    }
    possible[x][y] = 2;
    return;
}

bool dfs(int rest){
    int prev[8][8];
    REP(i, 8) REP(j, 8){
        prev[i][j] = possible[i][j];
    }
    if(rest == 0)
        return true;
    REP(i, 8) REP(j, 8){
        if(possible[i][j] == 1){
            update(i, j);
            if(!dfs(rest-1))
                REP(i, 8) REP(j, 8) possible[i][j] = prev[i][j];
            else return true;
        }
    }
    return false;
}

int main() {
    REP(i, 8) REP(j, 8) possible[i][j] = 1;
    int k;
    cin >> k;
    REP(i, k) {
        int x, y;
        cin >> x >> y;
        update(x, y);
    }

    int rest = 8 - k;
    dfs(rest);

    REP(i, 8){
        REP(j, 8){
            if(possible[i][j] == 2)
                cout << "Q";
            else if(possible[i][j] == 1)
                cout << "o";
            else
                cout << ".";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

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










int main() {

	int n, k, a;
	cin >> n >> k;
	map<int,int> m;
	for(int i = 0; i<n;i++){
		cin >> a;
		m[a]++;
	}
	int result = 0;
	vector<int> v;
	for(auto x:m) {
		v.push_back(x.second);
	}
	sort(v.rbegin(),v.rend());
	for(int i = k;i<v.size();i++) result+=v[i];
	cout << result << endl;
}



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

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

    long long n, a, b;
    cin >> n >> a >> b;

    vector<long long> H(n);
    long long total_h = 0;
    for(int i = 0; i < n; i++){
        cin >> H[i];
        total_h += H[i];
    }

    long long ng = 0;
    // long long ok = (total_h + a - 1) / a;
    long long ok = 1e9;
    while((ok - ng) > 1){
        long long mid = (ng + ok) / 2;
        long long t = 0;
        for(int i = 0; i < n; i++){
            if(H[i] - b * mid > 0){
                t += (H[i] - b * mid + a - b - 1) / (a - b);
            }
        }
        if(t <= mid) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long 
#define INF 1e9
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int n;
	cin>>n;
	cout<<(n%1000?1000-n%1000:0)<<endl;
	
	}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;



int main() {
	int a, b, result;
	cin >> a >> b;
	if (b < a) {
		result = a - 1;
	}
	else {
		result = a;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s;
    string ss; cin >> ss;
    ll half = 300000;
    REP(i, half){
        s.push_back(' ');
    }
    REP(i, ss.size()){
        s.push_back(ss[i]);
    }
    REP(i, half-ss.size()){
        s.push_back(' ');
    }
    ll begin = half;
    ll end = half + ss.size();
    bool rev = false;
    ll q; cin >> q;
    REP(_, q){
       ll t; cin >> t;
       if (t == 1){
           rev = rev ^ true;
       } else {
           ll b; cin >> b; b--;
           char c; cin >> c;
           if (b ^ rev){
               // usiro
               end++;
               s[end-1] = c;
           } else {
               // mae
               begin--;
               s[begin] = c;
           }
       }

    }
    string ans;
    if (!rev) {
        for (ll i = begin; i < end; i++) {
            ans.push_back(s[i]);
        }
    } else {
        for (ll i = end; i > begin; i--) {
            ans.push_back(s[i-1]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int ans;
    ans = (X - Z) / (Y + Z);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926
void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);
int sum(int n, int*);
int ave(int n, int*);
int min(int n, int*), min(int n, int m);
int max(int n, int*), max(int n, int m);

int main() {
	int N, M, A[200];
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &A[i]);
	}
	for (int k = 2; k <= M; k++) {
		for (int i = 1; i <= N - 1; i++) {
			if (A[i] % k > A[i + 1] % k) {
				swap(&A[i], &A[i + 1]);
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		printf("%d\n", A[i]);
	}
	return 0;
}

int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}
int sum(int n, int *all) {
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += all[i];
	}
	return total;
}
int ave(int n, int *all) {
	int total = 0;
	for (int i = 0; i<n; ++i) {
		total += all[i];
	}
	return total / n;
}
int min(int n, int *all) {
	int min = all[0];
	for (int i = 1; i < n; ++i) {
		if (min > all[i]) {
			min = all[i];
		}
	}
	return min;
}
int max(int n, int *all) {
	int max = all[0];
	for (int i = 1; i<n; ++i) {
		if (max<all[i]) {
			max = all[i];
		}
	}
	return max;
}
int max(int n, int m) {
	if (n >= m) {
		return n;
	}
	else {
		return m;
	}
}
int min(int n, int m) {
	if (n >= m) {
		return m;
	}
	else {
		return n;
	}
}

Measured memory_bytes: 2728
n,w=map(int,input().split())
VW=[list(map(int,input().split())) for _ in range(n)]

DP=[0]*(w+1)
for i in range(w+1):
    for volume,weight in VW:
        if 0<=i+weight<=w:
            DP[i+weight]=max(DP[i+weight],DP[i]+volume)
print(max(DP))


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long M{N};
    vector<unsigned long> facs;
    for(unsigned long i{1}; i * i <= N; ++i)if(N % i == 0){
        facs.push_back(i);
        if(i * i != N)facs.push_back(N / i);
    }
    N = M - 1;
    for(unsigned long i{1}; i * i <= N; ++i)if(N % i == 0){
        facs.push_back(i);
        if(i * i != N)facs.push_back(N / i);
    }
    const auto& check = [](unsigned long i, unsigned long M) -> bool {
        if(i == 1)return false;
        while(M % i == 0)M /= i;
        return M % i == 1;
    };
    unsigned long ans{0};
    for(const auto& i : facs)ans += check(i, M);
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<char> s(n);
  bool hina=false;
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(s[i]=='Y')
       hina=true;
  }
  if(hina)
    cout<<"Four";
  else cout<<"Three";
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n; cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	list<int> ans;
	if (n % 2 == 0) {
		rep(i, n) {
			if (i % 2 == 0) ans.push_back(a[i]);
			else ans.push_front(a[i]);
		}
	}
	else {
		rep(i, n) {
			if (i % 2 == 1) ans.push_back(a[i]);
			else ans.push_front(a[i]);
		}
	}
	
	
	for (auto i : ans) {
		cout << i << endl;
	}
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    // #ifndef MHT
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,ans=0;
    double d,x,y;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        x=x*x;
        y=y*y;
        x=x+y;
        x=sqrt(x);
        if(x<=d)ans++;
        else continue;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3864
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
#define debug(q,x) cout<<q<<x<<endl
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
const double ext = 1e-6;
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll r, d, x0;
	while (cin >> r >> d >> x0) {
		_for(i, 0, 10) {
			x0 = r * x0 - d;
			cout << x0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256