akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void write(int x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
ll n,a,b,c,d;
inline ll pd(ll x)
{
	ll t1=x*d;
	ll t2=(n-x-1)*c;
	ll t3=b-a;
	ll t4=x*c;
	ll t5=(n-x-1)*d;
	ll minn=t4-t5;
	ll maxn=t1-t2;
	if(t3<=maxn && t3>=minn) return 0;
	if(t3>maxn) return 1;
	return -1;
}
int main()
{
    cin>>n>>a>>b>>c>>d;
    if(a>b)
        swap(a,b);
    ll l=0,r=n-1;
    while(l<=r)
    {
    	ll mid=(l+r+1)/2;
    	ll k=pd(mid);
		if(k==0)
		{
    		cout<<"YES"<<endl;
            return 0;
    	}
    	if(k==1)
            l=mid+1;
    	else r=mid-1;
	}
	cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()) {
        if (s[i] == '+') ++ans;
        else --ans;
    }

    out(ans);

    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int a,b;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>a>>b;
    if(a<=b){
        for(int i=1;i<=b;i++) cout<<a;cout<<newl;
    }
    else{
        for(int i=1;i<=a;i++) cout<<b;cout<<newl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll x,k,d,ans;
    
    
    cin >> x >> k >> d;
    ll new_x = abs(x);
    ll amari = new_x%d;
    //<<amari<<endl;
    //cout<<new_x<<endl;
    if(new_x/k>=d){
        ans = new_x-(k*d);
        //cout<<ans<<endl;
    }else if(new_x%d==0){
        ll a = new_x/d;
        if((a-k)%2==0){
            ans = 0;
            //cout<<0<<endl;
        }else{
            ans = d;
            //cout<<d<<endl;
        }
    }else{
        ll a = new_x/d;
        if((a-k)%2==0){
            ans = amari;
            //cout<<ans<<endl;
        }else{
            ans = d-amari;
            //cout<<ans<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ios>
#include <iomanip>
#include <bitset>
#include <cstdlib>

#define INF 200000000
#define MOD 1000000007
//#define int long long int
#define ll long long int
#define _tilde_ ~

using namespace std;

int main()
{
    /*
    string s;
    cin >> s;

    int sum = 0;
    for(int BIT = 0 ; BIT < (1 << s.size()); ++BIT)
    {
        int tmp = 0;
        //cout << BIT << endl;
        for(int i = 0;i<s.size();++i){
            if(BIT & (1 << i) || i == (int)s.size()-1 )
            {
                string str = s.substr(tmp,i-tmp);
                cout <<" " <<  str;
                //sum += stoi(str);
                tmp = i;
            }
        }
        cout << endl;
    }
    //cout << sum << endl;
*/
    int a,b;
    cin >> a >> b;
    if(a>=13)
    {
        cout << b << endl; return 0;
    }else if(a>=6)
    {
        cout << b/2 << endl;
        return 0;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


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

int main()
{

  int N;

  cin >> N;

  if (N % 2 == 0)
  {
    cout << fixed << setprecision(10) << 0.5;
  }
  else if (N % 2 == 1)
  {
    double n = N;
    cout << fixed << setprecision(10) << ((N / 2) + 1) / n;
  }
}


Measured memory_bytes: 256
from sys import stdin


def main():
    S = stdin.readline().rstrip()
    T = stdin.readline().rstrip()
    for _ in range(len(T)):
        T = T[-1] + T[:-1]
        if S == T:
            print('Yes')
            break
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            ReadLine();
            var AN = Sarray();
            BigInteger sum = 1;
            if(AN.Contains(0))
            {
                WriteLine(0);
                return;
            }
            foreach (var A in AN)
            {
                sum *= A;
                if (1000000000000000000 < sum)
                {
                    WriteLine(-1);
                    return;
                }
            }
            WriteLine(sum);
        }

    }
}


Measured memory_bytes: 41840
order_times = []
n = 0
x = 0
5.times do
    order_times << gets.chomp.to_i
end

jast = order_times.select {|a| a % 10 == 0}
order_times.delete_if {|a| a % 10 == 0}
order_times.sort!{|a,b|b%10<=>a%10}
order_times = jast + order_times

order_times.each do |a|
    if x == 4
        break
    end

    if (n + a)%10 == 0
        n = (n + a)
    else
        m = (n + a)%10
        o = 10 - m
        n = n + a + o
    end
    x += 1
end

if n + order_times[4] == 0
    puts n
else
    puts order_times[4] + n
end

Measured memory_bytes: 1788
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
ll h,w,a,b,f[N];
ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
ll inv(ll x){
	return expo(x,hell-2,hell);
}
ll cal(ll x,ll y){
	return ((f[x]*inv(f[y]))%hell*inv(f[x-y]))%hell;
}
int main()
{
	ios
	ll i,j;
	f[0]=1;
	for(i=1;i<N;i++)
		f[i]=(f[i-1]*i)%hell;
	cin>>h>>w>>a>>b;
	ll ans=0;
	for(i=1;i<=h-a;i++){
		ans+=(cal(i+b-2,i-1)*cal(w-(b+1)+h-i,w-(b+1)))%hell;
		ans%=hell;
	}
	cout<<ans;
	return 0;
}

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

struct edge {
    int to, cap, rev;
};

using edges = vector<edge>;
using graph = vector<edges>;

int dfs(graph& g, vector<bool>& used, int v, int t, int f) {
    if(v == t) {
        return f;
    }
    used[v] = true;
    for(int i=0; i<g[v].size(); ++i) {
        edge& e = g[v][i];
        if(!used[e.to] && e.cap > 0) {
            int d = dfs(g, used, e.to, t, min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap = d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(graph& g, int s, int t) {
    int flow = 0;
    int INF = 1e9;
    vector<bool> used(g.size());
    while(true) {
        fill(used.begin(), used.end(), false);
        int f = dfs(g, used, s, t, INF);
        if(f == 0) {
            return flow;
        }
        flow += f;
    }
}

pair<int, int> add_edge(graph& g, int from, int to, int cap) {
    g[from].push_back(edge{to, cap, static_cast<int>(g[to].size())});
    g[to].push_back(edge{from, 0, static_cast<int>(g[from].size()-1)});
    return make_pair(from, (int)g[from].size()-1);
}

int main() {
    int N, M;
    cin >> N >> M;
    graph g(N);
    vector<pair<int, int>> idx(M);
    for(int i=0; i<M; ++i) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        add_edge(g, x, y, 1);
        idx[i] = add_edge(g, y, x, 1);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    int flow = max_flow(g, s, t);
    vector<int> res;
    for(int i=0; i<M; ++i) {
        if(g[idx[i].first][idx[i].second].cap == 0) {
            res.push_back(i+1);
        }
    }
    cout << flow << endl;
    cout << res.size() << endl;
    for(auto x : res) {
        cout << x << endl;
    }
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,m,p[2005][2005],s[2005][2005],k[2005][2005],ans,x,y;

char a[2005][2005];

vector <int> q;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> a[i][j];
            if(i==1 || j==1) continue;
            int t=0;
            if(a[i][j]=='#') t++;
            if(a[i-1][j]=='#') t++;
            if(a[i][j-1]=='#') t++;
            if(a[i-1][j-1]=='#') t++;
            if(!(t%2)) p[i][j]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(p[i][j]==0) continue;
            else s[i][j]=s[i-1][j]+1;
        }
    }
    for(int i=1;i<=n;i++){
        q.clear(); q.push_back(1);
        for(int j=2;j<=m;j++){
            while(q.size() && s[i][j]<=s[i][q[q.size()-1]]){
                int u=s[i][q[q.size()-1]],v=j-q[q.size()-1]+k[i][q[q.size()-1]];
                if(u && v && (u+1)*(v+1)>ans) ans=(u+1)*(v+1);
                k[i][j]+=k[i][q[q.size()-1]]+1;
                q.pop_back();
            }
            q.push_back(j);
        }
        while(q.size()){
            int u=s[i][q[q.size()-1]],v=m-q[q.size()-1]+1+k[i][q[q.size()-1]];
            if(u && v && (u+1)*(v+1)>ans) ans=(u+1)*(v+1);
            q.pop_back();
        }
    }
    ans=max(ans,n); ans=max(ans,m);
    cout << ans;
}


Measured memory_bytes: 51328
n=int(input())
ans=0
def yakusu(n):
    cnt=0
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            cnt+=1
            if i**2!=n:
                cnt+=1
    return cnt
for i in range(1,n+1,2):
    if yakusu(i)==8:
        ans+=1    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

VI graf[N], vec;
int vis[N], res[N], a, b, i, maxx, n, m;

void dfs(int w) {
	vis[w] = 1;
	for (auto &w2 : graf[w]) if (!vis[w2]) dfs(w2);
	vec.pb(w);
}
	
int main() {
scanf("%d %d", &n, &m);
for (i=1;i<=n;i++) {
	graf[i].clear();
	vis[i] = 0;
	res[i] = 0;
}
while (m--) {
	scanf("%d %d", &a, &b);
	graf[a].pb(b);
}
for (i=1;i<=n;i++) if (!vis[i]) dfs(i);
maxx = 0;
for (auto &w : vec) {
	res[w] = 0;
	for (auto &w2 : graf[w]) res[w] = max(res[w], res[w2] + 1);
	maxx = max(maxx, res[w]);
}
printf("%d\n", maxx);
return 0;
}

Measured memory_bytes: 9212
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;

const int N = 1e6 + 10;
char s[N];

int main() {
	scanf("%s", s + 1);
	int len = strlen(s + 1);
	ll ans = 0;
	ll last = 0;
	for (int i = 1; i <= len; i++) {
		if (s[i] == 'A') {
			if (s[i - 1] == 'B' && last > 0) last = 0;
			last++;
		} else if (s[i] == 'B') {
			if (last > 0 && s[i - 1] == 'B') last = 0;
		} else {
			if (last > 0 && s[i - 1] == 'B') ans += last;
			else last = 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# 方針
# 前から順に-1していく
# その際、常に前の数を見ておき、0になった場合一区切り
# カウンターを+1する
# また、最後の項に達したときも+1
# インデックスは先頭に戻して
# 全ての項が0になるまで繰り返す
# （全部0になったことを確認するため、初めにsumを取って
# 引き算するたびにsumも-1していき、0になったらループ脱出）

def main():
  n=I()
  l=LI()

  sm=sum(l)

  i=0
  c=0
  while True:

    # print(l)
    # print(c)

    if l[i]!=0:
      l[i]-=1
      sm-=1

      if i==n-1 or l[i+1]==0:
        c+=1

    i+=1
    if i>=n:
      i=0

      if sm==0:
        break

  return c

print(main())


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

void solve(int m, vector<int>h){
    vector<int>cost(m);
    cost[0] = 0;
    cost[1] = abs( h[0] - h[1] );
    for (int i=2; i<m; i++){
        cost[i] = min(
            ( cost[i-1] + abs( h[i] - h[i-1] ) ),
            ( cost[i-2] + abs( h[i] - h[i-2 ]) )
        );
    }
    cout << cost[m-1];
}

int main(){
    int n; cin>>n;
    vector<int>h(n); rep(i,n) cin>>h[i];
    solve(n,h);
}

Measured memory_bytes: 4584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,i;
    cin>>n>>i;
    cout<<n-i+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MAXN = 200005;
int a[MAXN];
long long sum[MAXN];
vector<int>ss;

int main()
{
    int n;
    cin>>n;
    for(int y = 1;y<=n;y++)
    {
        cout<<"ACL";
    }

    return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
void print(string S,int N,char m){
  if(N==0)cout<<S<<endl;
  else for(char a='a';a-m<=1;a++)print(S+a,N-1,max(a,m));
}
int main(){
  int N;cin>>N;string S="a";
  print(S,N-1,'a');
}


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

int main(){
  int n;
  cin >> n;
  vector<int> A(n+10);
  vector<int> B(n+10);
  for(int i = 2;i <= n;++i){
    cin >> A[i];
    B[A[i]] += 1;
  }
  rep(i,n){
    cout << B[i] << endl;
  }
  return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int n;
    cin >> n;

    if(n%1000 == 0){
        cout << 0 << endl;
    }
    else{
        int t = n / 1000;
        cout << (t+1)*1000 - n << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-

n = int(input())
x = [list(map(int, input().split())) for _ in range(2)]

s = 0
sum = []

for i in range(len(x[0])):
    for j in range(i+1):
        s += x[0][j]
    for j in range(i, len(x[0])):
        s += x[1][j]
    sum.append(s)
    s = 0

print(max(sum))
    

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

#define fo(i, n) for(i = 0; i < n; i++)
#define of(i, n) for(i = n - 1; i >= 0; i--)
#define ll long long

bool comp(int a, int b)
{
    return (a < b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k,max=0,flag=0,cnt=0,m,i,j,sum=0,t,y,a,b;
    long long x,ans,min;
    float n;
    cin>>n;
    cout<<ceil(n/2);
}



Measured memory_bytes: 256
from collections import Counter
MOD = 998244353
n = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
else:
    cnt = Counter(D[1:])
    if 0 < cnt[0]:
        print(0)
    else:
        U = 10**5
        ans = 1
        prev_v = 1
        for i in range(1, U):
            ans *= pow(prev_v, cnt[i], MOD)
            ans %= MOD
            prev_v = cnt[i]
        print(ans)


Measured memory_bytes: 25028
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;

char a[20][20], b[20][20];
int to[20], vis[20], vvv[20];
int n, m, last;

int check(){
	memset(vvv, 0, sizeof(vvv));
	int tot = m;
	for (int i = 0; i < m; i++){
		if (vvv[i]) continue;
		for (int j = 0; j < m; j++){
			if (vvv[j] || i == j) continue;
			int flag = 1;
			for (int k = 0; k < n; k++){
				flag &= a[k][i] == a[to[k]][j];
			}
			if (flag){
				vvv[i] = vvv[j] = 1, tot -= 2;
				break;
			}
		}
	}
	if (tot >= 2) return 0;
	if (tot == 1 && m % 2 == 0) return 0;
	if (tot == 0) return 1;
	for (int i = 0; i < m; i++){
		if (vvv[i]) continue;
		for (int j = 0; j < n; j++){
			if (a[j][i] != a[to[j]][i]) return 0;
		}
		return 1;
	}
}

int dfs(int now){
	if (last == 0) return check();
	if (vis[now]) return dfs(now + 1);
	for (int i = now + (1 - last % 2); i < n; i++){
		if (vis[i]) continue;
		vis[i] = vis[now] = 1, to[now] = i, to[i] = now, last -= 2 - (i == now);
		if (dfs(now + 1)) return 1;
		vis[i] = vis[now] = 0, to[now] = to[i] = -1, last += 2 - (i == now);
	}
	return 0;
}

int main(){
	memset(to, -1, sizeof(to));
	scanf("%d%d", &n, &m), last = n;
	for (int i = 0; i < n; i++){
		scanf("%s", a[i]);
	}
	if (dfs(0)) printf("YES\n");
	else printf("NO\n");
	return 0;
}


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

int main() {
  int a, b, c; cin >> a >> b >> c;
  int sum = a + b + c;
  int x = max({a, b, c});
  if (x == sum - x) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

typedef pair<ll, int> P;

int N, M;
P p[100000];

int main() {
    scanf("%d %d", &N, &M);
    rep(i, N) {
        scanf("%lld %d", &p[i].first, &p[i].second);
    }
    sort(p, p + N);
    ll cost = 0;
    int m = M;
    rep(i, N) {
        if (m <= 0) break;
        ll price = p[i].first;
        int num = p[i].second;
        int n = min(m, num);
        cost += price * n;
        m -= n;
    }
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a[] = new int[n];
            Set<Integer> cnt = new HashSet<>();
            int overred = 0;
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                if (a[i] <= 399) cnt.add(0);
                if (400 <= a[i] && a[i] <= 799) cnt.add(1);
                if (800 <= a[i] && a[i] <= 1199) cnt.add(2);
                if (1200 <= a[i] && a[i] <= 1599) cnt.add(3);
                if (1600 <= a[i] && a[i] <= 1999) cnt.add(4);
                if (2000 <= a[i] && a[i] <= 2399) cnt.add(5);
                if (2400 <= a[i] && a[i] <= 2799) cnt.add(6);
                if (2800 <= a[i] && a[i] <= 3199) cnt.add(7);
                if (3200 <= a[i]) overred++;
            }
            int ansmx = cnt.size() + overred;
            int ansmn = cnt.size();
            if (cnt.size() == 0) ansmn = 1;

            // 出力
            out.println(ansmn + " " + ansmx);

        }

    }
}



Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  long long int A[N], B[N], b, ans=0;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) B[i] = A[i] - i;
  sort(B, B+N);
  b = B[N/2];
  for(int i=0; i<N; i++) ans += abs(A[i]-(b+i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include<vector>
#include<algorithm>
#include <set>
#include<cmath>
//#include<dequeue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;
vector<int>li[100000];
int main()
{
    int n;
    scanf("%d",&n);
    forn(i,n-1)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        li[x-1].pb(i);
        li[y-1].pb(i);
    }
    int maxx=0;
    vector<int>color(n-1);
//    color[0]=1;
    forn(i,n)
    {
        int sz=li[i].size();
        maxx=max(sz,maxx);
        int col=1;
        set<int>tmp;
        tmp.clear();
//        set<int>::iterator it;
        forn(j,sz)
        {
//            printf("%d %d %d\n",i,j,color[li[i][j]]);
            if(color[li[i][j]]>0)
            {
                tmp.insert(color[li[i][j]]);
            }
        }
        forn(j,sz)
        {
//            printf("%d a ",col);
            if(tmp.find(col)!=tmp.end())col++;
//            printf("%d\n",col);
            if(color[li[i][j]]==0)
            {
                color[li[i][j]]=col;
                col++;
            }
        }
    }
    printf("%d\n",maxx);
    forn(i,n-1)
    {
        printf("%d\n",color[i]);
    }
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <string>

using namespace std;

bool IsPalin(const string &S, int start, int end) {
    int N = end - start + 1;
    for (int i=0; i<N; i++) {
        if (S[start+i] != S[end-i]) {
            return false;
        }
    }
    return true;
}
int main() {
    string S;
    cin >> S;

    int N = S.length();
    if (IsPalin(S, 0, N-1) &&
        IsPalin(S, 0, (N-1)/2-1) &&
        IsPalin(S, (N+3)/2-1, N-1)) {
            cout << "Yes" << endl;
        }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int N;
    cin >> N;
    
    for(ll h=1;h<=3500;h++){
        for(ll n=1;n<=3500;n++){
            ll l = N*h*n;
            ll r = 4*h*n-N*(n+h);
            if(r>0&&l%r==0){
                ll w = l/r;
                cout << h<<space<<n<<space<<w<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Transparent Mahjong
public class Main{

	int[] c, use;
	int free = 0;
	
	boolean f(int k, int u){
		if(free < u)return false;
		if(k==13){
			int F = 0;
			for(int i=1;i<=12;i++){
				F += Math.max(0, use[i]-c[i]);
				if(use[i]<c[i] || 4<use[i])return false;
			}
			return F==free;
		}
		if(4<use[k])return false;
		if(use[k]<=1){
			int d = Math.max(0, 3-(c[k]-use[k]));
			use[k]+=3;
			if(f(k, u+d))return true;
			use[k]-=3;
		}
		if(c[k]<=use[k] && f(k+1, u))return true;
		if(k<=10){
			for(int i=1;i<=4;i++){
				int d = 0;
				for(int j=k;j<k+3;j++){
					d += Math.max(0, i-(c[j]-use[j]));
					use[j]+=i;
				}
				if(f(k+1, u+d))return true;
				for(int j=k;j<k+3;j++)use[j]-=i;
			}
		}
		return false;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		c = new int[13];
		use = new int[13];
		for(int i=0;i<3*n+1;i++){
			String s = sc.next();
			if("*".equals(s))free++;
			else c[Integer.parseInt(s)]++;
		}
		List<Integer> res = new ArrayList<Integer>();
		for(int i=1;i<=12;i++){
			if(c[i]<4){
				c[i]++;
				for(int j=1;j<=12;j++){
					Arrays.fill(use, 0);
					use[j] = 2;
					if(f(1, 0)){
						res.add(i);
						break;
					}
				}
				c[i]--;
			}
		}
		if(res.isEmpty())System.out.println(-1);
		else for(int x:res)System.out.println(x);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

//    	File file = new File("input.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	if(A == B){
    		System.out.println(C);
    	}else{
    		if(A == C){
    			System.out.println(B);
    		}else{
    			System.out.println(A);
    		}
    	}
    }
}

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


int r,c;
char mapp[1000][1000];
int dx[8]={-1,1,-1,1,1,-1,0,0};
int dy[8]={0,1,1,-1,0,-1,-1,1}; 


int sweep(int x,int y)
{
	int ans=0;
	for(int i=0; i<8; ++i){
		int newx=dx[i]+x;
		int newy=dy[i]+y;
		if(newx>0&&newx<=r&&newy>0&&newy<=c)
		{
			if(mapp[newx][newy]=='#') ++ans;
		}
	}
	return ans;
}


int main(){
	scanf("%d%d",&r,&c);
	for(int i=1; i<=r; ++i){
		for(int j=1; j<=c; ++j){
			cin>>mapp[i][j];
		}
	}
	for(int i=1; i<=r; ++i){
		for(int j=1; j<=c; ++j){
			if(mapp[i][j]!='#') mapp[i][j]=sweep(i,j);
		}
	}
	for(int i=1; i<=r; ++i){
		for(int j=1; j<=c; ++j){
			if(mapp[i][j]!='#') printf("%c",mapp[i][j]+'0');
			else printf("#");
		}
		printf("\n");
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

char piece[9][4];

void rot(int i) {
  rep (j, 3) swap(piece[i][j], piece[i][j + 1]);
}

bool ok(char a, char b) {return (a ^ b) == 32;}

int solve(int i, int j) {
  int res = 0;
  rep (k, 4) {
    rot(i * 3 + j);
    if (i > 0 && !ok(piece[i * 3 + j][0], piece[i * 3 + j - 3][2])) continue;
    if (j > 0 && !ok(piece[i * 3 + j][1], piece[i * 3 + j - 1][3])) continue;
    if (j == 2) {
      if (i == 2) ++res;
      else res += solve(i + 1, 0);
    } else {
      res += solve(i, j + 1);
    }
  }
  return res;
}

bool mem[9][9];

bool check(vector<int> per) {
  rep (i, 3) rep (j, 3) {
    if (i > 0) if (!mem[per[i * 3 + j]][per[i * 3 + j - 3]]) return false;
    if (j > 0) if (!mem[per[i * 3 + j]][per[i * 3 + j - 1]]) return false;
  }
  return true;
}

void solve() {
  vector<string> p(9);
  rep (i, 9) cin >> p[i];
  rep (i, 9) rep (j, 9) mem[i][j] = false;
  rep (i, 9) rep (j, 9) rep (k1, 4) rep (k2, 4) if (ok(p[i][k1], p[j][k2])) mem[i][j] = true;
  vector<int> per;
  rep (i, 9) per.push_back(i);
  int res = 0;
  do {
    if (!check(per)) continue;
    rep (i, 9) rep (j, 4) piece[i][j] = p[per[i]][j];
    res += solve(0, 0);
  } while (next_permutation(per.begin(), per.end()));
  cout << res << endl;
}

int main() {
  int n;
  cin >> n;
  rep (i, n) solve();
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll n, m; cin >> n >> m;
  Vi is_danger(n + 10, 0);
  REP(i, m){
    ll a; cin >> a;
    is_danger[a] = 1;
  }
  Vi num(n + 10);
  num[0] = 1;
  REP(i, n){
    if(is_danger[i + 1] == 0) num[i + 1] += num[i]; num[i + 1] %= MOD;
    if(is_danger[i + 2] == 0) num[i + 2] += num[i]; num[i + 2] %= MOD;
  }
  cout << num[n] << endl;
}


Measured memory_bytes: 1792
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

H,W=get_i
c=array(H)
H.times do|i|
    c[i]=get_nsp
end
H.times do|i|
    2.times do
        puts c[i].join("")
    end
end

Measured memory_bytes: 2300
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

#define SIZE 10
Vec<Vec<int>> table(10, Vec<int>(10));
bool detection (int array[5]);

int main(void) {
    FOR(i, 0, 10) {
        FOR(j, 0, 10) {
            cin >> table[i][j];
        }
    }
    int count = 0;
    FOR(a, 0, 10) {
        FOR(b, 0, 10) {
            FOR(c, 0, 10) {
                FOR(d, 0, 10) {
                    int e = table[table[table[table[0][a]][b]][c]][d];
                    int array[5] = {a, b, c, d, e};
                    if (detection(array) == false) {
                        count++;
                    }
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

bool detection (int array[5]) {
    bool detect = true;
    FOR(i, 0, 10) {
        FOR(j, 0, 5) {
            if (i == array[j]) {
                continue;
            }
            int temp = array[j];
            array[j] = i;
            if (table[table[table[table[table[0][array[0]]][array[1]]][array[2]]][array[3]]][array[4]] == 0) {
                detect = false;
            }
            array[j] = temp;
        }
    }
    FOR (i, 0, 4) {
        if (array[i] == array[i + 1]) {
            continue;
        }
        swap(array[i], array[i + 1]);
        if (table[table[table[table[table[0][array[0]]][array[1]]][array[2]]][array[3]]][array[4]] == 0) {
            detect = false;
        }
        swap(array[i], array[i + 1]);
    }
    return detect;
}

Measured memory_bytes: 3156
i,A,B = map(int,input().split())
X=0
import math

for n in range(i+1):
    N = n%10 + math.floor((n/10)%10) + math.floor((n/100)%10) + math.floor((n/1000)%10) + math.floor((n/10000)%10)
    if A <= N <= B:
        X = X+n
        
print(X)


Measured memory_bytes: 9172
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace program
{
    class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine($"{input.Sum() - input.Max()}");
            Console.ReadKey();
        }
    }
}


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

class smart_sieve
{
    intmax_t L, R, M;
    vector<int> small;
    vector<vector<intmax_t>> large;
    vector<intmax_t> aux;

public:
    smart_sieve(intmax_t L, intmax_t R): L(L), R(R), M(sqrt(R)+1)
    {
        small.resize(M);
        iota(small.begin(), small.end(), 0);
        large.resize(R-L);
        aux.assign(R-L, 1);

        for(intmax_t i=2; i*i<R; i++)
        {
            if(small.at(i) < i) continue;
            small.at(i) = i;
            for(intmax_t j=i*i; j<M; j+=i)
                if(small.at(j) == j) small.at(j) = i;
            
            for(intmax_t j=(L+i-1)/i*i; j<R; j+=i)
            {
                intmax_t k=j;
                do
                {
                    if(aux.at(j-L)*aux.at(j-L) > R) break;
                    large.at(j-L).push_back(i);
                    aux.at(j-L) *= i;
                    k /= i;
                } while (k%i == 0);
            }
        }
    }
    vector<intmax_t> factor(intmax_t n)
    {
        assert(L <= n && n < R);
        vector<intmax_t> res = large.at(n-L);
        n /= aux.at(n-L);
        if(n >= M)
        {
            res.push_back(n);
            return res;
        }
        while(n > 1)
        {
            res.push_back(small.at(n));
            n /= small.at(n);
        }
        return res;
    }
};

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

    smart_sieve ss(n, n+1);
    vector<intmax_t> vec = ss.factor(n);
    int ans = 0;
    int insu = 1;
    int nax = 1;
    int cnum = 1;
    for(auto num : vec)
    {
        if(insu != num)
        {
            insu = num;
            cnum = 1;
            nax = num;
            ans++;
        }
        else if(nax < cnum * num)
        {
            nax = cnum * num;
            cnum = 1;
            ans++;
        }
        else
        {
            cnum *= num;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
class Solution
{
public:
    long long q,a,b,c,d;
    char str[200];
    Solution()
    {
        memset(str,0,sizeof(str));
    }
    void slove()
    {
        long long q;
        scanf("%lld",&q);
        while(q--)
        {
            scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
            long long minn = min(a,b);
            long long maxx = max(a,b);
            long long k = maxx/(minn+1);
            if(maxx%(minn+1))
                k++;
            long long l = 0,r = a+b,id = -1;
            while(l <= r)
            {
                long long mid = (l+r)/2;
                if(check(mid,k))
                    id = mid, l = mid + 1;
                else r = mid - 1;
            }
            id++;
            long long ln = 0;
            long long rn = d - c;
            for(long long i = c; i <= min(id,d); i++)
                str[ln++] = i%(k+1)==0?'B':'A';
            for(long long i = d; i >= max(id+1,c); i--)
                str[rn--] = (a + b - i + 1)%(k+1)==0?'A':'B';
            for(long long i = 0; i <= d-c; i++)
                printf("%c",str[i]);
            printf("\n");
        }
    }
    bool check(long long mid,long long k)
    {
        long long s_a = mid/(k+1)*k;
        s_a += mid%(k+1);
        long long s_b = mid/(k+1);
        s_a = a - s_a;
        s_b = b - s_b;
        if(s_a*k >= s_b)
            return true;
        return false;
    }
};
int  main(void)
{
    Solution A;
    long long c = 0;
    A.slove();
    return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] l = new int[n];
        int sum = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
            if (max < l[i]) {
                max = l[i];
            }
            sum += l[i];
        }
        if (sum - max > max) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n)
    {
        cin >> a[i];
    }

    rep(i, n)
    {
        mp[a[i]]++;
    }
    int ans = 0;
    for (auto p : mp)
    {
        int x = p.first;
        int cnt = p.second;
        if (cnt < x)
        {
            ans += cnt;
        }
        else
        {
            ans += cnt - x;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

int main(void){
    int N;  cin >> N;
    char s[N+1];
    scanf("%s",s);
    bool flag = true;

    if(N % 2 != 0) cout << "No";
    else{
        REP(i,N/2){
            if(s[i] != s[i+N/2]) flag = false;
        }
        if(flag == true) cout << "Yes";
        else cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n;

int main(){
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#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 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define int long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair


const int mod = 1e9+7;

inline int add(int a,int b){a+=b;if(a>=mod)a-=mod; return a;} 
inline int sub(int a,int b){a-=b;if(a<0) a += mod; return a;}
inline int mul(int a, int b){ return a*1ll*b%mod;}
inline int power(int x, ll y){
  int res = 1;
  while(y){
    if(y&1) res = mul(res , x);
    x = mul(x,x);
    y >>= 1;
  }
  return res;
}
const int N =105;
int L[N];

signed main(){
  fio; cout<<fixed<<setprecision(25);	
  int n; cin >> n;
  int cnt = 0;
  for(int i =1 ;i <= n ; ++i) cin >> L[i];
  for(int i = 1;i <= n ; ++i){
    for(int j = i+1;j <= n ; ++j){
      for(int k = j+1;k <= n ; ++k){
        if(L[i] != L[j] && L[i] != L[k] && L[j] != L[k]){
          if(L[i]+L[j]+L[k] > 2*max(L[i], max(L[j],L[k])))
            ++cnt;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const ll NN = 2e5 + 5;
ll n, w[99], x[99][99], has, y[99][99];
ll cek(ll aa)
{
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 1; j <= w[i]; j++)
        {
            ll org = aa&(1<<i);
            ll dia = aa&(1<<x[i][j]);
            if(org)
            {
                if(dia && (!y[i][j])) return 0;
                if((!dia) && y[i][j]) return 0;
            }
        }
    }
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(ll i = 0; i < n; i++)
    {
        cin >> w[i];
        for(ll j = 1; j <= w[i]; j++)
        {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    for(ll i = 0 ;i < (1<<n); i++)
    {
        if(cek(i))
            has = max(has, (ll)__builtin_popcount(i));
    }
    cout << has << "\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() {
	int	N;
	cin >> N;
	rep(i, 1 << N)
	{
		cout << i << ':';
		rep(j, N)
		{
			if (i & (1 << j))	
				cout << ' ' << j;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3076
#include <cstdio>

char prmt[10000005]={};

int rest[10000005]={};

int main(void){
int n,i,j;
prmt[0]=-1;
prmt[1]=-1;
for(i=2;i<=10000000;i++){
	if(prmt[i]==-1)continue;
	prmt[i]=1;
	j=i*2;
	while(j<=10000000){
		prmt[j]=-1;
		j+=i;
	}
}
j=13;
for(i=13;i<=10000000;i++){
	if(prmt[i]==1 && prmt[i-2]==1 && prmt[i-6]==1 && prmt[i-8]==1)j=i;
	rest[i]=j;
}
while(1){
scanf("%d",&n);
if(n==0)break;
printf("%d\n",rest[n]);
}
return 0;
}

Measured memory_bytes: 49856