akhauriyash/Code-Regression huggingface dataset:
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 4;

int n, res, a[N], b[N];

void solve() {
    cin >> n;
    map<int, int> pos;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = a[i];
        pos[a[i]] = i;
    }
    sort(b, b + n);
    for (int i = 0; i < n; ++i) if (i % 2) {
        res += ((i - pos[b[i]]) % 2 + 2) % 2;
    }

    cout << res << "\n";
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


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

const int MAX = 401;
const ll INF = 1001001001001001;

ll dp[MAX][MAX];
ll cum_sum[MAX];
ll a[MAX];

ll rec(int l,int r){
    if(dp[l][r]>0) return dp[l][r];

    if((r-l)==1) return dp[l][r]=0;

    if((r-l)==2) return dp[l][r] = cum_sum[r]-cum_sum[l];

    ll res = INF;
    for(int i=l+1;i<r;++i){
        res = min(res,rec(l,i)+rec(i,r));
    }

    dp[l][r] = res + cum_sum[r]-cum_sum[l];
    return dp[l][r];

}

int main(){
    int n;
    cin >> n;
    ll res=0;
    cum_sum[0]=0;
    rep(i,n){
        cin >> a[i];
        cum_sum[i+1]=a[i]+cum_sum[i];
    }
    cout << rec(0,n) << endl;
}

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

using namespace std;

int const MP = 999983;

bool is_prime[MP+1];
int sum_prime[MP+1];

void Sieve() {
  
  fill(is_prime, is_prime+MP+1, true);
  is_prime[0] = is_prime[1] = false;
  
  for(int i=2; (long long)i*i <= MP; i++) {
    if(is_prime[i]) {
      for(long long j=i*i; j<=MP; j+=i) {
	is_prime[j] = false;
      }
    }
  }
  
  for(int i=0; i<MP+1; i++) {
    sum_prime[i+1] += sum_prime[i] + is_prime[i+1];
  }
  
}

int main() {
  
  Sieve();
  
  int N;
  while(cin >> N && N) {
    int X = 0;
    for(int i=0; i<N; i++) {
      int p, m; cin >> p >> m;
      int L = max(p-m, 1), R = min(p+m, MP);
      int cnt = sum_prime[R]-sum_prime[L-1] - 1;
      X += cnt;
    }
    cout << X << endl;
  }
  
  return 0;
}

Measured memory_bytes: 6040
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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 ceilll(ll a, ll b) {return (a + b-1) / b;} // if(a%b == 0) (a/b) + 1
ll get_digit(ll a) {ll digit = 0; while(a != 0){a /= 10; digit++;} return digit;} // a != 0
template<typename T> void vecdbg(vector<T>& v){ rep(i, v.size()){cout << v[i] << " ";} br;}
template<typename T> void vecvecdbg(vector<vector<T>>& v){ rep(i, v.size()){rep(j, v[i].size()){cout << v[i][j] << " ";} br;}}

// 0 false, 1 true 
// string number to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
// global vector -> 0 initialization

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s, t; cin >> s >> t;

    ll res = 0;
    for(ll i = 0; i < s.size(); i++){
        if(i + t.size() > s.size()){
            continue;
        }else{
            ll cnt = 0;
            for(ll j = 0; j < t.size(); j++){
                if(s[i+j] == t[j]){
                    cnt++;
                }
            }
            res = max(cnt, res);
        }

    }
    cout << t.size() - res << endl;

}

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

int main() {
  int n; cin >> n;
  int bit = 0;
  int a,ex=0;

  REP(i,n) {
    cin >> a;
    if (a <= 399) bit|=(1<<1);
    else if (a <= 799) bit|=(1<<2);
    else if (a <= 1199) bit|=(1<<3);
    else if (a <= 1599) bit|=(1<<4);
    else if (a <= 1999) bit|=(1<<5);
    else if (a <= 2399) bit|=(1<<6);
    else if (a <= 2799) bit|=(1<<7);
    else if (a <= 3199) bit|=(1<<8);
    else ex++;
  }
  cout << max(1, __builtin_popcount(bit)) << " " << __builtin_popcount(bit)+ex << endl;
  return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  double r;
  cin >> r;

  r *= (2 * M_PI);

  cout << r << endl;

};


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int n;
int a[110]; 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	double he=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		he+=a[i];
	}
	int res=100000;
	int pl;
	for(int i=0;i<n;i++){
		if(abs(a[i]*n-he)<res){
			pl=i;
			res=abs(a[i]*n-he);
		}
	}
	cout<<pl<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unistd.h>
