akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		final long T = sc.nextLong();
		long[] t = new long[n];
		Arrays.setAll(t, i -> sc.nextLong());
		
		long sum = T;
		for (int i = 0; i < n - 1; i++) {
			sum += Math.min(T, t[i + 1] - t[i]);
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 92052
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PI;
PI sec[200010];
priority_queue<int,vector<int>,greater<int> > R;
int N,M;
vector<int> rs,chair;
bool check(int mid){
	chair.clear();
	rs.clear();
	while(!R.empty()) R.pop();
	for(int i=0;i<mid;i++)
		chair.push_back(0);
	for(int i=1;i<=M;i++){
		chair.push_back(i);
	}
	reverse(chair.begin(),chair.end());
	for(int i=0;i<N;i++){
		if(chair.size()==0) return false;
		int l=sec[i].first,r=sec[i].second;
		R.push(r);
		if(chair.back()<=l){
			chair.pop_back();
			continue;
		}
		rs.push_back(R.top());
		R.pop();
	}
	sort(rs.begin(),rs.end());
	reverse(chair.begin(),chair.end());
	size_t idx=0;
	for(int r:rs){
		while(idx<chair.size() && chair[idx]<r) idx++;
		if(idx==chair.size()) return false;
		idx++;
	}
	return true;
}
int main(){
	int l,r;
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++){
		scanf("%d%d",&l,&r);
		sec[i]=PI(l,r);
	}
	sort(sec,sec+N);
	l=0,r=N;
	while(l!=r){
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_V 51
typedef pair<int, int> P;
int V,E,G[MAX_V][MAX_V],h[MAX_V];
vector<P> p;

void dfs(int i){
  h[i]=1;
  REP(j,V) if(G[i][j]&&(!h[j])) dfs(j);
}

int main(){
  int s,t,ans=0,count;
  cin>>V>>E;
  REP(i,V) REP(j,V) G[i][j]=0;
  REP(i,E){
    cin>>s>>t;s--;t--;
    p.push_back({s,t});
    G[s][t]=G[t][s]=1;
  }
  REP(i,E){
    REP(i,V) h[i]=0;
    G[p.at(i).first][p.at(i).second]=G[p.at(i).second][p.at(i).first]=0;
    dfs(1);
    count=0;
    REP(j,V) count+=h[j];
    if(count!=V) ans++;
    G[p.at(i).first][p.at(i).second]=G[p.at(i).second][p.at(i).first]=1;  
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b)                                                           \
  for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i) // ROF(i,n,0)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで降順
#define SUM(a) accumulate(all(a), int(0))
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> T add(const T &a, const T &b) { return (a + b) % mod; }

signed main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  a = 60 * a + b;
  b = 60 * c + d;
  cout << b - a - e << endl;
}

Measured memory_bytes: 3592
r = 1
t = 0
m = 0
N = int(input())
txy = []

for i in range(N):
    txy.append([int(x) for x in input().split()])


for i in txy:
    t = i[0] - t
    m = abs((i[1] + i[2]) - m)
    
    if i[0] % 2 == 0:
        if (i[1] + i[2]) % 2 != 0:
            print("No")
            break
        elif t < m:
            print("No")
            break
            
    else:
        if (i[1] + i[2]) % 2 != 1:
            print("No")
            break
        elif t < m:
            print("No")
            break
    
   
    if r == N and t >= m:
        print("Yes")
        
    r += 1
    
    
    
            

Measured memory_bytes: 21156
program ABC085B;
{$mode Delphi}
uses SysUtils,fgl;
var
	n,i,r: longint;
	arr: TFPGMap<longint,integer>;
begin
	read(n);
	arr:=TFPGMap<longint,integer>.Create();
	for i:=0 to n-1 do begin
		read(r);
		// arr.AddOrSetData(r,1); // AtCoderでは使用不可
		arr.Remove(r);
		arr.Add(r,1);
	end;
	writeln(arr.Count);
end.


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

int main(){
	double x1,y1,x2,y2,x3,y3,xp,yp;
	while(cin>>x1){
		cin>>y1>>x2>>y2>>x3>>y3>>xp>>yp;
		double a1,a2,a3;
		a1=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
		a2=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
		a3=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
		if((a1>0 && a2>0 && a3>0) || (a1<0 && a2<0 && a3<0)){
			cout<<"YES"<<endl;
		}else {
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


template<class T>
void show_2d_vector(const vector<vector<T>> &v){
    for (auto v1: v) {
        for(auto v2: v1) {
            cout << v2 << " ";
        }
        cout << endl;
    }
}

template<class T>
void show_1d_vector(const vector<T> &v){
    for(auto v1: v) {
        cout << v1 << " ";
    }
    cout << endl;
}

vector<bool> is_possible(1000,false);


int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<ll>> a(10,vector<ll>(n+1,0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            if(j == int(s[i]-'0')){
                a[j][i+1] = a[j][i]+1;
            }else{
                a[j][i+1] = a[j][i];
            }
        }
    }

    ll ans = 0;
    for(int i = 1; i < n-1; i++){
        vector<ll> left;
        vector<ll> right;
        for(int j = 0; j < 10; j++){
            if(a[j][i]>0){left.push_back(j);}
            if(a[j][n]-a[j][i+1]>0){right.push_back(j);}
        }

        for(int j = 0; j < left.size(); j++){
            for(int k = 0; k < right.size(); k++){
                string num="";
                num += left[j]+'0';
                num += s[i];
                num += right[k]+'0';
                is_possible[stoi(num)] = true;
            }
        }
    }
    for(int i = 0; i < 1000; i++){
        if(is_possible[i]){ans++;}
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
 
  if (op == "+") {
    cout << A + B << endl;
  }
  else if (op == "-") {
    cout << A - B << endl;
  }
}


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

int main() {
int H,N,U;
  cin >> H >> N >> U;
  if(N==7&&H==5&&U==5||N==5&&H==7&&U==5||N==5&&H==5&&U==7){
  cout << "YES" << endl;
  }else{
    cout << "NO" << endl;}
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int max_val=-INF;
    int a[n],b[n];
    int last,id,ans;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]>max_val){
            max_val=a[i];
            id=i;
        }
    }
    ans=a[id]+b[id];
    cout<<ans<<endl;
   return 0;
}

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

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << H * W / 2 << endl;
    if (x * 2 == W && y * 2 == H)
        cout << 1 << endl;
    else
        cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int a,b; cin >> a >> b;
    int available = 1;
    int c = 0;

    while(available<b){
        available += a-1;
        c++;
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k;
  scanf("%d",&n);
  int b,f,r,v;
  int a[4][3][10]; //4?£????3????????????10??¨?±?????????°???????´?
  for(b=1;b<=4;b++){
    for(f=1;f<=3;f++){
      for(r=1;r<=10;r++){
        a[b-1][f-1][r-1]=0; //??¨????????¨?±???§?????????0???
      }
    }
  }
  for (k=1;k<=n;k++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    a[b-1][f-1][r-1] += v; //??¨?±??????\?±??????°??£??\
  }
  for(b=1;b<=4;b++){
    for(f=1;f<=3;f++){
      for(r=1;r<=10;r++){
        printf(" %d",a[b-1][f-1][r-1]);
      }
      printf("\n");
    }
    if(b<=3){
      for(k=1;k<=20;k++){
        printf("#");
      }
      printf("\n");
    }
  }
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

struct Edge {
    int to,cost;
    Edge (int t,int c) {
        to = t; cost = c;
    }
    bool operator>(const Edge& e)const {
        return cost > e.cost;
    } 
    bool operator<(const Edge& e)const {
        return cost < e.cost;
    }
};

int main (void) {
    int H,W;
    cin>>H>>W;
    vector<vector<Edge>> G(10);
    REP(i,10) {
        REP(j,10) {
            int c;
            cin>>c;
            G[j].pb(Edge(i,c)); //辺を逆向きに追加
        }
    }

    //Dijkstraで1をnに変えるのに必要なコストを求める。
    //-> グラフの辺は逆向きなので、
    //   nから1に変えるのに必要なコストを求めることになる（はず）
    priority_queue<Edge,vector<Edge>,greater<Edge>> pq;
    vector<int> dist(10,inf);
    vector<bool> used(10,false);
    dist[1] = 0;
    pq.push(Edge(1,0));
    while(pq.size()) {
        int from = pq.top().to;
        pq.pop();
        if (used[from]) continue;
        used[from] = true;
        REP(i,G[from].size()) {
            int c = G[from][i].cost;
            int t = G[from][i].to;
            if (dist[t] > c + dist[from]) {
                dist[t] = c + dist[from];
                pq.push(Edge(t,dist[t]));
            }
        }
    }
    ll ans = 0;
    REP(i,H) {
        REP(j,W) {
            int n;
            cin>>n;
            if (abs(n) != 1) {
                ans += dist[n];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int K, a[100010];

bool check(int val) {
    repr(i,K-1,0) {
        val -= (val % a[i]);
    }
    return val == 2;
}

signed main() {
    cin >> K;
    rep(i,0,K) cin >> a[i];
    reverse(a, a+K);

    bool ok = true;
    int val = 2;
    rep(i,0,K) {
        if(i == 0) {
            if(a[i] != 2) ok = false;
        }
        else {
            val = (val + a[i] - 1) / a[i] * a[i];
        }
    }

    ok &= check(val);

    if(!ok) cout << -1 << endl;
    else {
        int lb = val, ub = INF;
        while(ub - lb > 1) {
            int mid = (ub + lb) / 2;
            // printf("ub = %lld, lb = %lld, mid = %lld\n", ub, lb, mid);
            if(check(mid)) lb = mid;
            else ub = mid;
        }
        int mi = val, ma = lb;
        printf("%lld %lld\n", mi, ma);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
vector<ll> A;
int main(){
	int N;
	cin>>N;
	rep(i,N){
		ll x;
		cin>>x;
		A.pb(x);
	}
	sort(all(A));
	int ind=N-1;
	rep(i,N)if(A[i]>0)ind=min(ind,i);
	if(ind==0)ind++;
	ll res=A[0];
	for(int i=ind;i<N-1;i++){
		res-=A[i];
	}
	res=A[N-1]-res;
	for(int i=1;i<ind;i++){
		res-=A[i];
	}
	cout<<res<<endl;
	
	
	res=A[0];
	for(int i=ind;i<N-1;i++){
		cout<<res<<" "<<A[i]<<endl;
		res-=A[i];
	}
	cout<<A[N-1]<<" "<<res<<endl;
	res=A[N-1]-res;
	for(int i=1;i<ind;i++){
		cout<<res<<" "<<A[i]<<endl;
		res-=A[i];
	}
}

Measured memory_bytes: 2804
#include<stdio.h>

static const int N = 100;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  
  for(i = 2; i <= n; i++){
    key = A[i];
    j = i - 1;
    while(j > 0 && A[j] > key){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = key;
    trace(A,n);
  }

  return 0;
}



Measured memory_bytes: 2056
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  auto calc = [] (vector<vector<int>> v, int k, int q) {
    int n = (int) v.size();
    for (int i = 0; i < n; i++) sort(v[i].rbegin(), v[i].rend());
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    for (int i = 0; i < n; i++) que.emplace(v[i].back(), i);
    int mi = 1 << 30, mx = 0;
    while (q > 0 && que.size()) {
      auto cur = que.top();
      que.pop();
      int idx = cur.second;
      int val = cur.first;
      if ((int) v[idx].size() < k) continue;
      mi = min(mi, val);
      mx = max(mx, val);
      v[idx].pop_back();
      q--;
      if (v[idx].size()) que.emplace(v[idx].back(), idx);
    }
    return (q == 0 ? mx - mi : 1 << 30);
  };
  int ans = 1 << 30;
  for (int i = 0; i < n; i++) {
    vector<vector<int>> v;
    v.push_back({});
    for (int j = 0; j < n; j++) {
      if (a[j] >= a[i]) v.back().push_back(a[j]);
      else if (v.back().size()) v.push_back({});
    }
    if (v.back().empty()) v.pop_back();
    ans = min(ans, calc(v, k, q));
  }
  cout << ans << endl;
  return 0;
}

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

#define ll  long long int
 
int main()
{
  #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("oo.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
     ll ans=max(a*c , a*d);
     ll ans2=max(b*c,b*d);
     cout<<max(ans,ans2);
  return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string a,b;
  cin>>a>>b;
  rep(i,b.size()){
    cout<<a[i]<<b[i];
  }
  if(a.size()>b.size()){
    cout<<a[a.size()-1]<<endl;
  }else{
    cout<<endl;
  }
}
///////////////////////////

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

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

    int n;
    cin >> n;
    deque<int> dq;
    for (int i=0; i<n; ++i) {
        string com; int x;
        cin >> com;
        if (com == "insert") {
            cin >> x;
            dq.push_front(x);
        } else if (com == "delete") {
            cin >> x;
            auto it = find(dq.begin(), dq.end(), x);
            if (it != dq.end()) dq.erase(it);
        } else if (com == "deleteFirst") {
            dq.pop_front();
        } else if (com == "deleteLast") {
            dq.pop_back();
        }
    }
    
    int i = 0;
    for (int x: dq) {
        cout << (i++ ? " " : "") << x;
    }
    cout << endl;
    return 0;
}


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

typedef long long ll;

ll N;
vector<ll> A;
map<ll, ll> C;
ll Res;

int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A[i];
    ++C[A[i] - i];
  }
  for (ll i = 0; i < N; ++i) {
    Res += C[-A[i] - i];
  }
  cout << Res << endl;
  return 0;
}


Measured memory_bytes: 27428
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main(void) {

    int N;
    cin >> N;
    int X[N];
    for(int i = 0; i < N; i++) {
        cin >> X[i];
    }

    sort(X, X+N);
    int minx = X[0];
    int maxx = X[N-1];

    int min_cost = 1e+9; 
    for(int i = minx; i <= maxx; i++) {
        int cost = 0; 
        for(int j = 0; j < N; j++) {
            cost += (X[j] - i) * (X[j] - i);
        }
        min_cost = min(min_cost, cost);
    }
    cout << min_cost << endl;


    return 0;

}



Measured memory_bytes: 256
S = input()
T = input()
length =len(S)
S = "".join(S)
T = "".join(T)
listS=list(S)
listT=list(T)
num = len(T)
res = 0
for i in range(length):
    if (listS[num-1] != listT[num-1]):
        res +=1
    num -=1
print(res)

Measured memory_bytes: 12388
from sys import stdin
from collections import deque


def l2t(g):
    return tuple(map(tuple,g))




class BFS():
    def __init__(self, graph, m, n):
        # 盤面
        self.graph = graph
        self.m = m
        self.n = n
        # 始点からの距離
        self.dist = {}
        # キュー
        self.que = deque()

        self.eg_arr = [[[i for i in range(1,self.n+1)],[],[]],
                       [[],[],[i for i in range(1,self.n+1)]]]

    def list2num(self,g):
        str_ = ''
        for i in range(self.n):
            if i+1 in g[0]:
                str_ += '0'
            elif i+1 in g[1]:
                str_ += '1'
            else:
                str_ += '2'
        return str_

    def bfs(self):
        self.graph = self.list2num(self.graph)
        self.eg_arr[0] = self.list2num(self.eg_arr[0])
        self.eg_arr[1] = self.list2num(self.eg_arr[1])

        # 初期条件
        self.dist[self.graph] = 0
        self.que.append(self.graph)

        if self.graph in self.eg_arr:
            return 0

        while self.que:
            g = self.que.popleft()
            if self.dist[g] > self.m: continue

            ng_arr = []
            ind0 = g.rfind('0')
            ind1 = g.rfind('1')
            ind2 = g.rfind('2')
            if ind0 >= 0:
                if (ind1 >= 0 and ind1<ind0) or ind1 < 0:
                    ng = g[:ind0]+'1'+g[ind0+1:]
                    ng_arr.append(ng)
            if ind1 >= 0:
                if (ind0 >= 0 and ind0<ind1) or ind0 < 0:
                    ng = g[:ind1]+'0'+g[ind1+1:]
                    ng_arr.append(ng)
                if (ind2 >= 0 and ind2<ind1) or ind2 < 0:
                    ng = g[:ind1]+'2'+g[ind1+1:]
                    ng_arr.append(ng)
            if ind2 >= 0:
                if (ind1 >= 0 and ind1<ind2) or ind1 < 0:
                    ng = g[:ind2]+'1'+g[ind2+1:]
                    ng_arr.append(ng)

            for ng in ng_arr:
                if ng in self.dist.keys(): continue
                self.dist[ng] = self.dist[g] + 1
                self.que.append(ng)
                if ng in self.eg_arr:
                    return self.dist[ng]
        else:
            return -1


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    io_cnt = 0
    while True:
        try:
            n, m = list(map(int,_in[io_cnt].split(' ')))  # type:list(int)
            graph = []
            for i in range(3):
                _ = list(map(int,_in[io_cnt+i+1].split(' ')))  # type:list(int)
                if _[0] == 0:
                    graph.append([])
                else:
                    graph.append(_[1:])
            io_cnt += 4
            # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
            bfs = BFS(graph,m,n)
            cnt = bfs.bfs()
            # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            print(cnt)
        except:
            break


if __name__ == "__main__":
    main()



Measured memory_bytes: 326404
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 40000
#define INF 2147483647
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};


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

    int n, m, a, b, rtmp, r;
    vector<int> rv, av, bv;
    ll c;
    vector<ll> cv;
    cin >> n >> m >> r;
    rep(r){
        cin >> rtmp;
        rv.pb(rtmp-1);
    }
    sort(all(rv));
    vector< vector<ll> > d(n, vector<ll>(n, MOD));
    rep(n) d[i][i] = 0;
    rep(m){
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    repp(i, n){
        repp(j, n){
            repp(k, n){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    ll ans = MOD, tmp;
    do{
        tmp = 0;
        repp(i, r-1){
            tmp += d[rv[i]][rv[i+1]];
        }
        ans = min(ans, tmp);
    }while( next_permutation(all(rv)) );
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#define SF scanf
#define PF printf
#define MAXN 300010
using namespace std;
typedef long long ll;
int n;
ll L,ans,x[MAXN],t[MAXN];
pair<int,int> s[MAXN];
stack<int> q[2];
bool del[MAXN];
int main(){
    SF("%d%lld",&n,&L);
    for(int i=0;i<n;i++)
        SF("%lld",&x[i]);
    for(int i=0;i<n;i++){
        SF("%lld",&t[i]);
        ans+=(t[i]/(2ll*L))*2ll*L;
        t[i]%=(2ll*L);
    }
    bool flag=0;
    for(int i=0;i<n;i++){
        if(t[i]!=0){
            flag=1;
            if(t[i]<=2ll*(L-x[i]))
                s[i].first=0;
            else
                s[i].first=1;
            if(t[i]<=2ll*x[i])
                s[i].second=0;
            else
                s[i].second=1;
        }
        else{
            s[i].first=s[i].second=1;
        }
    }
    for(int i=0;i<n;i++)
        if(s[i].first==1&&s[i].second==1){
            del[i]=1;
            if(t[i]!=0)
                ans+=2ll*L; 
        }
    for(int i=0;i<n-1;i++){
        if(del[i]==1)
            continue;
        if(s[i].first==0&&s[i].second==1){
            /*if(!q[1].empty()){
                del[q[1].top()]=1;
                del[i]=1;
                q[1].pop();
                ans+=2ll*L;
            }
            else */if(!q[0].empty()){
                del[q[0].top()]=1;
                del[i]=1;
                q[0].pop();
                ans+=2ll*L;
            }
        }
        else if(s[i].second==0){
            q[s[i].first].push(i);
        }
    }
    while(!q[1].empty())
        q[1].pop();
    while(!q[0].empty())
        q[0].pop();
    for(int i=0;i<n-1;i++){
        if(del[i]==1||(s[i].first==0&&s[i].second==1))
            continue;
        if(s[i].first==0){
            if(!q[1].empty()){
                del[i]=1;
                del[q[1].top()]=1;
                q[1].pop();
                ans+=2ll*L;
            }
            else if(!q[0].empty()){
                del[i]=1;
                del[q[0].top()]=1;
                q[0].pop();
                ans+=2ll*L;
            }
            else
                q[0].push(i);
        }
        else
            q[1].push(i);
    }
    if(s[n-1].first==0&&del[n-1]==0){
        for(int i=0;i<n-1;i++)
            if(del[i]==0&&s[i].second==0){
                del[i]=1;
                del[n-1]=1;
                ans+=2ll*L;
                break;
            }
    }
    ll res=0,sum=0;
    for(int i=0;i<n;i++)
        if(del[i]==0)
            sum++;
    if(del[n-1]==0){
        if(s[n-1].first==1&&s[n-1].second==0)
            res=sum+1;
        else
            res=sum;
    }
    if(del[n-1]==1)
        res=sum+1;
    ans+=res*2ll*L;
    PF("%lld",ans);
} 


Measured memory_bytes: 8652
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dp[100005];
int h[100005];
int main() {
	scanf("%d",&n);
	k=2;
	for(int i=0; i<n; i++) {
		scanf("%d",&h[i]); 
	} 
	for(int i=1; i<n; i++) {
		dp[i]=2000000000;
		for(int j=max(0,i-k); j<i; j++) {
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	printf("%d\n",dp[n-1]);
}

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

using namespace std;

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

int main(){
    int N; cin >> N;
    double ans = 0;
    int count = 0;
    rep(i, N) {
        if ((i+1)%2 == 1) count++;
    }
    ans = (double)count / (double)N;
    cout << fixed << setprecision(6) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define ll long long

int main(void) {

    ll  a, b, c;
    cin >> a >> b >> c;

    ll left = 4 * a * b;
    ll right = (c-b-a)*(c-b-a);
    if((c-b-a)<0) right *= -1;
    cerr << left << endl;
    cerr << right << endl;


    string ans = (left<right) ? "Yes" : "No";
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

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

int main(){
    ll h, w, k;
    cin >> h >> w >> k;

    //dp[i][j] : 高さiで幅jに行ける本数
    ll dp[h+2][w+2] = {};
    dp[0][0] = 1;
    rep(i, h)rep(j, w){
        //
        rep(bit, (1<<(w-1))){
            //正しい線の引き方か？
            bool isok = true;
            rep(b, w)if((1<<b) & bit){
                if((1<<(b+1) & bit)){
                    isok = false;
                    break;
                }
            }
            if(!isok)continue;

            //右方向へ移動する
            if((1<<j) & bit){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
            //左方向へ移動する
            else if(j > 0 && ((1<<(j-1)) & bit)){
                dp[i+1][j-1] += dp[i][j];
                dp[i+1][j-1] %= MOD;
            }
            //そのまま下へ
            else {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }

    cout << dp[h][k-1] << endl;
}

Measured memory_bytes: 3516
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;
    int n = SIZE(s);

    int result = 0;

    REP(i,n){
        FOR(j,i,n){
            if(s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T'){
                break;
            }
            result = max(result,j-i+1);
        }
    }

    cout<<result<<endl;
	return;
}

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

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

int main(){

  int a = 0, b = 0, c = 0, d = 0, p;
  for(int i=0;i<4;i++){
    cin >> p;
    if(p == 1) a = 1;
    if(p == 9) b = 1;
    if(p == 7) c = 1;
    if(p == 4) d = 1;
  }

  if(a + b + c + d == 4) cout << "YES\n";
  else cout << "NO\n";

}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> height(n);
  rep(i, n) cin >> height[i];
  map<int, int> mp;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    if(mp[x] < height[y - 1]) mp[x] = height[y - 1];
    if(mp[y] < height[x - 1]) mp[y] = height[x - 1];
  }
  int res = 0;
  rep(i, n) {
    if(mp.count(i + 1) == 0) res++;
    else {
      if(height[i] > mp[i + 1]) res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 7716
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9+7;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if(s[0] == '0' || s[n-1] == '1')
    {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < n-2; i++)
    {
        if(s[i] != s[n-i-2])
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << "1 2" << endl;
    cout << "2 3" << endl;
    int pos = 2;
    for(int i = 1; i < n-2; i++)
    {
        if(s[i] == '1')
        {
            pos = i + 2;
        }
        cout << pos << " " << i+3 << endl;
    }
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e3+5;
ll a[maxn];
ll b[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n==m)
    {
        for(int i=0; i<n; i++)
            printf("%d",n);
    }
    else if(n>m)
        for(int i=0; i<n; i++)
            printf("%d",m);
    else for(int i=0; i<m; i++)
            printf("%d",n);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), a[] = IntStream.range(0, n).map(i -> scanner.nextInt() - i - 1).sorted().toArray();
        System.out.println(Arrays.stream(a).mapToLong(i -> Math.abs(i - a[n / 2])).sum());
    }
}

Measured memory_bytes: 87152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n ;
    ll a[n+1];
    ll sum=0;
    map<ll,ll>fr;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
        sum+=a[i];
        fr[a[i]]++;
    }
    ll q;
    cin >> q;
    while(q--)
    {
        ll x,y;
        cin >> x >> y;
        ///cout<<fr[x]<<" ";
        sum-=fr[x]*x;
        sum+=y*fr[x];
        fr[y]+=fr[x];
        fr[x]=0;
        cout<<sum<<'\n';
    }

    return 0;
}


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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 1000000007;

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], int n) {
    string result = "{";
    REP(i, 0, n) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

string bin_string(int x) {
    const int d = 64;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

vector<int> getZ(string s) {
    int n = s.size();
    vector<int> z(n);
    int x = 0, y = 0;
    REP(i, 1, n) {
        z[i] = max(0LL, min(z[i-x], y-i+1));
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
            x = i;
            y = i+z[i];
            ++z[i];
        }
    }
    return z;
}

int powa(int base, int exp) {
    if (exp<=0) return 1;
    if (base<=0) return 0;
    int val = powa(base, exp>>1);
    val = val*val % MOD;
    if (exp&1) {
        val = val*base % MOD;
    }
    return val;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    const int INNER = 80*160+10;
    const int OUTER = INNER+100;

    int R,C;
    cin >> R >> C;
    int grid[R][C];

    REP(r, 0, R) REP(c, 0, C) cin >> grid[r][c];
    REP(r, 0, R) REP(c, 0, C) {
        int x;
        cin >> x;
        grid[r][c] = abs(grid[r][c]-x);
    }

    bitset<2*OUTER> dp[R][C];
    dp[0][0][OUTER+grid[0][0]] = dp[0][0][OUTER-grid[0][0]] = 1;
    REP(r, 0, R) REP(c, 0, C) {
        if (r!=0) dp[r][c] |= dp[r-1][c]<<grid[r][c] | dp[r-1][c]>>grid[r][c];
        if (c!=0) dp[r][c] |= dp[r][c-1]<<grid[r][c] | dp[r][c-1]>>grid[r][c];
    }
    
    int res=0;
    while (!dp[R-1][C-1][OUTER+res] && !dp[R-1][C-1][OUTER-res]) ++res;
    cout << res;
}

Measured memory_bytes: 20480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		for(int i = 1;;i++) {
			if(Math.pow(k, i) > n) {
				System.out.println(i);
				break;
			}
		}
	}
}

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


const int MAXN = 501;
const int MAXH = 101;
const int MAXW = 101;
int N, W, H, X[MAXN], Y[MAXN], S, T;
int G[MAXH][MAXW];

int main() {
  while(cin >> N && N) {
    cin >> W >> H;
    for(int k = 0; k < N; ++k) {
      cin >> X[k] >> Y[k];
      --X[k], --Y[k];
    }
    cin >> S >> T;
    fill(G[0], G[MAXH], 0);
    int res = 0;
    for(int k = 0; k < N; ++k) {
      for(int i = -T+1; i <= 0; ++i) {
        for(int j = -S+1; j <= 0; ++j) {
          int ni = Y[k] + i;
          int nj = X[k] + j;
          if(ni < 0 || ni >= H) continue;
          if(nj < 0 || nj >= W) continue;
          res = max(res, ++G[ni][nj]);
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define PB push_back
#define MP make_pair
#define S second
#define F first
//#define D cout<<"*\n";
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define mod 1000000007 
#define inf 1e10;
const double pi = 3.14159265358979323846; 

int dp[105][100006];

int knapsack(int value[],int weight[],int n,int V)
{
	if(V<=0)
	return 0;
	if(n==0)
	return inf;
	
	int &ans=dp[n][V];
	if(ans!=-1)
	return ans;
	
	ans= min(knapsack(value,weight,n-1,V),knapsack(value,weight,n-1,V-value[n-1])+weight[n-1]);
	return ans;
}

signed main()
{
    fast
    int t=1;
   // cin>>t;
    
    while(t--)
    {
      int n,W;
      cin>>n>>W;
      
      int value[n],weight[n];
      int total=0;
      for(int i=0;i<n;i++)
      {
      	cin>>weight[i]>>value[i];
      	total+=value[i];
	  }
	  memset(dp,-1,sizeof(dp));
	  for(int i=total;i>=0;i--)
	  {
	  	//cout<<knapsack(value,weight,n,total)<<"\n";
          if(knapsack(value,weight,n,i)<=W)
          {
          	cout<<i;
          	break;
		  }
       }
    }
	return 0;
}

	

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

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	map <int, int> f;
	for(int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		f[x] += 1;
	}
	int ans = 0;
	for(auto i : f) {
		if(i.first <= i.second) ans += i.second - i.first;
		else ans += i.second;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		400010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

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

//
int main(){
	int K;cin >> K;

	int ans = 0;

	REPS(i,1,K+1){
		REPS(j,1,K+1){
			REPS(l,1,K+1){
				int t = gcd(i,j);
				ans += gcd(t,l);
			}
		}
	}

	cout << ans << endl;

	return 0;
}




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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	for (int m, f, r; cin >> m >> f >> r && !(m == -1 && f == -1 && r == -1);) {
		if (m == -1 || f == -1)cout << "F" << endl;
		else if (m + f >= 80)cout << "A" << endl;
		else if(m + f >= 65)cout << "B" << endl;
		else if (m + f >= 50)cout << "C" << endl;
		else if (m + f >= 30) {
			if (r >= 50)cout << "C" << endl;
			else cout << "D" << endl;
		}
		else cout << "F" << endl;
	}
	return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    ll dis = 1e13;
    ll ans = 0;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ll j = n / i;
            if (dis > abs(i - j))
            {
                dis = abs(i - j);
                ans = i + j - 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
	int a[2]; int i;
	for (i = 1; i <= 2; i++)
	{
		cin >> a[i];
	}
	int y;
	y = a[1] + a[2];
	int x;
	if (y % 2 != 0) x = y / 2 + 1;
	else x = y / 2;
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c >=22) cout<<"bust";
    else cout<<"win";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],c[maxn];
string s; 
il int check(int x)
{
	if(x <= 3)
		return x;
	for(int i=2;i<=sqrt(x);i++)
	{
		if(x%i==0)
			return i;
	}
	return x;
}
signed main()
{
	int n;
	cin >> n;
	int ans = 0;
	if(n==1)
	{
		cout << 0;
		return 0;
	}
	if(n<=5)
	{
		cout << 1;
		return 0;
	}
	while(n)
	{
		int p = check(n);
	//	cout << p << endl;
		if(p==0||n==1)
		{
			cout << ans;
			return 0;
		}
		int cnt = 0;
		while(n%p==0)
		{
			n/=p;
			cnt++;
		//	cout << p<< " " <<n << endl;
		}
		int k = 1;
		while(cnt)
		{
			if(cnt >= k)
				cnt-=k,ans++,k++;
			else
				cnt=0;
		}
	}
	return 0;
}

Measured memory_bytes: 3680
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <stack>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, x, n) for (int i = x; i < n; ++i)

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    int n, m;
    scanf("%d %d", &n, &m);
    int total = 0;
    REP(i, m)
    {
        int a;
        scanf("%d", &a);
        total += a;
    }
    if (total > n)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d\n", n - total);
    }
}

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

typedef pair<int, int> P;

int main()
{
    int n,p,d1,d2;
    while(cin >> n && n) {
        vector<P> v(n);
        for(int i = 0; i < n; i++) {
            cin >> p >> d1 >> d2;
            v[i] = P(d1 + d2, p);
        }
        
        sort(v.begin(), v.end());
        cout << v[n-1].second << " " <<  v[n-1].first << endl;
    }
}

Measured memory_bytes: 984
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define true 1
#define false 0

int isPrime(int);
int main(){
    int x,*prime,i,cnt=0,p;
    //要素数の決定
    scanf("%d",&x);
    prime=malloc(sizeof(int)*(x+1));
    //素数入力と判定
    for(i=0;i<x;i++){
    scanf("%d",&prime[i]);
    }
    for(i=0;i<x;i++){
       p=isPrime(prime[i]);
       
       if(p==false){
           cnt+=0;
           //printf("false\n");
       }else{
           cnt+=1;
           //printf("true\n");
       }
    }
     printf("%d\n",cnt);    
    free(prime);
    return 0;
}

int isPrime(int a){
    int i=3;
        if(a==1){
            return false;
        }
        else if(a>2 && a%2==0){
            return false;
        }
        while(i<=sqrt(a)){
             if(a%i==0){
                return false;
             }
             i+=2;
        }
    return true;
}


Measured memory_bytes: 2072
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	vector<int> counter = vector<int>(4, 0);
	for (int cnt = 0; cnt < 3; ++cnt){
		int a, b;
		cin >> a >> b;
		++counter[a];
		++counter[b];
		if(counter[a] > 2 || counter[b] > 2){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  if(n%1000==0){
    cout << 0 << endl;
    return 0;
  }
  cout << 1000-n%1000 << endl;
}



Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;

	for ( int i = A; i <= B; i++) {
		int a, b, c, d;
		a = i / 10000;
		b = i / 1000 % 10;
		c = i % 100 / 10;
		d = i % 10;
		if (a == d && b == c) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256