akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
signed main(){
	int n; cin >> n;
	int du = 0;
	for(int i = 1 ; i <= n ; ++i)
	{
		int a; cin >> a;
		du += a - 1;
	}
	cout << du;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N,K;cin>>N>>K;
  vll A(N);rep(i,N)cin>>A[i];
  for(int i=K;i<N;++i){
    if(A[i-K]<A[i]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4840
#include <iostream>

using namespace std;

int main(void){
    
    string a, b;

    cin >> a >> b;

    if(a == "H"){
        if(b == "H") cout << "H" << endl;
        else cout << "D" << endl;
    }else {
        if(b == "H") cout << "D" << endl;
        else cout << "H" << endl;
    }

    return 0;

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
//#include "stdc++.h"
#define llint long long int
#define ldouble long double

using namespace std;

int main() {
    string enki="ACGT";
    int n=0;
    char c;
    cin>>c;
    for(int i=0;i<4;i++){
        if(enki[i]==c){
            cout<<enki[3-i]<<endl;
            break;
        }
    }
return 0;
}

Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

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

using namespace std;
using namespace __gnu_pbds;

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

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	vector < int > v(5);
	for (auto &el: v) {
		cin >> el;
	}
	sort(all(v));
	int mn = INF;
	do {
		int t = 0;
		for (int i = 0; i < 5; ++i) {
			t += v[i];
			if (i == 4) {
				mn = min(mn, t);
			}
			t = ((t + 9) / 10) * 10;
		}
	} while (next_permutation(all(v)));
	cout << mn << "\n";
}

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

using namespace std;

const int INF = 1e9;

struct Edge {
    int from, to, cap, flow;
    Edge(int from, int to, int cap, int flow):from(from), to(to), cap(cap), flow(flow){}   
};

struct Maxflow {
    int n;
    vector<Edge> edges;
    vector<vector<int>> g;
    
    vector<int> p; //The id of the edge that connects to a vertex on the shortest path
    vector<int> a; //The possible flow change from the start to a vertex
    int flow = 0;
    
    Maxflow(int n) : n(n) {
        g.assign(n + 1, vector<int>());
    }
    
    void addEdge(int from, int to, int cap) {
        edges.push_back(Edge(from , to, cap, 0));
        edges.push_back(Edge(to, from, 0, 0));
        g[from].push_back(edges.size() - 2);
        g[to].push_back(edges.size() - 1);   
    }
    
    int solve(int s, int t) {
       while (findAugumentedPath(s, t)) {
       }
       return flow;
    }
    
    bool findAugumentedPath(int s, int t) {  
        p.assign(n + 1, -1);
        a.assign(n + 1, 0);
        
        queue<int> q;

        p[s] = -2;
        a[s] = INF;
        q.push(s);
        
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (int eid: g[u]) {
                Edge e = edges[eid];
                if (a[e.to] == 0 && e.cap > e.flow) {
                    p[e.to] = eid;
                    a[e.to] = min(a[u], e.cap - e.flow);
                    q.push(e.to);
                }
            }
            if (a[t] != 0) {
                break;
            }
        }
        if (a[t] == 0) {
            return false;
        }
        flow += a[t];
        for (int u = t; u != s; u = edges[p[u]].from) {
            edges[p[u]].flow += a[t];
            edges[p[u] ^ 1].flow -= a[t];
        }
        return true;
    }   
};


int main() {
    int m, n, e;
    //cin >> v >> e >> s >> t;
    cin >> m >> n >> e;
    int s = 0;
    int t = m + n + 1;
    Maxflow maxflow(m + n + 2);
    
    for (int i = 1; i < m + 1; i++) {
        maxflow.addEdge(0, i, 1);
    }
    for (int i = m + 1; i < m + n + 1; i++) {
        maxflow.addEdge(i, m + n + 1, 1);
    }
    for (int i = 0; i < e; i++) {
        int from, to;
        cin >> from >> to;
        maxflow.addEdge(from + 1, m + 1 + to, 1);
    }
    int ans = maxflow.solve(s, t);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3616
A, B, C, D = map(int,input().split())
tx = C - A
ty = D - B

def Ans(U,D,R,L,tx,ty):#U,R,D,L
    tx = abs(tx)
    ty = abs(ty)
    ans = U*ty+R*tx+D*ty+L*tx #1巡目
    ans += L+U*(ty+1)+R*(tx+1)+D+R+D*(ty+1)+L*(tx+1)+U
    return ans

if tx >= 0 and ty >= 0:
    print(Ans("U","D","R","L",tx,ty))
elif tx < 0 and ty < 0:
    print(Ans("D","U","L","R",tx,ty))
elif tx >= 0 and ty <0:
    print(Ans("D","U","R","L",tx,ty))
else:
    print(Ans("U","D","L","R",tx,ty))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int maxv = max({A, B, C});
  if ((3 * maxv - (A+B+C)) % 2 == 0) {
    cout << (3 * maxv - (A+B+C)) / 2 << endl;
  } else {
    cout << (3 * (maxv+1) - (A+B+C)) / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(ALL(a));
    ll ans = 1;
    rep(i,n){
        if(a[i] != 0 && ans<=(ll)1e18/a[i]){
            ans *= a[i];
        }else if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


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

int main(){
  int N = 0;
  cin >> N;
  vector<int> L(N);
  rep(i, N){
    cin >> L.at(i);
  }
  vector<int> b(1001, 0);
  rep(i, N){
    b.at(L.at(i))++;
  }
  int64_t cnt = 0;
  int64_t temp1, temp2, temp3 = 0;
  rep(i, 1001){
    if(b.at(i) > 0){
      temp1 = b.at(i);
      b.at(i)--;
      rep2(j, i, 1001){
        if(b.at(j) > 0){
          temp2 = b.at(j);
          b.at(j)--;
          rep2(k, j, 1001){
            if(b.at(k) > 0){
              temp3 = b.at(k);
              if(i < j+k && j < k+i && k < i+j){
                if(i == j && j == k){
                  cnt += temp1 * temp2 * temp3 / 6;
                }
                else if(i == j || j == k || k == i){
                  cnt += temp1 * temp2 * temp3 / 2;
                }
                else{
                cnt += temp1 * temp2 * temp3;
                }
              }
            }
          }
          b.at(j)++;
        }
        
      }
      b.at(i)++;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
using ll = long long;
const int MAX_A = 100000;
 
int main() {
    int N;
    ll K;
    ll cnt[MAX_A + 1];
    for (int i = 0; i < MAX_A + 1; ++i) {
        cnt[i] = 0;
    }
    cin >> N >> K;
 
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }
 
    for (int ans = 1; ans <= MAX_A; ++ans) {
        if (K <= cnt[ans]) {
            cout << ans << endl;
            break;
        }
        K -= cnt[ans];
    }
    return 0;
}

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

#define int long long
#define MAX_N (300005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;

int gcd(int a, int b){
    //cout << a <<" "<< b << endl;
    if(b==0) return a;
    return gcd(b, a%b);
}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int cntm=0, sum=0, mn=abs(A[0]);
    for(int i=0; i<N; i++){
        if(A[i]<=0) cntm++;
        sum += abs(A[i]);
        mn = min(mn, abs(A[i]));
    }
    //DEBUG3(cntm, sum, mn);
    if(cntm%2==0){
        cout << sum << endl;
    }
    else {
        cout << sum - 2*mn << endl;
    }

}

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

typedef long long int ll;

void dfs(ll curr, ll n, int use, int &ans){
	if(curr > n)return;
	if(use == 0b111)ans++;
	dfs(curr * 10 + 3, n, use | 0b001, ans);
	dfs(curr * 10 + 5, n, use | 0b010, ans);
	dfs(curr * 10 + 7, n, use | 0b100, ans);
}

int main(){
	ll n;cin >> n;
	int ans = 0;
	dfs(0, n, 0, ans);
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define NMAX 100001
struct union_find {
  std::vector< int > prt;
  std::vector< int > sz;
  union_find(int n) : prt(n), sz(n){
    for (int i = 0; i < n; i++) {
      prt[i] = i;
      sz[i] = 1;
    }
  }
  int find(int u) { return prt[u] == u ? u : find(prt[u]); }
  bool same(int u, int v) { return find(u) == find(v); }
  void unite(int u, int v) {
    if (sz[u = find(u)] > sz[v = find(v)]) std::swap(u, v);
    prt[u] = prt[v];
    sz[v] += std::exchange(sz[u], 0);
  }
};
int main() {
  int n, q; std::cin >> n >> q;
  union_find uf(n);
  for (int i = 0; i < q; i++) {
    int c; std::cin >> c;
    if (c == 0) {
      int u, v; std::cin >> u >> v;
      uf.unite(u, v);
    } else {
      int u, v; std::cin >> u >> v;
      std::cout << uf.same(u, v) << std::endl;
    }
  }
}



Measured memory_bytes: 3168
use std::collections::BinaryHeap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let mut b: Vec<i64> = sc.vec(n);

    let mut heap = BinaryHeap::new();
    for i in 0..n {
        maybe_push(&mut heap, &a, &b, i);
    }

    let mut ans = 0;
    while let Some((_, i)) = heap.pop() {
        let prev = b[(i + n - 1) % n];
        let center = b[i] - a[i];
        let next = b[(i + 1) % n];
        b[i] = a[i] + center % (prev + next);
        ans += center / (prev + next);
        maybe_push(&mut heap, &a, &b, (i + 1) % n);
        maybe_push(&mut heap, &a, &b, (i + n - 1) % n);
    }

    if a == b {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}

fn maybe_push(heap: &mut BinaryHeap<(i64, usize)>, a: &Vec<i64>, b: &Vec<i64>, i: usize) {
    let n = a.len();
    let prev = b[(i + n - 1) % n];
    let center = b[i] - a[i];
    let next = b[(i + 1) % n];
    if center >= (prev + next) {
        heap.push((center / (prev + next), i));
    }
}

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

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


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

using namespace std;

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

    int n, w;
    cin >> n >> w;

    long long a, b;
    vector<long long> cost(w + 1, -1);
    cost[0] = 0;

    for(int i = 0; i < n; ++i) {
        cin >> a >> b;
        for (int j = w; j >= a; j--) {
            if (cost[j - a] != -1)
                cost[j] = max(cost[j], cost[j - a] + b);
        }
    }

    long long ans = 0;
    for(int i = 0; i <= w; ++i)
        ans = max(ans, cost[i]);

    cout << ans << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll w,a,b;
  cin >> w >> a >> b;
  if(a + w <= b)cout << b - a - w << endl;
  else if(b + w <= a)cout << a - b - w << endl;
  else cout << 0 << endl;
}

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

int main() {

    int sz;
    cin>>sz;

    string a,b,c="";
    cin>>a>>b;

    for(int i=0;i<a.size();i++) {
        c+=a[i];
        c+=b[i];
    }

    cout << c <<'\n';

    return 0;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int s,w;
	cin >> s>>w;
    if(s<=w){
        cout<<"unsafe";
    }else{
        cout<<"safe";
    }
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mem(n,m) memset(n,m,sizeof(n))
#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
 
typedef long long int ll;
using namespace std;

const int N=100010;
int c[N][3], dp[N][3];


int main() {
    boost;
    int n;
    cin>>n;
    memset(dp, 0 ,sizeof(dp));
    for (int i=0;i<n;i++) for (int j=0;j<3;j++)cin>>c[i][j];
    for (int i=0;i<n;i++) {
            if (i==0) for (int j=0;j<3;j++) dp[0][j]=c[0][j];
            else {
                dp[i][0] = max(dp[i-1][1]+c[i][0], dp[i-1][2]+c[i][0]);
                dp[i][1] = max(dp[i-1][0]+c[i][1], dp[i-1][2]+c[i][1]);
                dp[i][2] = max(dp[i-1][1]+c[i][2], dp[i-1][0]+c[i][2]);
            }
        }
    cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  mat dp(n+1,vec(5));
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=0;i<n;i++) {
    dp[i+1][0]=a[i]+dp[i][0];
    dp[i+1][1]=min(dp[i][0],dp[i][1]);
    dp[i+1][2]=min({dp[i][0],dp[i][1],dp[i][2]});
    dp[i+1][3]=min({dp[i][0],dp[i][1],dp[i][2],dp[i][3]});
    dp[i+1][4]=min({dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4]})+a[i];
    if(a[i]%2) {
      dp[i+1][1]++;
      dp[i+1][3]++;
    }
    else {
      dp[i+1][2]++;
      if(a[i]==0) {
        dp[i+1][1]+=2;
        dp[i+1][3]+=2;
      }
    }
  }
  cout << *min_element(dp[n].begin(),dp[n].end()) << endl;
}

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

vector<vector<P>> g;
vector<int> res;
vector<int> cnt;
void dfs(int p, int u, int prev) {
  
  int c = 1;
  for (auto v : g[u]) {
    if (v.first == p) continue;
    if (c == prev) ++c;
    res[v.second] = c;
    dfs(u,v.first,c++);
  }
}
int mx = 0;
int main(){
  int n;
  cin >> n;
  g.resize(n);
  cnt.resize(n,0);
  res.resize(n-1);
  int root = -1;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back({b,i});
    g[b].push_back({a,i});
    cnt[a]++;
    cnt[b]++;
    if (mx < cnt[a]) root = a, mx = cnt[a];
    if (mx < cnt[b]) root = b, mx = cnt[b];
  }
  dfs(-1,root,-1);
  cout << mx << endl;
  for (auto e : res) cout << e << endl;
  return 0;
} 

Measured memory_bytes: 8576
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(13)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
int dn[4]={-1,1,0,0};
int dm[4]={0,0,-1,1};
ll longinf=(1ll<<60);

const ll MOD = 1e9+7;
int n,m;
int p[100002];
vector<int> connected[100002];
bool visited[100002];
int oya[100002];
void dfs(int i,int j){
      if(!visited[i]){
            visited[i]=true;
            oya[i]=j;
            for(auto& k:connected[i]){
                  dfs(k,j);
            }
      }
}
int main(){
      cin>>n>>m;
      rep1(i,n) cin>>p[i];
      rep1(i,m){
            int x,y;
            cin>>x>>y;
            connected[p[x]].push_back(p[y]);
            connected[p[y]].push_back(p[x]);
      }
      rep1(i,n){
            dfs(i,i);
      }
      int ans=0;
      rep1(i,n){
            if(oya[i]==oya[p[i]]){
                  ans++;
            }
      }
      cout<<ans<<endl;
      return 0;
}

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

int main(){
    string S;cin>>S;
    string a[16]={"AKIHABARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABR","AKIHBAR","AKIHBRA",
                "KIHABAR","KIHABRA","KIHBARA","AKIHBR","KIHABR","KIHBAR","KIHBRA","KIHBR"};
    rep(i,16){
        if(S==a[i]){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int c;
	char str[1000];
	gets(str);
	for(c=0;c<strlen(str);c++){
		if(strncmp(&str[c],"apple",5)==0){
			str[c]='p';
			str[c+1]='e';
			str[c+2]='a';
			str[c+3]='c';
			str[c+4]='h';
		}else if(strncmp(&str[c],"peach",5)==0){
			str[c]='a';
			str[c+1]='p';
			str[c+2]='p';
			str[c+3]='l';
			str[c+4]='e';
		}
	}
	printf("%s\n",str);
	return 0;
}

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

int N;
int K;
int Q;
int Ps[100005];

int main() {
  cin >> N >> K >> Q;
  int Ai;
  rep(i, Q) {
    scanf("%d", &Ai);
    Ai--;
    Ps[Ai]++;
  }
  rep(i, N) {
    if(K + Ps[i] - Q > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll S, W; cin >> S >> W;
    string ans = "safe";
    if(W>=S)ans = "unsafe";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

int main()
{
	int N, A, n;

	cin >> N >> A;

	n = N / 500;

	if ((N - 500 * n) <= A) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	cout << endl;

    return 0;
}

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

#define N 4
#define LIM 46


int ans[N][N]={
    {1,2,3,4},
    {5,6,7,8},
    {9,10,11,12},
    {13,14,15,0}};

int x[N*N]={3,0,1,2,
            3,0,1,2,
            3,0,1,2,
            3,0,1,2},
    y[N*N]={3,0,0,0,
            0,1,1,1,
            1,2,2,2,
            2,3,3,3};

int min = LIM;



void dfs(int p[N][N], int pr[N][N], int n)
{
    int i, j, i0, j0, d = 0;
    int f = 0;
    int tmp[N][N];

    for( i = 0 ; i < N ; i++)
    {
        for( j = 0 ; j < N ; j++)
        {
            if( ans[i][j] != p[i][j]) f++;
            if( p[i][j] == 0)
            {
                i0 = i;
                j0 = j;
            }
            else
                d += abs( j - x[p[i][j]] ) + abs( i-y[p[i][j]] );

        }
    }

    if( f == 0 )
    {
        if( min > n )
        {
            min = n;
        }
        return;
    }
    if( d + n > min ) return;


    if( i0 > 0 && i0 < N )
    {
        memcpy( tmp, p, sizeof(int) * N * N );
        f = tmp[i0][j0];
        tmp[i0][j0] = tmp[i0-1][j0];
        tmp[i0-1][j0] = f;
        if(memcmp( tmp, pr, sizeof(int)*N*N) != 0 )
            dfs(tmp, p, n+1);
    }
    if(j0 > 0 && j0 < N)
    {
        memcpy(tmp, p, sizeof(int) * N * N );
        f = tmp[i0][j0];
        tmp[i0][j0] = tmp[i0][j0-1];
        tmp[i0][j0-1] = f;
        if(memcmp(tmp, pr, sizeof(int) * N * N ) != 0)
            dfs(tmp, p, n+1);
    }

    if( i0 >= 0 && i0 < N-1)
    {
        memcpy( tmp, p, sizeof(int) * N * N);
        f = tmp[i0][j0];
        tmp[i0][j0] = tmp[i0+1][j0];
        tmp[i0+1][j0] = f;
        if(memcmp(tmp, pr, sizeof(int) * N * N ) != 0 )
            dfs(tmp, p, n+1);
    }
    if( j0 >= 0 && j0 < N-1)
    {
        memcpy( tmp, p, sizeof(int) * N * N );
        f = tmp[i0][j0];
        tmp[i0][j0] = tmp[i0][j0+1];
        tmp[i0][j0+1] = f;
        if(memcmp( tmp, pr, sizeof(int) * N * N ) != 0)
            dfs( tmp, p, n+1 );
    }

}

int main()
{
    int i,j;
    int A[N][N];

    for( i = 0 ; i < N ; i++)
    {
        for( j = 0 ; j < N ; j++)
        {
            scanf("%d", &A[i][j]);
        }
    }
    dfs( A, A, 0);

    printf("%d\n", min);

    return 0;
}



Measured memory_bytes: 2084
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		int d = Math.abs(a - b);
		int e = Math.abs(a - c);
		
		if (d >= e) {
			System.out.println("B");
		} else {
			System.out.println("A");
		}
	}
}

Measured memory_bytes: 21844
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut b: Vec<usize> = (0..n).map(|_| read()).collect();

    let mut ans = vec![];

    'outer: while !b.is_empty() {
        for i in (0..b.len()).rev() {
            if i + 1 == b[i] {
                b.remove(i);
                ans.push(i + 1);
                continue 'outer;
            }
        }
        println!("-1");
        return;
    }

    for x in ans.iter().rev() {
        println!("{}", x);
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
const int MAX_V = 10000; // 1????????§????´???°??¨?????????

int main() {
	int i, k, n, p, q;
	int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????????
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2??\???????´???°??¨??????
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
			}
		}
	}
	//?´???°??¨fin
	//while(scanf("%d",&n) != 0){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=n;i>=3;i--){//???????????¨????´???°????????????
			if(prime[i] == 1 && prime[i-2] == 1){
				p = i;
				q = p-2;
				break;
			}
		}
	// 	ans[a]=i; a++;
	// 	ans[a]=i-2; a++;
	// }
	// for(i=0;i<=a;i=i+2){
	// 	printf("%d %d\n",ans[i],ans[i+1]);
	// }
		printf("%d %d\n",q,p);
	}
	return 0;
}

Measured memory_bytes: 1064
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	int INF = 1 << 30;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();// the number of cities
		int M = sc.nextInt();// the number of goods
		int W = sc.nextInt();
		int T = sc.nextInt();
		String[] s = new String[M];
		int[] v = new int[M];
		int[] p = new int[M];
		Map<String, Integer> ref = new HashMap<>();

		for (int i = 0; i < M; i++) {
			s[i] = sc.next();// name
			ref.put(s[i], i);
			v[i] = sc.nextInt();// weight
			p[i] = sc.nextInt();// price at (0,0)
		}
		int[] x = new int[N + 1];
		int[] y = new int[N + 1];
		int[][] item = new int[N][M];
		for (int i = 0; i < N; i++) {
			Arrays.fill(item[i], INF);
			int L = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			while (L-- != 0) {
				int id = ref.get(sc.next());
				item[i][id] = sc.nextInt();// price
			}
		}
		int[][] adj = new int[N + 1][N + 1];
		for (int i = 0; i <= N; i++) {
			for (int j = i; j <= N; j++) {
				adj[i][j] = adj[j][i] = Math.abs(x[i] - x[j]) + Math.abs(y[i] - y[j]);
			}
		}
		int[][] dist = new int[(1 << N)][N];
		for (int S = 1; S < (1 << N); S++) {
			for (int last = 0; last < N; last++) {
				if (((S >> last) & 1) == 1) {
					int ns = S - (1 << last);
					if (ns == 0) {
						dist[S][last] = adj[last][N];
					} else {
						int min = INF;
						for (int j = 0; j < N; j++) {
							if (((ns >> j) & 1) == 1) {
								min = Math.min(min, dist[ns][j] + adj[j][last]);
							}
						}
						dist[S][last] = min;
					}
				}
			}
		}
		int[] bestTime = new int[1 << N];
		for (int S = 1; S < 1 << N; S++) {
			int min = INF;
			for (int i = 0; i < N; i++) {
				if (((S >> i) & 1) == 1)
					min = Math.min(min, dist[S][i] + adj[i][N]);
			}
			bestTime[S] = min;
		}
		int[] bestShell = new int[1 << N];
		int[] c = new int[M];
		int[] ws = new int[W + 1];
		for (int V = 1; V < 1 << N; V++) {
			Arrays.fill(ws, 0);
			Arrays.fill(c, INF);
			for (int i = 0; i < N; i++) {
				if (((V >> i) & 1) == 1) {
					for (int j = 0; j < M; j++) {
						c[j] = Math.min(c[j], item[i][j]);
					}
				}
			}
			for (int i = 0; i < M; i++) {
				c[i] = Math.max(0, p[i] - c[i]);
			}
			for (int i = 1; i <= W; i++) {
				for (int j = 0; j < M; j++) {
					if (v[j] <= i) {
						ws[i] = Math.max(ws[i], ws[i - v[j]] + c[j]);
						bestShell[V] = Math.max(bestShell[V], ws[i]);
					}
				}
				// bestShell[V] = ws[V];
			}
		}
		long ans = 0;
		long[] dp = new long[T + 1];
		for (int t = 1; t <= T; t++) {
			for (int V = 1; V < 1 << N; V++) {
				if (bestTime[V] <= t) {
					dp[t] = Math.max(dp[t], dp[t - bestTime[V]] + bestShell[V]);
				}
			}
			ans = Math.max(ans, dp[t]);
		}
		System.out.println(dp[T]);
	}
}

