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

#define NDEBUG 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>
#include <list>
#include <functional>
#include <numeric>

//find out the use of the below
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define PI acos(-1)
//number of digits in int
int mx = 1;
int leas(int x) {
    if (x == 0)
        return 0;
    else
        return x-1;
}
void add(vector<int> &nu) {
    nu[0]++;
    int i = 0;
    for (;i < 99; ++i){
        if (nu[i] >= 10){
            if (NDEBUG)
                cout << i+1 << "th index is >= 10\n";
            if (i == mx-1)
                mx++;
            nu[i+1] += nu[i]/10;
            nu[i] = nu[i]%10;

        } else if (i > 0 && nu[i-1] - nu[i] > 1) {
            nu[i] += 1;
            nu[i-1] = leas(nu[i]);
            i--;
        } else if (i == mx-1 || abs(nu[i+1]-nu[i]) <= 1) {
            break;
        }
    }
    //assume i is correct and balance the rest
    i = min(i, mx-1);
    i--;
    while (i >= 0) {
        nu[i] = leas(nu[i+1]);
        i--;
    }
}
void pr(vector<int> &nu) {
    for (int i = mx-1; i >= 0; --i)
        cout << nu[i];
    cout << endl;
}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    fio;
    int k;
    cin >> k;
    vector<int> nu(100, 0);
    nu[0] = 1;
    //pr(nu);

    for (int i = 2; i <= k; ++i){
        add(nu);
        //pr(nu);
    }
    pr(nu);


    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



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

