akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll d, n;
  cin >> d >> n;
  ll ans = n*(int)pow(100, d);
  if(n == 100) ans += pow(100, d);
  cout << ans << endl;
}

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

int main(){
 string S,T;
  cin >> S >> T;
  int counter=0;
  int b;
  b = S.size();
  for (int i=0;i<b;i++){
    if(S.at(i) != T.at(i)){
      counter =counter + 1;
    }
  }
  cout << counter << endl;
}

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int h1,m1,h2,m2; cin>>h1>>m1>>h2>>m2;
	int t1=h1*60+m1; int t2=h2*60+m2;
	int k; cin>>k;
	cout<<t2-t1-k<<'\n';
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define iterator IT
#define SIZ(V) V.size()
#define FS(a) fixed<<setprecision(a)
using namespace std;
namespace STARTER {
	int MAX(int a,int b) {return a>b?a:b;}
	int MIN(int a,int b) {return a<b?a:b;}
	int ABS(int a) {return a<0?-a:a;}
	int GCD(int a,int b) {return !b?a:GCD(b,a%b);}
	int LCM(int a,int b) {return a/GCD(a,b)*b;}
	int QSM(int a,int b,int p) {int ret=1;while (b) (b&1)&&(ret=ret*a%p),a=a*a%p,b>>=1;return ret;}
	int ROUND(double a) {return a+0.5;}
}
using STARTER::MAX;
using STARTER::MIN;
using STARTER::ABS;
using STARTER::GCD;
using STARTER::LCM;
using STARTER::QSM;
using STARTER::ROUND;
int main() {
	string s;cin>>s;
	if (s[2]==s[3]&&s[4]==s[5]) puts("Yes");
	else puts("No");
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

class UnionFind{
    ll n;
    vector<ll> par;
    vector<ll> depth;

    public:

    UnionFind(ll num){
        n = num;
        par.resize(n);
        REP(i,n) par[i] = i;
        depth.resize(n, 1);
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(depth[x] >= depth[y]){
            par[y] = x;
            if(depth[x] == depth[y])
                depth[x]++;
        }
        else{
            par[x] = y;
        }
    }
    
    ll find(ll x){
        if(x == par[x])
            return x;
        else
            return par[x] = find(par[x]);
    }
};

int main(){
    ll N, M;
    cin >> N >> M;

    UnionFind uni(N);
    REP(i,M){
        ll x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        uni.unite(x, y);
    }

    ll ans = 0;
    REP(i,N){
        if(uni.find(i) == i)
            ans++;
    }

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


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

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

    int h, w;
    cin >> h >> w;
    vector<string> board(h);
    for (int i = 0; i < h; i++) cin >> board[i];

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

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (board[i][j] == '#') {
                cout << '#';
            } else {
                int cnt = 0;
                for (int k = 0; k < 8; k++) {
                    int x = i + dx[k], y = j + dy[k];
                    if (0 <= x && x < h && 0 <= y && y < w && board[x][y] == '#') {
                        cnt++;
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
use itertools::Itertools as _;
use proconio::*;
macro_rules! p {
    ($x:expr) => {
        println!("{}", $x);
    };
}
fn main() {
    input! {
        n:usize,
        s:[usize;n],
        t:[usize;n],
        u:[u64;n],
        v:[u64;n],
    }
    let mask = std::u64::MAX;
    let (or, and) = (1, 0);
    // 1確定
    let mut one = vec![vec![0u64; n]; n];
    // 0確定
    let mut zero = vec![vec![0u64; n]; n];

    // 自明
    for i in 0..n {
        for j in 0..n {
            if s[i] == and {
                one[i][j] |= u[i];
            } else {
                zero[i][j] |= !u[i];
            }
            if t[j] == and {
                one[i][j] |= v[j];
            } else {
                zero[i][j] |= !v[j];
            }
            if one[i][j] & zero[i][j] != 0 {
                p!(-1);
                return;
            }
        }
    }
    let mut ans = one.clone();

    // 条件を満たさない行/列のあるbitを調べる
    let check = |ans: &[Vec<u64>]| {
        let mut u_check = (0..n)
            .map(|i| if s[i] == or { 0 } else { mask })
            .collect_vec();
        let mut v_check = (0..n)
            .map(|j| if t[j] == or { 0 } else { mask })
            .collect_vec();

        for i in 0..n {
            for j in 0..n {
                if s[i] == and {
                    u_check[i] &= ans[i][j];
                } else {
                    u_check[i] |= ans[i][j];
                }
                if t[j] == and {
                    v_check[j] &= ans[i][j];
                } else {
                    v_check[j] |= ans[i][j];
                }
            }
        }
        let check = u
            .iter()
            .zip(&u_check)
            .chain(v.iter().zip(&v_check))
            .map(|(x, y)| x ^ y)
            .fold(0, |x, y| x | y);
        check
    };

    // 市松
    // 未確定が2*2以上なら必ず通る
    // 市松が間違っていたので修正
    let mut iflip;
    let mut jflip = 0u64;
    for i in 0..n {
        iflip = 0;
        jflip ^= if s[i] == and { !u[i] } else { u[i] };
        for j in 0..n {
            ans[i][j] |= !zero[i][j] & (iflip ^ jflip);
            iflip ^= !(one[i][j] | zero[i][j]);
        }
    }

    let fail = check(&ans);
    // 全部or
    for i in 0..n {
        for j in 0..n {
            ans[i][j] &= !fail;
            ans[i][j] |= fail & (u[i] | v[j]) & !zero[i][j];
        }
    }

    let fail = check(&ans);
    // 全部and
    for i in 0..n {
        for j in 0..n {
            ans[i][j] &= !fail;
            ans[i][j] |= fail & ((u[i] & v[j]) | one[i][j]);
        }
    }

    let fail = check(&ans);
    if fail != 0 {
        p!(-1);
        return;
    }

    ans.iter().for_each(|x| p!(x.iter().join(" ")));
}


Measured memory_bytes: 11452
// https://atcoder.jp/contests/abc131/tasks/abc131_a

#include <bits/stdc++.h>
using namespace std;

int n, a, b, c, d;

int main()
{
	cin >> n;
	a = n / 1000;
	b = n / 100 % 10;
	c = n % 100 / 10;
	d = n % 10;
	if (a == b or b == c or c == d) cout << "Bad";
	else cout << "Good";
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;
ll lsum[500010],rsum[500010];

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

  cin>>S;
  ll N=S.size();
  rep(i,N){
    if(S[i]=='<') lsum[i+1]=lsum[i]-1;
    else lsum[i+1]=0;
  }
  for(ll i=N-1;i>=0;i--){
    if(S[i]=='>') rsum[i]=rsum[i+1]-1;
    else rsum[i]=0;
  }
  ll res=0;
  rep(i,N+1){
    res+=-min(lsum[i],rsum[i]);
  }
  cout<<res<<endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int start, finish;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A') {
      start = i;
      break;
    }
  }
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'Z') {
      finish = i;
    }
  }
  cout << finish - start + 1;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll N;
VL(a);
multiset<ll> st;

signed main() {
    cin >> N;
    REP(i, N) {
        LCIN(A);
        auto itr = st.lower_bound(A);
        if(itr != st.begin()) {
            st.erase(--itr);
        }
        st.insert(A);
    }
    cout << st.size() << "\n";
}


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

/*Range Sum,Range Add*/
/*区間和、区間加算*/

class RSAQ{
public: 
  typedef long long ll;

  //マージ可能な主データ型
  struct D{
    ll value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(ll value):value(value){}
    bool operator < (D a)const {return value < a.value;}
  };

  //遅延用の型  
  struct T{
    int type; //0 - empty   , 1 - update
    ll value;
    T():type(0),value(0){}
    T(int type,ll value):type(type),value(value){}
  };

  
  int n, n_;
  vector<D> dat;
  vector<T> td;
  D returnD = D(0); // 範囲外の時に返す値。
  
  RSAQ(){n=-1;}
  RSAQ(int n_):n_(n_){
    n=1;
    while(n < n_) n *= 2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  inline D merge(const D a,const D b)const{return a.value + b.value;}
  
  void delay(int k,int len){
    if(td[k].type==0) return;
    ll type = td[k].type;
    ll v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    len /= 2;
    {
      int l = k*2+1;
      dat[l].value += v * len;
      td[l].type = type;
      td[l].value += v;
    }
    {
      int r = k*2+2;
      dat[r].value += v * len;
      td[r].type = type;
      td[r].value += v;
    }
  }

  D write(int k, D x, int len){
    dat[k].value += x.value * len;
    td[k].type = 1;
    td[k].value += x.value;
    return dat[k];
  }
  
  D dfs(const int a,const int b,const D x,const bool flag, int k, int l, int r){
    if(r <= a||b <= l) return flag? dat[k]:returnD;
    if(a <= l && r <= b) return flag? write(k, x, r - l):dat[k];
    delay(k, r - l);
    D vl = dfs(a, b, x, flag, k*2+1, l, (l+r)/2);
    D vr = dfs(a, b, x, flag, k*2+2, (l+r)/2, r);
    return flag? (dat[k] = merge(vl, vr)):merge(vl, vr);
  }

  //[l,r)の値をx変更　query(l,r,x)
  void add(int l,int r,ll x){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    dfs(l, r, D(x), true, 0, 0, n);
  }
  
  //[l,r)の合計値を得る　find(a,b);
  ll get(int l,int r){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    D res = dfs(l, r, D(), false, 0, 0, n);
    return res.value;
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  
  RSAQ rsaq(n);

  while(q--){
    int cmd;
    cin>>cmd;
    if(cmd == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rsaq.add(s-1,t,x);
    }
    
    if(cmd == 1){
      int s,t;
      cin>>s>>t;
      cout<<rsaq.get(s-1,t)<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 8892
#include <iostream>

using namespace std;

int sub(int b, int n)
{
	if (n%b != 0)
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

int solve(int g, int b, int n)
{
	int cnt = 0;
	for (; n >= 0; n -= g)
	{
		cnt += sub(b, n);
	}

	return cnt;
}

int main()
{
	int r, g, b, n;

	cin >> r >> g >> b >> n;

	int cnt = 0;
	for (; n >= 0; n -= r)
	{
		cnt += solve(g, b, n);
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = []
C = []
D = [0]*N
E = [0]*N
t = 0
for i in range(N):
    B.append(i+1-A[i])
    C.append(i+1+A[i])
for i in range(N):
    if B[i] > 0 and B[i] <= N:
        D[B[i]-1] += 1
    if C[i] <= N:
        E[C[i]-1] += 1
for i in range(N):
    t += D[i]*E[i]
print(t)

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

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

  int x,y;
  cin >> x >> y;

  bool ok = false;
  for (int i = 0; i <= x; i++) {
    int tmp = i * 2 + (x - i) * 4;
    if(tmp == y) ok = true;
  }
  if(ok) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


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

int main() {
  string a;
  cin >> a;
  if(a.size() < 4){
    cout << "No" << endl;
    return 0;
  }
  if(a.at(0) == 'Y' && a.at(1) == 'A' && a.at(2) == 'K' && a.at(3) == 'I'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

long long Calc(vector <long> &A,long L) {
    long long steps=0;
    for(int i=0;i<A.size();++i) {
        if(A[i]<=L) continue;
        steps += ceil(A[i]/L);
    }
    return steps;
}

void Crack() {
	long n,K;
    cin >> n >> K;
    vector <long> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    sort(A.begin(),A.end());
    long ans,m,l=1,r=A[n-1];
    long long k;
    while(l<=r) {
        m = l + (r-l)/2;
        k = Calc(A,m);
        if(k<=K) {
            ans = m;
            r = m-1;
        } else l = m+1;
    }
    cout << ans << endl;
}

int main()
{
	Boost;
    Crack();
	return 0;
}

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

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

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

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int A,B,N;
    cin >> N >> A >> B;

    int sum = A +B;
    int maxN = min(A,B);
    int minN;
    if (sum <= N){
        minN = 0;
    } else {
        minN = sum - N;
    }
    cout << maxN << ' ' << minN << endl;




    return 0;
}


Measured memory_bytes: 888
# Volume0-0049
# Blood Groups
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0049

result = Array[ 0, 0, 0, 0 ]
while line = $stdin.gets
	data = line.chomp.split( "," )
	case data[ 1 ]
	when "A"
		result[ 0 ] += 1
	when "B"
		result[ 1 ] += 1
	when "AB"
		result[ 2 ] += 1
	when "O"
		result[ 3 ] += 1
	end
end
result.each{ |n|
	puts n
}


Measured memory_bytes: 6080
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

s = input()

tmp = sys.stdin.read().lower().split()

print(tmp.count(s))




Measured memory_bytes: 6876
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] x = new int[N];
        long answer = 0;
        for (int i = 0; i < N; i++) {
            x[i] = scan.nextInt();
            answer += Math.min(x[i]*2, Math.abs(K-x[i])*2);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        mp[x]++;
    }
    int m;
    cin >> m;
    bool ok = true;
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        if(mp[x] > 0){
            mp[x] -= 1;
        }else{
            ok = false;
        }
    }
    if(ok){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;

}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    ll a, b, k; cin >> a >> b >> k;
    ll t=k;
    k = max(0LL, k-a);
    a = max(0LL, a-t);
    b = max(0LL, b-k);
    cout << a << ' ' << b << endl;

}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
		public static void main(String[] args) {
		
	   Scanner sc = new Scanner(System.in);
	   
	   String S = sc.next();
	   
	   if(S.equals("hi")) {
		   System.out.println("Yes");
	   }else if(S.equals("hihi")) {
		   System.out.println("Yes");
	   }else if(S.equals("hihihi")) {
		   System.out.println("Yes");
	   }else if(S.equals("hihihihi")) {
		   System.out.println("Yes");
	   }else if(S.equals("hihihihihi")) {
		   System.out.println("Yes");
	   }else {
		   System.out.println("No");
	   }
	   }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    ull N, K;
    cin >> N >> K;
    auto A = make_vec<ull>(N);

    REP(i, N) { cin >> A.at(i); }
    auto zoc = make_vec<ull>(66, 2);

    REP(bit, 63) {
        REP(i, N) {
            if (A[i] % 2 == 0) {
                zoc[bit][0]++;
            } else {
                zoc[bit][1]++;
            }
            A[i] /= 2;
        }
    }

    ll ans = 0;
    ll bit = 62;
    while (bit >= 0) {
        ll mask = 1ULL << bit;
        if (mask & K) {
            if (zoc[bit][0] > zoc[bit][1]) {
                ans += zoc[bit][0] << bit;
            } else {
                while (bit >= 0) {
                    ans += max(zoc[bit][0], zoc[bit][1]) << bit;
                    bit--;
                }
                break;
            }
        } else {
            ans += zoc[bit][1] << bit;
        }
        bit--;
    }

    cout << ans << endl;

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmax(T &a,const T b){if(a < b){a=b; return true;} return false;}
template<typename T> bool chmin(T &a,const T b){if(a > b){a=b; return true;} return false;}

int main(){
    /*
    int n; cin >> n;
    vi x(n), y(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
    }
    */
    int n; cin >> n;
    vector<queue<int>> com(n);
    for(int i=0; i<n; i++){
        for(int j=0; j<n-1; j++){
            int a; cin >> a;
            a--;
            com[i].push(a);
        }
    }
 
    set<int> prev;
    for(int i=0; i<n; i++) prev.insert(i);
    int ans=0;
    while(!prev.empty()){
        set<int> tmp;
        bool flag=false;
        for(auto p: prev){
            if(com[p].empty()) continue;
            int op=com[p].front();
            flag=true;
            if(com[op].front() == p){
                tmp.insert(p);
                tmp.insert(op);
            }
        }
        for(auto p: tmp){
            com[p].pop();
        }
        if(tmp.empty()){
            if(flag) ans=-1;
            break;
        }
        ans++;
        prev=tmp;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

int main(){
  int N;
  cin >> N;
  vector <int> v(N); 
  vector <int> c(N);
  rep(i, N) cin >> v.at(i);
  rep(i, N) cin >> c.at(i);
  
  int res = 0;
  rep(i, N){
    if(v.at(i)-c.at(i) > 0){
      res += v.at(i)-c.at(i);
    }
  }
  
  cout << res;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
double x[3],y[3],d[3],ok=0,ng=10000,t,s,r,ma;
bool solve(double x){
	if(r<x)return false;
	double bai=(r-x)/r;
	return bai*ma>=x*2;
}
signed main(){
	rep(i,3)cin>>x[i]>>y[i];
	rep(i,3){
		d[i]=hypot(x[i]-x[(i+1)%3],y[i]-y[(i+1)%3]);
	}
	t=(d[0]+d[1]+d[2])/2;
	s=sqrt(t*(t-d[0])*(t-d[1])*(t-d[2]));
	r=s/t;
	ma=max({d[0],d[1],d[2]});
	rep(i,100000){
		double mid=(ok+ng)/2;
		if(solve(mid))ok=mid;
		else ng=mid;
	}
	printf("%.12lf\n",ok);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int		main(void)
{
	int A, B, C, D;

	scanf ("%d %d %d %d", &A, &B, &C, &D);

	while (1)
	{
		C -= B;
		if (C <= 0)
		{
			printf("Yes");
			return (0);
		}

		A -= D;
		if (A <= 0)
		{
			printf("No");
			return (0);
		}
	}
}

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int sum = 0;
  
  for(int i = 0; i < K; i++){
    if(A != 0){
      sum++;
      A--;
    }
    else if(B != 0){
      B--;
    }
    else if(C != 0){
      sum--;
      C--;
    }
  }
  
  cout << sum << endl;
  
  return 0;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  long ans = 0, count;
  for(int i = 0; i < K; i++){
    count = 0;
    for(int j = 1; j <= N / K; j++){
      if(N <= j * K + i)break;
      if(T.at((j - 1) * K + i) == T.at(j * K + i)){
        count++;
      } else {
        count = 0;
      }
      if(count % 2 == 0){
        if(T.at(j * K + i) == 'r')ans += P;
        else if(T.at(j * K + i) == 's')ans += R;
        else ans += S;
      }
    }
  }
  for(int i = 0; i < K; i++){
    if(i >= N)break;
    if(T.at(i) == 'r')ans += P;
    else if(T.at(i) == 's')ans += R;
    else ans += S;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String[] s = new String[n];
    int ans = 0;
    
    for(int i=0; i<n; i++){
		s[i] = sc.next();
    }
      
    System.out.println(elmDup(s));
  }
  
   static int elmDup(String[] s) {
    Set<String> linkedHashSet = new LinkedHashSet<String>();

    for (int i = 0; i < s.length; i++) {
    linkedHashSet.add(s[i]);
    }

    Object[] s_after = linkedHashSet.toArray();
     
     return s_after.length;
  }
}

Measured memory_bytes: 74120
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int n = Integer.parseInt(input());
		int taroScore = 0;
		int hanakoScore = 0;

		for (int i = 0; i < n; i++) {

			String[] tempList = input().split(" ");

			if (0 < tempList[0].compareToIgnoreCase(tempList[1])) {

				taroScore += 3;

			} else if (tempList[0].compareToIgnoreCase(tempList[1]) < 0) {

				hanakoScore += 3;

			} else if (tempList[0].compareToIgnoreCase(tempList[1]) == 0) {

				taroScore += 1;
				hanakoScore += 1;

			}
		}

		System.out.println(taroScore + " " + hanakoScore);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 31336
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using namespace std;
#define INF 1000000000000000LL
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
using ipair = std::pair<ll,ll>;

struct Edge{
    ll to, weight;
};

vector<ll> dist1,dist2;//,pred;
vector<vector<Edge>> edgeVec1,edgeVec2;// edge[u]:uから繋がるEdge

void dijkstra1(int N, int start){
    dist1[start]=0;
    //pred[start]=-1;
    priority_queue<ipair,vector<ipair>,greater<ipair>> que;
    que.push(make_pair(0,start));
    while(!que.empty()){
        ll nowDist,pre;
        tie(nowDist,pre) = que.top();
        que.pop();
        if(nowDist>dist1[pre]) continue;
        for(Edge e :edgeVec1[pre]){
            if(dist1[e.to]>dist1[pre]+e.weight){
                dist1[e.to] = dist1[pre] + e.weight;
                //pred[e.to] = pre;
                que.push(make_pair(dist1[e.to],e.to));
            }
        }
    }
}

void dijkstra2(int N, int start){
    dist2[start]=0;
    //pred[start]=-1;
    priority_queue<ipair,vector<ipair>,greater<ipair>> que;
    que.push(make_pair(0,start));
    while(!que.empty()){
        ll nowDist,pre;
        tie(nowDist,pre) = que.top();
        que.pop();
        if(nowDist>dist2[pre]) continue;
        for(Edge e :edgeVec2[pre]){
            if(dist2[e.to]>dist2[pre]+e.weight){
                dist2[e.to] = dist2[pre] + e.weight;
                //pred[e.to] = pre;
                que.push(make_pair(dist2[e.to],e.to));
            }
        }
    }
}


int main() {
    ll n,m,s,t;// Node num, Edge num, start point ,goal point
    cin >> n >> m >> s>> t;
    dist1.assign(n,INF);
    dist2.assign(n,INF);
    edgeVec1.assign(n,vector<Edge>{});
    edgeVec2.assign(n,vector<Edge>{});

    ll u,v,a,b;
    rep(i,0,m){
        cin >> u >> v >> a >> b;
        u --; v--;
        edgeVec1[u].push_back(Edge{v,a});
        edgeVec1[v].push_back(Edge{u,a});
        edgeVec2[u].push_back(Edge{v,b});
        edgeVec2[v].push_back(Edge{u,b});
    }

    ll money = 1e15;
    dijkstra1(n,s-1);
    dijkstra2(n,t-1);
    vector<ll> sumDist(n),ans(n);
    rep(i,0,n) sumDist[i] = dist1[i]+dist2[i];

    ll mi = sumDist[n-1];
    for(ll i=n-1;i>=0;i--){
        mi = min(mi,sumDist[i]);
        ans[i] = money - mi;
    }

    for(ll i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 19780
S = input().strip()
K = int(input())

ans = ""
for i, s in enumerate(S):
    if i == len(S) - 1:
        if ord(s) + K <= ord("z"):
            ans += chr(ord(s) + K)
        else:
            ans += chr(ord("a") + (ord(s) + K - ord("z") - 1) % 26)
    elif s == "a":
        ans += "a"
        continue
    elif ord("z") + 1 - ord(s) <= K:
        ans += "a"
        K -= (ord("z") + 1 - ord(s))
    else:
        ans += s

print(ans)



Measured memory_bytes: 9432
n = int(input())

p = {}
pre = str(input())
p[pre] = 1
pre = pre[len(pre)-1]

ret = True

for i in range(n-1) :
    w = str(input())

    if pre != w[0] :
        ret = False

    if w in p :
        ret = False
    else:
        p[w] = 1
        
    pre = w[len(w)-1]

if ret :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	int N, A[101];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	int temp;
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		for (int j = i; j > 0; j--) {
			if (A[j - 1] <= A[j]) {
				break;
			}
			else {
				cnt++;
				temp = A[j - 1];
				A[j - 1] = A[j];
				A[j] = temp;
			}
		}
	}
	for (int j = 0; j < N-1; j++) cout << A[j] << " ";
	cout << A[N-1]<< endl;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

from collections import Counter


n, m, k = map(int, input().split())

graph1 = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(x) - 1 for x in input().split()]
    graph1[a].append(b); graph1[b].append(a)

graph2 = [[] for _ in range(n)]
for _ in range(k):
    c, d = [int(x) - 1 for x in input().split()]
    graph2[c].append(d); graph2[d].append(c)

def dfs(now):
    X[now] = x
    for next in graph1[now]:
        if X[next]:
            continue
        dfs(next)

X = [0] * n
x = 1
for i in range(n):
    if X[i]:
        continue
    dfs(i)
    x += 1

cnt = Counter(X)

ans = []
for i in range(n):
    x = X[i]
    tmp = cnt[x] - 1
    tmp -= len(graph1[i])
    tmp -= sum(X[j] == x for j in graph2[i])
    ans.append(tmp)

print(*ans)


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

int main() {
  int N,AC=0,WA=0,TLE=0,RE=0;
  cin>>N;
  string S;
 
  rep(i,N){cin >> S;
          if(S=="AC"){AC++;}else if(S=="WA"){WA++;}else if(S=="TLE"){TLE++;}else{RE++;}
          }
  
  cout<<"AC x "<<AC<<endl;
  cout<<"WA x "<<WA<<endl;
  cout<<"TLE x "<<TLE<<endl;
  cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll a[3*n];
  for (int i = 0; i < 3 * n; i++) cin >> a[i];
  priority_queue<ll,vector<ll>,greater<ll>> pq1;
  vector<ll> left;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    pq1.push(a[i]);
    sum += a[i];
  }
  left.push_back(sum);
  for (int i = 0; i < n; i++) {
    pq1.push(a[n + i]);
    sum += a[n + i];
    sum -= pq1.top();
    pq1.pop();
    left.push_back(sum);
  }
  sum = 0;
  priority_queue<ll> pq2;
  for (int i = 0; i < n; i++) {
    pq2.push(a[3*n-i-1]);
    sum += a[3*n-i-1];
  }
  vector<ll> right;
  right.push_back(sum);
  for (int i = 0; i < n; i++) {
    pq2.push(a[2*n-i-1]);
    sum += a[2*n-i-1];
    sum -= pq2.top();
    pq2.pop();
    right.push_back(sum);
  }
  ll ans = -1e18;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, left[i] - right[n - i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6516
#include<cstdio>
#include<algorithm>
#include<vector>

#define INF 1e6

using namespace std;

typedef long long ll;
int n,d;
struct data{
	ll x,y,c;
};

bool comp(const data& d1,const data& d2){
	return d1.c<d2.c;
};

data s[200001];

struct segtree{
	int val,b,s,v2;
};
segtree seg[2][1<<19];
vector<ll> x_d,y_d;

void init(){
	for(int i=0;i<(1<<19);i++)seg[0][i].s=seg[1][i].s=INF;
	for(int i=1<<18;i<1<<19;i++)seg[0][i].v2=seg[1][i].v2=i-(1<<18);
	sort(x_d.begin(),x_d.end());
	x_d.erase(unique(x_d.begin(),x_d.end()),x_d.end());
	sort(y_d.begin(),y_d.end());
	y_d.erase(unique(y_d.begin(),y_d.end()),y_d.end());
	for(int i=0;i<n;i++){
		int num=lower_bound(x_d.begin(),x_d.end(),s[i].x)-x_d.begin();
		s[i].x=num;
		num=lower_bound(y_d.begin(),y_d.end(),s[i].y)-y_d.begin();
		s[i].y=num;
	}
}

void update(int upd,int x,int a){
	x+=(1<<18);
	seg[upd][x].val+=a;
	if(seg[upd][x].val>=1)seg[upd][x].s=seg[upd][x].b=seg[upd][x].v2;
	else{
		seg[upd][x].s=INF;
		seg[upd][x].b=0;
	}
	while(x>0){
		x=(x-1)/2;
		seg[upd][x].s=min(seg[upd][x*2+1].s,seg[upd][x*2+2].s);
		seg[upd][x].b=max(seg[upd][x*2+1].b,seg[upd][x*2+2].b);
	}
}


int main(void){
	scanf("%d%d",&n,&d);
	for(int i=0;i<n;i++){
		scanf("%lld%lld%lld",&s[i].x,&s[i].y,&s[i].c);
		x_d.push_back(s[i].x);
		y_d.push_back(s[i].y);
	}
	init();
	sort(s,s+n,comp);
	ll res=0;
	int mc=0;
	for(int i=0;i<n;i++){
		update(0,s[i].x,1);
		update(1,s[i].y,1);
		while(s[i].c-s[mc].c>d){
			update(0,s[mc].x,-1);
			update(1,s[mc].y,-1);
			mc++;
		}
		res=max(res,(x_d[seg[0][0].b]-x_d[seg[0][0].s])*(y_d[seg[1][0].b]-y_d[seg[1][0].s]));
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 25404
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a,b; 
	cin>>a>>b; 
	for(int i=1;i<=100000;i++){
		if(int(i*0.08)==a and int(i*0.1)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define Long long long int
using namespace std;
int a[300002];
main(){
	int n;
	cin >> n;
	for(int i=0;i<3*n;i++){
		scanf("%d",a+i);
	}
	sort(a,a+3*n);
	Long sum = 0;
	for(int i=0;i<n;i++){
		sum += a[n+2*i];
	}
	cout << sum;
}

Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){

  int N, Y;
  cin >> N >> Y;
  
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N - x; y++) {
      int z = N - x - y;
      int p = 10000*x + 5000*y + 1000*z;
      if(p == Y){
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#define ll long long
using namespace std;

int main()
{
	int n, bn, ans = 0;
	vector<int> b;

	cin >> n;
	for (int i = 0; i < n-1; i++) {
		cin >> bn;
		b.emplace_back(bn);
	}
	for (int i = 0; i < n - 2; i++) {
		ans += min(b[i], b[i + 1]);
	}
	ans += b[0];
	ans += b[n - 2];
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
# print(n)
result_set = set()
for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            result = str(i) + str(j) + str(k)
            result_set.add(result)
print(len(result_set))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

    string ans=a>=3200?s:"red";
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

class SegmentTreeOverwriteRMQ:
    M: int
    H: int
    N: int
    st: [int]
    cover: [int]
    I: int = 99999999999999

    def __init__(self, n):
        self.N = n
        self.H = 1
        while self.H < self.N:
            self.H *= 2
        self.M = self.H * 2
        self.cover = [self.I] * self.H
        self.st = [self.I] * self.M
        for i in range(self.H-1, 0, -1):
            self.propagate(i)

    def propagate(self, i):
        if self.cover[i] == self.I:
            self.st[i] = min(self.st[2*i], self.st[2*i+1])
        else:
            self.st[i] = self.cover[i]

    def update(self, l, r, v):
        self._update(l, r, v, 0, self.H, 1)

    def _update(self, l, r, v, cl, cr, cur):
        if l <= cl and cr <= r:
            if cr == cl + 1:
                self.st[cur] = v
            else:
                self.cover[cur] = v
                self.propagate(cur)
        else:
            mid = (cl+cr)//2
            bp = False
            if self.cover[cur] != self.I:
                if 2*cur >= self.H:
                    self.st[2*cur] = self.cover[cur]
                    self.st[2*cur+1] = self.cover[cur]
                else:
                    self.cover[2*cur] = self.cover[cur]
                    self.cover[2 * cur + 1] = self.cover[cur]
                    bp = True
                self.cover[cur] = self.I
            if cl < r and l < mid:
                self._update(l, r, v, cl, mid, 2*cur)
            elif bp:
                self.propagate(2*cur)
            if mid < r and l < cr:
                self._update(l, r, v, mid, cr, 2*cur+1)
            elif bp:
                self.propagate(2*cur+1)
            self.propagate(cur)

    def min(self, l, r):
        return self._min(l, r, 0, self.H, 1)

    def _min(self, l, r, cl, cr, cur):
        if l <= cl and cr <= r:
            return self.st[cur]
        else:
            if self.cover[cur] != self.I:
                return self.cover[cur]
            L, R = self.I, self.I
            mid = cl+cr>>1
            if cl < r and l < mid:
                L = self._min(l, r, cl, mid, 2*cur)
            if mid < r and l < cr:
                R = self._min(l, r, mid, cr, 2*cur+1)
            return min(L, R)

n, q = na()

row = SegmentTreeOverwriteRMQ(n+2)
row.update(2, n, n)

col = SegmentTreeOverwriteRMQ(n+2)
col.update(2, n, n)

rmin = n
cmin = n

black = (n-2)*(n-2)
for z in range(q):
    t, x = na()
    if t == 1:
        black -= row.min(x, x + 1) - 2
        if x < rmin:
            rmin = x
            col.update(0, cmin, rmin)
    else:
        black -= col.min(x, x + 1) - 2
        if x < cmin:
            cmin = x
            row.update(0, rmin, cmin)
print(black)



Measured memory_bytes: 87656
n = int(input())
deme = [[int(i) for i in input().split()] for _ in range(n)]

count = 0
p = [0]

for x in range(n):
    if deme[x][0] == deme[x][1]:
        count += 1
        p.append(count)

    else:
        count = 0


if max(p) >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
#include <stdio.h>
int main()
{
	int S, a, b, c;

	scanf("%d", &S);

	a = S / 3600;
	b = S % 3600 / 60;
	c = S % 3600 % 60;

	printf("%d:%d:%d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2108
def q a, b
  return Math.sqrt(a**2 + b**2)
end

while [0,0,0] != (d,w,h=gets.split.map &:to_i)
  gets.to_i.times do
    r = gets.to_i
    if [q(d,w), q(d,h), q(w,h)].min < r*2
      puts "OK"
    else
      puts "NA"
    end
  end
end

Measured memory_bytes: 6116