akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
    #pragma GCC optimize("O3")
    #endif
    #include "bits/stdc++.h"
    using namespace std;
    #define sim template <class c
    #define ris return *this
    #define dor > debug &operator<<
    #define eni(x)                                                                    \
        sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
        {
    sim > struct rge
    {
        c b, e;
    };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c *x) -> decltype(cerr << *x, 0);
    sim > char dud(...);
    struct debug
    {
    #ifdef LOCAL
        ~debug()
        {
            cerr << endl;
        }
        eni(!=) cerr << boolalpha << i;
        ris;
    } eni(==) ris << range(begin(i), end(i));
    }
    sim, class b dor(pair<b, c> d)
    {
        ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d)
    {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
    }
    #else
        sim dor(const c &)
        {
            ris;
        }
    #endif
    }
    ;
    #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
    #define fastio                        \
        ios_base::sync_with_stdio(false); \
        cin.tie(0);
    #define endl '\n'
    typedef long long ll;
    typedef long double ld;
    const ll MOD = 1e9 + 7;
    const ll N = 1e5 + 10;
    
int arr[26];
    int main()
    {
        fastio
int x;
cin>>x;
int arr[x];
for (int i = 0; i < x; i++)
{
    cin>>arr[i];
}
sort(arr,arr+x,greater<int>());
int sum1=0;
int sum2=0;
for (int i = 0; i < x; i++)
{
    if(i%2==0)
    sum1+=arr[i];
    else
    {
        sum2+=arr[i];
    }
    
}
cout<<sum1-sum2<<endl;



        return 0;
    }

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	string a,b;
	cin>>a>>b;
	rep(i,0,3){
		if(a[i]==b[i]) ans++;
	}	
	ret(ans)
	
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#pragma GCC optimize(2)
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s1,s2,s3;
int main()
{
	fast;
	cin>>s1>>s2>>s3;
	cout<<s1[0]<<s2[0]<<s3[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int n, m, r;
ll dl[220][220], dw[220][220];
ll dp[1100][220];
int a[1100];

ll rec(int s, int j) {
	// 从起点的时候，可能会提前把船开到某个地方
	if (s == 0) {
		dp[s][j] = dw[a[0]][j] + dl[j][a[0]];
		return dp[s][j];
	}
	if (dp[s][j] != -1) return dp[s][j];
	// 直接从上一个点走陆地过来
	ll res = dl[a[s - 1]][a[s]] + rec(s - 1, j);
 	//也可能是到达了s - 1点后，把船开到了某个地方，然后从s - 1点走过来。
 	for (int k = 1; k <= n; k++) {
 		res = min(res, rec(s - 1, k) + dl[a[s - 1]][k] + dw[k][j] + dl[j][a[s]]);
 	}
 	dp[s][j] = res;
	return res;
}

int main() {
	while (scanf("%d%d", &n, &m) != -1) {
        if (n == 0 && m == 0) break;
        for (int i = 1; i <= n; i++) { 
            for (int j = 1; j <= n; j++) {
                dl[i][j] = dl[j][i] = INF;
                dw[i][j] = dw[j][i] = INF;
            }
        }
		for (int i = 1; i <= n; i++) {
			dl[i][i] = 0;
			dw[i][i] = 0;
		}
        
		for (int i = 0; i < m; i++) {
			int a, b, c; char s[20];
			scanf("%d%d%d%s", &a, &b, &c, s);
			if (s[0] == 'L') 
				dl[a][b] = dl[b][a] = c;
			else 
				dw[a][b] = dw[b][a] = c;
		}
		scanf("%d", &r);
		for (int i = 0; i < r; i++) 
			scanf("%d", a + i);
        
		for (int k = 1; k <= n; k++) {
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					dw[i][j] = min(dw[i][j], dw[i][k] + dw[k][j]);
					dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
				}
			}
		}

		ll res = INF;
        for (int i = 0; i <= r; i++) 
            for (int j = 0; j <= n; j++) 
                dp[i][j] = -1;
        
		for (int i = 1; i <= n; i++)
			res = min(res, rec(r - 1, i));
       
		printf("%lld\n", res);
	}
	return 0;
}