int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    string ans = "";
    rep(i,n){
        ans += s.at(i);
        ans += t.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int N=2005;

int n,m,t,ans;
int dp[N][N],mp[N][N],st[N],f[N],g[N];
char s[N][N];

bool pd(int x1,int y1,int x2,int y2){
	int sum;
	sum=mp[x1][y1]+mp[x1][y2]+mp[x2][y1]+mp[x2][y2];
	return !(sum&1);
}

void init(){
	int i,j,k;
	for (i=1;i<n;i++){
		for (j=m-1;j;j--){
			if (pd(i,j,i+1,j+1)) dp[i][j]=dp[i][j+1]+1;
			else dp[i][j]=0;
		}
	}
}

void work(){
	int i,j;
	for (i=1;i<m;i++){
		t=0;
		for (j=1;j<n;j++){
			while (t&&dp[j][i]<dp[st[t]][i]){
				f[st[t]]=j; t--;
			}
			st[++t]=j;
		}
		for (j=1;j<=t;j++) f[st[j]]=n;
		t=0;
		for (j=n-1;j;j--){
			while (t&&dp[j][i]<dp[st[t]][i]){
				g[st[t]]=j+1; t--;
			}
			st[++t]=j;
		}
		for (j=1;j<=t;j++) g[st[j]]=1;
		for (j=1;j<n;j++) ans=max(ans,(f[j]-g[j]+1)*(dp[j][i]+1));
	}
}

int main(){
	int i,j;
	scanf("%d%d",&n,&m); ans=max(n,m);
	for (i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for (j=1;j<=m;j++) mp[i][j]=s[i][j]=='.';
	}
	init();
	work();
	printf("%d\n",ans);
	return 0;
}

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

const int INF = INT_MAX;

typedef struct {
  char suit;
  int num;
} elem;

int partition(vector<elem> &arr, int p, int r)
{
  int i = p, x = arr[r-1].num;
  for (int j = p; j < r; j++)
    if (arr[j].num <= x)
      swap(arr[i++], arr[j]);
  return i-1;
}

void quick_sort(vector<elem> &arr, int p, int r)
{
  if (p < r) {
    int q = partition(arr, p, r);
    quick_sort(arr, p, q);
    quick_sort(arr, q+1, r);
  }
}

bool eq(elem a, elem b)
{
  return a.suit == b.suit && a.num == b.num;
}

bool is_stable(vector<elem> &qsorted, vector<elem> &msorted)
{
  for (int i = 0; i < qsorted.size(); i++)
    if (!eq(qsorted[i], msorted[i]))
      return false;
  return true;
}


vector<elem> ls, rs;

void merge(vector<elem> &as, int left, int mid, int right)
{
  int l_size = mid - left;
  int r_size = right - mid;
  copy(as.begin()+left, as.begin()+left+l_size, ls.begin());
  copy(as.begin()+mid, as.begin()+mid+r_size, rs.begin());
  ls[l_size] = (elem){ 'Z', INF };
  rs[r_size] = (elem){ 'Z', INF };

  for (int i = left, li = 0, ri = 0; i < right; i++) {
    if (ls[li].num <= rs[ri].num)
      as[i] = ls[li++];
    else
      as[i] = rs[ri++];
  }
}

void merge_sort(vector<elem> &as, int left, int right)
{
  if (left+1 == right) return;
  int mid = left+(right-left)/2;
  merge_sort(as, left, mid);
  merge_sort(as, mid, right);
  merge(as, left, mid, right);
}


int main()
{
  int n; cin >> n;
  vector<elem> arr1 = vector<elem>(n);
  vector<elem> arr2 = vector<elem>(n);
  ls = vector<elem>(n/2+1);
  rs = vector<elem>(n/2+1);
  for (int i = 0; i < n; i++) {
    char suit; int num;
    cin >> suit >> num;
    arr1[i] = (elem){ suit, num };
  }
  copy(arr1.begin(), arr1.end(), arr2.begin());
  quick_sort(arr1, 0, n);
  merge_sort(arr2, 0, n);

  cout << (is_stable(arr1, arr2)?"Stable":"Not stable") << endl;
  for (int i = 0; i < n; i++)
    printf("%c %d\n", arr1[i].suit, arr1[i].num);
  return EXIT_SUCCESS;
}


Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n;
    cin>>n;
    vector<P> a[n];
    REP(i,n){
        int s;
        cin>>s;
        REP(j,s){
            int x,y;
            cin>>x>>y;
            x--;
            P t=make_pair(x,y);
            a[i].push_back(t);
        }
    }
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        vector<int> S;
        REP(i,n){
            if(bit & (1<<i)){
                S.push_back(i);
            }
        }
        bool f=true;
        REP(i,SZ(S)){
            for(auto t:a[S[i]]){
                if(((bit>>t.first)&1)^t.second){
                    f=false;
                    break;
                }
            }
            if(!f)break;
        }
        if(f) ans=max(ans,SZ(S));
    }
    OUT(ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	LL H, W, N;
	cin >> H >> W >> N;
	map<pair<LL, LL>, LL> m;
	REP( i, N )
	{
		LL a, b;
		cin >> a >> b;
		--a;
		--b;
		REP( k, 3 ) REP( l, 3 )
		{
			LL r = a - k;
			LL c = b - l;
			if( r >= 0 && r < H - 2 && c >= 0 && c < W - 2 )
			{
				++m[ make_pair( r, c ) ];
			}
		}
	}
	LL ans[ 10 ];
	REP( i, 10 ) ans[ i ] = 0;
	for( auto pair : m )
	{
		++ans[ pair.second ];
	}
	LL sum1to9 = 0;
	for( int i = 1; i <= 9; ++i ) sum1to9 += ans[ i ];
	ans[ 0 ] = ( H - 2 ) * ( W - 2 ) - sum1to9;
	REP( i, 10 ) cout << ans[ i ] << endl;
	return 0;
}