Measured memory_bytes: 33176
n = int,input()
a = list(map(int, input().split()))
a.insert(0, 0)
cost = []
for i in range(0,len(a)-1):
    c = a[i+1] - a[i]
    cost.append(abs(c))
cost.append(abs(a[len(a)-1]))
total = 0
for i in range(0,len(cost)):
    total += cost[i]
for i in range(1,len(a)):
    if(i!=len(a)-1):
        print(total - cost[i-1] - cost[i] + abs(a[i+1] - a[i-1]))
    else:
        print(total - cost[i-1] - cost[i] + abs(a[i-1]))


Measured memory_bytes: 14172
private fun readInts() = readLine()!!.split(" ").map(String::toInt)

fun main(args: Array<out String>) {
    val (N) = readInts()
    val h = readInts()

    val costs = Array(N) { 0 }
    costs[0] = 0
    costs[1] = Math.abs(h[1] - h[0])

    (2 until N).forEach { index ->
        val height = h[index]
        val _1 = costs[index - 1] + Math.abs(height - h[index - 1])
        val _2 = costs[index - 2] + Math.abs(height - h[index - 2])

        costs[index] = setOf(_1, _2).min()!!
    }

    println(costs[N - 1]) // 0-indexed
}

Measured memory_bytes: 62812
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

