akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
	#include<stdlib.h>
	#include<vector>
	#include<algorithm>
	#include<stdio.h>
	#include<string>
	#include<map>
	#include<math.h>
	#include<iomanip>
	#include<set>
	#include<limits.h>
	#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
	#define swap(a,b) a^=b;b^=a;a^=b;
	#define chmax(a,b) {if(a < b) a = b;}
	#define chmin(a,b) {if(a > b) a = b;}
	using namespace std;
	typedef long long ll;
	ll gcd(ll, ll);
	vector<bool> to_binary(int);
	int sum(vector<int>);
	int min(vector<int>);
	int max(vector<int>);
	ll nCr(ll n, ll r);

	const ll INF = 1LL << 60;

	typedef tuple<ll, ll> mtupl;

	bool mycomp(mtupl x, mtupl y) {
		return get<1>(x) < get<1>(y);
	}

	bool solve(int a, int b, int c) {
		vector<int> tmp{ a,b,c };
		sort(tmp.begin(), tmp.end());
		return tmp[1] == b;
	}

	int main(void) {
		cin.tie(0);
		ios::sync_with_stdio(false);
		//Program Start	

		int N;
		cin >> N;

		vector<int> d(N);
		rep(i, N)
			cin >> d[i];

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

		if (N == 1)
			cout << "1" << endl;
		else
			cout << d[N / 2] - d[N / 2 - 1] << endl;



	ProgramEndPointLabel:;

		//Program End
		system("pause");

		return 0;
	}

	ll nCr(ll n, ll r) {
		ll res = 1;
		for (int i = 0; i < r; i++) {
			res *= (n - i);
		}
		for (int i = 1; i <= r; i++) {
			res /= i;
		}
		return res;
	}

	int vsum(vector<int> v) {
		int res = 0;
		for (auto it = v.begin(); it != v.end(); it++)
			res += *it;
		return res;
	}
	int vmin(vector<int> v) {
		int min = INT32_MAX;
		for (auto it = v.begin(); it != v.end(); it++)
			min = std::min(min, *it);
		return min;
	}
	int vmax(vector<int> v) {
		int max = 0;
		for (auto it = v.begin(); it != v.end(); it++)
			max = std::max(max, *it);
		return max;
	}

	ll gcd(ll A, ll B) {
		int r = A % B;
		while (r != 0) {
			A = B;
			B = r;
			r = A % B;
		}

		return B;
	}

	vector<bool> to_binary(int x) {
		vector<bool> res;
		while (x != 0) {
			res.push_back(x % 2);
			x /= 2;
		}
		return res;
	}


Measured memory_bytes: 888
/* Author- Abhijeet Trigunait */

#include<bits/stdc++.h>
#define lld long long int
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define mod 1e9+7
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define gcd(x,y) __gcd(x,y)
#define endl '\n'

using namespace std;

lld dp[100005][3]={0};

struct activity{
	lld a,b,c;
};

lld findMaxHappiness(vector<activity> vac,lld n){
     dp[0][0]=vac[0].a;
     dp[0][1]=vac[0].b;
     dp[0][2]=vac[0].c;
     for(lld i=1;i<n;++i){
         dp[i][0]=vac[i].a+max(dp[i-1][1],dp[i-1][2]);
         dp[i][1]=vac[i].b+max(dp[i-1][0],dp[i-1][2]);
         dp[i][2]=vac[i].c+max(dp[i-1][0],dp[i-1][1]);
     }
     return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

int main(){

	#ifndef ONLINE_JUDGE 
 	freopen("input.txt","r",stdin);
 	freopen("output.txt","w",stdout);
 	#endif
 	lld n;
 	cin>>n;
 	vector<activity> vac(n);
 	for(lld i=0;i<n;++i){
 		cin>>vac[i].a;
 		cin>>vac[i].b;
 		cin>>vac[i].c;
 	}cout<<findMaxHappiness(vac,n)<<endl;
}

Measured memory_bytes: 10152
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	ll N;
  	cin >> N;
	vector<ll>a(N);
    ll sum = 0;
    rep(i,N) {
    	cin >> a[i];
        sum += a[i];
    }
    sum -= N;
    cout << sum << endl;
    // m = lcm(a[i]) - 1 とすれば m mod a[i] = a[i] - 1
    // f(m) = (Σ a[i]) - N


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#define f first
#define s second 
using namespace std;
int n,m;

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

  vector<int> vec(n+2,0);
  
  for(int i = 0;i < m;i++){
	int f,t;
	cin >> t >> f;
	vec[t]++;
	vec[f]--;
  }
  for(int i = 0;i < n+1;i++){
	vec[i+1] += vec[i];
  }
  int ans = 0;
  for(int i = 0;i < n+2;i++){
	if(vec[i])ans++;
  }
  cout << n+1+ans*2 << endl;
  
  return 0;
}

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