Measured memory_bytes: 56448
Module Program
  Sub Main
    Dim s=GetInts()
    Dim x=foo(s(0)),y=foo(s(1))
    Dim ans=If(x=y,"Yes","No")
    Console.WriteLine(ans)
  End Sub
    Function foo(x As Integer) As Integer
      Select Case x
      Case 2
        Return 0
      Case 4,6,9,11
        Return 1
      Case Else
        Return 2
      End Select
    End Function
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  using ll = long long;
  ll a,b,c;
  cin>>a>>b>>c;

  ll d=c-(a+b);
  if(d<=0) drop("No");

  cout<<(4*a*b<d*d?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
from itertools import accumulate as acc
MOD=10**9+7
N,M=map(int,input().split())
if N==1: print(1),sys.exit()
a=[0]*(N+1)
for i in range(M):
  a[int(input())]=-1
pat=[0 for i in range(N+1)]
pat[0]=1
if a[1]==0: pat[1]=1

for i in range(2,N+1):
    if a[i]==-1: continue
    if a[i-1]==0 and a[i-2]==0: pat[i]=pat[i-1]+pat[i-2]
    elif a[i-1]==0 and a[i-2]==-1: pat[i]=pat[i-1]
    elif a[i-1]==-1 and a[i-2]==0: pat[i]=pat[i-2]
    else: print(0),sys.exit()
    pat[i]%=MOD
print(pat[N])

Measured memory_bytes: 7856
import java.util.Arrays;
import java.util.Scanner;

/**
 * Slimes
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] L = new int[N];
            for (int i = 0; i < N; i++) {
                L[i] = sc.nextInt();
            }

            Arrays.sort(L);

            int ans = 0;

            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    for (int k = j + 1; k < N; k++) {
                        if (L[k] >= L[i] + L[j]) {
                            break;
                        }

                        ans++;
                    }
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 26720
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		cout<<a[i];
		if(i==3)
		{
			cout<<" ";
		}
	} 
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

S = input()
K = int(input())
N = len(S)
Ans = 0
i = 0
wcount = 0
Headcount = 1
Lastcount = 1
a = 0
b = N - 1

if N == 1:
  KK = K // 2
  Ans = Ans + KK
  print(Ans)
  sys.exit()

for p in range(0,N-1):
  if S[p] != S[p+1]:
    wcount = wcount + 1
    
if wcount == 0:
  KK = N * K // 2
  Ans = Ans + KK
  print(Ans)
  sys.exit()
  
while i < N-1:
  if S[i] == S[i+1]:
    Ans = Ans + 1
    i = i + 2
  else:
    i = i + 1

Ans = Ans * K

if S[N-1] == S[0]:
  while S[a] == S[a + 1]:
    Headcount = Headcount + 1
    a = a + 1
  while S[b] == S[b - 1]:
    Lastcount = Lastcount + 1
    b = b - 1  
    
  if Lastcount % 2 + Headcount % 2 == 2:
    Ans = Ans + K - 1

print(Ans)

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

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

    if(A>=B&&A>=C) A*=10;
    else if(B>=A&&B>=C) B*=10;
    else C*=10;

    cout << A+B+C << endl;
    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
A = [int(X) for X in input().split()]
Left  = [0]*(N+1)
Right = [0]*(N+1)
GCDLR = [0]*(N+1)
for T in range(0,N):
    Left[T+1] = math.gcd(Left[T],A[T])
    Right[N-T-1] = math.gcd(Right[N-T],A[N-T-1])
    
for T in range(0,N):
    GCDLR[T] = math.gcd(Left[T],Right[T+1])
print(max(GCDLR))

Measured memory_bytes: 24912
#include<bits/stdc++.h>
#define maxn 105
using namespace std;
int n;
int sum[maxn];
int main()  {
    cin>>n;
    int s=n|1;
    if (~n&1)    cout<<n*(n-1)/2-n/2<<endl; else cout<<n*(n-1)/2-(n-1)/2<<endl;
    for (int i=1;i<=n;++i)
        for (int j=1;j<i;++j)
            if (i+j!=s)
                printf("%d %d\n",i,j),sum[i]+=j,sum[j]+=i;
    for (int i=1;i<=n;++i)  assert(sum[i]==n*(n+1)/2-s);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi = vector<int>;
using vl= vector<ll>;
using vs=vector<string>;

ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a);}
ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}
ll power(ll a,ll b) {ll i,p=1; for(i=0;i<b;i++){p*=a;} return p;}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
	ll n=0;
	cin>>n;
	ll array[n]={0};
	ll hash[100001]={0};
ll sum=0;
for(int i=0;i<n;i++){
	cin>>array[i];
	hash[array[i]]++;
	sum+=array[i];
}
ll q=0;
	cin>>q;
	for(int i=0;i<q;i++){
	ll b=0,c=0;
	cin>>b>>c;
	sum+=hash[b]*c-hash[b]*b;
	hash[c]+=hash[b];
	hash[b]=0;
	cout<<sum<<"\n";
}



        }

    return 0;
}


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

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

int main()
{
    int a = 0;
    int b = 0;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}

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

int a[100009];
bool r[100009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		a[i] = 1; r[i] = false;
	}
	r[1] = true;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		a[x]--; a[y]++;
		if (r[x]) r[y] = true;
		if (a[x] == 0) r[x] = false;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (r[i])
			ans++;
	cout << ans << '\n';	
	return 0;
}

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

int main() {
  int N; cin >>N;
  int hairetsu=1e9+1;
  vector<bool> check(hairetsu);
  rep(i,0,N) {
    int A; cin >>A;
    if (check[A]) check[A]=false;
    else check[A]=true;
  }
  int ans=0;
  rep(i,0,check.size()) {
    if (check[i]) ans++;
  }
  cout <<ans <<endl;
  return 0;
}


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

using namespace std;

int main() {
  int n, w;
  cin >> n >> w;
  vector<long long> dp(w+1);
  int weight;
  long long val;
  for (int i=0; i<n; ++i) {
    cin >> weight >> val;
    for (int x = w - weight; x>=0; --x) {
      dp[x+weight] = max(dp[x+weight], dp[x] + val);
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #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...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e6;

void solve(){
    // 0<3>2>1>0<1<2>0<1<2<3<4<5>2>1>0<1

    string s;cin>>s;
    ll n=s.size();
    ll sum=0,val=0,lt=0;
    vll a={0},b(n+1,0);
    vpll v={{0,0}};
    for(ll i=0;i<n;i++){
        if(s[i]=='<'){
            lt=0;
            val++;
            sum+=val;
        }else{
            if(lt==0){
                val=0;
                lt++;
                a.pb(val);
                v.pb({val,sum});
                continue;
            }
            lt++;
            val--;
            if(val<0){
                // trace(i-lt+2,i);
                b[i-lt+2]++;b[i+1]--;
                val=0;
                sum+=lt-1;
            }else{
                sum+=val;
            }
        }
        a.pb(val);
        // v.pb({val,s2um});
        // trace(i,sum);
    }
    for(ll i=1;i<n+1;i++) b[i]+=b[i-1];
    // trace(b);
    for(ll i=0;i<n+1;i++) a[i]+=b[i];
    // trace(a);
    for(ll i=0;i<n;i++) if(s[i]=='>'&&a[i]<=a[i+1]) a[i]=a[i+1]+1;
    // trace(a);
    // trace(v);
    sum=0;
    for(ll i=0;i<n+1;i++) sum+=a[i];
    cout<<sum<<"\n";
}

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

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 12564
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = list(map(int, input().split()))
    kek = sorted(arr)
    
    cnt = 0
    for i in range(n):
        cnt += (arr[i] != kek[i])
    
    if cnt > 2:
        print("NO")
    else:
        print("YES")
    
    return 0

main()

Measured memory_bytes: 3060
n = gets.to_i
ds = gets.split.map &:to_i

if ds[0] != 0 || ds.count{ |x| x == 0} != 1 then
	puts 0
	exit
end

sum = 1

dss = ds[1..-1].group_by{|x| x}

dss.keys.sort.each_cons(2){ |x|
	if x[0] + 1 != x[1] then
		puts 0
		exit
	end
	
	sum = sum * (dss[x[0]].size ** dss[x[1]].size) % 998244353
}

puts sum

Measured memory_bytes: 24560
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            Console.WriteLine(N[1]==N[2]&&(N[0]==N[2] || N[2]==N[3])?"Yes":"No");
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
   int h, w;
   cin >> h >> w;
   vector<int>alp(26);
   vector<string>board(h);
   rep(i, 0, h)cin >> board[i];
   rep(i, 0, h){
       rep(j, 0, w){
           int p = board[i][j]-'a';
           alp[p]++;
       }
   }
   bool flag = true;
   if(h%2==0 && w%2==0){
       rep(i, 0, 26){
           if(alp[i]%4!=0)flag = false;
       }
   }else if(h%2==1 && w%2==0){
       int cnt = 0;
       rep(i, 0, 26){
           if(alp[i]%2==1)flag = false;
           else if(alp[i]%4==2)cnt++;
       }
       if(2*cnt>w)flag = false;
   }else if(h%2==0 && w%2==1){
       int cnt = 0;
       rep(i, 0, 26){
           if(alp[i]%2==1)flag = false;
           else if(alp[i]%4==2)cnt++;
       }
       if(2*cnt>h)flag = false;
   }else{
       int cnt1 = 0, cnt2 = 0;
       rep(i, 0, 26){
           if(alp[i]%4==1)cnt1++;
           else if(alp[i]%4==2)cnt2++;
       }
       if(cnt1!=1)flag = false;
       if(2*cnt2>(h-1+w-1))flag = false;
       //cout << "Pass" << endl;
   }
   if(flag)cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int n,a,n2=0,n4=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==0){
      if(a%4==0)n4++;
      else n2++;
    }
  }
  cout<<(n-n2-n4<=n4||n/2<=n4?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var k = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(a.OrderBy(x => x).Take(k).Sum());
    }
}


Measured memory_bytes: 28492
main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    ns <- map read . words <$> getLine :: IO [Int]
    print $ sim ns

sim :: [Int] -> Int
sim (a:b:ns)
    | a == (-1) = sim (b:ns)
    | a == b    = 1 + sim ((-1):ns)
    | otherwise = sim (b:ns)
sim _ = 0

Measured memory_bytes: 892
#include <stdio.h>
 
int main(void) {
    int a[100], i, n;
     
        scanf("%d", &n);
        for(i = 0; i < n; i++){
            scanf("%d", &a[i]);
        }
        for(i = n-1; i >=0; i--){
            printf("%d",a[i]);
            if(i == 0){
                break;
            }
            printf(" ");
        }
         
        printf("\n");
     
    return 0;
}

Measured memory_bytes: 2688
n=input()
l=list(map(int,input().split()))
n=int(input())
for i in range(n):
    b,e,t=map(int,input().split())
    l1=l[b:e]
    l2=l[t:t+e-b]
    l[b:e]=l2
    l[t:t+e-b]=l1
    
l3=map(str,l)
print(' '.join(map(str,l3)))


Measured memory_bytes: 5636
from collections import Counter
n=int(input())
lst=[]
for i in range(n):
    lst.append(input())
dct=Counter(lst)
try:
    print("AC x",dct["AC"])
except:
    print("AC x 0")

try:
    print("WA x",dct["WA"])
except:
    print("WA x 0")

try:
    print("TLE x",dct["TLE"])
except:
    print("TLE x 0")

try:
    print("RE x",dct["RE"])
except:
    print("RE x 0")

Measured memory_bytes: 16604
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
/*
0-1 
bfs
*/



int main(){
	int r,c;
	cin>>r>>c;	
	int x,y;
	cin>>x>>y;
	x--;
	y--;
	int w,z;
	cin>>w>>z;
	w--;
	z--;
	vector<string> s;
	rep(i,0,r){
		string p;
		cin>>p;
		s.pb(p);
	}
	
	using pii = pair<int,pair<int, int>>;
    priority_queue<pii, vector<pii>, greater<pii>> dq;
	dq.push({0,{x,y}});
	
	int dr[6] = {-2,-1,0,1,0,2};
	int dc[6] = {-2,0,-1,0,1,2};
	int ma = 1e9;
	int dp[r][c];
	rep(i,0,r){
		rep(j,0,c){
			dp[i][j] = ma;
		}
	}
	dp[x][y] = 0;
	
	
	while(!dq.empty()){
		int dis = dq.top().first;
		x = dq.top().second.first;
		y = dq.top().second.second;
		dq.pop();
		if(dis!=dp[x][y]) continue;
		rep(i,1,5){
				
						int nx = x+dr[i];
						int ny = y+dc[i];
						if(nx>=0 && nx<r && ny>=0 && ny<c){
							if(dp[nx][ny]>dp[x][y] && s[nx][ny]=='.'){
								//cout<<nx<<" "<<ny<<endl;
								dp[nx][ny]  = dp[x][y];
								dq.push({dp[nx][ny],{nx,ny}});
							}	
				}
					
		}
	
		for(auto i : dr){
			for(auto j : dc){
				
				int nx = x+i;
				int ny = y+j;
				if(nx>=0 && nx<r && ny>=0 && ny<c){
					if(dp[nx][ny]>dp[x][y]+1 && s[nx][ny]=='.'){
						//cout<<nx<<"gggggg"<<ny<<endl;
						dp[nx][ny]  = dp[x][y]+1;
						dq.push({dp[nx][ny],{nx,ny}});
					}	
				}
				
				
			}
		}
		
		
		
			
	}
	if(dp[w][z]==ma) cout<<-1;
	else cout<<dp[w][z];
	

	
	
}
		 

Measured memory_bytes: 8576
#include <stdio.h>

int main(void)
{
	int N, a;
    int min = 1001;
    int max = -1;
  
    scanf("%d", &N);
    for(int i=1; i<=N; i++){
    	scanf("%d", &a);
        if(min > a ) min=a;
        if(max < a ) max=a;
    }
    printf("%d", max-min);
}

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

int c[1001][1001];

int lcs(string X,string Y){
	

int m = X.size();
int n = Y.size();
int max1 = 0;

X = ' '+X;
Y = ' '+Y;
for(int i=1;i<=m;i++) c[i][0] = 0;
for(int j=1;j<=n;j++) c[0][j] = 0;

for(int i=1;i<=m;i++){
	for(int j=1;j<=n;j++){
		if(X[i]==Y[j]){
			c[i][j] = c[i-1][j-1]+1; 
		}
		else {
			c[i][j] = max(c[i-1][j],c[i][j-1]);
		}
		max1 = max(max1,c[i][j]);
		}
	} 
	return max1;
}



int main(){
	int q;
	string s1,s2;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>s1>>s2;
		cout<<lcs(s1,s2)<<endl;
	}
	return 0;
} 

Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> adp(n + 1, 0), bdp(n + 1, 0);
    rep(i, n) {
        ll p;
        cin >> p;
        p--;
        adp[p] += i;
        bdp[p + 1] -= i;
    }
    rep(i, n) {
        adp[i + 1] += adp[i];
        bdp[i + 1] += bdp[i];
    }
    vector<ll> a(n), b(n);
    rep(i, n) {
        a[i] = (i + 1) + adp[i];
        b[i] = (n - i) + bdp[i] + abs(bdp[n]);
    }
    rep(i, n) printf("%lld%s", a[i], (i == (n - 1)) ? "\n" : " ");
    rep(i, n) printf("%lld%s", b[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 1280
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

typedef long double ld;
typedef long long int lli;
typedef pair <lli, lli> pii;
#define pb push_back
#define recout(x) return cout << (x), 0
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
#define all(x) x.begin(), x.end()
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const lli N = 1e7 + 10, N2 = 2e5, delta = 46639, mod = 1e9 + 7, oo = 1e18, LOG = 20, SQ = 300;
const ld PI = 3.141592653589793;

bool a[25][25];
lli dp[N];

lli f (lli x) {
	return x % mod;
}

int32_t main() {
	fast;
	lli n;
	cin >> n;
	for (lli i = 0; i < n; i++)
		for (lli j = 0; j < n; j++)
			cin >> a[i][j];
	dp[0] = 1;
	for (lli mask = 1; mask < (1ll << n); mask++)
		for (lli i = 0; i < n; i++)
			if (mask & (1ll << i) && a[__builtin_popcount(mask) - 1][i])
				dp[mask] = f (dp[mask] + dp[mask ^ (1ll << i)]);
	cout << dp[(1ll << n) - 1] << '\n';
	return 0;
}


Measured memory_bytes: 18688
#include <stdio.h>

int main(){
    int i, n, f[50];

    scanf("%d",&n);

    f[0]=1;
    f[1]=1;

    for(i=2; i<n+2; i++)
        f[i] = f[i-1] + f[i-2];

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

    return 0;
}



Measured memory_bytes: 2112
use std::io::*;
use std::str::FromStr;

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

#[allow(dead_code)]
fn naive(a: i64, b: i64, c: i64, d: i64) -> bool {
    let mut cnt = a;
    let mut visited = vec![false; (a + c + d + 1) as usize];
    while !visited[cnt as usize] {
        println!("{}", cnt);
        visited[cnt as usize] = true;
        if cnt < b {
            return false;
        }
        cnt -= b;
        if cnt <= c {
            cnt += d;
        }
    }
    return true;
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn solve(a: i64, b: i64, c: i64, d: i64) -> bool {
    if a < b || d < b {
        return false;
    }
    if a <= c || b <= c {
        return true;
    }
    let offset = a - (a - c) / b * b - c;
    let mut diff = d - b;
    if diff == 0 {
        return c + offset >= b;
    }
    assert!(offset >= 0);
    let g = gcd(d, diff);
    let mut min_value = c + offset % g;
    if min_value == c {
        min_value += g;
    }
    // println!("{} {} {} {} {}", diff, offset, g, offset % g, min_value);
    min_value >= b
}

fn main() {
    let t = read::<usize>();
    for _ in 0..t {
        let a = read::<i64>();
        let b = read::<i64>();
        let c = read::<i64>();
        let d = read::<i64>();
        // assert!(naive(a, b, c, d) == solve(a, b, c, d));
        // println!("{}", if naive(a, b, c, d) { "Yes" } else { "No" });
        println!("{}", if solve(a, b, c, d) { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll h = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        if(a < h) ans += h - a;
        h = max(a, h);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {

  ll N;
  cin>>N;
  ll ans=0;
  string S;
  FOR(i,0,40){
    ll mods = myPow(2,i+1,LLONG_MAX);
    //cout<<mods<<endl;
    if(N%mods!=0){
      ans=ans+myPow(10,i,LLONG_MAX);
      N=N-myPow(-2,i,LLONG_MAX);
      //cout<<myPow(10,i,LLONG_MAX)<<endl;
      S.append("1");
    }else{
      S.append("0");
    }
    //cout<<N<<" "<<ans<<endl;
    if(N==0)break;

  }




  //cout<<S<<endl;
  FOR(i,0,S.size()-1){
    cout<<S[S.size()-1-i];
  }
  cout<<endl;


  return 0;
}
 


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	int ans=0;
	rep(i,n)rep(j,n){
		if(i==j) continue;
		chmax(ans,abs(a[i]-a[j]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
cc = []
aa = []
for _ in range(n):
    c,*a = [int(i) for i in input().split()]
    cc.append(c)
    aa.append(a)
ans = 10**18
for i in range(2**n):
    ri = [0]*m
    co = 0
    for j in range(n):
        if (i>>j) & 1 == 1:
            co += cc[j]
            for k in range(m):
                ri[k] += aa[j][k]
                
    for j in ri:
        if j < x:
            break
    else:
        ans = min(ans,co)
        
if ans == 10**18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68688
/*                        
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************
   
   
   
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE 
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
 
*/     

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {
    
    FASTIO;
    
    ll n, ans=0;
    cin >> n;
    vector<ll> v;
    for(ll i=0; i<n; i++){
        ll a;
        cin >> a;
        v.push_back(a);
    }
    map<ll, ll> id;
        
    for(auto u : v) id[u]++;
    
    for( auto u : id){
        if(u.first>u.second) ans+=u.second;
        else if(u.first<u.second) ans+=(u.second-u.first);
    }
    
    cout << ans << endl;
    
    
	return 0;
}

Measured memory_bytes: 9972
#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<stack>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int MAX = 1000010;
bool prime[MAX+2];
 
 
 
 
class AOJ2048{
private:
  int a,b;
  vector<int> A,B;
public:
  AOJ2048(int a,int b):a(a),b(b){}
    
  
 
  vector<int> div(int num){
    vector<int> vec;
    for(int i=2;i<=num/2+1;i++){
      if(num%i == 0){
    vec.pb(i);
    //cout << "pre " << num << endl;
    while(num%i == 0)
      num = num/i;
    //cout << "after " << num << endl << endl;
    if(num == 1)break;
      }
    }
    if(num != 1)vec.pb(num);
    // rep(i,vec.size()){
    //cout <<"vec = " << vec[i] << endl;
    // }
    return vec;
  }
 
  void run(){
    
    A = div(a);
    B = div(b);
    ll totalA,totalB;
    totalA = totalB = 0;
    int maxa,maxb;
    maxa=maxb=0;
    rep(i,A.size()){
      if(prime[A[i]]){
    maxa = max(maxa,A[i]);
    totalA += A[i];
      }
      //cout << "a = " << A[i] << endl;
    }   
 
    rep(i,B.size()){
      if(prime[B[i]]){
      maxb = max(maxb,B[i]);
      totalB += B[i];
      }
    }   
    totalA -= maxa;
    maxa -= totalA;
    totalB -= maxb;
    maxb -= totalB;
    if(maxa > maxb){
      cout << 'a' << endl;
    }
    else cout << 'b' << endl;
 
  }
 
 
};
 
void eratos(){
  rep(i,MAX+1)prime[i] = false;
  for(int i=3;i<=MAX;i+=2)prime[i] = true;
  prime[2] = true;
  int lim = (int)sqrt((double)MAX)+1;
  for(int i=3;i<=lim;i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<=MAX;j+=i)prime[j] = false;
  }
}
 
int main(){
  int Aa,Ba;
    eratos();
   
    while(true){
      cin >> Aa >> Ba;
      if(Aa+Ba == 0)break;
      AOJ2048 ans = AOJ2048(Aa,Ba);
      ans.run();
    }
return 0;
}

Measured memory_bytes: 2184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	char ca;
	cin>>ca;
	vector<char> a(26),b(26);
	for(int i=65; i<91; i++){
		a[i-65]=i;
	}
	for(int i=97; i<123; i++){
		b[i-97] = i;
	}
	
	for(int it=0; it<26; it++){
		if(a[it] == ca){
		 	cout<<"A";
		 	break;
		}
	}
	for(int it=0; it<26; it++){
		if(b[it] == ca){
		 	cout<<"a";
		 	break;
		}
	}
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
const int MAX_N=300;
int N;
double memo[MAX_N+1][MAX_N+1][MAX_N+1];
double dfs(int a,int b,int c){
    if(a+b+c==0) return 0;
    if(memo[a][b][c]!=0) return memo[a][b][c];
    double ret=0;
    double p=(double)a/(double)N,
           q=(double)b/(double)N,
           r=(double)c/(double)N;
    if(a>0) ret+=dfs(a-1,b,c)*p/(p+q+r);
    if(b>0) ret+=dfs(a+1,b-1,c)*q/(p+q+r);
    if(c>0) ret+=dfs(a,b+1,c-1)*r/(p+q+r);
    ret+=1.0/(p+q+r);
    return memo[a][b][c] = ret;
}

signed main(){
	cin>>N;
    int a[4]={};
    REP(i,N){
        int x;
        cin>>x;
        a[x]++;
    }
    printf("%.16f\n",dfs(a[1],a[2],a[3]));
}

Measured memory_bytes: 213248
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>
using namespace std;
#define int long long

signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> a(n);
    for (int i = 0; i != n; ++i)
        cin >> a[i];
    sort(a.rbegin(), a.rend());
    int l = p - 1, r = n - 1;
    while (l < r) {
        int x = (l + r + 1) / 2;
        if (a[x] + m < a[p - 1]) {
            r = x - 1;
            continue;
        }
        int can = (p - 1) * m + (n - x) * m;
        for (int i = p - 1; i < x; ++i)
            can += max(0LL, a[x] + m - a[i]);
        if (can >= m * v)
            l = x;
        else
            r = x - 1;
    }
    cout << l + 1;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll treasure[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	for (ll i = 1;i <= 3500;++i) {
		for (ll j = 1;j <= 3500;++j) {
			ll bunsi = 4 * i * j - j * n - i * n;
			if (bunsi <= 0)continue;
			ll bunbo = i * j * n;
			if (bunbo % bunsi == 0) {
				ll k = bunbo / bunsi;
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	char A, B, C;
	cin >> A >> B >> C;
	if (A == B && B == C) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256