akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

vector<ll> a;
ll n, m;
#pragma region BinarySearch
bool isOK(ll x)
{
	ll cnt = 0;
	rep(i, n)
	{
		ll it = a.end() - lower_bound(all(a), x - a[i]);
		cnt += it;
	}
	if (m <= cnt) return true;
	else return false;
}

ll binary_search()
{
	ll ng = 1e6, ok = 2;
	while (abs(ok - ng) > 1)
	{
		ll mid = (ok + ng) / 2;
		if (isOK(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}
#pragma endregion

int main()
{
	cin >> n >> m;
	a.resize(n); rep(i, n)cin >> a[i];
	sort(all(a));
	ll mn = binary_search();
	vector<ll> s(n + 1);
	s[0] = 0; rep(i, n)s[i + 1] = s[i] + a[i];
	ll res = 0;
	ll cnt = 0;
	rep(i, n)
	{
		int x = upper_bound(all(a), mn - a[i]) - a.begin();
		res += s[n] - s[x] + (n - x)*a[i];
		cnt += n - x;
	}
	res += mn * (m - cnt);
	cout << res << endl;
}

Measured memory_bytes: 1792
//By Tushar Gautam
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin>>x>>y;
    if(max(x,y)<9) cout<<"Yay!";
    else cout<<":(";
    return 0;
}

Measured memory_bytes: 256
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input()) - 1])

Measured memory_bytes: 3060
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (d > t * s) cout << "No\n";
    else cout << "Yes\n";
    
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  int one;
  REP(i, n) {
    int a; cin >> a;
    if (a == 1) one = i;
  }
  int ans = 1, now = k;
  while (now < n) {
    ++ans;
    now += k-1;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
import itertools


def resolve(in_):
    N = int(next(in_))
    xy = (tuple(map(int, line.split())) for line in itertools.islice(in_, N))
    zw = tuple((x + y, x - y) for x, y in xy)

    zmax = zmin = zw[0][0]
    wmax = wmin = zw[0][1]
    for z, w in zw[1:]:
        zmax = max(zmax, z)
        zmin = min(zmin, z)
        wmax = max(wmax, w)
        wmin = min(wmin, w)

    ans = max(zmax - zmin, wmax - wmin)
    
    return ans
    

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37476
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  string s;
  cin >> s;
  cout << s[0] << s.length()-2 << s[s.length()-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define jaldi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define kuch(a,n) for(ll i=0;i<n;i++) cin>>a[i]
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define bs(v,x)	binary_search(v.begin(),v.end(),x)
#define mci(b)	cout<<b<<"\n"
#define bvb(n)	long long n;cin>>n;

typedef long long ll;
typedef vector<long long> vll ;
typedef long double ld;
const ll maxn = 1e9, mod = 1e9 + 7;


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

ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
} 

int main()
{
	jaldi;
	ll n,max_weight;
	cin>>n>>max_weight;ll dp[n+1][max_weight+1];
	for(ll i=0;i<=n;i++)
		dp[i][0]=0;
	for(ll i=0;i<=max_weight;i++)
		dp[0][i]=0;
	for(ll i=1;i<=n;i++)
	{
		ll x,y;cin>>x>>y;
		dp[i][x]=y;
		for (ll j = 1; j <=max_weight; j++)
		{
			if(j<x)	dp[i][j]=dp[i-1][j];
			else if(j>x)
			{
				dp[i][j]=max(y+dp[i-1][j-x],dp[i-1][j]);
			}
		}
	}
	ll ans=0;
	for(ll i=1;i<=max_weight;i++)
	{
		ans=max(ans,dp[n][i]);
	}
	mci(ans);
	
	
	return 0;
}

Measured memory_bytes: 79104
#include<iostream>
using namespace std;
long long n,m,c=0,s=0,q;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>q;c+=q;
	}
	for(int i=0;i<m;i++){
		cin>>q;s+=q;
	}
	cout<<s*c<<endl;
}


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

int n, m;
int a[100010], b[100010], cnt;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x * f;
}