#define int long long
const int inf=8938103643641919514ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
signed main(){
	int i,j;
	int aa,bb,cc;
	cin>>a>>b>>c;
	i=0;
	while(a%2==0&&b%2==0&&c%2==0){
		aa=a;
		bb=b;
		cc=c;
		a=(bb+cc)/2;
		b=(aa+cc)/2;
		c=(aa+bb)/2;
		i++;
		if(i==100000000){
			cout<<"-1"<<endl;
			return 0;
		}
	}
	cout<<i<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
for(int i = 0 ; i < n ;i++){
 cin>>arr[i];
}
int dp[n];
dp[0] = 0;
for(int i = 1;  i< n; i++){
  dp[i] = dp[i-1] + abs(arr[i] -arr[i-1]);
  if(i >= 2){
   dp[i] = min(dp[i] , dp[i-2] + abs(arr[i] - arr[i-2]));
  }
}
cout<<dp[n-1]<<endl;
}



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

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

  int ans=0;
  for (int i = 1; i <= m; i++)
  {
    for (int j = 1; j <= d; j++)
    {
      int d1=j%10;
      int d10=j/10;
      if(d1>=2  && d10>=2 && d1*d10==i) ans++;
    }
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
use std::collections::*;

fn main() {
    input! {
       N:usize,
       mut A:[i64;N]
    }
    A.push(0);
    let mut money = 1000;
    let mut stock = 0;
    for i in 0..N {
        if A[i] < A[i + 1] {
            // buy
            stock += money / A[i];
            money = money % A[i];
        } else if A[i] > A[i + 1] {
            // sell
            money += stock * A[i];
            stock = 0;
        }
    }
    //println!("{:?}", A);
    println!("{}", money);
}


Measured memory_bytes: 2152
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] s = new String[N];
        for(int i = 0; i < N; i++){
            s[i]  = sc.next();
        }
        sc.close();
        
        Arrays.sort(s);
        for(int i = 0; i < N; i++){
            System.out.print(s[i]);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << '\n';
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
long long int x;
double y;
long long int yy;

int main(){
    scanf("%lld %lf", &x, &y);
    y += 1e-6;
    yy = y * 100;
    yy = (yy * x) / 100;
    printf("%lld", yy);
}


Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<class T, class Compare = less<T>>
struct SparseTable {

    bool builded = false;
    const int n;
    const Compare cmp;
    vector<T> elements;
    vector<vector<int>> table;
    vector<size_t> log2;

    SparseTable():n(0){}
    SparseTable(int n, T v = T(), const Compare &f = Compare()):
        n(n), log2(n + 1), elements(n), cmp(f)
    {
        for (int i = 2; i <= n; i++) log2[i] = log2[i / 2] + 1;
        elements.assign(n, v);
        table.assign(log2[n] + 1, vector<int>(n));
    }

    template<class InputIterator>
    SparseTable(InputIterator first, InputIterator last,
                const Compare &f = Compare()):
        n(distance(first, last)), log2(n + 1), elements(first, last), cmp(f)
    {
        for (int i = 2; i <= n; i++) log2[i] = log2[i / 2] + 1;
        table.assign(log2[n] + 1, vector<int>(n));
        build();
        //table = vector<vector<T>>(logn, vector<T>(first, last));
    }

    void build(void) {
        for (int i = 0; i < n; i++) table[0][i] = i;
        
        for (int i = 0; i < log2[n]; i++) {
            int w = 1 << i;
            for (int j = 0; j + (w * 2) <= n; j++) {
                int l = table[i][j];
                int r = table[i][j + w];

                if (cmp(elements[l], elements[r])) table[i + 1][j] = l;
                else table[i + 1][j] = r;
            }
        }

        builded = true;
    }

    void set(int k, T dat) {
        elements[k] = dat;
        builded = false;
        return;
    }

    //[l, r)
    T fold(int l, int r) {
        if (!builded) build();

        int k = log2[r - l];
        l = table[k][l];
        r = table[k][r - (1 << k)];

        if (cmp(elements[l], elements[r])) return elements[l];
        else return elements[r];
    }

    int size() { return n; }

    T operator[] (const int k) { return elements[k]; }
};
//===
llong n;
llong k;
llong p[200005];
llong dp[200005];

int main() {
    cin >> n >> k;

    p[0] = 1ll << 50ll;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    
    SparseTable<llong, greater<llong> > RMQ(p, p + n + 1);
    SparseTable<llong, less<llong> > RmQ(p, p + n + 1);

    dp[1] = 1;
    for (int i = 1; i <= n; i++) {
        if(p[i] > p[i - 1]) dp[i] = dp[i - 1] + 1;
        else dp[i] = 1;
    }

    llong cnt = 0;
    llong f = 0;
    for (int i = k; i <= n; i++) {
        if (dp[i] >= k) {
            f = 1;
            continue;
        }
        
        if (p[i - k] >= RmQ.fold(i - k + 1, i + 1) ||
            RMQ.fold(i - k + 1, i + 1) != p[i]) cnt++;
    }

    cout << cnt + f << endl;

    return 0;
}


Measured memory_bytes: 38640
import java.util.*;
class Main{
  public static void main(String[] args){
  	int x = 0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    
    for(int i = 0; i < (N - 2); i++){
    	if( S.charAt(i) == 'A' && S.charAt(i+1) == 'B'){
        	if(S.charAt(i+2) == 'C'){
            	x += 1;
            }
          
        }
      
    }
    System.out.println(x);
  
  }
}


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

int main(){
   int N,ans = 0;
  cin >> N;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  for(int i=0; i<N-1; i++){
    if(vec[i] == vec[i+1] && vec[i+1] == vec[i+2]){
      ans++;
      vec[i+1] = 10000-i;
    }
    else if(vec[i] == vec[i+1]){
      ans++;
      vec[i] = 10000-i;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3604
def parseParenthesis(formula):
    pos = 0
    count = 0
    while True:
        if formula[pos] == '(':
            count += 1
        elif formula[pos] == ')':
            count -= 1
        elif count == 1 and (formula[pos] == '+' or formula[pos] == '*'):
            sign = formula[pos]
            formulaA = formula[1:pos]
            formulaB = formula[pos + 1: -1]
            return formulaA, sign, formulaB
        pos += 1

def eval_or(a, b):
    if a == '0':
        return b
    elif a == '1':
        return '1' if b == '0' else b
    elif a == '2':
        return '2'

def eval_and(a, b):
    if a == '0':
        return '0'
    elif a == '1':
        return '0' if b == '0' else '1'
    elif a == '2':
        return b

def eval_neg(a):
    if a == '1':
        return '1'
    return '2' if a == '0' else '0'

def evaluate(formula, p, q, r):
    if formula == '0' or formula == '1' or formula == '2':
        return formula
    if formula == 'P':
        return p
    if formula == 'Q':
        return q
    if formula == 'R':
        return r

    if formula[0] == '(':
        formulaA, sign, formulaB = parseParenthesis(formula)
        evalA = evaluate(formulaA, p, q, r)
        evalB = evaluate(formulaB, p, q, r)
        if sign == '+':
            return eval_or(evalA, evalB)
        elif sign == '*':
            return eval_and(evalA, evalB)
    elif formula[0] == '-':
        return eval_neg(evaluate(formula[1:], p, q, r))

if __name__ == '__main__':
    while True:
        formula = input().strip()
        if formula == '.':
            break

        count = 0
        for p in range(3):
            for q in range(3):
                for r in range(3):
                    if evaluate(formula, str(p), str(q), str(r)) == '2':
                        count += 1
        print(count)


Measured memory_bytes: 5580
#include <cstdio>
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    int in[N];

    for (int i = 0; i < N; i++) std::cin >> in[i] ;

    int cnt = 0;
    int current_i = 1;
    for (int i = 0; i < N; i++) {
        if (in[i] == current_i) {
            current_i++;
        }
        else {
            cnt++;
        }
    }

    if (current_i == 1) std::cout << -1 << std::endl;
    else std::cout << cnt << std::endl;

    return 0;
}

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


int main(){
  int h,t[300];
  cin>>h;
  for(int i=1;i<=h;i++)cin>>t[i];
  for(int i=1;i<=h;i++){
    cout<<"node "<<i<<": key = "<<t[i]<<", ";
    if(i!=1)cout<<"parent key = "<<t[i/2]<<", ";
    if(i*2<=h)cout<<"left key = "<<t[i*2]<<", ";
    if(i*2+1<=h)cout<<"right key = "<<t[i*2+1]<<", ";
    cout<<endl; 
  }
  return 0;
}

Measured memory_bytes: 1164
x,y,z,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

tmp=[]
for a in A:
  for b in B:
    tmp.append(a+b)
tmp.sort(reverse=True)
tmp=tmp[:k+1]

ans=[]
for c in C:
  for t in tmp:
    ans.append(c+t)

ans.sort(reverse=True)
for i in range(k):
  print(ans[i])

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

#define l first
#define r second

using namespace std;

int n, m;
vector<pair<int, int> > seg;
int st[800010], lazy[800010];
int ans = 0;

void build(int l, int r, int i){
    if(l > r) return;

    if(l == r){
        st[i] = r - m - 1;
        return;
    }

    int m = (l + r) >> 1;

    build(l, m, i << 1);
    build(m + 1, r, 1 + (i << 1));

    st[i] = max(st[i << 1], st[1 + (i << 1)]);
}

void propagate(int l, int r, int i){
    if(lazy[i]){
        if(l != r){
            lazy[i << 1] += lazy[i];
            lazy[1 + (i << 1)] += lazy[i];
        }
        st[i] += lazy[i];
    }

    lazy[i] = 0;
}

void update(int l, int r, int ls, int rs, int i){
    propagate(l, r, i);

    if(r < ls || rs < l) return;

    if(ls <= l && r <= rs){
        lazy[i] += 1;
        propagate(l, r, i);
        return;
    }

    int m = (l + r) >> 1;

    update(l, m, ls, rs, i << 1);
    update(m + 1, r, ls, rs, 1 + (i << 1));

    st[i] = max(st[i << 1], st[1 + (i << 1)]);
}

int query(int l, int r, int ls, int rs, int i){
    propagate(l, r, i);

    if(r < ls || rs < l) return 0;

    if(ls <= l && r <= rs) return st[i];

    int m = (l + r) >> 1;

    return max(query(l, m, ls, rs, i << 1), query(m + 1, r, ls, rs, 1 + (i << 1)));
}

int main(){
    scanf("%d%d", &n, &m);

    seg.resize(n);

    for(int i = 0; i < n; i++)
        scanf("%d%d", &seg[i].l, &seg[i].r);

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

    build(1, m + 1, 1);

    for(auto k : seg){
        update(1, m + 1, 1, k.r, 1);

        ans = max(ans, query(1, m + 1, k.l + 1, m + 1, 1) - k.l);
    }

    ans = max(ans, n - m);

    printf("%d\n", ans);
    
    return 0;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int X = int.Parse(Console.ReadLine());

        var lis = new int[] { 7, 5, 3 };

        if (lis.Contains(X))
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const int maxn=1E5+5;
typedef long long int ll;
int n,size,head[maxn],ans[maxn];
ll a[maxn],sum[maxn];
map<ll,ll>what;
struct edge
{
	int to,next;
}E[maxn*2];
inline void add(int u,int v)
{
	E[++size].to=v;
	E[size].next=head[u];
	head[u]=size;
}
ll dfs(int u,int F,ll d)
{
	ll sum=0;
	for(int i=head[u];i;i=E[i].next)
	{
		int v=E[i].to;
		if(v==F)
			continue;
		ans[v]=u;
		sum+=dfs(v,u,d+1);
	}
	return sum+d;
}
inline void solve()
{
	for(int i=1;i<=n;++i)
		sum[i]=1;
	for(int i=1;i<n;++i)
	{
		ll x=a[i]-n+sum[what[a[i]]]*2;
		if(!what[x])
		{
			cout<<-1<<endl;
			exit(0);
		}
		add(what[x],what[a[i]]);
		sum[what[x]]+=sum[what[a[i]]];
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		what[a[i]]=i;
	}
	ll g=a[1],pos=1;
	for(int i=2;i<=n;++i)
		if(a[i]<g)
			g=a[i],pos=i;
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	solve();
	if(dfs(pos,pos,0)!=g)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<=n;++i)
		if(ans[i])
			cout<<i<<" "<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/
int main()
{
    int a;
    cin>>a;
    vector<int> b;
    rep(i,a){
        int temp;
        cin>>temp;
        b.push_back(temp);
    }
    SORT(b);
    reverse(begin(b), end(b));
    int ans=1;
    rep(i,a-1)
        if(b[i]>b[i+1]) ans++;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

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

int main()
{
	while (true) {
		int w, h;
		cin >> w >> h;

		if (w == 0 && h == 0) {
			break;
		}

		vector<vector<int>> tatekabe(h, vector<int>(w - 1, 0));
		vector<vector<int>> yokokabe(h - 1, vector<int>(w, 0));
		vector<vector<int>> f(w, vector<int>(h, 0));

		for (int i = 0; i < 2 * h - 1; i++) {
			if (i % 2 == 0) {
				for (int j = 0; j < w - 1; j++) {
					cin >> tatekabe[i / 2][j];
				}
			}
			else {
				for (int j = 0; j < w; j++) {
					cin >> yokokabe[i / 2][j];
				}
			}
		}

		int ans = 1;
		queue<pair<int, int>> q;
		q.push({ 0,0 });
		f[0][0] = 1;

		while (true) {
			if (q.empty() == true) {
				cout << 0 << endl;
				break;
			}

			unsigned int cnt = q.size();
			while (cnt != 0) {

				pair<int, int> temp = q.front();
				q.pop();
				cnt--;

				if (temp.first == w - 1 && temp.second == h - 1) {
					cout << ans << endl;
					goto End;
				}

				for (int i = 0; i < 4; i++) {
					bool flag = true;
					int nx = temp.first + dx[i];
					int ny = temp.second + dy[i];

					if (nx < 0 || nx >= w || ny < 0 || ny >= h) {
						continue;
					}

					switch (i) {
					case 0:
						if (tatekabe[temp.second][temp.first] == 1) {
							flag = false;
						}
						break;
					case 1:
						if (yokokabe[temp.second][temp.first] == 1) {
							flag = false;
						}
						break;
					case 2:
						if (tatekabe[temp.second][temp.first - 1] == 1) {
							flag = false;
						}
						break;
					case 3:
						if (yokokabe[temp.second - 1][temp.first] == 1) {
							flag = false;
						}
						break;
					}

					if (flag == true && f[nx][ny] == 0) {
						q.push({ nx,ny });
						f[nx][ny] = 1;
					}
				}
			}
			ans++;
		}
	End:
		;
	}

	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	vi v(n);
	rep(i, 0, n-1) cin >> v[i];
	sort(all(v));
	int ans = 0;
	repr(mid, n-1, 0){
		repr(low, mid-1, 0){
			auto itr = lb(all(v), v[mid]+v[low]);
			int dist = distance(itr, v.end());
			ans += (n-1-mid)-dist;
		}
	}
	cout << ans;
}

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

	// test
	solve();

	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c;
  long long k;
  cin>>a>>b>>c>>k;
  if(fabs(a-b)>pow(10,18))
  {
     cout<<"Unfair"<<endl;
     return 0;
  }
  if(k%2)
  {
    long long a1,b1;
    a1=b+c;
    b1=a+c;
    a=a1;
    b=b1;
  }
  cout<<a-b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
const double eps = 1e-7;
int N, M, K, Q, T;

int main()
{
	int i, j, a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int k1 = (c + b - 1) / b;
	int k2 = (a + d - 1) / d;
	if (k1 <= k2) {
		printf("Yes");
	}
	else printf("No");
	
	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

template<typename T>
struct BIT{
    int N;
    vector<T> dat;
    BIT(int n) : N(n), dat(n+1,0){ }
    void add(int i, T num){
        for(int x = i+1; x <= N; x += (x & -x)){
            dat[x] += num;
            dat[x] %= mod;
        }
    }
    T sum(int i){
        T ret = 0;
        for(int x = i+1; x > 0; x -= (x & -x)){
            ret += dat[x];
            ret %= mod;
        }
        return ret;
    }
    T sum(int i, int j){
        return (sum(j) + mod - sum(i-1)) % mod;
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int N, K; cin >> N >> K;
    vi A(N);
    rep(i,N) cin >> A[i];
    vector<BIT<ll>> dp(N+1, BIT<ll>(K+1));

    dp[0].add(0, 1);
    rep(i,N){
        rep(j,K+1){
            dp[i+1].add(j, dp[i].sum(max(0, j-A[i]), j));
        }
    }
    cout << dp[N].sum(K, K) << endl;
    return 0;
}

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

long long solve();

int main()
{
	printf("%lld\n", solve());

	return 0;
}

long long solve()
{
	int n, m;
	scanf("%d%d", &n, &m);
	if (n >= m) return 0;
	std::vector<int> x(m);
	for (auto& e: x) scanf("%d", &e);
	std::sort(x.begin(), x.end());
	std::vector<int> distance(m - 1);
	for (int i{}; i < m - 1; i++)
		distance[i] = x[i + 1] - x[i];
	std::sort(distance.begin(), distance.end());
	long long ret{};
	for (int i{}; i < m - n; i++)
		ret += distance[i];
	return ret;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){
        if(b<c){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

long long N, A[4545], dp[2525][2525], i, j, r, m;
pair<long long, long long> p, q;

int main(){
  scanf("%lld", &N);
  for(i = 0; i < N; ++i){
    scanf("%lld", A + i);
    A[i + N] = A[i];
  }
  //for(i = 0; i < N * 2; ++i)cout << A[i] << " ";
  //cout << endl;
  if(N % 2 != 0){
    for(i = 0; i < N; ++i)dp[i][0] = A[i];
    for(j = 1; j <= N; j += 2){
      for(i = 0; i < N; ++i){
        dp[i][j] = (A[i] > A[i + j])?dp[(i + 1) % N][j - 1]:dp[i][j - 1];
      }
      for(i = 0; i < N; ++i){
	//cout << i << " " << j + 1 << " " << dp[(i + 1) % N][j] + A[i] << " " << dp[i][j] + A[i + j + 1] << endl;
	dp[i][j + 1] = max(dp[(i + 1) % N][j] + A[i], dp[i][j] + A[i + j + 1]);
      }
    }
  }else{
    for(i = 0; i < N; ++i)dp[i][0] = 0;
    for(j = 1; j <= N; j += 2){
      for(i = 0; i < N; ++i){
	dp[i][j] = max(dp[(i + 1) % N][j - 1] + A[i], dp[i][j - 1] + A[i + j]);
      }
      for(i = 0; i < N; ++i){
        dp[i][j + 1] = (A[i] > A[i + j + 1])?dp[(i + 1) % N][j]:dp[i][j];
      }
    }
  }
  /*
  for(i = 0; i < N; ++i){
    for(j = 0; j <= N; ++j)cout << dp[i][j] << " ";
    cout << endl;
  }*/
  for(i = 0; i < N; ++i){
    r = A[i] + dp[(i + 1) % N][N - 2];
    m = max(r, m);
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 42436
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(h * w - (h / a * a) * (w / b * b));
	}
}



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

#define int long long

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;



signed main() {
    IOS();
    
    int N;
    while(cin>>N){
        if(N==0)break;
        map<char,char>mp;
    rep(i,0,N){
        char a,b;
        cin>>a>>b;
        mp[a]=b;
    }
    int M;cin>>M;
    rep(i,0,M){
        char a;cin>>a;
        if(mp[a])cout<<mp[a];
        else cout<<a;
    }
    cout<<endl;
    }

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}


Measured memory_bytes: 3028
import sys
input = sys.stdin.readline

N, D = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for xy in XY:
    x, y = xy[0], xy[1]
    if (x*x + y*y)**0.5 <= D:
        ans += 1
print(ans)


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

using namespace std;

#define all(v)   v.begin(), v.end()
#define pb       push_back
#define sz(x)    (int) (x.size())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE


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


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

    string s, t; cin >> s >> t;
    int n = sz(s), c= 0;
    for(int i = 0; i < n; i++)
        c += (s[i] != t[i]);

    cout << c;
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define int long long

int solve() {
	int n, k;
	cin >> n >> k;
	int a[n];
	int i;
	for (i = 0; i < n; i++)cin >> a[i];

	int dp[k + 1] = {0};
	int j;
	for (i = 1; i <= k; i++) {
		for (j = 0; j < n; j++) {
			if (i - a[j] >= 0) {
				if (dp[i - a[j]] == 0) {
					dp[i] = 1;
					break;
				}
			}
		}
	}

	// for (i = 0; i <= k; i++)cout << dp[i] << " ";

	if (dp[k] == 1)cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}

int32_t main() {

	solve();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int n,m,i;
    cin>>n>>m;
    string a[n];
    f(i=0; i<n; i++)
    {
       cin>>a[i];
    }
    sort(a,a+n);
    f(i=0; i<n; i++)
    {
       cout<<a[i];
    }
    return 0;

}


Measured memory_bytes: 3628
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C, D = get_ints

puts (C-A).abs <= D || ((C-B).abs <= D && (B-A).abs <=D) ? 'Yes' :'No'


Measured memory_bytes: 14428
#include <iostream>

void swap(int& x, int& y)
{
	int tmp = x;
	x = y;
	y = tmp;
}

int partition(int* A, int p, int r)
{
	int key = A[r];
	int i = p - 1;
	for (int j=p; j<r; j++) {
		if (A[j] <= key) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i+1;
}
	

int main()
{
	int n;
	std::cin >> n;
	
	int *A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];
	
	int k = partition(A, 0, n-1);
	
	std::cout << A[0];
	for (int i=1; i<k; i++) std::cout << " " << A[i];
	std::cout << " [" << A[k] << "]";
	for (int i=k+1; i<n; i++) std::cout << " " << A[i];
	std::cout << std::endl;
	
	delete[] A;
	
	return 0;
}




Measured memory_bytes: 3116
#pragma region
#include <assert.h>
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &v) {
  return os << v.first << ' ' << v.second << '\n';
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for (T t : v) os << t << ' ';
  return os << '\n';
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
#pragma endregion

#define int long long
int mod = 1e9 + 7;  // 998244353;

void solvetestcase() {
  int n, q;
  cin >> n >> q;
  int left = (n - 2) * (n - 2);
  map<int, int> mv, mh;

  mv[0] = n - 2;
  mh[0] = n - 2;

  while (q--) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      auto itr = mv.lower_bound(x);
      itr--;
      int ans = itr->second;
      left -= ans;
      mv[x] = ans;
      mh[0] = min(mh[0], x - 2);
    } else {
      auto itr = mh.lower_bound(x);
      itr--;
      int ans = itr->second;
      left -= ans;
      mh[x] = ans;
      mv[0] = min(mv[0], x - 2);
    }
  }

  cout << left << endl;
}

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

  int t = 1;
  // cin >> t;

  for (int T = 1; T <= t; T++) {
    // cout << "Case #" << T << ": ";
    solvetestcase();
    cout.flush();
  }

  return 0;
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/


Measured memory_bytes: 16116
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    ll a;
    multiset<ll> se;
    rep(i,n){
        cin >> a; 
        a = -a;
        if(se.upper_bound(a) == se.end()){
            se.insert(a);
        }else{
            auto it = se.upper_bound(a);
            se.erase(it);
            se.insert(a);
        }
    } 
    cout << se.size() << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
 
int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  ll min_,max_;
  max_ = min(A,B);
  min_ = (A+B)-N;
  if(min_<0)min_=0;
  cout<<max_<<" "<<min_<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

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

int h[1000];
signed main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> h[i];
    }   
    bool flg = false;
    int x;
    int cnt = 0;
    while(true){
        rep(i,n){
            flg = false;
            if(h[i] != 0){ 
                x = i;
                flg = true;
                break;
            }
        }
        if(flg){
            for(int i = x;i<n;++i){
                if(h[i] > 0) --h[i];
                else break;
            }
            cnt++;
        }
        else break;
    }   
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
#include <iomanip>
using namespace std;
 
int main() 
{
    int n, m;
    cin >> n >> m;
    if (n == m)
    {
        cout << "Yes";
    }
    else if (m<n && m>=0)
    {
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
int main()
{
	string str1, str2; cin >> str1 >> str2;
	int len1 = str1.length();
	int len2 = str2.length();

	int dp[3002][3002];
	memset(dp, 0, sizeof(dp));
	bool dir[3002][3002];
	
	//false meaning increase first 
	//true meaning increase second
	FOR(i, len1) {
		FOR(a, len2) {
			if (str1[i] == str2[a]) {
				dp[i + 1][a+1] = dp[i][a] + 1;
			}
			else if (dp[i + 1][a]> dp[i][a+1]) {
				dp[i + 1][a+1] = dp[i + 1][a];
				dir[i + 1][a+1] = true;
			}
			else {
				dp[i + 1][a+1] = dp[i][a+1];
				dir[i + 1][a + 1] = false;
			}
		}
	}
	string out = "";
	
	int i, a; i = len1 - 1; a = len2 - 1;
	
	while (i>=0&&a>=0) {
		//cout << i << " " << a << "\n";
		//cout << dir[i + 1][a + 1] << "\n";
		if (str1[i] == str2[a]) {
			out += str1[i];
			i--;
			a--;
		}
		else if (dir[i+1][a+1]) {
			a--;
		}
		else {
			i--;
		}
	}
	reverse(out.begin(), out.end());
	cout << out<< "\n";
}


Measured memory_bytes: 44288
#include <bits/stdc++.h>
#define NMAX 500010

using namespace std;

int N, nextNode[NMAX][2], leaves[NMAX];
long long DP[NMAX][2];

void DFS (int node, int depth) {
	if (node == N) return;

	DFS(nextNode[node][0], depth + 1);
	DFS(nextNode[node][1], depth + 1);

	leaves[node] = leaves[nextNode[node][0]] + leaves[nextNode[node][1]];
	DP[node][0] = DP[nextNode[node][0]][0] + leaves[nextNode[node][0]] + DP[nextNode[node][1]][0] + leaves[nextNode[node][1]];
	DP[node][1] = DP[node][0];
	DP[node][1] = min(DP[node][1], DP[nextNode[node][0]][0] + leaves[nextNode[node][0]] + DP[nextNode[node][1]][1] + 1);
	DP[node][1] = min(DP[node][1], DP[nextNode[node][1]][0] + leaves[nextNode[node][1]] + DP[nextNode[node][0]][1] + 1);
	DP[node][1] = min(DP[node][1], DP[nextNode[node][0]][1] + 1 + depth + DP[nextNode[node][1]][1] + 1);
}

int main()
{
	cin >> N;
	for (int i = 1; i < N; i++) cin >> nextNode[i][0] >> nextNode[i][1];

	leaves[N] = 1;
	DFS (1, 0);

	cout << DP[1][1] << '\n';
	return 0;
}



Measured memory_bytes: 32292
#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 ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n,m;
  cin >> n >> m;
  REP(i,m){
    int a;
    cin >> a;
    n -= a;
  }

  cout << (n>=0 ? n : -1 ) << endl;
}



Measured memory_bytes: 3624
// Tourist's solution
// Just time test

#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1234567;
 
int dist[N];
vector < pair <int, int> > g[N];
vector <int> new_g[N], all[N];
int was[N];
int x[N];
int ptr[N];
 
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int foo, bar, qwe;
    scanf("%d %d %d", &foo, &bar, &qwe);
    foo--; bar--;
    g[foo].push_back(make_pair(qwe, bar));
    g[bar].push_back(make_pair(qwe, foo));
    all[qwe].push_back(foo);
    all[qwe].push_back(bar);
  }
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
    ptr[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    was[i] = -1;
  }
  int new_n = n;
  for (int i = 0; i < N; i++) {
    new_g[i].clear();
  }
  for (int color = 0; color < N; color++) {
    if (all[color].empty()) {
      continue;
    }
    for (int it = 0; it < (int) all[color].size(); it++) {
      int v = all[color][it];
      if (was[v] == color) {
        continue;
      }
      int b = 0, e = 1;
      x[0] = v;
      was[v] = color;
      while (b < e) {
        while (ptr[x[b]] < (int) g[x[b]].size()) {
          int c = g[x[b]][ptr[x[b]]].first;
          if (c != color) {
            break;
          }
          int u = g[x[b]][ptr[x[b]]].second;
          if (was[u] != color) {
            was[u] = color;
            x[e] = u;
            e++;
          }
          ptr[x[b]]++;
        }
        b++;
      }
      for (int i = 0; i < e; i++) {
        new_g[x[i]].push_back(new_n);
        new_g[new_n].push_back(x[i]);
      }
      new_n++;
    }
  }
  for (int i = 0; i < new_n; i++) {
    dist[i] = -2;
  }
  int b = 0, e = 1;
  x[0] = 0;
  dist[0] = 0;
  while (b < e) {
    for (int j = 0; j < (int) new_g[x[b]].size(); j++) {
      int u = new_g[x[b]][j];
      if (dist[u] == -2) {
        dist[u] = dist[x[b]] + 1;
        x[e] = u;
        e++;
      }
    }
    b++;
  }
  printf("%d\n", dist[n - 1] / 2);
  return 0;
}

Measured memory_bytes: 116096
a = input()
b = input()
c = input()
a = a.replace("a","")
b = b.replace("b","")
c = c.replace("c","")
turn = 'a'
for i in range(500):
	if turn == 'a':
		if int(len(a)) == 0:
			print("A")
			break
		else:
			turn = str(a[0])
			a = a[1:]
	if turn == 'b':
		if int(len(b)) == 0:
			print('B')
			break
		else:
			turn = str(b[0])
			b = b[1:]
	if turn == 'c':
		if int(len(c)) == 0:
			print('C')
			break
		else:
			turn = str(c[0])
			c = c[1:]

Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

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

int main() {
    int h, w;
    std::cin >> h >> w;

    std::vector<std::vector<char>> s(h, std::vector<char>(w));
    for(int i = 0;i < h; i++) {
        for(int j = 0; j < w; j++) {
            std::cin >> s[i][j];
        }
    }

    bool f = true;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {

            if(s[i][j] == '#') {
                int cnt = 0;
                for(int k = 0; k < 4; k++) {
                
                        int nx = i + dy[k];
                        int ny = j + dx[k];

                        if(nx >= 0 && nx < h && ny >= 0 && ny < w) {
                            if(s[nx][ny] != '#') {
                                cnt ++;
                            }
                        }
                }     

                if(cnt >= 4) {
                    f = false;
                }   
            }



        }
    }


    std::string ans = f?"Yes":"No";

    std::cout << ans << std::endl;
}

Measured memory_bytes: 3640