ll x;

int main() {
    ios::sync_with_stdio(false);
    cin>>x;
    ll res=100;
    int cnt=0;
     while(res<x){
         res=res+res*0.01;
         cnt++;
     }
     printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 3784
def dask(x,y):
  if(a[x][y]=="."):
    return [0,0,False]
  if(a[x+1][y]=="#"):
    for i in range(w):
      if(i>y and a[x][i]=="#"):
        return [0,0,False]
    return [x+1,y,True]
  if(a[x][y+1]=="#"):
    for i in range(h):
      if(i>x and a[i][y]=="#"):
        return [0,0,False]
    return [x,y+1,True]
  return [0,0,False]
h,w=map(int,input().split())
a=[input()+"." for _ in[0]*h]+["."*(w+1)]
x=0
y=0
fl=True
while(fl and (x<h-1 or y<w-1)):
  x,y,fl=dask(x,y)
print("Possible" if fl else "Impossible")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn =25;
int x[maxn][15];
bool judge(int x)
{
	for(int i=0;i*i<20000;i++)
	{
		if(x==i*i)return 1;
	}
	return 0;
}
int main()
{
	std::ios::sync_with_stdio(false);
	int n,d;
	cin>>n>>d;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>x[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int a=0;
			for(int k=0;k<d;k++)
			{
				a+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			if(judge(a))ans++;
		}
	}
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll i, ll z) {
	ll sum = 1;
	for (ll j = max(z, 2LL); j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%Mod;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
struct A {
	int x, y;
};
bool operator<(A a, A b) {
	if (a.y != b.y) return a.y > b.y;
	return a.x > b.x;
}
int n;
A a[300000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
	}
	sort(a, a + n);
	priority_queue<int, vector<int>, greater<int>>p;
	priority_queue<int>q;
	//入っていない、入っている
	int ans = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		p.push(a[i].x);
		while (!p.empty() && !q.empty() && p.top() < q.top()) {
			int t = p.top(), y = q.top();
			sum -= y; sum += t;
			p.pop(); q.pop();
			p.push(y);
			q.push(t);
		}
		while (!p.empty() && sum + p.top() <= (ans + 1)*a[i].y) {
			q.push(p.top());
			sum += p.top();
			ans++;
			p.pop();
		}
	}
	cout << ans << endl;
	getchar(); getchar();
}


Measured memory_bytes: 11732
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 998244353

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

class Combination:
    def __init__(self, max_n=100007, mod=mod):
        self.mod = mod
        self.fac = [0] * max_n
        self.finv = [0] * max_n
        self.inv = [0] * max_n

        self.fac[0] = 1
        self.fac[1] = 1
        self.finv[0] = 1
        self.finv[1] = 1
        self.inv[1] = 1
        for i in range(2, max_n):
            self.fac[i] = self.fac[i - 1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod
    
    def choose(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k] * self.finv[n - k] % self.mod) % self.mod
    

def modpow(n, p, m):
    if p == 0:
        return 1
    if p % 2 == 0:
        t = modpow(n, p // 2, m)
        return t * t % m
    return n * modpow(n, p - 1, m) % m

n, m, k = na()
C = Combination(10 ** 5 * 4)
ans = 0
for i in range(k + 1):
    ans += C.choose(n - 1, i) * m % mod * modpow(m - 1, n - i - 1, mod) % mod

print(ans % mod)

Measured memory_bytes: 56548
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y){
    return x / gcd(x, y) * y;
}

signed main()
{
    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    int ans = t[0];
    for (int i = 0; i < n; i++)
    {
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;
    
    int area, perimeter;
    area = x * y;
    perimeter = (x + y) * 2;
    
    printf("%d %d\n", area, perimeter);
    return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {

	vector<int> a(4,0);
	for (int i = 0; i < 3; i++) {
		int n, k;
		cin >> n >> k;
		switch (n * 1) {
		case 1:a[0]++;
			break;
		case 2:a[1]++;
			break;
		case 3:a[2]++;
			break;
		case 4:a[3]++;
			break;
		}
		switch (k * 1) {
		case 1:a[0]++;
			break;
		case 2:a[1]++;
			break;
		case 3:a[2]++;
			break;
		case 4:a[3]++;
			break;
		}
	}
	
	sort(a.begin(), a.end());
	if (a[0] == 1 && a[1] == 1 && a[2] == 2 && a[3] == 2)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=1e5+10;
int n,t[MAXN];
int check(int x)
{
	if(t[x-1]==n-t[x-1])
		return 1;
	return 0;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
		++t[read()];
	for(int i=1;i<=100000;++i)
		t[i]+=t[i-1];
	int ans=0;
	for(int i=1;i<=100000;++i)
		ans+=check(i);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S,T;
    cin >> S >> T;
    ll s = S.size();
    ll t = T.size();
    if(s < t){
        cout << "LESS" << endl;
        return 0;
    }
    else if(t < s){
        cout << "GREATER" << endl;
        return 0;
    }
    else{
        if(S == T)cout << "EQUAL" << endl;
        else if(S < T)cout << "LESS" << endl;
        else cout << "GREATER" << endl;
    }
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

const int N=1e6+10;
ll a[N];
int sum[11];
main(){
    ios
    int h,w,n;scanf("%d%d%d",&h,&w,&n);
    h-=2,w-=2;
    int x,y;
    int cnt=0;
    ll m=(ll)h*w;
    rep(iii,n){
        scanf("%d%d",&x,&y);
        rep(i,3)if( x-i>=1 && x-i<=h){
            rep(j,3)if(y-j>=1 && y-j<=w){
            a[cnt++]=((ll)(x-i)<<32)+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<" ";
    rep2(i,1,9)cout<<sum[i]<<" ";
}



Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    //cin >> h >> w;
    while (cin >> h >> w,h != 0 && w != 0){
        for (int i = 0; i < h; i++) {
            for ( int j = 0; j < w; j++) {
                cout << '#';
            }
            cout << "\n";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <cstdint>
#include <string.h>
#include <queue>

using namespace std;

int main()
{
    uint64_t N, K;
    cin >> N >> K;

    uint64_t tree[101000];
    for (int i = 0; i < N; ++i) {
        cin >> tree[i];
    }
    sort(tree, &tree[N], std::greater<>());
    uint64_t difMin = tree[0] - tree[K - 1];
    for (int i = 0; i < N - K+1; ++i) {
        difMin = min(difMin, tree[i]-tree[i + K-1]);
    }
    cout << difMin << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		long MOD = 1000000007;
		
		// 計算
		long result = 0;
		
		// 出力
		for(int i = 1; i <= k; i++){
		    if(n-k+1 < i){
		        result = 0;
		    }else{
		        result = (combination(n-k+1, i, MOD)*combination(k-1, i-1, MOD))%MOD;
		    }
		    System.out.println(result);
		}
		//System.out.println(result);
	}
	
	public static long pow(long a,long n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a);
	        }
	        a=(a*a);
	        n>>=1;
	    }
	    return res;
	}
	
	public static long pow(long a,long n, long MOD) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a)%MOD;
	        }
	        a=(a*a)%MOD;
	        n>>=1;
	    }
	    return res%MOD;
	}
	
	public static long[] fact(int n) {
	    long[] f = new long[n+1];
	    for(int i = 0; i < n+1; i++){
	        if(i == 0) f[i] = 1;
	        if(i > 0) f[i] = f[i-1]*i;
	    }
	    return f;
	}
	
	public static long[] fact(int n, long MOD) {
	    long[] f = new long[n+1];
	    for(int i = 0; i < n+1; i++){
	        if(i == 0) f[i] = 1;
	        if(i > 0) f[i] = (f[i-1]*i)%MOD;
	    }
	    return f;
	}
	
	public static long combination(int n, int k) {
	    long[] f = fact(n);
	    return f[n]/(f[k]*f[n - k]);
	}
	
	public static long combination(int n, int k, long MOD) {
	    long[] f = fact(n, MOD);
	    long a = f[n];
	    long b = pow(f[k], MOD - 2, MOD);
	    long c = pow(f[n - k], MOD - 2, MOD);
	    return (((a*b)%MOD)*c)%MOD;
	}
}

Measured memory_bytes: 34004
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}
ll n,W,i,w[100009],v[100009],a[109][100009],j;
int main() {
    cin>>n>>W;
    for(i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    for(i=0;i<=n;i++){
        for(j=0;j<=W;j++){
            if(i==0 || j==0){
                a[i][j]=0;
            }
            else if(j>=w[i-1]){
                a[i][j] = maxx(a[i-1][j] , v[i-1] + a[i-1][j - w[i-1]]);
            }
            else{
                a[i][j] = a[i-1][j];
            }
            // cout<<a[i][j]<<" ";
        }
        // cout<<endl;
    }
    cout<<a[n][W];
}


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

auto clk=clock();
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define Mod 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)

bool comp(string s1,string s2){
    return ((s1+s2)<(s2+s1));
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,l; cin>>n>>l;
    vector<string>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end(),comp);
    for(int i=0;i<n;i++) cout<<v[i];
    cerr<<"\n"<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<"\n";
    return 0;
}


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

int main() {
	int n;

	cin >> n;

	int *a = new int[n+1];
	string s;

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

	s = "APPROVED";
	a[0] = 1;

	for (int i = 1; i <= n; i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0 || a[i] % 5 == 0) {
				s = "APPROVED";
			}
			else {
				s = "DENIED";
				break;

			}
		}
	}

	cout << s;
	return 0;
}

Measured memory_bytes: 256