Measured memory_bytes: 5100
/*
[abc129] E - Sum Equals Xor
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 100001;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int extgcd(int a, int b, int& x, int& y) {
        int d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    static int mod_inv(int a, int m) {
        int x, y;
        extgcd(a, m, x, y);
        return (m + x) % m;
    }
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf& operator+=(gf x) { return *this = (*this + x); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf operator/(gf x) { return *this * x.inv(); }
    gf inv() { return gf(mod_inv(n, MOD)); }
    gf pow(int n) {
        gf a = *this;
        gf x = 1;
        for (; n > 0; n >>= 1) {
            if (n & 1) {
                x = x * a;
            }
            a = a * a;
        }
        return x;
    }
};

bitset<MAX_N> L;
gf dp[MAX_N + 1][2];

ll solve() {
    dp[0][0] = 1;
    for (int i = 0; i < MAX_N; i++) {
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int j = 0; j <= (smaller ? 1 : L[MAX_N - i - 1]); j++) {
                dp[i + 1][smaller || j < L[MAX_N - i - 1]] +=
                    dp[i][smaller] * (j + 1);
            }
        }
    }
    gf ans = dp[MAX_N][0] + dp[MAX_N][1];
    return ans.n;
}

int main() {
    cin >> L;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    string S;
    int ans = 0;
    cin >> S;
    FOR(i,0,3)
        if (S[i] == '1')
            ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
    
    long long x;
    cin >> x;

    long long v = 100;

    int counter = 0;

    while (v < x) {
        v += (double) v * 0.01;
        counter += 1;
    }

    cout << counter << endl;

    return 0;
}

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

int main(){

  int d;
  int sum;

  while(cin>>d){
    sum=0;
    for(int i=1; d*i<600; i++){
      sum+=(d*i)*(d*i)*d;
    }
    cout << sum << endl;
  }


  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(n), b(n), c(n - 1);
    cin >> a >> b >> c;
    int ans = 0;
    rep(i, n) a[i]--;
    rep(i, n) {
        ans += b[a[i]];
        if(i > 0 && a[i] - a[i - 1] == 1) {
            ans += c[a[i - 1]];
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <list>
 
using namespace std;

const int MOD = 1000000007;

int main() {
	int n;
	long long sum = 0;
	cin >> n;
    long long arr[n+1];
    long long arrsum = 0;
	
    for(int i=0; i<n; i++){
        long long num;
        cin >> num;
        arr[i] = num;
        arrsum += num;
    }
    
    for(int i=0; i<n-1; i++){
        arrsum -= arr[i];
        int arrsummod = arrsum % MOD;
        int result = arr[i] * arrsummod % MOD;
        sum += result;
        sum %= MOD;
    }
    cout << sum % MOD << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n,bb[101];
    cin>>n;
    for(int i=0;i<n-1;i++)cin>>bb[i];
    int sum=bb[0];
    for(int i=1;i<n-1;i++){
        if(bb[i]>bb[i-1]){
            sum+=bb[i-1];
        }else{
            sum+=bb[i];
        }
    }
    sum+=bb[n-2];
    cout<<sum;
    return 0;
}

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

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

int n;

void solve() {
  int b[20], a[20], res = 0;
  rep(i,n) cin>>b[i];
  while (true) {
    rep(j,n) {
      int cnt = 0;
      rep (k,n) if (b[j] == b[k]) cnt++;
      a[j] = cnt;
    }
    
    bool flag = false;
    rep(j,n) if (b[j] != a[j]) flag = true;
    if (!flag) break;
    
    rep(j,n) b[j] = a[j];
    res++;
  }
  cout<<res<<endl<<a[0];
  REP(i,1,n) cout<<" "<<a[i];
  cout<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector> 
using namespace std;
 
vector<int> G[100];
int d[100];

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++) d[i] = -1;

    int u, k, v;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k; j++){
            cin >> v;
            G[u-1].push_back(v-1);
        }
    }

    queue<int> q;
    q.push(0);
    d[0] = 0;
    while(!q.empty()){
        for(int &v : G[q.front()]){
            if(d[v] == -1){
                q.push(v);
                d[v] = d[q.front()] + 1;
            }
        }
        q.pop();
    }

    for(int i=0; i<n; i++){
        cout << i+1 << ' ' << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;

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

    sort(a.begin(), a.end(), greater<ll>());
    
    ll K = 0;
    while(true){
        bool change = false;
        for(int i=0;i<N;i++){
            if(a[i] + K >= N){
                change = true;
                ll b = a[i] + K;
                ll k = b / N;
                a[i] -= k * (N + 1);
                K += k;
            }
        }
        if(!change){
            break;
        }
    }
    cout << K << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t,pref[N];



int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	sort(ar+1,ar+n+1);
	fo(i,1,n)
		pref[i]=pref[i-1]+ar[i];
	for(int i=n;i>=1;i--)
	{
		if((ar[i]+pref[i-1])*2>=ar[i+1])
			sum++;
		else
			break;
	}
	cout<<sum<<endl;
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x; cin>>x;
		ans = __gcd(ans, x);
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;
#define lli long long int

int main(){
    lli h, m = 1, c = 0;
    cin >> h;
    while(h){
        c += m;
        m = m*2;
        h = h/2;
    }
    cout << c << endl;
    return 0;
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;

    char c[N + 1];
    c[0] = 'R';
    for (int i = 1; i <= N; i++)
    {
        cin >> c[i];
    }

    int counter = 0;
    int numBeforeAllRed = 0;
    for (int i = 1; i <= N; i++)
    {
        if (c[i] == 'W')
        {
            counter++;
        }
        else
        {
            break;
        }
    }
    if (counter >= N / 2)
    {
        numBeforeAllRed = 1;
    }
    counter = 0;
    for (int i = N; i != 1; i--)
    {
        if (c[i] == 'R')
        {
            if (numBeforeAllRed > 0)
            {
                if (i > numBeforeAllRed)
                {
                    counter++;
                }
                else
                {
                    break;
                }
            }
            else
            {
                for (int j = 1; j < i; j++)
                {
                    numBeforeAllRed = j;
                    if (c[j] == 'W')
                    {
                        c[j] = 'R';
                        c[i] = 'W';
                        counter++;
                        numBeforeAllRed = 0;
                        break;
                    }
                }
            }
        }
    }
    cout << counter << "\n";
}


Measured memory_bytes: 3320
#include <cassert>
#include <cstdint>
#include <functional>
#include <tuple>
#include <vector>

template <typename Abelian> class PotentializedUnionFindTree {

public:
	using value_type = Abelian;
	using reference = value_type &;
	using const_reference = const value_type &;
	using size_type = std::uint_fast32_t;

private:
	using F = std::function<value_type(const_reference, const_reference)>;
	using G = std::function<value_type(const_reference)>;
	const F f;
	const G g;
	const value_type neutral_;
	std::vector<std::tuple<bool, size_type, value_type>> tree;

public:
	PotentializedUnionFindTree(const size_type size,
		const_reference neutral = value_type(),
		const F &f = std::plus<value_type>(),
		const G &g = std::negate<value_type>())
		: f(f), g(g), neutral_(neutral), tree(size, std::forward_as_tuple(1, 1, neutral_)) {}
	size_type find(const size_type x) {
		assert(x < tree.size());
		if (std::get<0>(tree[x]))
			return x;
		const size_type t = std::get<1>(tree[x]);
		std::get<1>(tree[x]) = find(t);
		std::get<2>(tree[x]) = f(std::get<2>(tree[t]), std::get<2>(tree[x]));
		return std::get<1>(tree[x]);
	}
	value_type potential(const size_type x) {
		assert(x < tree.size());
		find(x);
		return std::get<2>(tree[x]);
	}
	value_type diff(const size_type x, const size_type y) {
		assert(x < tree.size());
		assert(y < tree.size());
		return f(potential(y), g(potential(x)));
	}
	bool unite(size_type x, size_type y, value_type d) {
		assert(x < tree.size());
		assert(y < tree.size());
		d = f(d, diff(y, x));
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (std::get<1>(tree[x]) < std::get<1>(tree[y]))
			std::swap(x, y), d = g(d);
		std::get<1>(tree[x]) += std::get<1>(tree[y]);
		tree[y] = std::forward_as_tuple(0, x, d);
		return true;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < tree.size());
		assert(y < tree.size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < tree.size());
		return std::get<1>(tree[find(x)]);
	}
};

#include<iostream>
int main(void) {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFindTree<int> T(n, 0);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
long long int arr[200001];
long long int x[200001];
long long int sum;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
		x[arr[i]]++;
	}
	for(int i=1;i<=n;i++){
		sum+=(x[i]*(x[i]-1))/2;
	}
	for(int i=0;i<n;i++){
		long long int ans=sum-(x[arr[i]]*(x[arr[i]]-1)/2);
		if((x[arr[i]]-1)*(x[arr[i]]-2)/2>=0)ans+=(x[arr[i]]-1)*(x[arr[i]]-2)/2;
		printf("%lld\n",ans>0?ans:0);
	}
}

Measured memory_bytes: 4608
from collections import deque
from sys import stdin
n = int(input())
L = deque()
for _ in range(n):
    com = list(map(str, stdin.readline().split()))
    if com[0] == 'insert':
        i = int(com[1])
        L.appendleft(i)
    elif com[0] == 'delete':
        i = int(com[1])
        try:
            L.remove(i)
        except ValueError:
            continue
    elif com[0] == 'deleteFirst':
        L.popleft()
    elif com[0] == 'deleteLast':
        L.pop()
for i in range(len(L)):
    if i == len(L) - 1:
        print(L[i])
    else:
        print(L[i], end=' ')


Measured memory_bytes: 45908
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  ll X;
  cin>>X;

  for(int k=1;100*k<=X;k++){
    ll rest=X-100*k;
    if(rest<=5*k){
      cout<<1<<endl;
      return 0;
    }
  }

  cout<<0<<endl;

  return 0;
}


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

int main()
{
	int k;
	string s;
	cin >> k;
	cin >> s;

	string result;
	if (s.size() <= k){
		result = s;
	}else{
		result = s.substr(0,k) + "...";
	}
	cout << result << "\n";
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

using ll = long long int;

int main(){
    
    string S;
    cin >> S;
    
    int minmaxcnt = 10000;
    for(char c = 'a'; c <= 'z'; ++c){
        int cnt = 0;
        int maxcnt = 0;
        for(int i = 0; i < S.size(); ++i){
            if(S[i] != c){
              cnt++;
            }else{
                maxcnt = max(cnt, maxcnt);
                cnt = 0;
            }
        }
        maxcnt = max(cnt, maxcnt);
        minmaxcnt = min(maxcnt, minmaxcnt);
    }
    
    cout << minmaxcnt << endl;
    
    return 0;
}

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

int main()
{
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];

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

  if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

read=sys.stdin.read
class Unionfind():
    def __init__(self,n):
        self.parents=[-1]*n
        self.ranks=[0]*n
        self.dist=[0]*n 
    
    def find(self,x):
        if self.parents[x]<0:
            return self.dist[x],x
        else:
            tmp=self.find(self.parents[x])
            self.dist[x]+=tmp[0]
            self.parents[x]=tmp[1]
            return self.dist[x],self.parents[x]
    
    def union(self,x,y,d):
        rx=self.find(x)[-1]
        ry=self.find(y)[-1]
        diff=d+self.dist[x]-self.dist[y]
        if rx==ry:
            if diff!=0:
                return True
            return False
        if self.ranks[ry]>self.ranks[rx]:
            rx,ry=ry,rx
            diff=-diff
        self.parents[ry]=rx
        self.dist[ry]=diff
        if self.ranks[ry]==self.ranks[rx]:
            self.ranks[rx]+=1
        return False
    
def main():
    n,m,*lrd=map(int,read().split())
    v=Unionfind(n)
    for l,r,d in zip(*[iter(lrd)]*3):
        if v.union(l-1,r-1,d):
            print('No')
            break
    else:
        print('Yes')
if __name__=='__main__':
    main()


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

int main()
{
    char s;
    int count;

    count = 0;
    for(int i = 0; i < 3; i++) {
        cin >> s;
        if(s == '1') {
            count += 1;
        }
    }

    cout << count << endl;
    return 0;
}

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

static const int maxn=10000;

struct Node {
  int parent,left,right;
};

Node T[maxn];
int n,D[maxn],H[maxn];

void setDepth(int u,int d) {
  if (u==(-1)) {
    return ;
  }
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}
int setHeight(int u) {
  int h1=0,h2=0;
  if (T[u].left!=(-1)) {
    h1=setHeight(T[u].left)+1;
  }
  if (T[u].right!=(-1)) {
    h2=setHeight(T[u].right)+1;
  }
  return H[u]=max(h1,h2);
}
int getSibling(int u) {
  if (T[u].parent==(-1)) {
    return (-1);
  }
  if (T[T[u].parent].left!=u and T[T[u].parent].left!=(-1)) {
    return T[T[u].parent].left;
  }
  if (T[T[u].parent].right!=u and T[T[u].parent].right!=(-1)) {
    return T[T[u].parent].right;
  }
  return (-1);
}
void print(int u) {
  cout<<"node "<<u<<": "<<flush;
  cout<<"parent = "<<T[u].parent<<", "<<flush;
  cout<<"sibling = "<<getSibling(u)<<", "<<flush;
  int deg=0;
  if (T[u].left!=(-1)) {
    deg++;
  }
  if (T[u].right!=(-1)) {
    deg++;
  }
  cout<<"degree = "<<deg<<", "<<flush;
  cout<<"depth = "<<D[u]<<", "<<flush;
  cout<<"height = "<<H[u]<<", "<<flush;
  if (T[u].parent==(-1)) {
    cout<<"root"<<endl;
  }
  else if (T[u].left==(-1) and T[u].right==(-1)) {
    cout<<"leaf"<<endl;
  }
  else {
    cout<<"internal node"<<endl;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin>>n;
  for (int i=0; i<n; i++) {
    T[i].parent=(-1);
  }
  for (int i=0; i<n; i++) {
    int v,l,r;
    cin>>v>>l>>r;
    T[v].left=l;
    T[v].right=r;
    if (l!=(-1)) {
      T[l].parent=v;
    }
    if (r!=(-1)) {
      T[r].parent=v;
    }
  }
  int root=0;
  for (int i=0; i<n; i++) {
    if (T[i].parent==(-1)) {
      root=i;
    }
  }
  setDepth(root,0);
  setHeight(root);
  for (int i=0; i<n; i++) {
    print(i);
  }
  return 0;
}


Measured memory_bytes: 3188
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n;
    int a[1000];
    int cost;
    int ans = 1000000000;
    cin >>n;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,100){
        cost = 0;
        rep(j,n){
            cost += (a[j]-i)*(a[j]-i);
        }
        if(cost < ans){
            ans = cost;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
 
int main(){
	int N,M;
	cin >> N >> M;

    int K;
    int food_like[N][M];

    int tmp;

    for(int i=0; i<M; i++){
        for(int j=0; j<N; j++){
            food_like[j][i]=0;
        }
        
    }

    for(int i=0; i<N; i++){

        cin >> K;

        for(int j=0; j<K; j++){
            cin >> tmp;
            food_like[i][tmp-1] = 1;
        }
    }
    
    int count = 0;

    for(int i=0; i<M; i++){
        int sum = 0;
        for(int j=0; j<N; j++){
            sum += food_like[j][i];
        }
        if(sum==N){count++;}
    }

    cout << count << endl;

    return 0;
    

    
}

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

const int maxn=105;
int main()
{
    int n,wn[maxn],tmp,ans;
    char a[26],b[26],w[maxn];
    while(~scanf("%d",&n))
    {
        ans=0;
        scanf("%s",&w);
        for(int i=0;i<n;i++)    wn[i]=w[i]-'a';
        for(int i=1;i<n;i++)
        {
            tmp=0;
            fill(a,a+26,0);
            fill(b,b+26,0);
            for(int j=0;j<i;j++)    a[wn[j]]++;
            for(int k=i;k<n;k++)
            {
                if(a[wn[k]]) tmp++;
                a[wn[k]]=0;
            }
            ans=max(ans,tmp);
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h1, m1, h2, m2, k;
    cin, h1, m1, h2, m2, k;
    h1 = h1 * 60 + m1;
    h2 = h2 * 60 + m2;
    print(max(h2 - h1 - k, 0));
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  int ans=0,cnt=0;
  rep(i,s.size())
  {
    if(s.at(i)=='A' || s.at(i)=='T' || s.at(i)=='G' || s.at(i)=='C')
    {
      cnt++;
    }
    else
    {
      ans=max(ans,cnt);
      cnt=0;
    }

    ans=max(ans,cnt);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,m;cin>>n;
  vector<string> s(n);
  rep(i,n){
    cin>>s[i];
  }
  cin>>m;
  vector<string> t(m);
  rep(i,m){
  	cin>>t[i];
  }
  int ans=0;
  rep(i,n){
    string tmp=s[i];
    int score=0;
    rep(j,n){
      if(tmp==s[j]){
        score++;
      }
    }
    rep(j,m){
      if(tmp==t[j]){
        score--;
      }
    }
    ans=max(ans,score);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file

int a[100005];
int main()
{
    int n;
    cin>>n;
    MEM(a,0);
    rep(i,0,n)
    {
        int num;
        cin>>num;
        a[num]++;

    }
    ll sum=0;
    rep(i,0,100005)
    {
        sum+=a[i]*i;
    }
    int q;
    cin>>q;
    while(q--)///a[n]为n出现的次数
    {
        int b,c;
        cin>>b>>c;
        sum=sum+a[b]*(c-b);
        a[c]+=a[b];
        a[b]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 4024
line = gets.chomp.split(" ")

students = []
line[0].to_i.times do
    position = gets.chomp.split(" ")
    students.push(position.map!(&:to_i))
end

points = []
line[1].to_i.times do
    position = gets.chomp.split(" ")
    points.push(position.map!(&:to_i))
end

line[0].to_i.times do |i|
    ans = 0
    min = 10 ** 8 * 2
    line[1].to_i.times do |j|
        dist = (students[i][0] - points[j][0]).abs + (students[i][1] - points[j][1]).abs
        if min > dist
            min = dist
            ans = j
        end
    end
    puts ans+1
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b) * c / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.append(N+a[0])
#print(a)
max = 0
for i in range(len(a)-1):
  p = abs(a[i]-a[i+1])
  max = p if max < p else max
print(N-max)


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

using namespace std;

#define ll long long
#define mod 1000000007

void solve(){
	double n,t,d;
	cin>>n>>t>>d;
	if(n / d <= t){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

int main(){
	int t = 1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string A, B, C, card;
    cin >> A >> B >> C;
    card = A.substr(0, 1);
    while (true) {
        if (card == "a") {
            if (A.empty()) {
                cout << "A" << endl;
                break;
            } else {
                card = A.substr(0, 1);
                A.erase(0, 1);
            }
        } else if (card == "b") {
            if (B.empty()) {
                cout << "B" << endl;
                break;
            } else {
                card = B.substr(0, 1);
                B.erase(0, 1);
            }
        } else {
            if (C.empty()) {
                cout << "C" << endl;
                break;
            } else {
                card = C.substr(0, 1);
                C.erase(0, 1);
            }
        }
    }
    return 0;
}

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

int main(){
    int n;  cin >> n;
    vector<ll> a(n+2);
    for(int i=1; i<=n; i++){
        cin >> a.at(i);
    }
    vector<pair<ll, ll>> dis(n+1);

    for(int i=0; i<=n; i++){
        if(i==n) dis.at(i) = make_pair(abs(a.at(i+1)-a.at(i)), 0);
        else
            dis.at(i) = make_pair(abs(a.at(i+1)-a.at(i)),abs(a.at(i+2)-a.at(i))); 
    }
    ll sum=0;
    for(int i=0; i<=n; i++) sum += dis.at(i).first;
    for(int i=0; i<n; i++){
        ll tmp = sum;
        tmp = tmp-(dis.at(i).first+dis.at(i+1).first)+dis.at(i).second;
        cout << tmp << endl;
    }


}

Measured memory_bytes: 3584
import queue
h, w = list(map(int, input().split()))
s = [[' ']*(w+1) for i in range(h+1)]
for i in range(h):
    tmp = list(input())
    for j in range(w):
        s[i][j] = tmp[j]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
cnt = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            cnt += 1
def bfs():
    d =[[10**10]*(w) for i in range(h)]

    que = queue.Queue()

    que.put([0, 0])
    d[0][0] = 0

    while not que.empty():
        p = que.get()
        if p[0] == h and p[1] == w:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != '#' and d[nx][ny] == 10**10:
                que.put([nx, ny])
                d[nx][ny] = d[p[0]][p[1]] + 1
    
    return d[h-1][w-1]

print(cnt - bfs() - 1) if bfs() != 10**10 else print(-1)

Measured memory_bytes: 45032
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse4,sse4.2,popcnt,abm,mmx,avx")
#endif
#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

vector<int> a, b, res;

int n;
const int N = 2e5 + 5;
int cnt_a[N], cnt_b[N];

const int RANDOM =
    chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);

bool validate() {
  bool valid = true;
  for (int i = 0; i < n; ++i) {
    valid &= (a[i] != res[i]);
  }
  return valid;
}

bool solve() {
  res = b;
  for (int t = 0; t < 20; ++t) {
    rotate(begin(res), begin(res) + rng() % n, end(res));
    if (validate()) return true;
  }
  res = b;
  reverse(all(res));
  for (int t = 0; t < 20; ++t) {
    if (validate()) return true;
    shuffle(all(res), rng);
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif
  cin >> n;
  a.resize(n), b.resize(n), res.resize(n);
  cin >> a >> b;
  for (int x : b) ++cnt_b[x];
  for (int x : a) {
    ++cnt_a[x];
    if (cnt_b[x] + cnt_a[x] > n) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (solve()) {
    cout << "Yes" << endl;
    cout << res << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 7268
#include<stdio.h>

int main(void)

{

 int i,j,x;

 int max=0;

 int min=0;

 long sum=0L;

   scanf("%d",&j);

   for(i=0;i<j;i++){

  scanf("%d",&x);

  sum+=(long)x;

  if(i==0){

   max=x;

   min=x;

  }

  if(x>max){

   max=x;

  }else if(x<min){

   min=x;

  }

  x=0;

 }

 printf("%d %d %ld\n",min,max,sum);

   return 0;

}

Measured memory_bytes: 600
import Data.List.Split
import Text.Printf

main = do
    input <- fmap (map (map read.splitOn ",").lines) getContents
    print $ total input
    print $ round'.average $ input
total :: Num a => [[a]] -> a
total = sum.map product

average xs = (fromIntegral.sum.map last $ xs)/ (fromIntegral.length $ xs)

round' :: Double -> Int
round' n
    | x >= 0.5 = ceiling n
    | x <  0.5 = floor n
    where (a,x) = properFraction n

Measured memory_bytes: 3636
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, maxv;
	cin >> n >> maxv;
	int ans = INF;
	while (n--)
	{
		int c, t;
		cin >> c >> t;
		if (t > maxv) continue;
		ans = min(ans, c);
	}
	if (ans == INF) puts("TLE");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


SIZE = 105
table = [0]*SIZE

N = int(input())
input_array = list(map(int,input().split()))

maximum = 0

for i in range(N):
    table[0] -= 1
    table[input_array[i]] += 1
    maximum = max(maximum,input_array[i])

for i in range(maximum-1,-1,-1):
    table[i] += table[i+1]

ans = 0

for i in range(1,maximum+1):
    if i <= table[i]:
        ans = i

print("%d"%(ans))



Measured memory_bytes: 13876
#include <bits/stdc++.h>
using namespace std;
int main() {
	double_t a, b, c;
	cout << fixed << setprecision(10);
	cin >> a >> b >> c;
	double_t s, l, h;
	s = a * b * sin(3.14159265 * c / 180) * 0.5;
	l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(3.14159265 * c / 180));
	h = sin(3.14159265 * c / 180) * b;
	cout << s << endl;
	cout << l << endl;
	cout << h << endl;
}


Measured memory_bytes: 3496
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final int a = scanner.nextInt();
    final int b = scanner.nextInt();
    final int x = scanner.nextInt();
    System.out.println((x - a) >= 0 && (x - a) <= b ? "YES" : "NO");
  }
}


Measured memory_bytes: 21716
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		int count1=0,count2=0,count3=0;
		ArrayList<Integer> ar=new ArrayList<Integer>();
		for(int i=0;i<N;i++){
			ar.add(sc.nextInt());
		}
		for(int i=0;i<N;i++){
			if(ar.get(i)<=A){
				count1++;
			}
			else if(ar.get(i)>=A+1&&ar.get(i)<=B){
				count2++;
			}
			else{
				count3++;
			}
		}
		System.out.println(Math.min(count1, Math.min(count2, count3)));
	}

}


Measured memory_bytes: 23508
import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  xs <- (map read . words) <$> getLine
  if xs !! 0 == 0 && xs !! 1 == 0 then return ()
    else do {
    putStrLn $ solve xs;
    main
    }

solve :: [Int] -> String
solve xs
  | h == 0 = ""
  | otherwise = (replicate w '#') ++ "\n" ++ solve ((h-1) : w : [])
  where h = xs !! 0
        w = xs !! 1

Measured memory_bytes: 3884
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n,sum=0;
    cin>>n;
    vector<ll> a(n),b;
    rep(i,n) {
        cin>>a[i];
        sum += a[i];
        if(a[i]%10!=0) b.insert(b.begin(), a[i]);
        
    }
    sort(ALL(b));
    rep(i,b.size()) if(sum%10==0) sum -= b[i];
    cout<<(sum%10==0 ? 0:sum)<<endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()
#define TST(H) (#H);

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int r,c, k;
	cin >>r >>c >>k;
	vector<VI> dt(r+4, VI(c+4));
	vector<vector<VL>> dp(4,vector<VL>(r+4 ,VL(c+4)));
	rep(i, k){
		int y, x, v;
		cin >>y >>x >>v;
		dt[y-1][x-1] = v;
	}

	dp[1][0][0] = dt[0][0];
	rep(y, r)  rep(x,c) rep(i, 4){
		dp[0][y+1][x] = max(dp[0][y+1][x], dp[i][y][x]);
		dp[1][y+1][x] = max(dp[1][y+1][x], dp[i][y][x] + dt[y+1][x]);
		dp[i][y][x+1] = max(dp[i][y][x+1], dp[i][y][x]);
		if(i<3)
			dp[i+1][y][x+1] = max(dp[i+1][y][x+1], dp[i][y][x] + dt[y][x+1]);
	}
	ll ans = 0;
	rep(i, 4) ans = max(ans, dp[i][r-1][c-1]);
	cout << ans <<"\n";
	

	return 0;
}



Measured memory_bytes: 391800
//https://atcoder.jp/contests/dp/tasks/dp_e
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int n, W;
	cin >> n >> W;
	vector<vector<int>> wv (n, vector<int> (2));
	for (auto& x:wv) {
		for (auto&y:x) {
			cin >> y;
		}
	}
	int sv = 0;
	for (auto x:wv) {
		sv+=x[1];
	}
	vector<long> dp (sv+1, 1e9); // min weight for value 0 to sv
	dp[0] = 0;
	for (auto x:wv) {
		for (int i = sv-x[1]; i >= 0; i--) {
			dp[i+x[1]] = min(dp[i+x[1]], dp[i]+x[0]);
		}
	}
	long m = 0;
	for (long i = 0; i < (long)dp.size(); i++) {
		if (dp[i] <= W) {
			m = max(m, i);
		}
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1024
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize,
      sa: [String; n]
    };

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;

    for s in sa {
        if s == "AC" {
            ac += 1
        } else if s == "WA" {
            wa += 1
        } else if s == "TLE" {
            tle += 1
        } else {
            re += 1
        }
    }

    println!("AC x {}\nWA x {}\nTLE x {}\nRE x {}", ac, wa, tle, re);
}


Measured memory_bytes: 7820
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T>
T gcd(T x, T y)
{
    if (x < y)
    {
        std::swap(x, y); //小さい方をyとする
    }
    int r = x % y;
    while( r != 0 )
    {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main()
{
    string s;
    cin >> s;
    string key = "keyence";
    if (s.compare(key) == 0)
    {
        cout << "YES" << endl;
        return 0;
    }
    // 取り除く文字列を全探索する
    for (int left = 0; left < s.size(); ++left)
    {
        for (int right = left; right < s.size(); ++right)
        {
            string sub = "";
            for (int k = 0; k < s.size(); ++k)
            {
                if (k >= left && k <= right) continue;
                else sub.push_back(s[k]);
            }
            if (sub.compare(key) == 0)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256