int main() {
	int i;
	n = read(), n = read();
	for(i = 1; i <= n; i++) a[i] = read();
	for(i = 2; i < n; i++) {
		if(a[i] & 1) {
			if(a[1] & 1) {
				if(a[n] & 1) break;
				swap(a[n], a[i]);
			}
			else swap(a[i], a[1]);
		}
	}
	if(i < n) {
		printf("Impossible\n");
		return 0;
	}
	if(n == 1) {
		if(a[1] == 1) b[cnt = 1] = 1;
		else {
			b[1] = a[1]-1;
			b[cnt=2] = 1;
		}
	}
	else {
		if(a[1] != 1) b[++cnt] = a[1]-1;
		for(i = 2; i < n; i++) b[++cnt] = a[i];
		b[++cnt] = a[n]+1;
	}
	for(i = 1; i <= n; i++) printf("%d ", a[i]);
	printf("\n");
	printf("%d\n", cnt);
	for(i = 1; i <= cnt; i++) printf("%d ", b[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[3][3]={},b[3][3]={};
    for(int i=0;i<3;i++){//ビンゴカード
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    int n,num;
    cin >> n;
    
    for(int k=0;k<n;k++){//ナンバー
        cin >> num;
        for(int i=0;i<3;i++){//ビンゴカードとナンバーの整合確認
            for(int j=0;j<3;j++){
                if(a[i][j]==num){
                    b[i][j] = 1;//穴あけ
                }
            }
        } 
    }
    int count = 0;
    if(b[0][0]==b[1][1]&&b[1][1]==b[2][2]&&b[2][2]==1){
        count++;
    }
    if(b[0][2]==b[1][1]&&b[1][1]==b[2][0]&&b[2][0]==1){
        count++;
    }
    for(int i=0;i<3;i++){//ビンゴカードとナンバーの整合確認
        if(b[i][0]==b[i][1]&&b[i][1]==b[i][2]&&b[i][2]==1){
            count++;
        }
        for(int j=0;j<3;j++){
            if(b[0][j]==b[1][j]&&b[1][j]==b[2][j]&&b[2][j]==1){
                count++;
            }
        }
    }

    if(count>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    bool ON=true;
    if(n<30){
        ON = false;
    }
    if(ON)
    cout <<"Yes"<<endl;
    else
         cout <<"No"<<endl;
}





Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//累積和
struct cumulative_sum {
    // data[i]:[0,i)の和
    vector<long long int> data;
    //コンストラクタ O(n)
    template <typename T>
    cumulative_sum(vector<T>& v) {
        data.assign(v.size() + 1, 0);
        for (int i = 0; i < (int)v.size(); i++) {
            data[i + 1] = data[i] + v[i];
        }
    }
    //[a,b)の和を求める
    long long int sum(long long int a, long long int b) {
        return data[b] - data[a];
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    // a:そのまま、b:満足セット
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = max(a[i], 0);
    }
    cumulative_sum cum_a(a), cum_b(b);
    // i:諦める区間の左端
    lint ans = 0;
    for (int i = 0; i <= n - k; i++) {
        lint candidate = cum_b.sum(0, i) + max((lint)0, cum_a.sum(i, i + k)) +
                         cum_b.sum(i + k, n);
        ans = max(ans, candidate);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vii;
typedef pair<int, int> pi;
typedef tuple<int, int, int> t3;
typedef map<int, int> mi;
#define fi first
#define se second
#define vt vector
#define be begin()
#define ed end()
#define sz size()
#define cl clear()
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define lb(v, x) lower_bound(v.begin(), v.end(), x)
#define lbi(v, x) (lb(v, x) - v.begin())
#define tp(t, x, y) t x, y; tie(x, y)
#define tp3(t, x, y, z) t x, y, z; tie(x, y, z)
#define mp make_pair
#define mt make_tuple
#define co const
#define fc(x) for(int x = 1, _end = ri(); x <= _end; x++)
void uni(vi &v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }

db rd() { db x; cin >> x; return x; }
ll ri() { ll x; cin >> x; return x; }
string rs() { string s; cin >> s; return s; }
pi rpi() { pi x; cin >> x.fi >> x.se; return x; }
vi rvi(int n, int f = 0) { vi v(n + f); for (int i = f; i < v.size(); i++) cin >> v[i]; return v; }
vii rvii(int n, int m, int f = 0) { vii v(n + f, vi(n + f)); for (int i = f; i < v.size(); i++) for (int j = f; j < v[0].size(); j++) cin >> v[i][j]; return v; }
void pr() {}; template <class T, class ...U> void pr(T x, U ...y) { cout << x << ' ', pr(y...); }
void prl() { cout << '\n'; }; template <class T, class ...U> void prl(T x, U ...y) { cout << x << ' ', prl(y...); }
void pr(const vi &v, int f = 0) { for (int i = f; i < v.size(); i++) cout << v[i] << ' '; }
void prl(const vi &v, int f = 0) { pr(v, f); cout << '\n'; }
void pr(const pi &x) { cout << x.fi << ' ' << x.se; };
void prl(const pi &x) { pr(x); cout << '\n'; }

#define rep(i, l, r) for (int i = l; i < r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

const int N = 2e5 + 5, M = 1e9 + 7;

vt<string> a = {"dream", "dreamer", "erase", "eraser"};

int main() {
  auto s = rs();
  vt<int> dp(s.sz + 1);
  dp[0] = 1;
  int n = s.sz;
  rep(i, 1, n + 1) {
    for (auto &t : a) {
      if (t.sz <= i && s.substr(i - t.sz, t.sz) == t) dp[i] += dp[i - t.sz];
    }
  }
  pr(dp[n] ? "YES" : "NO");
}


Measured memory_bytes: 3848
from collections import deque

n=int(input())

tree=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  tree[u].append([v,w])
  tree[v].append([u,w])

dist=[-1]*n
dist[0]=0

ans=[-1]*n
ans[0]=0

dq=deque()
dq.append(0)

while dq:
  x=dq.popleft()
  for vv,ww in tree[x]:
    if dist[vv]==-1:
      dq.append(vv)
      dist[vv]=dist[x]+ww
      if dist[vv]%2==0:
        ans[vv]=0
      else:
        ans[vv]=1

for i in ans:
  print(i)

Measured memory_bytes: 50072
#include <cstdio>
#include <cstdlib>

int main()
{
  int n;
  scanf("%d", &n);
  int sum = 0;
  int a[100];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
    sum += a[i];
  }
  int ans = 0;
  int mind = 1e9;
  for (int i = 0; i < n; ++i)
  {
    if (std::abs(sum - n * a[i]) < mind)
    {
      ans = i;
      mind = std::abs(sum - n * a[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1)res=res*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return res;
}

ll L;
Tu ans[65];
int m=0,n=0;
int main(){
	cin>>L;
	int r;
	for(int i=0;i<=19;i++){
		if(mod_pow(2,i)<=L){
			r=i;
			//cout<<mod_pow(2,i)<<endl;
		}
	}
	n=r+1;
	for(int i=1;i<r+1;i++){
		ans[m]=Tu(i,i+1,0);
		m++;
		ans[m]=Tu(i,i+1,(ll)(mod_pow(2,i-1)));
		m++;
	}
	
	for(int t=n-1;t>=1;t--){
		if(L-mod_pow(2,t-1)>=mod_pow(2,r)){
			ans[m]=Tu(t,n,L-mod_pow(2,t-1));
			L-=mod_pow(2,t-1);
			m++;
		}
	}
	cout<<n<<" "<<m<<endl;
	REP(i,m){
		cout<<get<0>(ans[i])<<" "<<get<1>(ans[i])<<" "<<get<2>(ans[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
typedef long long int ll;
typedef pair<int, int> P;
 
const long long INF = 3e18 + 12;
const int inf = 1e9;
 
int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i, a + 1) {
    rep(j, b + 1) {
      rep(k, c + 1) {
        if (i * 500 + j * 100 + k * 50 == x) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if(ceil((float)c / b) <= ceil((float)a / d)){
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 1732
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#include<stdio.h>
 
int main(){
    long long int N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;
    long long int p[6];
    for(int i=0;i<6;++i){
        p[i]=0;
    }
    long long int t[5];
    t[0]=A;
    t[1]=B;
    t[2]=C;
    t[3]=D;
    t[4]=E;
    p[1]=N;
    long long int num=0;
    long long int para_min;
    long long int r[5];
    long long int tmp=0;
    long long int right=0;
    sort(t,t+5);
    num=ceil((N-1)/t[0])+5;
    cout << num;
}

Measured memory_bytes: 256
A[2<<17];*p=A;main(n){for(;~scanf("%d",p++););qsort(p=A+1,*A,8,"\x8b\7+\6\xc3");for(n=*p;p[2];)n+=fmin(*p-p++[2],p[2]-*p++);n+=p[1];printf("%d",n);}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #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>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e18
    const int N=1e6+6;
    const int MOD=1e9+7;
    void solve()
    {
    	int n,k;
    	cin>>n>>k;
    	string s;
    	cin>>s;
    	s[k-1]=s[k-1]-'A'+'a';
    	cout<<s<<endl;
    }
	signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
        	solve();
        }
    }

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> masu(H + 2, vector<int>(W + 2, 0));
  vector<vector<int>> output(H + 2, vector<int>(W + 2, 0));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char tmp;
      cin >> tmp;
      if (tmp == '.') {
        masu[i + 1][j + 1] = 0;
      } else {
        masu[i + 1][j + 1] = 1;
      }
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (masu[i][j] == 1) {
        continue;
      }
      output[i][j] = masu[i - 1][j - 1] + masu[i - 1][j] + masu[i - 1][j + 1] +
                     masu[i][j - 1] + masu[i][j + 1] + masu[i + 1][j - 1] +
                     masu[i + 1][j] + masu[i + 1][j + 1];
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (masu[i][j] == 1) {
        cout << '#';
      } else {
        cout << output[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  set <int> s;
  for(int i = 0;i < n;++i){
    int num;
    cin >> num;
    auto itr = s.find(num);
    if(itr == s.end()) s.insert(num);
    else s.erase(num);
  }
  cout << (int)s.size() << endl;
  return 0;
}

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

long long count;


int main(){
	
	long long N, min, max;
	cin >> N >> min >> max;

	if(N == 1 && max - min >=1) {
		cout << 0 << endl;
		return 0;}
	if(min > max) {
		cout << 0 << endl;
		return 0;}
	if(N == 1 && max == min){
		cout << 1 << endl;
		return 0;
	}
	if(N)

	N = N - 2;

	count = count + max * N - min * N + 1;
	

	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b,c;
int i;
scanf("%d",&a);
for(i=1;i<=a;i++)
{
b=i%10;
c=i/10;
if(i%3==0)
{
printf(" %d",i);
}
else if(b==3)
{
printf(" %d",i);
}
else if(c==3)
{
printf(" %d",i);
}
else if(c%10==3)
{
printf(" %d",i);
}
else if(c/10==3)
{
printf(" %d",i);
}
else if(c/10%10==3)
{
printf(" %d",i);
}
else if(c/10/10==3)
{
printf(" %d",i);
}
}
printf("\n");
return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  string s;cin>>s;

  for(int i=1;i < siz(s);i++)
  {
    if(s[i]==s[i-1]){
      cout<<i<<" "<<i+1<<endl;
      return 0;
    }

    if(2<=i && s[i]==s[i-2]){
      cout<<i-1<<" "<<i+1<<endl;
      return 0;
    }
  }

  cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	set<ll> S;
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		int a;
		scanf("%d",&a);
		if(S.count(a)>0)S.erase(a);
		else S.insert(a);
	}
	printf("%d\n",S.size());
}


Measured memory_bytes: 4864
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

double dp[3010][3010] = {};


int main(){
  int n;

  scanf("%d", &n);

  dp[0][0] = 1;

  for(int i=0;i<n;i++){
    double p;
    scanf("%lf", &p);

    for(int j=0;j<=i;j++){
      dp[i+1][j] += dp[i][j] * (1-p);
      dp[i+1][j+1] += dp[i][j] * p;
    }
  }

  double ans = 0;

  for(int i=(n+1)/2;i<=n;i++)
    ans += dp[n][i];

  printf("%.10lf\n", ans);

  return 0;
}


Measured memory_bytes: 69120
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
struct Widget
{
public:
    vector<double> mins, maxs;

    Widget()
    : mins(3, 1e10)
    , maxs(3, -1e10)
    {}

    void Add(double n, int d)
    {
        ++d;
        chmin(mins[d], n);
        chmax(maxs[d], n);
    }

    double Get(double t)
    {
        double min = 1e10;
        double max = -1e10;
        rep(d, 0, 3)
        {
            chmin(min, mins[d] + d * t);
            chmax(max, maxs[d] + d * t);
        }
        return max - min;
    }

    vector<double> GetTimings()
    {
        vector<double> ts;
        rep(i, 0, 3)
        {
            rep(j, 0, i) // j < i
            {
                // mins
                {
                    const double t = (mins[j] - mins[i]) / (i - j);
                    if (t > 0) ts.push_back(t);
                }

                // maxs
                {
                    const double t = (maxs[j] - maxs[i]) / (i - j);
                    if (t > 0) ts.push_back(t);
                }
            }
        }
        return ts;
    }
};

void _main()
{
    int N;
    cin >> N;
    Widget xWidget, yWidget;
    rep(i, 0, N)
    {
        int x, y;
        char d;
        cin >> x >> y >> d;
        switch (d)
        {
            case 'R': xWidget.Add(x, +1); yWidget.Add(y,  0); break;
            case 'L': xWidget.Add(x, -1); yWidget.Add(y,  0); break;
            case 'U': xWidget.Add(x,  0); yWidget.Add(y, +1); break;
            case 'D': xWidget.Add(x,  0); yWidget.Add(y, -1); break;
        }
    }
    vector<double> ts;
    ts.push_back(0.0);
    ts.push_back(1e10);
    {
        vector<double> timings = xWidget.GetTimings();
        ts.insert(ts.end(), timings.begin(), timings.end());
    }
    {
        vector<double> timings = yWidget.GetTimings();
        ts.insert(ts.end(), timings.begin(), timings.end());
    }
    sort(ts.begin(), ts.end());
    double ans = 1e18;
    for (const double t : ts)
    {
        chmin(ans, xWidget.Get(t) * yWidget.Get(t));
    }
    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
import sys

import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

permutations = list(itertools.permutations(range(1, n+1)))
p = permutations.index(p)
q = permutations.index(q)

print(abs(p-q))


Measured memory_bytes: 8052
using System;
using System.Text.RegularExpressions;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    class Program
    {
        class ReverseComparer : IComparer<int>
        {
            public int Compare(int x, int y)
            {
                // 既定のComparerとは反対の結果を返す
                return Comparer<int>.Default.Compare(y, x);
            }
        }

        static void Main(string[] args)
        {

            List<int> values = new List<int>();
            string str = Console.ReadLine(); //標準入力
            //string str = "3 3 4";
            string[] str2 = str.Split(' ');
            int a = int.Parse(str2[0]);
            int b = int.Parse(str2[1]);
            int c = int.Parse(str2[2]);

            str = Console.ReadLine(); //標準入力  
            //str = "2";
            str2 = str.Split(' ');
            int d = int.Parse(str2[0]);

            values.Add(a);
            values.Add(b);
            values.Add(c);

            IComparer<int> reverseComparer = new ReverseComparer();
            values.Sort(reverseComparer);

            for(int i = 0; i < d;i++)
            {
                values[0] = values[0] * 2;
            }

            int count = values.Sum();

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define base 1777771
using namespace std;
typedef unsigned long long ull;
ull H[300001],h[300001],Pow[300001]={1};
int n;

ull get(int l,int r,ull *a){return a[r]-a[l]*Pow[r-l];}

int search(int a,int b,int R){
  int L=0,M;
  while(L<R){
    M=(L+R)/2;
    if(get(a,a+M,H)!=get(b,b+M,h)) R=M;
    else L=M+1;
  }
  return L-1;
}

int main(){
  string A,a;
  cin>>A>>a;
  n=a.size();
  for(int i=1;i<=A.size();i++)H[i]=H[i-1]*base+A[i-1];
  for(int i=1;i<=a.size();i++) h[i]=h[i-1]*base+a[i-1];
  for(int i=1;i<=A.size();i++) Pow[i]=Pow[i-1]*base;

  int ans=0;
  for(int i=0;i<=A.size()-n;i++){
    int res=search(i,0,n+1);
    if(res==n)continue;
    ans+=(res+search(i+res+1,res+1,n-res)==n-1);
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    int n;
    cin >> n;
    int x=1;
    while(x<=n){
        if(floor(x*1.08)==n) {
            cout << x << endl;
            return 0;
        }
        x++;
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3640
#pragma region
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 1e3 + 5;
const ll mod = 1e9 + 7;
ll n, m, dp[maxn][maxn];
char maze[maxn][maxn];
int main() {
    IO;
    cin >> n >> m;
    rep(i, 1, n) cin >> (maze[i] + 1);
    dp[1][1] = 1;
    rep(i, 1, n) rep(j, 1, m) {
        if (maze[i][j] == '#') continue;
        if (j - 1 >= 1 && maze[i][j - 1] - '#') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
        if (i - 1 >= 1 && maze[i - 1][j] - '#') dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
    }
    cout << dp[n][m] << endl;
}

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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n, d) for (int i = (s); i < (int)(n); i += (d))
#define allpt(v) (v).begin(), (v).end()
#define allpt_c(v) (v).cbegin(), (v).cend()
#define allpt_r(v) (v).rbegin(), (v).rend()

const int mod = 1e9 + 7, mod2 = 998244353, mod3 = 1e9 + 9;
const ll inf = 1e18;

const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(const vector<T> &v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;

    return;
}

template <typename T>
void show2dvec(const vector<vector<T>> &v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

template <typename T, typename S>
void show1dpair(const vector<pair<T, S>> &v)
{
    int n = v.size();
    rep(i, n) cout << v[i].first << wsp << v[i].second << rt;
    return;
}

template <typename T, typename S>
void pairzip(const vector<pair<T, S>> &v, vector<T> &t, vector<T> &s)
{
    int n = v.size();
    rep(i, n)
    {
        t.push_back(v[i].first);
        s.push_back(v[i].second);
    }
    return;
}

template <typename T>
void maxvec(vector<T> &v)
{
    T s = v[0];
    int n = v.size();
    rep(i, n - 1)
    {
        if (s > v[i + 1])
        {
            v[i + 1] = s;
        }
        s = v[i + 1];
    }
}

template <typename T, typename S>
bool myfind(T t, S s)
{
    return find(t.cbegin(), t.cend(), s) != t.cend();
}

bool check(int y, int x, int h, int w)
{
    return 0 <= y && y < h && 0 <= x && x < w;
}

VL cumsum(const VL &v)
{
    int s = 0;
    VL ret = {0};

    rep(i, v.size())
    {
        s += v[i];
        ret.push_back(s);
    }
    return ret;
}

bool iskadomatsu(int a, int b, int c)
{
    return (a != b && b != c && c != a) && ((a > b && b < c) || (a < b && b > c));
}

VS split(string s, char c)
{
    VS ret;
    string part;
    s += c;
    rep(i, s.length())
    {
        if (s[i] == c)
        {
            ret.emplace_back(part);
            part = "";
        }
        else if (s[i] != c)
        {
            part += s[i];
        }
    }
    return ret;
}



int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    double r;
    cin >> r;
    cout << 6.28318530717 * r << rt;
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	int D[N][2];
	for(int i=0;i<N;i++){
		cin >> D[i][0] >> D[i][1];
	}
	string ans = "No";
	for(int i=0;i<N-2;i++){
		if(D[i][0] == D[i][1]
			&& D[i+1][0] == D[i+1][1]
			&& D[i+2][0] == D[i+2][1]) {
			ans = "Yes";
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
s = input()

pre = int(s[:2])
suf = int(s[2:])

if suf >= 1 and suf <= 12:
    if pre >= 1 and pre <= 12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
        
elif pre >= 1 and pre <= 12:
    print('MMYY')
    
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
vector<ll> a;
int main() {
  ll n,k,x;
  cin>>n>>k;
  a.push_back(k);
  for(int i=0;i<n;i++){
    cin>>x;
    a.push_back(x);
  }
  sort(a.begin(),a.end());
  ll d=a[1]-a[0];
  for(int i=2;i<=n;i++){
    d=__gcd(d,a[i]-a[i-1]);
  }
  cout<<d<<endl;
	return 0;
}

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

#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("avx,sse4")

#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define sqr(x) ((x)*(x))

using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
typedef vector<int> VI;
typedef vector<VI> VII;

namespace Main{

const int N=105,P=1e9+7;

inline int fpow(int a,int t){
	static int r;
	for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;
	return r;
}

int f[N][N],v[N][N];
int Solve1D(int a,int A){return a;}
int Solve2D(int a,int A,int b,int B){
	return (((ll)a*fpow(Solve1D(b,B),A/a)+(ll)b*fpow(Solve1D(a,A),B/b)-(ll)a*b)%P+P)%P;
}
int Solve3D(int a,int A,int b,int B,int c,int C){
	if(A%a||B%b||C%c)return 0;
	// trival cases
	int ae=A/a,be=B/b,ce=C/c;
	int ret=(
	((ll)a*fpow(Solve2D(b,B,c,C),ae)
	+(ll)b*fpow(Solve2D(a,A,c,C),be)
	+(ll)c*fpow(Solve2D(a,A,b,B),ce)
	-(ll)a*b*fpow(Solve1D(c,C),ae*be)
	-(ll)a*c*fpow(Solve1D(b,B),ae*ce)
	-(ll)b*c*fpow(Solve1D(a,A),be*ce)
	+(ll)a*b*c)%P+P)%P;
	// non-trival cases
	fo(i,**v=1,max(ae,be))fo(j,*v[i]=1,i)v[i][j]=(v[i-1][j-1]+v[i-1][j])%P;
	fd(i,ae,1)fd(j,be,1){
		f[i][j]=(ll)v[ae][i]*v[be][j]%P*fpow(c,(ae-i)*(be-j))%P;
		fo(k,i,ae)fo(t,j,be)if(k>i||t>j)f[i][j]=(f[i][j]-(ll)f[k][t]*v[k][i]%P*v[t][j]%P+P)%P;
		int p=fpow(b,i),q=fpow(a,j),w=((fpow(p+q-1,ce)-fpow(p,ce)-fpow(q,ce)+1)%P+P)%P;
		if(i<ae||j<be)ret=(ret+(ll)a*b*c*f[i][j]%P*w)%P;
	}
	return ret;
}

}

int a,b,c,A,B,C;

int main(){
	cin>>a>>b>>c>>A>>B>>C;
	cout<<Main::Solve3D(a,A,b,B,c,C);
	return 0;
}

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

#define ll      long long
#define MAX     1000007
#define inf     99999999999999
#define MOD     1000000007
#define pii     pair<int,int>
#define FIN     freopen("input.txt","r",stdin);
#define FOUT    freopen("output.txt","w",stdout);
map<ll,ll> mp;

int main ()
{
    ll n;
    scanf("%lld",&n);
    ll ara[MAX];
    for(int i=0;i<n;i++)
    {
        ll temp;
        scanf("%lld",&temp);
        mp[temp]++;
    }
    ll res = 0;
    map<ll,ll>::iterator it;
    for(it = mp.begin();it!=mp.end();it++)
    {
        ll val = it->first;
        ll amount = it->second;

        if(amount>val)
        {
            res += (amount - val);
        }
        else if(amount < val)
        {
            res += amount;
        }
    }
    printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
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(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, X, tmpx;
    vector<ll> x;
    cin >> n >> X;
    rep(i, n){
        cin >> tmpx;
        x.push_back(tmpx);
    }

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

    vector<ll> diff;
    rep(i, n){
        diff.push_back(abs(x[i]-X));
    }

    ll res = diff[0];
    rep(i, n){
        res = gcd(res, diff[i]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int M;
    float allvote=0;
    float count = 0;
    cin>>N>>M;
    
    float A[N];
    
    for(int i = 0;i<N;i++){
      cin>>A[i];
      allvote+=A[i];
    }
    float minimum =allvote/(4*M);
  	
    for(int i = 0;i<N;i++){
      if(A[i]>=minimum){
        count++;
      }
    }
  	if(count>=M){
  		cout<<"Yes"<<endl;
    }else{
      	cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;

int cnt[6];
int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int a1, a2, a3, b1,b2,b3;
    cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
    cnt[a1]++;
    cnt[a2]++;
    cnt[a3]++;
    cnt[b1]++;
    cnt[b2]++;
    cnt[b3]++;
    sort(cnt, cnt+4);
    if(cnt[2] == 1) cout << "NO";
    else cout << "YES";
    return 0;
}


Measured memory_bytes: 256
def main():
    n, m, k = map(int, input().split())
    mod = 998244353
    if m == 1:
        if k == n-1 or n == 1:
            print(1)
        else:
            print(0)
        return
        
    ans = 0
    m1 = [None]*n
    kai = [None]*n
    mi = 1
    ki = 1
    for i in range(n):
        m1[i] = mi
        mi *= m-1
        mi %= mod
        kai[i] = ki
        ki *= (i+1)
        ki %= mod
        
    def comb(a, b):
        return kai[a]*fermat(kai[a-b]*kai[b], mod)
        
    def fermat(x, p):
        """
        1/x (mod p) を返す
            x**(p-1) ≡ 1    [if gcd(x, p) == 1]
            x**(p-2) ≡ 1/x
            繰返し二乗法 
                ex: x**50  = (x**25)**2
                    x**25  = (x**12)**2 * x
                    x**12  = (x**6)**2
                    x**6   = (x**3)**2
        """
        times = []
        mod = p
        p -= 2
        while p > 1:
            times.append(p%2)
            p //= 2
        x %= mod
        out = x
        for i in times[::-1]:
            if i:
                out = (x*pow(out, 2, mod))%mod
            else:
                out = pow(out, 2, mod)
        return out
               
    for i in range(k+1):
        ans += m*comb(n-1, i)*m1[n-i-1]
        ans %= mod
    print(ans)

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 83360
#include<stdio.h>
#define N 100
main()
{
  int n,i,j,c[N],d,mini,count=0;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    {
      scanf("%d",&c[i]);
    }
  for(i=0;i<n;i++)
    {
      mini = i;
      for(j=i;j<n;j++)
	{
	  if(c[j] < c[mini])
	    {
    
	      mini = j;
	    }
	}
      if(mini!=i)count++;
      d = c[i];
      c[i] = c[mini];
      c[mini] = d;
    }


for(i=0;i<n;i++)
  {
    if(i==n-1){printf("%d\n",c[i]);break;}
    printf("%d ",c[i]);
  }

 printf("%d\n",count);
return 0;
}
	  

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int sum = 0;
    for(int i = 0; i < s.length(); i++) {
        sum += s[i] - '0';
        sum %= 9;
    }
    if(sum % 9 == 0) cout << "Yes"<<endl;
    else cout << "No"<<endl;
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 2e3 + 100;

int n, m, dp[N][N];
vector<int> a, p;

int solve(int l, int r){
   if (l > r){
      return 0;
   }

   tr(l, r);
   int &ans = dp[l][r];
   if (ans != -1){
      return ans;
   }

   ans = -inf;
   int idx = n - (r-l+1);
   int oidx = p[idx];

   smax(ans, a[oidx] * abs(oidx - l) + solve(l+1, r));
   smax(ans, a[oidx] * abs(oidx - r) + solve(l, r-1));

   return ans;
}

int32_t main(){_
   
   cin >> n;

   p.resize(n);
   a.resize(n);
   for (int i = 0; i < n; ++i)
   {
      cin >> a[i];
      p[i] = i;
   }
     
   sort(p.begin(), p.end(), [&](int x, int y){
      return a[x] > a[y];
   });

   memset(dp, -1, sizeof dp);

   cout<<solve(0,n-1);

   return 0;
}

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

#define ll long long

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s;
    cin >> n >> s;

    set<ll> r, g, b;
    for(int i=0; i<n; i++){
        if(s[i]=='R') r.insert(i);
        else if(s[i]=='G') g.insert(i);
        else b.insert(i);
    }

    set<ll>::iterator rt;
    set<ll>::iterator gt;
    
    ll count=0;
    ll sizeofb = b.size();
    for(rt=r.begin(); rt!=r.end(); rt++){
        
        for(gt=g.begin(); gt!=g.end(); gt++){

            ll x=*rt,y=*gt;
            if(x>y){
                x=*gt; y=*rt;
            }
            ll diff=y-x;
            ll noOfBnotcontributing=0;

            if(b.find(y+diff)!=b.end()) noOfBnotcontributing++;
            if(b.find(x-diff)!=b.end()) noOfBnotcontributing++;
            if(!((x+y)&1)){
                if(b.find((x+y)/2)!=b.end()) noOfBnotcontributing++;
            }

            count+=sizeofb-noOfBnotcontributing;
        }
    }

    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <algorithm>
#include <map>

int main() {
    using namespace std;

    int N;
    string S;
    cin >> N;
    cin >> S;


    int r = 0;

    for (int i=0; i<N; i++) {
        std::map<char, int> m;

//        cout << "### div: " << i << endl;
        for (int j=0; j<i; j++) {
            char c = S[j];

//            cout << "== " << c << endl;

            // if (m.end() != m.find(c)){
            //     continue;
            // }
            for (int k=i; k<N; k++) {
//                cout << S[k] << " " << (c == S[k] ? 't' : 'f') << endl; 
                if (c == S[k]) {
                    m[c] = 1;
                    break;
                }
            }
        }

        int count = m.size();
//        cout << "count: " << count << endl;
        r = max(r, count);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"

using namespace std;

long long int N, M, K, L, R, H, W;

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

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s == "abc") {
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256