int main(){
    int h,w;
    while(true){
        cin >> h >> w;
        if(h==0&&w==0)
        break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1)
                cout << '#';
                else
                cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3108
n = int(input())
prime = 0

def is_prime(q):
    if q == 2:
        return True
    if q < 2:
        return False
    return pow(2, q-1, q) == 1


prime = 0
for i in range(n):
    m = int(input())
    if is_prime(m):
        prime += 1
print(prime)

Measured memory_bytes: 7696
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int N = S.size();
    int count = 0;
    if (S[0] == 'A' && S[1] >= 'a' && S[1] <= 'z' && S[N - 1] >= 'a' && S[N - 1] <= 'z')
    {
        for (int i = 2; i < N; i++)
        {
            if (S[i] >= 'a' && S[i] <= 'z')
            {
                continue;
            }
            else if (S[i] == 'C')
            {
                count++;
            }
            else
            {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    else
    {
        cout << "WA" << endl;
        return 0;
    }
    if (count == 1)
    {
        cout << "AC" << endl;
    }
    else
    {
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
l=[]
while gets
  n,m=$_.split.map(&:to_i)
  if n==0 and m==0
    tf=true
    (1..(l.max)).each do |x|
      if x.between?(1,2) then tf=l.count(x).odd?
      else tf=l.count(x).even? end
      break unless tf
    end
    puts tf ? "OK" : "NG"
    l=[]
  else
    l<<n<<m
  end
end

Measured memory_bytes: 8752
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

int main() {
  int N, K;
  scanf("%d %d", &N, &K);

  if ((N+1)/2 >= K) {
    puts("YES");
  } else {
    puts("NO");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long h, w, c[10][10], s = 0, m;
    cin >> h >> w;
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++) cin >> c[i][j];
    for (int k = 0; k < 10; k++)
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++) 
        {
            cin >> m;
            if (m >= 0) s += c[m][1];
        }
    }
    cout << s;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>

using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> p;
    vector<int> q;
    for(int i = 0;i < n;i++){
      int a;
      cin >> a;
      p.push_back(a);
    }
    for(int i = 0;i < n;i++){
      int b;
      cin >> b;
      q.push_back(b);
    }
    vector<int> one_case;
    for (int i = 1; i < n+1; i++) { // one_case = {0,1,2,3,...n-1} とする
        one_case.emplace_back(i);
    }
  
    int f = 0;
   int h = 0;
   int kaisuu = 1;
   int pnogyou = 0;
   int hnogyou = 0;
    do {
        for (auto num : one_case) {
          if(num == p[f]){
            f++;
          }
          if(num == q[h]){
            h++;
          }
        };
        if(f == n) pnogyou = kaisuu;
        if(h == n) hnogyou = kaisuu;
        h = 0;
        f = 0;
        kaisuu ++;
    } while (next_permutation(one_case.begin(), one_case.end()));
    // 順列の最後になるまで one_case を並び替えながらループ
    cout << abs(pnogyou - hnogyou);
    return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))

tmp = 0
for i in range(len(A) - 1):
    tmp = max(tmp, A[i+1] - A[i])

gyaku = K - A[-1] + A[0]

tmp = max(tmp, gyaku)

print(K - tmp)

Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

/*
    辺が存在しない場合、dist[i][j] = INF、ただしdist[i][i] = 0 とする
    頂点数 V のとき :
    vector<vector<int>> dist(V, vector<int>(V, INF));
    for(int i = 0; i < V; i++){
        dist[i][i] = 0;
    }
*/
template <typename T>
void WarshallFloyd(vector<vector<T>>& dist) {
    int V = dist.size();
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    // dist[i][i] < 0 が存在 <-> 負の閉路が存在
}

signed main() {
    int n, m;
    ll l;
    cin >> n >> m >> l;
    int a, b;
    ll c;
    vector<vector<ll>> dist(n, vector<ll>(n, LINF));
    for (int i = 0; i < n; i++) {
        dist[i][i] = 0;
    }
    rep(i, m) {
        cin >> a >> b >> c;
        if (c > l) continue;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    int q;
    cin >> q;
    int s[q], t[q];
    rep(i, q) {
        cin >> s[i] >> t[i];
        s[i]--;
        t[i]--;
    }
    WarshallFloyd(dist);
    vector<vector<ll>> distt(n, vector<ll>(n, LINF));
    for (int i = 0; i < n; i++) {
        distt[i][i] = 0;
    }
    for (int u = 0; u < n; u++){
        for (int v = 0; v < n; v++){
            if (dist[u][v] <= l) distt[u][v] = 1;
        }
    }
    WarshallFloyd(distt);
    rep(i, q) {
        cout << (dist[s[i]][t[i]] != LINF ? distt[s[i]][t[i]] - 1 : -1) << endl;
    }
    return 0;
}

Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}

const int maxn = 1e4 + 5;
vector <int> e[maxn];
queue <int> q;
int val[maxn];
int vis[maxn];
int a[maxn];
int n;

int main(){
  rd(n);
  rep(i, 1, n - 1){
    int u, v; rd(u), rd(v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  rep(i, 1, n) rd(a[i]);
  sort(a + 1, a + n + 1);
  int ans = 0;
  rep(i, 1, n - 1) ans += a[i];
  printf("%d\n", ans);
  q.push(1);
  vis[1] = 1;
  int m = n;
  while(m --){
    int u = q.front();
    val[u] = a[m + 1];
    q.pop();
    for(int i = 0; i < e[u].size(); ++ i){
      if(!vis[e[u][i]]){
	vis[e[u][i]] = 1;
	q.push(e[u][i]);
      }
    }
  }
  rep(i, 1, n) printf("%d ", val[i]);
  return 0;
}


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

int main() {

    string s;
    cin >> s;
    size_t size = s.length();
    cout << s[0] << size - 2 << s[size - 1] << endl;

}


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


int n;
int A[10];

std::queue<int> input;

void solve() {
    bool                            flag = true;
    std::queue< std::pair<int, int> > que; // empty : -1

    que.push( std::make_pair(input.front(), -1) );
    // que.push( std::make_pair(-1, input.front()) );
    input.pop();
    while (!input.empty() && flag) {
        bool b = false;
        // bfs
        std::pair<int, int> p = que.front();
        que.pop();
        int n = input.front();

        if (p.first < n) {
            que.push( std::make_pair(n, p.second) );
            b = true;
            // std::cout << n << '\t' << p.second << std::endl;
        }

        if (p.second < n) {
            que.push( std::make_pair(p.first,  n) );
            b = true;
            // std::cout << p.first << '\n' << n << std::endl;
        }

        if (b) input.pop();

        if (que.empty()) flag = false;
    }

    if (flag) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


int main() {
    std::cin >> n;
    for (int i=0; i<n; i++) {
        int a;
        for (int j=0; j<10; j++) {
            std::cin >> a;
            input.push(a);
        }
        solve();
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 998244353
#define F first
#define S second
#ifdef LOCAL
    #include "trace.h"
#else
    #define trace(args...)
#endif
 
ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

class SegmentTreeSum{
// 0-Indexed
// update(index, val) 
// query(l, r)
public:
	vector<ll> t;
	vector<ll> lazy;
	ll n;
	SegmentTreeSum(){

	}
	SegmentTreeSum(ll len){
		n = len;
		t.resize(4*n, 0);
		lazy.resize(4*n, 0);
	}
	SegmentTreeSum(ll len, ll val){
		n = len;
		vector<ll> a;
		a.resize(n, val);
		t.resize(4*n);
		lazy.resize(4*n, 0);
		build(a, 1, 0, n-1);
	}
	SegmentTreeSum(vector<ll> &inp){
		n = inp.size();
		t.resize(4*n);
		lazy.resize(4*n, 0);
		build(inp, 1, 0, n-1);
	}

	ll left(ll p){ return p<<1;}

	ll right(ll p){ return (p<<1)+1;}
	
	void build(vector<ll> &a, ll v, ll tl, ll tr){
		if(tl==tr)
        	t[v]=a[tl]%MOD;
    	else{
        	build(a, left(v),tl,(tl+tr)/2);
        	build(a, right(v),(tl+tr)/2+1,tr);
        	t[v] = (t[left(v)] + t[right(v)])%MOD;
    	}
	}

	ll query(ll v, ll tl, ll tr, ll l, ll r){
		if(l>r)
			return 0;
		if(lazy[v] != 0){
			t[v] += ((tr - tl + 1) * lazy[v])%MOD;
			if(tl != tr){
				lazy[left(v)] += lazy[v]%MOD;
				lazy[right(v)] += lazy[v]%MOD;
			}
			lazy[v] = 0;
		}

		if(l == tl && r == tr)
			return t[v]%MOD;
		ll tm = (tl+tr)/2;
	    ll p1 = query(left(v), tl, tm, l, min(r,tm));
	    ll p2 = query(right(v), tm+1, tr, max(l,tm+1), r);
	    return (p1 + p2)%MOD;
	}

	void update(ll v, ll tl, ll tr, ll l, ll r, ll add){
    	
    	if(lazy[v] != 0){
    		t[v] += ((tr - tl + 1) * lazy[v])%MOD;
    		if(tl != tr){
    			lazy[left(v)] += lazy[v]%MOD;
    			lazy[right(v)] += lazy[v]%MOD;
    		}
    		lazy[v] = 0;
    	}

    	if (l > r)
        	return;

    	if (l == tl && r == tr){
        	t[v] += ((tr - tl + 1) * add)%MOD;
        	if(tl != tr){
        		lazy[left(v)] += add%MOD;
        		lazy[right(v)] += add%MOD;
        	}
        	return;
    	}

    	ll tm = (tl + tr)/2;
    	update(left(v), tl, tm, l, min(r, tm), add);
    	update(right(v), tm+1, tr, max(l, tm+1), r, add);
    	t[v] = (t[left(v)] + t[right(v)])%MOD;
	}

	void update(ll l,ll r, ll add){
		if(l>n-1) return;
	     update(1, 0, n-1, l, min(r, n-1), add);
	}

	ll query(ll l,ll r){ 
		return query(1, 0, n-1, l, r);
	}
};

void solve(){
	ll n, d; cin>>n>>d;
	vector<pair<ll, ll> > a(d);
	for(auto &e: a) cin>>e.F>>e.S;

	SegmentTreeSum tree(n);
	tree.update(0, 0, 1);
	for(ll i = 0; i<n-1; i++)
		for(auto &e: a)
			tree.update(i+e.F, i+e.S, tree.query(i, i));
	cout<<(tree.query(n-1, n-1)+MOD)%MOD<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	ll t=1;
	// cin>>t;
	while(t--)
		solve();
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N, Z, W;
int as[2500];
int dp[4][2100][2100];

int rec(int idx, int x_idx, int y_idx){
    int nxt = max(x_idx, y_idx) + 1;
    if(nxt == N + 2){
        return abs(as[x_idx] - as[y_idx]);
    }
    if(dp[idx][x_idx][y_idx] != -1){
        return dp[idx][x_idx][y_idx];
    }
    
    int res;
    
    if(idx == 0){ // X
        res = rec(1, nxt, y_idx);
    }else if(idx == 1){ // X (引いた)
        res = max(rec(1, nxt, y_idx),
                  rec(2, x_idx, y_idx));
    }else if(idx == 2){ // Y
        res = rec(3, x_idx, nxt);
    }else{ // Y (引いた)
        res = min(rec(3, x_idx, nxt),
                  rec(0, x_idx, y_idx));
    }

    return dp[idx][x_idx][y_idx] = res;
}

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

    std::cin >> N >> Z >> W;

    as[0] = Z;
    as[1] = W;
    
    for(int i=2;i<N+2;++i){
        std::cin >> as[i];
    }

    memset(dp, -1, sizeof(dp));
    
    int res = rec(0, 0, 1);
    std::cout << res << std::endl;
}


Measured memory_bytes: 69504
I, O, _, R, L, _, _ = map(int, input().split())

ans = O
if I * R * L == 0:
    ans += (I // 2 + L // 2 + R // 2) * 2
else:
    M = I % 2 + L % 2 + R % 2
    if M <= 1:
        ans += (I // 2 + L // 2 + R // 2) * 2
    else:
        ans += 3
        I -= 1
        L -= 1
        R -= 1
        ans += (I // 2 + L // 2 + R // 2) * 2

print(ans)


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    ll N;
    string S;
    cin >> N;
    cin >> S;
    ll M = S.size();
    vi ns(10, 0);
    vi p(M+1, 0);
    for(int i = M-1; i >= 0; i--){
        if(ns[S[i]-'0'] == 0){
            ns[S[i]-'0']++;
            p[i] = p[i+1]+1;
        }
        else {
            p[i] = p[i+1];
        }
    }
    ll ans=0;
    vi F(100, 0);
    for(int i = 0; i < M-2 ; i++){
        for(int j = i+1; j < M-1; j++){
            int a = S[i];
            int b = S[j];
            int n = a*10+b;
            if(F[n] == 1)continue;
            F[n] = 1;
            ans += p[j+1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
    int arrrr[4];
    cin>>arrrr[0]>>arrrr[1]>>arrrr[2];
    sort(arrrr,arrrr+3);
    if(arrrr[0]==5 && arrrr[1]==5 && arrrr[2]==7  )
    {
        printf("YES\n");
    }
    else printf("NO\n");

}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	vector<int> A(N+2), d(N+1);
	rep(i,N) cin >> A[i+1];
	rep(i,N+1) d[i]=abs(A[i+1]-A[i]);
	int ans=0;
	rep(i,N+1) ans+=d[i];
	for(int i=1; i<=N; i++){
		vector<int> a(3);
		rep(j,3) a[j]=A[i-1+j];
		sort(a.begin(),a.end());
		if(a[1]==A[i]) cout << ans << endl;
		else if(a[1]==A[i-1]) cout << ans-d[i-1]*2 << endl;
		else cout << ans-d[i]*2 << endl;
	}

	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main( void ) {

	int i, j, h[10], temp;

	for ( i = 0; i < 10; i++ ) {

		scanf( "%d", &h[i] );

	}

	for ( i = 0; i < 10; i++ ) {

		for ( j = 0; j < 9; j++ ) {

			if ( h[j] < h[j+1] ) {

				temp = h[j];
				h[j] = h[j+1];
				h[j+1] = temp;

			}

		}

	}

	for ( i = 0; i < 3; i++ ) {

		printf( "%d\n", h[i] );

	}

	return 0;

}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    int sum = 0;
    for(int a=0; a<10; a++){
      for(int b=0; b<10; b++){
	for(int c=0; c<10; c++){
	  for(int d=0; d<10; d++){
	    if(a+b+c+d == n){sum++;}
	  }
	}
      }
    }
    cout <<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()

const int MAXN = 100;
int F[MAXN] = {};
ll P[MAXN][11];

int ni() {
    int i;
    cin >> i;
    return i;
}

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

    REP(i, N) {
        REP(j, 10) {
            F[i] <<= 1;
            F[i] += ni();
        }
    }

    REP(i, N) {
        REP(j, 11) {
            P[i][j] = ni();
        }
    }

    ll ans = -INF;
    FOR(bit, 1, 1<<10) {
        ll sum = 0;
        REP(i, N) {
            int a = (bit & F[i]);
            int popcount = 0;
            REP(j, 10) {
                if ((a>>j)&1) popcount++;
            }
            sum += P[i][popcount];
        }
        ans = max(ans, sum);
    }

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

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

int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    long long ans=1;
    for(int i=1;i<n;i++){
        bool ok=true;
        for(int j=i-1;j>=0;j--){
            if(h[i]<h[j]) ok=false;
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;
}

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

UL D;
LL C[26];
LL S[400][26];

UL T[400];
LL Last[400][26];
LL Score[26] = {};
LL Sum = 0;

LL MaxScore = -1000000000;
UL ans[400];

mt19937 mt;

void CalcScore(UL i){
 Sum -= Score[i];
 Score[i]=0;
 rep(d,D){
  Last[d+1][i]=Last[d][i];
  if(T[d]==i) {
   Score[i] += S[d][i];
   Last[d+1][i]=d;
  }
  Score[i] -= C[i] * ((LL)d-Last[d+1][i]);
 }
 Sum += Score[i];
}

void Change(){
 UL d = mt() % D;
 UL t = mt() % 26;
 UL TBuf = T[d]; T[d] = t;
 CalcScore(TBuf);
 CalcScore(t);
 if (Sum <= MaxScore - 500) {
  T[d] = TBuf;
  CalcScore(t);
  CalcScore(TBuf);
 }
 else if(MaxScore < Sum) {
  rep(d,D) ans[d] = T[d];
  MaxScore = Sum;
 }
}

void Step(){
 Change();
}

int main() {
 ULL StartP = clock();
 mt.seed(999999999);

 scanf("%u", &D);
 rep(i,26) scanf("%lld",&C[i]);
 rep(i,D)rep(j,26) scanf("%lld",&S[i][j]);
 
 rep(d,D) T[d] = mt() % 26;
 rep(i,26) CalcScore(i);
 MaxScore = Sum;
 rep(i,26) Last[0][i] = -1;
 while(true){
  ULL CheckP = clock();
  if(CheckP-StartP > CLOCKS_PER_SEC * 3 / 2) break;
  Step();
 }
 
 rep(i,D) printf("%u\n", ans[i]+1);
 
 return 0;
}



Measured memory_bytes: 3920
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int flag=1;
    int len=s.size();
    if(len==1)
    {
        cout << s << endl;
    }
    else
    {
        for(int i=1; i<len; i++)
            if(s[i]!='0')
                flag=0;
        if(flag)
            cout << "10" << endl;
        else
        {
            int sum=0;
            for(int i=0; i<len; i++)
                sum+=(s[i]-'0');
            cout << sum << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String keyword = br.readLine();
		int cnt=0;
		String str;
		while((str = br.readLine()) != null){
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 17036
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int ns,nl;
pi d[11][11];

typedef pair<int,vi> IV;

bool better(IV a,IV b){
    return a.fir>b.fir || a.fir==b.fir && a.sec<b.sec;
}

IV f(int cur,int mask){
    IV res=mp(0,vi());
    rep(i,ns)if(d[cur][i].fir!=-1 && !(mask>>d[cur][i].sec&1)){
        IV res2=f(i,mask|1<<d[cur][i].sec);
        res2.fir+=d[cur][i].fir;
        if(better(res2,res))res=res2;
    }
    vi v=res.sec;
    res.sec.clear();
    res.sec.pb(cur);
    rep(i,v.sz)res.sec.pb(v[i]);
    return res;
}

int main(){
	while(cin>>ns>>nl && ns){
        rep(i,ns)rep(j,ns)d[i][j]=mp(-1,-1);
        rep(i,nl){
            int s,t,D;
            cin>>s>>t>>D;
            s--;t--;
            d[s][t]=d[t][s]=mp(D,i);
        }
        IV ans=mp(0,vi());
        rep(i,ns){
            IV res=f(i,0);
            if(better(res,ans))ans=res;
        }
        cout<<ans.fir<<endl;
        rep(i,ans.sec.sz)cout<<ans.sec[i]+1<<(i==ans.sec.sz-1?"\n":" ");
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}

//floor(Ax/B)−A×floor(x/B)

int main() {
  long long int A,B,N;
  cin >> A >> B >> N;
  //int count=0;
  long long int x=1;
  long long result=0;
  while(x<=N&&x<10000000){
    if(((A*x/B)-A*(x/B))>result){
      result=A*x/B-A*(x/B);
    }
    x++;
  }
  long long int memo=0;
  long long int C=B/A;
  int count=0;
  if(B>N){
    x=C;
    while(x<=N&&x<10000000){
      if(((A*x/B)-A*(x/B))>result){
      	result=A*x/B-A*(x/B);
        memo=x;
      }
      x++;
    }
  }
  else{
    x=C;
    while(x<=N&&x<10000000){
      if(((A*x/B)-A*(x/B))>result){
      	result=A*x/B-A*(x/B);
        memo=x;
      }
      x++;
    }
    if(B>=10000000){
      count=0;
      x=B-5000000;
      while(x<=N&&count<=10000000){
        if(((A*x/B)-A*(x/B))>result){
      	  result=A*x/B-A*(x/B);
          memo=x;
        }
        x++;
        count++;
      }
    }
  }
  if(N>=10000000){
    x=N;
    count=0;
    while(x<=N&&count<=10000000){
        if(((A*x/B)-A*(x/B))>result){
      	  result=A*x/B-A*(x/B);
          memo=x;
        }
        x--;
        count++;
      }
  }
  cout << result;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
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; }

int main()
{
  //input
  ll N, M; cin >> N >> M; //S,C

  //main
  ll ans = 0;
  if(M-2*N >= 0){
    M -= 2*N;
    ans = N+M/4;
  }else{//初期段階でS型のピースが余る
    ans = M/2;
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main() {
    
    string s;
    cin >> s;
    int flag = 0;

    for (auto x: s)
        flag |= x == '7';

    if(flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3624
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function hpush(h::Array{Tuple{Int,Int},1},x::Tuple{Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = div(l,2)
		while h[k][2]>x[2]&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(div(k,2),1)
			l = div(l,2)
		end
	end
end

function hpop(h::Array{Tuple{Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>=l
				break
			elseif 2*k+1>=l
				if h[2*k][2]>=z[2]
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k][2]>=z[2]&&h[2*k+1][2]>=z[2]
					break
				else
					t = h[2*k][2]<h[2*k+1][2]?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end

function dijkstra(e::Array{Array{Tuple{Int,Int},1},1},k)
	dis = -ones(Int, length(e))
	h = Array{Tuple{Int,Int},1}()
	push!(h,(k,0))
	while !isempty(h)
		v,w = hpop(h)
		dis[v] = dis[v]<0?w:min(dis[v],w)
		for i in 1:length(e[v])
			if dis[e[v][i][1]]<0　|| dis[e[v][i][1]]>w+e[v][i][2]
				dis[e[v][i][1]] = w+e[v][i][2]
				hpush(h,(e[v][i][1],w+e[v][i][2]))
			end
		end
	end
	dis
end

function main()
	n,m,s,t = readline() |> split |> parseMap
	e = [Tuple{Int,Int}[] for i in 1:n]
	f = [Tuple{Int,Int}[] for i in 1:n]
	for i in 1:m
		u,v,a,b = readline() |> split |> parseMap
		push!(e[u],(v,a))
		push!(e[v],(u,a))
		push!(f[u],(v,b))
		push!(f[v],(u,b))
	end
	dy = dijkstra(e,s)
	ds = dijkstra(f,t)
	x = Array{Tuple{Int,Int},1}(n)
	for i in 1:n
		x[i] = (i,dy[i]+ds[i])
	end
	x = sort(x,by=x->x[2])
	(p,q) = x[1]
	for i in 0:n-1
		if p>i
			println(10^15-q)
		else
			while p<=i
				(p,q) = shift!(x)
			end
			println(10^15-q)
		end
	end
end

main()

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

int main() {
    int n;cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,greater<int>());
    ll ans=0;
    for (int i=0;i<n-1;i++)
        ans+=a[(i+1)/2];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4364
#include <iostream>
using namespace std;
int main(void){
    long int a[100000] ,b[100000] ;
    int N ;
    cin >> N ;
    for(int i=0;i<N;i++){
         cin >> a[i] >> b[i] ;
    }
    
    long int ans = 0 ;
    for(int i=N-1;i>=0;i--){
         if((a[i]+ans)%b[i]!=0){
              ans += b[i] - (a[i]+ans) % b[i] ;
         }
    }
    cout << ans ;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define REP(i,a,b) for(int i=a; i<=int(b); i++)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll ans[10011]={0};
    REP(i,1,101){
        REP(j,1,101){
            REP(k,1,101){
                ll cur=i*i+j*j+k*k+i*j+i*k+j*k;
                if(cur<=10010) ans[cur]++;
            }
        }
    }
    ll n;
    cin >> n;
    REP(i,1,n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3692
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long D) {
    write("Christmas");
    iota(25 - D).each!(_ => write(" Eve"));
    writeln;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long D;
    D = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(D);
    else
        solve(D).writeln;
}


Measured memory_bytes: 256
// AOJ 0603: Illumination
// 2017.10.31 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char a[100002];
int t[100002];
char buf[200100], *p;

int main()
{
	int n, i, k, sz, ans;

	fgets(buf, 10, stdin), n = atoi(buf);
	fgets(p=buf, sizeof(buf), stdin);
	for (i = 0; i < n; i++) a[i] = *p, p+=2;

	for (sz = 0, k = 0, i = 0; i < n; i++) {
		if (k > 0) {
			if (a[i] == a[i-1]) t[sz++] = k, k = 0;
		}
		k++;
	}
	if (k > 0) t[sz++] = k;

	for (ans = k = 0, i = 0; i < sz; i++) {
		k += t[i];
		if (i > 2) k -= t[i-3];
		if (ans < k) ans = k;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2252
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007
P f (int x){
    int a = x % 10 ;
    int b = 0 ;
    while(x){
        b = x ;
        x /= 10 ;
    }
    return P(a, b) ;
}
int main() {
    int n ;
    cin >> n ;
    map<P, int> mp ;
    for(int i = 1 ; i <= n ; i++){
        P p = f(i) ;
        mp[p]++ ;
    }
    ll ans = 0 ;
    for(int i = 1 ; i <= n ; i++){
        P p = f(i) ;
        P q(p.second, p.first) ;
        ans += mp[q] ;
    }
    cout << ans << endl ;
}  

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	db(15-(a+b+c+d+e));
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<PII,char> PIIC;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define FOREACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)

#define MOD 1000000007
#define INF 2000000000

LL A, B, N, t, ans;
int main() {
    cin >> N >> A >> B;
    ans = 0LL;
    set<LL> classes;
    for (size_t i = 0; i < N; i ++){
	cin >> t;
	if (t < A || t >= B){
	    if (classes.find(t) == classes.end())
	    {
		classes.insert(t);
		ans ++;
	    }
	}
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int main(){
  int total_d;
  while(~scanf("%d",&total_d)){
    int total_one_choice_problem;
    scanf("%d",&total_one_choice_problem);

    vector<int> single_points;
    for(int problem_idx=0;problem_idx<total_one_choice_problem;problem_idx++){
      char type[32];
      int point;
      scanf("%s %d",type,&point);
      if(strcmp(type,"D") != 0){
	continue;
      }
      single_points.push_back(point);
    }
    int total_two_choice_problem;
    vector<int> double_points;
    scanf("%d",&total_two_choice_problem);
    for(int problem_idx=0;problem_idx<total_two_choice_problem;problem_idx++){
      char type[32];
      int point;
      scanf("%s %d",type,&point);
      if(strcmp(type,"DD") != 0){
	continue;
      }
      double_points.push_back(point);
    }

    int dp[15];
    memset(dp,0,sizeof(dp));

    for(int i=0;i<single_points.size();i++){
      for(int from=13;from>=0;from--){
	dp[from + 1] = max(dp[from] + single_points[i],dp[from+1]);
      }
    }
    for(int i=0;i<double_points.size();i++){
      for(int from=13;from>=0;from--){
	dp[from + 2] = max(dp[from] + double_points[i],dp[from+2]);
      }
    }

    int max_point = 0;
    for(int d=total_d;d>=0;d--){
      max_point = max(max_point,dp[d]);
    }
    printf("%d\n",max_point);
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  Vi ari(8);
  int all=0,n;
  cin >> n;
  int memo;
  rep(i,0,n){
    cin >> memo;
    if(memo<=399) ari[0]++;
    else if(memo<=799) ari[1]++;
    else if(memo<=1199) ari[2]++;
    else if(memo<=1599) ari[3]++;
    else if(memo<=1999) ari[4]++;
    else if(memo<=2399) ari[5]++;
    else if(memo<=2799) ari[6]++;
    else if(memo<=3199) ari[7]++;
    else all++;
  }
  int ansmin=0,ansmax=0;
  rep(i,0,8){
    if(ari[i]>=1) ansmin++;
  }
  ansmax = ansmin + all;
  if(ansmin==0) ansmin++;
  cout << ansmin << ' ' << ansmax << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}
int n, tot;
int val[N],wt[N];
int dp[1010][10010];
int solve(int pos , int sum){
  if(pos==n+1){
    if(sum<=0)return 0;
    else
      return 1e15;
  }
  if(sum<=0)return 0;
  if(dp[pos][sum]!=-1)return dp[pos][sum];
  int ans =1e15;
  ans = min(val[pos] + solve(pos+1,sum-wt[pos]) , val[pos]+solve(pos,sum-wt[pos]));
  ans = min(ans , solve(pos+1,sum));
  return dp[pos][sum]= ans;
}
signed main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    memset(dp,-1,sizeof(dp));
    cin >>tot >> n;
    for(int i =1 ;i <=n;i++){
      cin >> wt[i] >> val[i];
    }
    cout << solve(1,tot);

  
  
  }
  cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
	vector<int> a(n + 1);
	map<int, set<int> > MP;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 2; i <= n; ++i) MP[i - a[i]].insert(i);
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		int val = i + a[i];
		if (!MP[val].empty()) ans += MP[val].size();
		int x = i - a[i];
		if (MP[x].count(i)) MP[x].erase(i);
	}
	cout << ans;
}

Measured memory_bytes: 46232
#include <stdio.h>

#define abs(x) (((x)>0)?(x):-(x))

int main()
{
  int i, j, k, n;
  scanf("%d %d", &n, &k);
  
  int h[n+k];
  int cost[n+k];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  for (; i<n+k; i++) {
    h[i] = h[n-1];
    cost[i] = 0;
  }

  for (i=n-1; i>=0; i--) {
    cost[i] = abs(h[i]-h[i+k])+cost[i+k];
    for (j=k-1; j>0; j--) {
      if (cost[i] > abs(h[i]-h[i+j])+cost[i+j])
	cost[i] = abs(h[i]-h[i+j])+cost[i+j];
    }
  }
  
  printf("%d\n", cost[0]);

  return 0;
}


Measured memory_bytes: 896
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll 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%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll dp[3302][3302];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    for (int i = 0; i < s.length(); ++i)
    {
    	for (int j = 0; j < t.length(); ++j)
    	{
    		if(s[i]==t[j])
    		{
    			dp[i+1][j+1]=1+dp[i][j];
    		}
    		else
    		{
    			dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
    		}
    	}
    }
    int i=s.length();
    int j=t.length();
    string ans="";
    while(i>0 && j>0)
    {
    	if(s[i-1]==t[j-1])
    	{
    		ans+=s[i-1];
    		// cout<<s[i-1];
    		i--;
    		j--;
    	}
    	else
    	{
    		if(dp[i-1][j]>dp[i][j-1])
    		{
    			i--;
    		}
    		else
    		{
    			j--;
    		}
    	}
    }
    for (int i = 0; i < ans.length(); ++i)
    {
    	cout<<ans[ans.length()-1-i];
    }
    cout<<'\n';
    // cout<<dp[s.length()][t.length()]<<'\n';
}


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


def upper(arr, x):
    # xよりも大きい最小のindexを返す
    if arr[0] > x:
        return 0
    high, low = len(arr), 0
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] > x:
            high = mid
        else:
            low = mid
    return high


def lower(arr, x):
    # xよりも小さい最大のindexを返す
    if arr[-1] < x:
        return len(arr) - 1
    high, low = len(arr) - 1, -1
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid
        else:
            high = mid
    return low


A, B, Q = map(int, input().split(' '))
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]

for _ in range(Q):
    x = int(input())
    shr_u, shr_l = upper(s, x), lower(s, x)
    tmp_u, tmp_l = upper(t, x), lower(t, x)
    ans = 10 ** 18
    if shr_u != A and tmp_u != B:
        ans = min(ans, max(s[shr_u] - x, t[tmp_u] - x))
    if shr_l != -1 and tmp_l != -1:
        ans = min(ans, max(x - s[shr_l], x - t[tmp_l]))
    if shr_l != -1 and tmp_u != B:
        cost = t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x)
        ans = min(ans, cost)
    if shr_u != A and tmp_l != -1:
        cost = s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l])
        ans = min(ans, cost)
    print(ans)

Measured memory_bytes: 130652