akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  string S;
  cin >> S;
  int m;
  m=stoi(S.substr(5,2));
  if(m>=5){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
}


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

int main() {
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'x') {
            count++;
        }
    }
    if (count <= 7) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 K PIC 9(6).
        01 X PIC 9(10).
	    01 temp1 PIC 9(10).
        01 temp2 PIC 9(10).
        01 N PIC 9(10).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
        	PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1)=SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO K.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1)=SPACE
        	END-PERFORM.
        	COMPUTE N=temp2 - temp1.
        	MOVE INP(temp1:N) TO X.
			COMPUTE K = K * 500.
			IF K >= X THEN
				DISPLAY "Yes"
			ELSE 
				DISPLAY "No"
			END-IF.
		STOP RUN.

Measured memory_bytes: 636
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int N,A,sum=0,max=0;
        scanf("%d\n",&N );
        for (int i = 0; i < N; i++) {
          scanf("%d\n",&A );
          sum+=A;
          if (A>max) {
            max=A;
          }
        }
if (sum-max>max) {
  printf("Yes\n");
}else{
  printf("No\n");
}
        return 0;
}


Measured memory_bytes: 128
import math

a, b, x = map(int, input().split())
size = x/a

if size > a*b/2:
    #台形のパターン
    tan = (2*b - (2*x/a/a))/a
else:
    #三角形のパターン
    tan = (a*b*b)/2/x

print(math.degrees(math.atan(tan)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<vector<int>> to(n);
    rep(i, n)rep(j, n){
        int a;
        cin >> a;
        if(a == 1)to[i].push_back(j);
    }
    vector<vector<vector<P>>> dp(n, vector<vector<P>>(61));
    rep(i, n){
        for(int t : to[i]){
            dp[i][0].push_back(make_pair(t, 1));
        }
    }
    ll mod = 1000000007;
    rep(i, 60){
        rep(j, n){
            vector<ll> cnt(n, 0);
            for(P p : dp[j][i]){
                int v = p.first;
                ll num = p.second;
                for(P t : dp[v][i]){
                    (cnt[t.first] += num * t.second % mod) %= mod;
                }
            }
            rep(l, n){
                if(cnt[l] > 0){
                    dp[j][i+1].push_back(make_pair(l, cnt[l]));
                }
            }
        }
    }
    
    vector<vector<ll>> num(n, vector<ll>(62, 0));
    rep(i, n)num[i][0] = 1;
    rep(i, 61){
        if(1 & (k >> i)){
            rep(j, n){
                for(P p : dp[j][i]){
                    (num[p.first][i+1] += num[j][i] * p.second % mod) %= mod;
                }
            }
        }else{
            rep(j, n){
                num[j][i+1] = num[j][i];
            }
        }
    }
    
    ll ans = 0;
    rep(i, n)(ans += num[i][61]) %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 5308
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	
	string x, y;
	cin >> x >> y;
	if (x > y) cout << ">" << endl;
	else if (x < y) cout << "<" << endl;
	else cout << "=" << endl;

	return 0;
}

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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n;
    string s;
    cin>>n>>s;
    int sz = s.size();
    for(int i = 0;i < sz;i++) {
        cout<<char((s[i] - 'A' + n) % 26 + 'A');
    }

    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  rep(i, N){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  // cout << b[(N+1)/2-1] << " " << b[(N+1)/2] << endl;

  rep(i, N){
    if(a[i] >= b[(N+1)/2]){
      print(b[(N+1)/2-1]);
    } else {
      print(b[(N+1)/2]);
    }
  }
 
}


Measured memory_bytes: 3712
#include <stdio.h>
#define Max 20

int A[Max],n;

int solve(int, int);

int main(){
  int k,j,m[2000],ans;
  scanf("%d",&n);
  for(j = 0; j < n; j++){
    scanf("%d",&A[j]);
  }
  scanf("%d",&k);
  for(j = 0; j < k; j++){
    scanf("%d",&m[j]);
  }

  for(j = 0; j < k; j++){
    ans = solve(0,m[j]);
    if(ans == 1){
      printf("yes\n");
    }
    else if(ans == 0){
      printf("no\n");
    }
  }

  return 0;
}


int solve(int i,int m){
  int res;

  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
  
}

Measured memory_bytes: 588
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++){
		cin >> d[i];
	}
	ll ans = 0;
	for (int i = 0; i < n-1; i++){
		for (int j = i+1; j < n; j++){
			ans += d[i]*d[j];
		}
	} 
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  vector<int> v;
  int n;
  while(cin >> n){
    v.push_back(n);
  }
  sort(v.begin(), v.end(), greater<int>());
  for(int i = 0; i < 3; i++){
    cout << v[i] << endl;
  }
  return 0;
}

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

int main(){
  int n;cin>>n;
  vector<int> edge[n];
  for(int i=1;i<n;i++){
    int u,v;cin>>u>>v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  vector<int> parent(n,-1),son[n];
  queue<int> que;
  que.push(0);
  while(que.size()){
    int p=que.front();que.pop();
    for(int q:edge[p]){
      if(parent[p]==q)continue;
      parent[q]=p;
      son[p].push_back(q);
      que.push(q);
    }
  }
  vector<int> res(n),ant(n,0),tant(n,0);
  int ans=0;
  for(int i=0;i<n;i++){
    res[i]=son[i].size();
    if(!res[i])que.push(i);
  }
  while(que.size()){
    int p=que.front();que.pop();//cout<<"P"<<p<<endl;
    int cnt=0;
    for(int q:son[p]){
      if(ant[q])ant[p]=1;
      else cnt++;
    }
    if(cnt>1){
      for(int q:son[p]){
        if(!ant[q])ant[q]=tant[q]=1,ans++,cnt--;
        if(cnt==1)break;
      }
      ant[p]=1;
    }
    if(~parent[p])if(--res[parent[p]]==0)que.push(parent[p]);
  }
  int f=0;
  if(son[0].size()==1){
    int p=son[0][0];
    for(int q:son[p])if(!ant[q])f=1;
  }
  if(son[0].size()==2){
    int a=son[0][0],b=son[0][1];assert(ant[a]||ant[b]);
    if(!ant[a]&&!tant[b])for(int q:son[b])if(!ant[q])f=1;
    if(!ant[b]&&!tant[a])for(int q:son[a])if(!ant[q])f=1;
  }
  ans+=f;
  //for(int i=0;i<n;i++)cout<<ant[i]<<" ";cout<<endl;
  cout<<max(ans,1)<<endl;
}


Measured memory_bytes: 12800
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define PRINT
#define LCERR
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>

namespace {

using namespace std;

int gcd_extended(int a, int b, int* x, int* y) {
    if (a == 0) {
        *x = 0;
        *y = 1;
        return b;
    }

    int x1, y1;
    int gcd = gcd_extended(b % a, a, &x1, &y1);
    *x = y1 - (b / a) * x1;
    *y = x1;
    return gcd;
}

int mod_inverse(int b, int m) {
    int x, y;
    int gcd = gcd_extended(b, m, &x, &y);
    if (gcd != 1)
        return -1;
    else
        return (x % m + m) % m;
}

const int MODULO = 1000000007;

class Solution {
public:
//    int blue_and_red_balls(int N, int K) {
//        int64_t result = 1;
//        for (int i = 1; i <= K; ++i) {
//            result += bnr(N, K, i);
//            result %= MODULO;
//        }
//        return result;
//    }

    int bnr(int N, int K, int i) {
        int64_t result = 1;
        // arrange blue
        result *= C(K - 1, i - 1);
        result %= MODULO;

        // arrange red
        int64_t red_arrange = 0;
        if (i == 1) {
            red_arrange = N - K + 1;
        } else {
            for (int middle_red = i - 1; middle_red <= N - K; ++middle_red) {
                int64_t cur_arrange = C(middle_red - 1, i - 2);
                int red_left = N - K - middle_red;
                cur_arrange *= (red_left + 1);
                cur_arrange %= MODULO;
                red_arrange += cur_arrange;
                red_arrange %= MODULO;
            }
        }

        PRINT("B: {}, R: {}\n", result, red_arrange);

        result *= red_arrange;
        result %= MODULO;
        return result;
    }

    int C(int n, int m) {
        if (m == 0) return 1;
        auto iter = mem.find(make_pair(n, m));
        if (iter != mem.end()) {
            return iter->second;
        }
        int64_t r = C(n, m - 1);
        r *= n - (m - 1);
        r %= MODULO;
        if (m >= 2) {
            r *= mod_inverse(m, MODULO);
            r %= MODULO;
        }

        mem.emplace_hint(iter, make_pair(n, m), r);
        PRINT("C {} {} = {}\n", n, m, r);
        return r;
    }

private:

    map<pair<int, int>, int> mem;
};

int solve() {
    Solution solution;
    // handle IO here
    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= K; ++i) {
        cout << solution.bnr(N, K, i) << endl;
    }
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


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


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

int main(void) {
	ll a, b, k, t, ans = 0;

	cin >> a >> b;

	if (a > b) swap(a, b);
	k = gcd(a, b);

	for (t = 2; t * t <= k; t++) {
		if (k % t == 0) {
			while (k % t == 0) k /= t;
			ans++;
		}
	}

	if (k > 1) ans++;

	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    
    int sum = 0;

    if (a < b) {
        sum += a;
    }
    else {
        sum += b;
    }

    if (c < d) {
        sum += c;
    }
    else {
        sum += d;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
s =str(input())

if len(s) == 2:
    if s[0]==s[1]:
        sIndex = 1
        eIndex = 2
    else:
        sIndex = -1
        eIndex = -1
elif len(s)>2:
    sIndex=-1
    eIndex=-1
    for i in range(len(s)-2):
        par_str = s[i:i+3]
        if (par_str.count(par_str[0])>=2) | (par_str.count(par_str[1])>=2):
            sIndex = i + 1
            eIndex = i + 3
            break
    
ans = str(sIndex)+' '+str(eIndex)
print(ans)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
const int MOD = 1e9+7;

int main(){
  int n ; cin >> n;
  long long power = 1;
  for(int i = 1; i <= n; ++i){
    power *= i;
    power %= MOD;
  }
  cout << power << endl;
  return 0; 
}


Measured memory_bytes: 3528
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







class dinic {
private:
    struct edge {
        ll to, cap, rev;
    };
    vector<vector<edge>> list;  // グラフの隣接リスト
    vector<ll> level;    // sからの距離
    vector<ll> iter;     // どこまで調べ終わったか
public:
    dinic(ll n) : list(n), level(n), iter(n){}
    
    void add_edge(ll from, ll to, ll cap){
        list[from].push_back((edge){to, cap, (ll)list[to].size()});
        list[to].push_back((edge){from, 0, (ll)list[from].size() - 1});
    }
    
    void bfs(ll s){
        level.assign(level.size(), -1);
        queue<ll> que;
        level[s] = 0;
        que.push(s);
        while(!que.empty()){
            ll v = que.front(); que.pop();
            for(auto &x : list[v]){
                if(x.cap > 0 && level[x.to] < 0){
                    level[x.to] = level[v] + 1;
                    que.push(x.to);
                }
            }
        }
    }
    
    ll dfs(ll v, ll t, ll f){
        if(v == t) return f;
    
        for(ll &i = iter[v]; i < list[v].size(); i++){
            edge &e = list[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                ll d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    list[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    
    ll max_flow(ll s, ll t){
        ll flow = 0;
    
        for(;;){
            bfs(s);
            if(level[t] < 0) return flow;
            
            iter.assign(iter.size(), 0);
            
            ll f;
            while((f = dfs(s, t, INF)) > 0){
                flow += f;
            }
        }
    }
};




int main(){
    ll n;
	cin >> n;
	dinic dic(n + 2);
	ll sum = 0;
	REP(i, n) {
		ll a;
		cin >> a;
		if (a >= 0) {
			dic.add_edge(0, i + 1, 0);
			dic.add_edge(i + 1, n + 1, a);
			sum += a;
		}
		else {
			dic.add_edge(0, i + 1, -a);
			dic.add_edge(i + 1, n + 1, 0);
		}
	}
	for (ll i = 1; i <= n / 2; i++) {
		for (ll j = i * 2; j <= n; j += i) {
			dic.add_edge(i, j, INF);
		}
	}
	cout << sum - dic.max_flow(0, n + 1) << endl;
}

Measured memory_bytes: 256
x, k, d = gets.split.map(&:to_i)
# スタートが負の場合でも正の時と同様に考えてOK
x = x.abs
# 絶対値が変わらなくなるまでに必要な移動回数(t)とその時のx座標(m)
t, m = x.divmod(d)
if t >= k
  # x座標が0まで到達しない場合はより0に近い値を出力
  puts (x-k*d).abs
elsif (k-t).even?
  # t回目から偶数回移動する場合はmで止まる
  puts m
else
  # t回目から奇数回移動する場合はmの反対側で止まる
  puts (m-d).abs
end

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

using namespace std;

int sum(int n){
	int res = 0;
	string s = to_string(n);
	for(int i = 0; i < s.size(); ++i){
		res += s[i]-48;
	}
	return res;
}

int main(){
	int N, A, B, ans = 0; cin >> N >> A >> B;
	for(int i = 1; i <= N; ++i){
		int k = sum(i);
		if(A <= k && k <= B) ans += i;
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x,y;
    cin >> n >> x >> y;
    int dist = 0;
    vector<int> ans(n+5,0);
    for(int i=1;i<n;i++){
    	for(int j=i+1;j<=n;j++){
    		dist = min(abs(i-x)+abs(j-y)+1,abs(i-j));
    		ans[dist]++;
		}
	}
	for(int i=1;i<n;i++){
		cout << ans[i] << "\n";
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    rep(i,s.size()) s.at(i) = 'x';

    cout << s << endl;
}


Measured memory_bytes: 256
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	Raghav();
	int l, r, d, ans = 0;
	cin >> l >> r >> d;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3624
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vli vector<lli>
#define vi vector<int>
#define vs vector<string>
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

typedef long long int lli;
typedef long int li;

const lli mod=1000000007;
const lli limit=1000000;

using namespace std;

void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k,x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    lli aa[a],bb[b];
    vli cc;
    FOR(i,a)cin>>aa[i];
    FOR(i,b)cin>>bb[i];
    sort(aa,aa+a);
    sort(bb,bb+b);
    temp=a-x;
    for(i=temp;i<a;i++)cc.pb(aa[i]);
    temp=b-y;
    for(i=temp;i<b;i++)cc.pb(bb[i]);
    FOR(i,c){cin>>temp;cc.pb(temp);}
    sort(cc.begin(),cc.end(),greater<lli>());
    temp=0;
    FOR(i,x+y)temp+=cc[i];
    cout<<temp<<endl;
    

 
}

Measured memory_bytes: 8048
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt(), K = sc.nextInt();
        sc.close();
        final int mod = 1000000007;
        int dp[][] = new int[H + 1][W];
        dp[0][0] = 1;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                for (int k = 0; k < 1 << (W - 1); ++k) {
                    boolean ok = true;
                    for (int l = 0; l < W - 2; ++l) {
                        if (((k >> l) & 1) == 1 && ((k >> (l + 1)) & 1) == 1) {
                            ok = false;
                        }
                    }
                    if (ok) {
                        if (j >= 1 && ((k >> (j - 1)) & 1) == 1) {
                            dp[i + 1][j - 1] += dp[i][j];
                            dp[i + 1][j - 1] %= mod;
                        } else if (j <= W - 2 && ((k >> j) & 1) == 1) {
                            dp[i + 1][j + 1] += dp[i][j];
                            dp[i + 1][j + 1] %= mod;
                        } else {
                            dp[i + 1][j] += dp[i][j];
                            dp[i + 1][j] %= mod;
                        }
                    }
                }
            }
        }

        System.out.println(dp[H][K - 1]);
    }
}

Measured memory_bytes: 22868
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

void rotate(string &s)
{
  int n = s.size();
  char temp = s.at(0);
  rep(i, n - 1)
  {
    s.at(i) = s.at(i + 1);
  }
  s.at(n - 1) = temp;
}

int main()
{
  string s, t;
  cin >> s >> t;
  rep(i,s.size()){
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }
    rotate(s);
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,m,a[10000],b[10000],c[10000],d[10010],i,j,r[10010],t,s;
int main(){
  while(scanf("%d",&n),n){
    scanf("%d",&m);
    for(i=0;i<m;i++){
      r[i]=i;
      scanf("%d,%d,%d",&a[i],&b[i],&c[i]);
      a[i]++;
      b[i]++;
      for(j=i;j;j--){
	if(c[r[j-1]]>c[r[j]]){
	  t=r[j-1];
	  r[j-1]=r[j];
	  r[j]=t;
	}
      }
    }
    int p[10010]={0};
    for(i=s=0;i<m;i++){
      for(;p[a[r[i]]];a[r[i]]=p[a[r[i]]]);
      for(;p[b[r[i]]];b[r[i]]=p[b[r[i]]]);
      if(b[r[i]]-a[r[i]]){
	if(d[a[r[i]]]< d[b[r[i]]])p[a[r[i]]]=b[r[i]];
	if(d[b[r[i]]]<=d[a[r[i]]])p[b[r[i]]]=a[r[i]];
	if(d[a[r[i]]]==d[b[r[i]]])d[b[r[i]]]++;
	s+=c[r[i]]-100;
      }
    }
    printf("%d\n",s/100);
  }
  return 0;
}

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

using namespace std;

#define int long long

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef unordered_map<int,int> mii;
typedef unordered_map<char,int> mci;
typedef unordered_map<string,int> msi;

#define pb push_back
#define f first
#define s second 
 

void solve() {
    int n,W; cin>>n>>W;
    vi v(n),w(n);
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    int V = 0;
    for(int i=0;i<n;i++) {
        V += v[i];
    }
    vvi dp(n+1,vi(V+1));
    for(int i=0;i<=n;i++) {
        dp[i][0] = 0;
    }
    for(int i=1;i<=V;i++) {
        dp[0][i] = INF;
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=V;j++) {
            dp[i][j] = dp[i-1][j];
            if(v[i-1]<=j) dp[i][j] = min(dp[i][j],w[i-1]+dp[i-1][j-v[i-1]]);
        }
    }
    int res;
    for(int i=0;i<=V;i++) {
        //cout<<i<<'-'<<dp[n][i]<<' ';
        if(dp[n][i]<=W) {
            res = i;
        }
    }
    //cout<<endl;
    cout<<res<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //#ifdef LOCAL
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int tc; tc=1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}

Measured memory_bytes: 82996
import numpy as np

H,W = map(int,input().split())
use = np.zeros((H,W),dtype=int)
for i in range(H):
    s = input()
    for j,st in enumerate(s):
        if st == ".":
            use[i][j] = 10**9

for i in range(1,H):
    use[i,:] = np.minimum(use[i,:],use[i-1,:]+1)
for i in reversed(range(H-1)):
    use[i,:] = np.minimum(use[i,:],use[i+1,:]+1)
for j in range(1,W):
    use[:,j] = np.minimum(use[:,j],use[:,j-1]+1)
for j in reversed(range(W-1)):
    use[:,j] = np.minimum(use[:,j],use[:,j+1]+1)

print(np.max(use))

Measured memory_bytes: 20724
#ABC097C
s=str(input())
K=int(input())
s_all=[]
s_ans=[]
for i in range(K):
    for j in range(len(s)-i):
        s_all.append(s[j:j+i+1])
sorted_s_all=sorted(s_all)
for i in range(len(sorted_s_all)):
    if i==0:
        s_ans.append(sorted_s_all[i])
    elif sorted_s_all[i]!=sorted_s_all[i-1]:
        now=sorted_s_all[i]
        before=sorted_s_all[i-1]
        s_ans.append(sorted_s_all[i])
print(str(s_ans[K-1]))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


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


Measured memory_bytes: 3716
from functools import reduce

N, K = map(int, input().split())
a, b = (
    zip(*(map(int, input().split()) for _ in range(N - 1))) if N - 1 else
    ((), ())
)

MOD = 10**9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


G = [{} for _ in range(N + 1)]
for x, y in zip(a, b):
    G[x][y] = 1
    G[y][x] = 1
INF = 10**9


def p(n, r):
    return reduce(
        lambda acc, i: acc * (n - i),
        range(r),
        ModInt(1)
    )


# 解は K * (K-1)P(d_1) * (K-2)P(d_2-1) * (K-2)P(d_3-1) * ... * (K-2)P(d_N-1) である
ans = reduce(
    lambda acc, i: acc * p(K - 2, len(G[i]) - 1),
    range(2, N + 1),
    K * p(K - 1, len(G[1]))
)

print(ans)


Measured memory_bytes: 121432
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;

 		
int main() {

int A,B,C,D;

cin>>A>>B>>C>>D;

int a=min(A,B);
int b=min(C,D);

ce(a+b)

}


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

//map<long long , int> pa;

int main()
{
  long long H,N,K,sa,c,i,ans,sum;
  cin>>N>>K;
  long long A[N];
  sa=N-K;
  sum=c=0;
  if(sa<=0)
  {
    ans=0;
    goto end;
  }
  for(i=0;i<N;i++)
  {
    cin>>A[i];
    sum+=A[i];
  }
  sort(A,A+N);
 
  for(i=0;i<K;i++)
  {
    c+=A[N-1-i];
    //cout<<A[N-1-i];
  }
  ans=sum-c;  
  
  end:;
  cout<<ans;
    
}

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

using namespace std;

int main()
{
    string a;
    cin>>a;
    int siz=a.length();
    int maxi=0;
    int counter=0;
    for(int i=0;i<siz;i++){

        if(a[i]=='A'){
            counter++;
            continue;
        }
        if(a[i]=='C'){
            counter++;
            continue;
        }
        if(a[i]=='T'){
            counter++;
            continue;
        }
        if(a[i]=='G'){
            counter++;
            continue;
        }
        else{
            maxi=max(counter,maxi);
            counter=0;
            continue;
        }
    }
    maxi=max(counter,maxi);
    cout<<maxi<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

int32_t main () {
  hellcat;

	string s;
	cin >> s;

	if (s == "ABC") cout << "ARC\n";
	else cout << "ABC\n";

	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int ctoi(char);

int main()
{
    int N ,M;
    cin >> N >> M;
    vector<int> m(N, 0);
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        m.at(a-1)++;
        m.at(b-1)++;
    }

    rep(i, N)
    {
        cout << m[i] << endl;
    }

    
}


int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c -'0';
    }
    return -1;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Num[] nums = new Num[n];
		for (int i = 0; i < n; i++) {
		    nums[i] = new Num(i, sc.nextInt());
		}
		Arrays.sort(nums);
		UnionFindTree uft = new UnionFindTree(n);
		HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    for (int j = 2; j <= Math.sqrt(nums[i].value); j++) {
		        if (nums[i].value % j == 0) {
		            if (!map.containsKey(j)) {
		                map.put(j, new ArrayList<>());
		            }
		            map.get(j).add(i);
		        }
		        while (nums[i].value % j == 0) {
		            nums[i].value /= j;
		        }
		    }
		    if (nums[i].value != 1) {
	            if (!map.containsKey(nums[i].value)) {
	                map.put(nums[i].value, new ArrayList<>());
	            }
	            map.get(nums[i].value).add(i);
		    }
		}
		for (ArrayList<Integer> list : map.values()) {
		    for (int i = 1; i < list.size(); i++) {
		        uft.unite(list.get(i), list.get(0));
		    }
		}
		for (int i = 0; i < n; i++) {
		    if (!uft.same(i, nums[i].idx)) {
		        System.out.println(0);
		        return;
		    }
		}
		System.out.println(1);
	}
	
	static class Num implements Comparable<Num> {
	    int idx;
	    int value;
	    
	    public Num(int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Num another) {
	        return value - another.value;
	    }
	}
	
	static class UnionFindTree {
	    int[] parents;
	    
	    public UnionFindTree(int size) {
	        parents = new int[size];
	        for (int i = 0; i < size; i++) {
	            parents[i] = i;
	        }
	    }
	    
	    public int find(int x) {
	        if (parents[x] == x) {
	            return x;
	        } else {
	            return parents[x] = find(parents[x]);
	        }
	    }
	    
	    public boolean same(int x, int y) {
	        return find(x) == find(y);
	    }
	    
	    public void unite(int x, int y) {
	        if (same(x, y)) {
	            return;
	        }
	        parents[find(x)] = find(y);
	    }
	}
}



Measured memory_bytes: 73808
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#include <ctime>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define random(x) (rand()%x)+1
#define LL long long
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define eps 1e-12
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
const int mod=1e9+7;
int main()
{
    //input;output;
    string str;
    while(cin>>str)
    {
        if(str.length()>=4&&str.substr(0,4)=="YAKI")
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func mainFn() {
	n := getInt()
	ds := getIntSlice(n)

	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			ans += ds[i] * ds[j]
		}
	}

	puts(ans)
}

// -----------------------------------------

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// scanner.Buffer(make([]byte, buf), buf)
	scanner.Split(bufio.ScanWords)
	mainFn()
	writer.Flush()
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func puts(a ...interface{}) {
	if _, err := fmt.Fprintln(writer, a...); err != nil {
		panic(err)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<queue>
using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);
int n,M[N][N];
int d[N];
void bfs(int s)
{
  queue<int> q;
  q.push(s);
  for(int i = 0;i<n;i++)
     d[i] = INFTY;
  d[s] = 0;
  int u;
  while (!q.empty())
  {
    u = q.front(),q.pop();
    for(int v = 0;v<n;v++)
    {
      if(M[u][v] == 0) continue ;
      if(d[v]!= INFTY ) continue ;
      d[v] = d[u]+1;
      q.push(v);
    }
  }
  for(int i = 0;i<n;i++)
  {
    cout<<i+1<<" "<<((d[i] == INFTY) ? (-1) : d[i] ) <<endl;
  
  }
}
int main()
{
  int u,k,v;
  cin>>n;
  for(int i = 0;i<n;i++)
  {
    for(int j=  0;j<n;j++)
       M[i][j] = 0;
  }
  for(int i = 0;i<n;i++)
    {
      cin>>u>>k;
      u--;
      for(int j = 0;j<k;j++)
      {
        cin>>v;
        v--;
        M[u][v] = 1;
      }
    }
  bfs(0);
 return 0;
}



Measured memory_bytes: 3076
#include <stdio.h>

int main(void){
  int n,i,j,len;
  char taro[101],hanako[101],a;
  scanf("%d",&n);
  int scoretaro = 0,scorehanako = 0;
  a = getchar();
  
  for(i = 0; i < n; i++){
    for(j = 0; j < 100; j++){
      taro[j] = getchar();
      if(taro[j] == ' ')break;
    }
    int lentaro = j;
    if(i == 0)lentaro -= 1;
    for(j = 0; j < 100; j++){
      hanako[j] = getchar();
      if(hanako[j] == '\n')break;
    }
    int lenhanako = j;
    if(lentaro < lenhanako)len = lenhanako;
    else len = lentaro;

    for(j = 0; j < len; j++){
      if(taro[j] < hanako[j]){
        scoretaro += 3;
        break;
      }
      else if(taro[j] > hanako[j]){
        scorehanako += 3;
        break;
      }
      else if(taro[j] == hanako[j] && j == len - 1){
        scoretaro++;
        scorehanako++;
      }
    }
  }
  printf("%d %d\n",scorehanako,scoretaro);
  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
#define ld long double
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define REPE(i,a,b) for(ll i = a; i <= b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int mod = 1e9+7;
const int mod1 = 998244353;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int, int>&i, const pair<int, int>&j) {
   return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
   string s, t;
   cin >> s >> t;

   int cnt = 0;
   for(int i = 0; i < s.size(); i++) {
      if(s[i] != t[i]) cnt++;
   }
   
   cout << cnt;
} 

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   faster;
   cout.precision(10);
   cout << fixed;

   int t = 1;
   //cin >> t;
   while(t--) {
      test();
   }
   return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	if(exponent<0) exponent+=MOD-1;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[MAX];
map<int,int> m;
map<int,bool> visited;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		m[arr[i]]++;
		visited[arr[i]]=false;
	}	
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(visited[arr[i]])
			continue;
		if(m[arr[i]]>arr[i])
			ans+=m[arr[i]]-arr[i];
		else if(m[arr[i]]!=arr[i])
			ans+=m[arr[i]];
		visited[arr[i]]=true;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    char a[100][100]={'.'};
    cin>>n>>m;
    for(int i=0;i<=55;i++){
        for(int j=0;j<=55;j++)
            a[i][j]='.';
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
            //cout<<a[i][j];
        }
        //cout<<endl;
        
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='.')
                continue;
            else{
                if((a[i][j+1]=='.')&&(a[i-1][j]=='.')&&(a[i][j-1]=='.')&&(a[i+1][j]=='.')){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
awk -v x="AC WA TLE RE" '
BEGIN {
  split(x,y)
  for(i=1;i<=4;i++) a[y[i]]=0
}
NR!=1 {
  a[$0]++
}
END{
  for(i=1;i<=4;i++) print y[i],"x",a[y[i]]
}'

Measured memory_bytes: 4284
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pll pair<double,ll>



int main()
{
    ll x,y;
    cin >> x >> y;
    
    if(x == y)
    {
        cout << 0 << endl;
        return 0;
    }
    else if((-x)==y)
    {
        cout << 1 << endl;
        return 0;
    }
    else
    {
        ll dist = abs(abs(x) - abs(y));
        if(y == 0)
        {
            if(x < 0)
            {
                cout << dist << endl;
                return 0;
            }
            else
            {
                cout << dist + 1 << endl;
                return 0;
            }
        }
        else if(x == 0)
        {
            if(y > 0)
            {
                cout << dist << endl;
                return 0;
            }
            else
            {
                cout << dist + 1 << endl;
                return 0;
            }
        }
        else
        {
            if(x * y < 0)
            {
                cout << dist + 1 << endl;
                return 0;
            }
            else
            {
                if(x < y)
                {
                    cout << dist << endl;
                    return 0;
                }
                else
                {
                    cout << dist + 2 << endl;
                    return 0;
                }
            }
            
        }
    }
}

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

long long u[3333][3333];
long long S[123456];
long long dp[123456];
int main(){
    long long n;
    cin >> n;
    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < n; j++){
            cin >> u[i][j];
        }
    }
    for(long long b = 0; b < (1 << n); b++){
        for(long long i = 0; i < n; i++)
            for(long long j = i; j < n; j++)
                if(((1<<i)& b) && ((1<<j) &b)) S[b] += u[i][j];
    }
    for(long long b = 1; b < (1 << n); b++){
        dp[b] = S[b];
        for(long long j = b &(b - 1); j; j = b&(j - 1))
            dp[b] = max(dp[b], dp[b ^ j] + S[j]);
    }
    cout << dp[(1 << n) - 1] << endl;

}


Measured memory_bytes: 3328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Echizen
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int t;
            /**
             * Rating 1-399 : gray
             Rating 400-799 : brown
             Rating 800-1199 : green
             Rating 1200-1599 : cyan
             Rating 1600-1999 : blue
             Rating 2000-2399 : yellow
             Rating 2400-2799 : orange
             Rating 2800-3199 : red
             */
            boolean gray = false;
            boolean brown = false;
            boolean green = false;
            boolean cyan = false;
            boolean blue = false;
            boolean yellow = false;
            boolean orange = false;
            boolean red = false;
            t = in.nextInt();
            int[] arr = new int[t];
            int cout = 0;
            for (int i = 0; i < t; i++) {
                arr[i] = in.nextInt();
                if (arr[i] > 3199) {
                    cout += 1;
                }
            }
            int count_min = 0, count_max = 0;
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] >= 1 && arr[i] <= 399 && gray == false) {
                    gray = true;
                    count_min += 1;
                } else if (arr[i] >= 400 && arr[i] <= 799 && brown == false) {
                    brown = true;
                    count_min += 1;
                } else if (arr[i] >= 800 && arr[i] <= 1199 && green == false) {
                    green = true;
                    count_min += 1;
                } else if (arr[i] >= 1200 && arr[i] <= 1599 && cyan == false) {
                    cyan = true;
                    count_min += 1;
                } else if (arr[i] >= 1600 && arr[i] <= 1999 && blue == false) {
                    blue = true;
                    count_min += 1;
                } else if (arr[i] >= 2000 && arr[i] <= 2399 && yellow == false) {
                    yellow = true;
                    count_min += 1;
                } else if (arr[i] >= 2400 && arr[i] <= 2799 && orange == false) {
                    orange = true;
                    count_min += 1;
                } else if (arr[i] >= 2800 && arr[i] <= 3199 && red == false) {
                    red = true;
                    count_min += 1;
                }
            }
            out.println(count_min == 0 ? 1 : count_min);
            out.println(count_min + cout);
        }

    }
}



Measured memory_bytes: 21844
n,k = map(int,input().split())
l = list(map(int, input().split()))

s=len(set(l))

from collections import Counter
c = Counter(l)
c = sorted(c.items(), key=lambda x:x[1])

if s-k > 0:
    x=0
    for  i in range(s-k):
        x += c[i][1]
    print(x)
else:
    print(0)

Measured memory_bytes: 48436
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<long long> pw;
    int x;
    scanf("%d",&x);
    for(int i=-1000;i<=1000;i++)
    {
        pw.push_back((long long)i*i*i*i*i);
    }
    for(int i=pw.size()-1;i>=0;i--)
    {
        if(binary_search (pw.begin(), pw.end(), pw[i]-x))
        {
            printf("%d %d\n",i-1000,lower_bound(pw.begin(), pw.end(), pw[i]-x) - pw.begin()-1000);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3252