akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"charmap.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int a[100010];
int main(){
	int n,k,q;
	cin>>n>>k>>q;
	forn(i,n){
		a[i]=k;
	}
	rep(i,q){
		int c;
		cin>>c;
		a[c]++;
	}
	forn(i,n){
		a[i]-=q;
		if(a[i]>0){
			puts("Yes");
		}
		else{
			puts("No");
		}
	}
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll x;
    cin>>x;
    ll ans=0;
    while(x>=500){
        x-=500;
        ans+=1000;
    }
    while(x>=5){
        x-=5;
        ans+=5;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
int main(){
    ll n; cin>>n;
    for(int i=1; i<=3500;i++){
        for(int j=1; j<=3500;j++){
            ll sub=4*i*j-i*n-j*n;
            ll cal=i*j*n;
            if(sub>0&&cal%sub==0){cout<<i<<" "<<j<<" "<<cal/sub<<endl; return 0;}
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int c[10000007];
	long long int i, j;
	for (i = 0; i <= n; i++)
		c[i] = 1;
	for (i = 2; i <= n; i++)
		for (j = i; j <= n; j += i)
			c[j]++;
	long long int ans = 0;
	for (i = 1; i <= n; i++)
		ans += i * c[i];
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector< int > arr(n,1);
  int ans = n;
  int d;
  int x;
  for(int i = 0;  i < k ; ++i){
    cin >> d;
    for(int j = 0; j< d; ++j){
      cin >> x;
      if(arr[x-1] == 1){
        ans--; arr[x-1]--;
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void)
{
  int a[10000],n,i,max,min;
  long long int sum;
  scanf("%d",&n);
  for(i=0;i<n;i++ )
    {
      scanf("%d",&a[i]);
    }
  max=a[0];
  min=a[0];
  sum=a[0];
  for(i=1;i<n;i++)
    {
      if(max<a[i])
	{ max=a[i];}
      if(min>a[i])
	{min=a[i];}
      sum=sum+a[i];
    }
  printf("%d %d %lld\n",min,max,sum);
  
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  string w;
  cin >> w;
  if(w.length() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  sort(ALL(w));
  REP(i, w.length() - 1) {
    if(w[i] != w[i + 1] && i % 2 == 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)

for i in range(n):
    if a[i] in d.keys():
        d[a[i]] += 1
    else:
        d[a[i]] = 1

if max(d.values()) >= 2:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 33988
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > edges(n);
    vector<vector<bool> > graph(n, vector<bool>(n, false));
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        graph[a][b] = true;
    }

    for(int x=0; x<n; ++x){
        vector<int> prev(n, -1);
        queue<int> q;
        q.push(x);
        while(!q.empty()){
            int a = q.front();
            q.pop();
            for(int b : edges[a]){
                if(prev[b] == -1){
                    prev[b] = a;
                    q.push(b);
                }
            }
        }

        if(prev[x] != -1){
            vector<bool> used(n, false);
            int y = x;
            do{
                used[y] = true;
                y = prev[y];
            }while(y != x);

            for(int i=0; i<n; ++i){
                for(int j=0; j<n; ++j){
                    if(used[i] && used[j] && graph[i][j]){
                        int a = prev[j];
                        while(a != i){
                            used[a] = false;
                            a = prev[a];
                        }
                        prev[j] = i;
                    }
                }
            }

            vector<int> ans;
            for(int i=0; i<n; ++i){
                if(used[i])
                    ans.push_back(i+1);
            }
            cout << ans.size() << endl;
            for(int a : ans)
                cout << a << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const ll inf = 1e18;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, nChild[maxn];
ii par[maxn];
vector<ii> a[maxn];
ll l[maxn];

int fixRoot(int u) {
    nChild[u] = 1;
    REP(i, a[u].sz()) {
        int v = a[u][i].fi;
        if (v!=par[u].fi) {
            par[v].fi = u;
            par[v].se = a[u][i].se;
            nChild[u] += fixRoot(v);
        }
    }
    return nChild[u];
}

int findCentroid(int u) {
    REP(i, a[u].sz()) {
        int v = a[u][i].fi;
        if (v!=par[u].fi && nChild[v]>n/2) {
            return findCentroid(v);
        }
    }
    return u;
}

ll level(int u) {return l[u]>-1 ? l[u] : l[u]=level(par[u].fi)+par[u].se;}

int main() {
    //freopen("halminton.inp", "r", stdin);
    //freopen("halminton.ans", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    FOR(i, 1, n-1) {
        int u, v, w; cin >> u >> v >> w;
        a[u].push_back(ii(v, w));
        a[v].push_back(ii(u, w));
    }
    fixRoot(1);
    int root = findCentroid(1);
    memset(par, 0, sizeof(par));
    fixRoot(root);
    memset(l, -1, sizeof(l));
    l[root] = 0;
    ll res = 0, MIN = inf, MAX = -inf;
    int sp;
    FOR(i, 1, n) res += 2*level(i);
    REP(i, a[root].sz()) {
        int v = a[root][i].fi;
        if (MAX<nChild[v]) {
            MAX = nChild[v];
            sp = v;
        }
    }
    REP(i, a[root].sz()) {
        int v = a[root][i].fi;
        if (n-(v!=sp)-MAX<MAX) continue;
        if (nChild[v]-1<=n-nChild[v]-1) MIN = min(MIN, l[v]);
        else MIN = min(MIN, 3*l[i]);
    }
    cout << res-MIN;
}



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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 1 ; i <= a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second
#define INF 1000000000

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}



void solve()
{
	int a,b;
	cin>>a>>b;

	cout<<a*b<<"\n";
}



int main() {

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


	int t = 1;
	//cin >> t;


	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    ll N,A,B;
    cin>>N>>A>>B;
    if((A-B)%2==0){
        cout<<abs(A-B)/2<<endl;
    }
    else{
     	ll p=0;
         ll k=0;
           ll c=A;
          ll d=B;
        if(A<B){
            p+=A-1;
            p++;
            B-=A;
          	A=0;
            p+=(B-A)/2;
            k+=N-d;
            k++;
            c+=N-d+1;
          	d=N;
            k+=(d-c)/2;
        }
        else if(A==B){
            p=N-A;
            k=A-1;
        }
        else{
            p+=B-1;
            p++;
            A-=B;
          	B=0;
            p+=(A-B)/2;
            k+=N-c;
            k++;
            d+=N-c+1;
          	c=N;
            k+=(c-d)/2;
        }
         cout<<min(p,k)<<endl;
    }
}


Measured memory_bytes: 3620
N, X, Y = map(int,input().split())
X = X-1
Y = Y-1
CNT = [0]*(N)
for i in range(N):
  for j in range(i+1,N):
    nn1 = j-i
    nn2 = abs(i-X)+abs(j-Y)+1
    if nn1>nn2:
      CNT[nn2] += 1
    else:
      CNT[nn1] += 1
for i in range(1,N):
  print(CNT[i])

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main() {
  int b, f, r, v;
  int i, j, k, n;
  int A[4][3][10] = {};
  
  cin >> n;
  for(i = 0; i < n; i++) {
	cin >> b >> f >> r >> v;
	A[b-1][f-1][r-1] += v;
  }
  
  for(i = 0; i < 4; i++) {
	for(j = 0; j < 3; j++) {
	  for(k = 0; k < 10; k++) {
		cout << " " << A[i][j][k];
	  }
	  cout << endl;
	}
	if (i < 3) {
	  cout << "####################" << endl;
	}
  }
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool enable = true;
    int start = a % b;
    int counter = 2;
    while (true) {
        if ((a * counter) % b == c) break;
        if ((a * counter) % b == start) {
            enable = false;
            break;
        }
        ++counter;
    }
    cout << (enable ? "YES" : "NO") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
n,m=map(int, input().split())
e=[[] for _ in range(n)]
e_rev=[[] for _ in range(n)]
for i in range(m):
    ai,bi=map(int, input().split())
    e[ai].append(bi)
    e_rev[bi].append(ai)

p_ord=[]
used=[0]*n
def dfs(v):
    used[v]=1
    for u in e[v]:
        if not used[u]:
            dfs(u)
    p_ord.append(v)
for i in range(n):
    if not used[i]:
        dfs(i)
compo = [0]*n
used=[0]*n
def dfs_rev(v,c):
    compo[v]=c
    used[v]=1
    for u in e_rev[v]:
        if not used[u]:
            dfs_rev(u,c)
cnt=0
for i in reversed(p_ord):
    if not used[i]:
        dfs_rev(i,cnt)
        cnt+=1
cc=[[] for _ in range(cnt+1)]
for i in range(n):
    cc[compo[i]].append(i)

print(len([cci for cci in cc if cci]))
for cci in cc:
    if cci:
        print(len(cci),*cci)

Measured memory_bytes: 275752
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int a, b, c;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> a>>b>>c;
	if (a == b && b == c) {
		out << "Yes" << endl;
	}
	else {
		out << "No" << endl;
	}

	return 0;
}
#endif


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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long K, long long T, std::vector<long long> a){
  sort(a.rbegin(), a.rend());
  if(T==1)
    std::cout << K-1 << std::endl;
  else
    std::cout << max((ll)0, a[0]-(K-a[0])-1) << std::endl;
}

int main(){
  long long K;
  scanf("%lld",&K);
  long long T;
  scanf("%lld",&T);
  std::vector<long long> a(T);
  for(int i = 0 ; i < T ; i++){
    scanf("%lld",&a[i]);
  }
  solve(K, T, std::move(a));
  return 0;
}


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

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

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    string s;
    cin >> n >> s;

    vector<int> a(n);
    rep(i, n) {
        if(s[i] == 'R') a[i] = 0;
        if(s[i] == 'G') a[i] = 1;
        if(s[i] == 'B') a[i] = 2;
    }

    ll ans = 1;
    vector<int> cnt(3);
    rep(i, n) ++cnt[a[i]];
    rep(i, 3) ans *= cnt[i];
    //rep(i, 3) cout << cnt[i] << endl;
    //cout << ans << endl;
    rep(j, n) rep(i, j) {
        int k = j + (j - i);
        if(k >= n) continue;
        if(a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
        --ans;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll=long long;

int main(){
    const ll INF=1e9+100;
    ll N,W;
    cin >> N >> W;
    vector<ll> w(N);
    vector<ll> v(N);
    for(ll i=0;i<N;i++){
        cin >> w[i] >> v[i];
    }
    ll dp[1000000];
    for(ll i=0;i<1e6;i++){
        dp[i]=INF;
    }
    dp[0]=0;
    for(ll i=0;i<N;i++){
        for(ll j=1e5;j>=0;j--){
            if(dp[j]!=INF){
                dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<=1e5;i++){
        if(dp[i]<=W){
            ans=i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8064
#include<stdio.h>

int main(void){
  int n;
  int r;
  int p;
  int c;
  int i;
  int j;
  for(;;){
    scanf("%d %d",&n,&r);
    if(n==0)
      {
	if(r==0){break;}
      }
    int card[n];
    for(i=n;i>0;i--)
      {
	card[n-i]=i;
      }
    /*--------------確認用-------------------
    printf("card:");
    for(i=0;i<n;i++)
      {
	printf("%d ",card[i]);
      }
    printf("\n");
    /*--------------------------------------*/
    for(i=0;i<r;i++)
      {
	scanf("%d %d",&p,&c);
	int card_p[p-1];
	int card_c[c];
	for(j=0;j<p-1;j++)
	  {
	    card_p[j]=card[j];
	  }
	/*---------確認用-------------------------
	printf("card_p:");
	for(j=0;j<p-1;j++)
	  {
	    printf("%d ",card_p[j]);
	  }
	printf("\n");
	/*----------------------------------------*/
	for(j=0;j<c;j++)
	  {
	    card_c[j]=card[p+j-1];
	  }
	/*---------確認用-------------------------
	printf("card_c:");
	for(j=0;j<c;j++)
	  {
	    printf("%d ",card_c[j]);
	  }
	printf("\n");
	/*----------------------------------------*/
	for(j=0;j<c;j++)
	  {
	    card[j]=card_c[j];
	  }
	for(j=0;j<p-1;j++)
	  {
	    card[c+j]=card_p[j];
	  }
	/*-----------------------------------------
	for(j=0;j<n;j++)
	  {
	    printf("%d ",card[j]);
	  }
	printf("\n");
	/*----------------------------------------*/
      }
    printf("%d\n",card[0]);
  }
  
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

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

    rep(n,0,N) cout<<accumulate(ToEnd(adj.at(n)),0)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(a>=x)
	{
	  if(a>=b)
	  {
  		if(a-b>=0&&a-b<=x){printf("delicious");}
  		else printf("dangerous");
     	}
		 	else if (b>a){
			 if(b-a<=x)printf("safe");
			 else printf("dangerous");
			 }
	}
	else 
	{
		if(a>=b){printf("delicious");}
		else printf("safe");
	}
} 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;

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

	vector<int> taste(N);

	int x = 0;

	taste[0] = L + 1 - 1;
	for (int i = 2; i <= N; i++)
	{
		taste[i - 1] = L + i - 1;
		
		if (abs(taste[i - 2]) > taste[i - 1])
		{
			x = i - 1;
		}
	}
	
	taste[x] = 0;

	int sum = accumulate(taste.begin(), taste.end(), 0);
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import math
X = int(input())

if X == 1:
    print(1,0)
    exit()

def repeat_any_square( a,n ):
    if n == 1:
        return a
    x = repeat_any_square( a,n//2 )
    x *= x
    if n % 2 == 1:
        x *= a
    return x

ans = []
for i in range(-1000,1000):
    ans.append(repeat_any_square(i,5))

#print(ans)
for i in range(2000):
    if ((ans[i] - X) in ans) == True:
        flag_A = 1
        flag_B = 1
        if ans[i] < 0:
            flag_A = -1
        if ans[i] - X < 0:
            flag_B = -1
        print(flag_A*int(math.pow(flag_A*ans[i],1/5)),flag_B*int(math.pow(flag_B*(ans[i]-X),1/5)))

        exit()

Measured memory_bytes: 9452
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<pair<int,int> > v;
int N;
int main (){
    cin >> N;
    for(int i=0;i<N;i++) {
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());
    long long int time = 0;
    bool over = false;
    for(int i=0;i<N;i++) {
        time += v[i].second;
        if(v[i].first < time) over = true;
    }
    cout << ( over ? "No": "Yes") << endl;
    return 0;
}


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

int main() {
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);

  int seven = 0;
  int five = 0;

  for(int data : vec)
  {
    if(data == 7)
      seven++;
    else if(data == 5)
      five++;
  }
  
  if((seven == 1) && (five == 2))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool Check(string S, int A, int B, int C, int D) {
    int fm = min(A, B);
    int fM = max(A, B);
    int lm = min(C, D);
    int lM = max(C, D);
    while(lM < S.size()) S.pop_back();

    if(S.find("##", fm) != std::string::npos) {
        return false;
    }

    if(((A < B) && (C < D)) || ((A > B) && (C > D))) {
        return true;
    } else {
        string T2 = S.substr(fM - 2, lm - fM + 3);
        if(T2.find("...") == std::string::npos) {
            return false;
        }
        return true;
    }
}

int main() {
    int N, A, B, C, D;
    string S;

    cin >> N >> A >> B >> C >> D;
    cin >> S;

    bool result = Check(S, A, B, C, D);

    if(result) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main() {	
	vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k - 1] << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
		

}
int main(){
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll ans=0;
  
if(A>=K){
  ans+=K;
}
else{
  ans+=A;
K-=A;
  
  if(B>=K){
    
  }
else{
K-=B;
  ans-=K;
  
}
}

  cout<<ans<<endl;
}


Measured memory_bytes: 3636
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(input())

row = [0] * h
col = [0] * w

for i in range(h):
    if '#' in a[i]:
        row[i] = True

for i in range(h):
    for j in range(w):
        if '#' == a[i][j]:
            col[j] = True

for i in range(h):
    output = ''
    for j in range(w):
        if row[i] and col[j]:
            output += a[i][j]
    if not output == '':
        print(output)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];

    int sum = a[0];

    int ans = 0;
    for(int i=1;i<n;i++){
        ans += sum*a[i];
        ans%=M;
        sum+=a[i];
        sum%=M;
    }


    cout << ans << "\n";

}


Measured memory_bytes: 5200
#include<stdio.h>
#include<stdlib.h>

int main(){
	int n,t[101],rank[101],x,y;
	int a,b,c,d;
	
	scanf("%d\n",&n);
	for(x=0;x<=n;x++){
		t[x]=0;
		rank[x]=1;
	}
	for(x=0;x<n*(n-1)/2;x++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d)t[a]+=3;
		if(c<d)t[b]+=3;
		if(c==d)t[a]+=1,t[b]+=1;
	}
	for(x=1;x<=n;x++){
		for(y=x+1;y<=n;y++){
			if(t[x]>t[y])rank[y]+=1;
			if(t[x]<t[y])rank[x]+=1;
		}
	}
	for(x=1;x<=n;x++){
		printf("%d\n",rank[x]);
	}
	return 0;
} 

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

int main() {
	ll x;
	cin >> x;
	ll ans = 0;
	ans += (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll a,b,c; cin >> a >> b >> c;
    ll ttl = a + b + c;
    ll ma = max(max(a,b),c);
    if(ma == (ttl - ma))out("Yes");
    else out("No");
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    string str;
    cin >> str;
    long long count=0,sum=0;
    for(char c : str){
        if(c == 'B'){
            count++;
        }else{
            sum += count;
        }
    }
    cout << sum;
    return 0;
}

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

int main(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double rad = 2.0 * M_PI * abs((60.0 * h + m) - 12.0 * m) / (60.0 * 12.0);
  double ans = sqrt(a * a + b * b - 2 * a * b * cos(rad));
  printf("%.20f\n", ans);
}


Measured memory_bytes: 4152
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
ll dp[2001][2001];
ll n, a[2000];
ll H(ll s){
	if (s == n) s = 0;
	if (s == -1) s = n-1;
	return s;
}
ll solve(ll r, ll l) {
	if (r == l) return a[r];
	ll sum = 0;
	ll r2 = H(r + 1);
	sum += a[r];
	if (r2 != l) {
		ll l2 = l;
		if (a[r2] > a[l])
			r2 = H(r2 + 1);
		else
			l2 = H(l - 1);
		if (dp[r2][l2] != -1)
			sum += dp[r2][l2];
		else
			sum += (dp[r2][l2] = solve(r2, l2));
	}
	ll sum2 = 0;
	ll l2 = H(l - 1);
	sum2 += a[l];
	if (l2 != r) {
		ll r2 = r;
		if (a[l2] > a[r])
			l2 = H(l2 - 1);
		else
			r2 = H(r + 1);
		if (dp[r2][l2] != -1)
			sum2 += dp[r2][l2];
		else
			sum2 += (dp[r2][l2] = solve(r2, l2));
	}
	sum = max(sum, sum2);
	return sum;
}
int main() {
	while (cin >> n) {
		for (ll i = 0; i < n; i++)
			cin >> a[i];
		ll sum = 0;
		for (ll i = 0; i <= n; i++) {
			for (ll j = 0; j <= n; j++) {
				dp[i][j] = -1;
			}
		}
		if (n == 1) sum = a[0];
		else if (n == 2) sum = max(a[0], a[1]);
		else {
			for (ll i = 0; i < n; i++) {
				ll r2 = H(i + 1), l2 = H(i - 1);
				if (a[r2] > a[l2])
					r2 = H(r2 + 1);
				else
					l2 = H(l2 - 1);
				sum = max(sum, a[i] + solve(r2, l2));
			}
		}
		cout << sum << endl;
	}
}

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


int main(){
	string input;
	cin >> input;
	
	if(input[0] == 'A' && input[1] == 'C'){
		cout << "Yes" << endl;
		return 0;
	}
	for(int i=0;i<input.size()-2;i++){
		if(input[i] == 'A' && input[i+1] == 'C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
#define _debug(x) cout << #x << " = " << x << endl;
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
typedef long long ll;
using namespace std;

double distance(double a, double b) {
	return sqrt(a*a + b*b);
}

void solve() {
	int n, d, cnt = 0; cin >> n >> d;
	while(n--) {
		double x, y; cin >> x >> y;
		if (distance(x, y) <= d) ++cnt;
	}
	cout << cnt << endl;
}   

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

    // int t; cin >> t;
    // while(t--) 
        solve();
}

Measured memory_bytes: 3860
n = int(input())
p = list(map(int, input().split()))

def solve():
  # 昇順にソートしたリストを生成
  p_sorted = sorted(p, reverse=False)
  cnt = 0
  for i in range(0, n):
    if p[i] != p_sorted[i]:
      cnt += 1

    if cnt >= 3:
      print("NO")
      return

  print("YES")
  return


if __name__ == "__main__":
  solve()

Measured memory_bytes: 3060
# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod



MOD = 10**9+7
n = 2*10**5 + 1

H,W,A,B = map(int, input().split())

# 二項係数の準備
inv = inv_mod(n,MOD)
fac = fact(n,MOD)
facInv = fact_inv(n,inv,MOD)

# 手前×奥を実行して足していく
ans = 0
for h in range(H-A):
    temp = nCr(h+(B-1), h, MOD, fac, facInv) \
            * nCr((H-h-1)+(W-B-1), W-B-1, MOD, fac, facInv)
    ans = (ans + temp) % MOD
    
print(ans)

Measured memory_bytes: 27064
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for(int i = 0; i < 3; ++i)
			a[i] = sc.nextInt();
		Arrays.sort(a);
		for(int i = 0; i < 3; ++i){
			if(i != 0) System.out.print(" ");
			System.out.print(a[i]);
		}
		System.out.println();
	}
}



Measured memory_bytes: 26424
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;


int main(){
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    int k;
    cin >> k;
    rep(i, k) *max_element(all(a)) *= 2;
    LL ans = accumulate(all(a), 0LL);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 20;
int n, m, x, y, q, d,z, w = 0, sum, ans = 0;
vector<int>a;
const int MAX = 510000;
const int MOD = 1000000007;
int main(void) {
	string s; cin >> s;
	reverse(ALL(s));
	string t[4] = { "resare","esare","remaerd","maerd" };
	rep(i, s.size()) {
		if (s.substr(i, 5) == t[1] || s.substr(i, 5) == t[3]) {
			i += 4; continue;
		}if (s.substr(i, 6) == t[0]) {
			i += 5; continue;
		}if (s.substr(i, 7) == t[2]) {
			i += 6; continue;
		}
		cout << "NO" << endl;
		return 0;
	}cout << "YES" << endl;
}

Measured memory_bytes: 3724
#include <iostream>

using namespace std;

int main()
{
  int n,a,b,p1,p2 = 0; 
  cin >> n >> a >> b;
  
  p1 = n * a;
  p2 = b;
  
  if (p1 < p2){
    cout << p1 << endl;
  }
  else{
  	cout << p2 << endl;  
  }
}

Measured memory_bytes: 764
#!/usr/bin/env python
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))
idx = X.argsort()
low = idx[N//2-1]
high = idx[N//2]

res = np.zeros(N, dtype=int)
res[idx[:N//2]] = X[high]
res[idx[N//2:]] = X[low]

for i in range(N):
    print(res[i])

Measured memory_bytes: 34176
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	int x,y,a,b,c;
	cin>> x>>y>>a>>b>>c;
	vector<ll> r,g,t;
	for(int i=0;i<a;i++){
		int u;
		cin>>u;
		r.pb(u);
	}
	for(int i=0;i<b;i++){
		int u;
		cin>>u;
		g.pb(u);
		
	}
	for(int i=0;i<c;i++){
		int u;
		cin>>u;
		t.pb(u);
	}
	sort(r.begin(), r.end(), greater<ll>());
	sort(t.begin(), t.end(), greater<ll>());
	sort(g.begin(), g.end(), greater<ll>());
	
	vector<ll> tot;
	for(int i=0;i<x;i++){
		tot.pb(r[i]);
	}		
	for(int i=0;i<y;i++){
		tot.pb(g[i]);
	}
	sort(tot.begin(), tot.end(),greater<ll>());
	ll ans = 0;
	int p = 0;
	int cnt = 0;
	for(int i=0;cnt<tot.size();i++){
		if(p < t.size() && t[p] > tot[i]){
			ans += t[p];
			p++;
			i--;
		}
		else{
			ans += tot[i];
		}
		cnt += 1;
	}
	cout<<ans<<endl;
}

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


Measured memory_bytes: 4852
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#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 shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
const int dlu=13;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

int jeszkol[nax][nax];

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if ((a/dlu)==(b/dlu) && !jeszkol[x][a/dlu])
	{
		szuk(a, b, x+1, y, w);
		return;
	}
	if ((a/dlu)==(b/dlu) && !jeszkol[y][a/dlu])
	{
		szuk(a, b, x, y-1, w);
		return;
	}
	if (w==(b-a+1)*(y-x+1))
	{
		for (int i=a; i<=b; i++)
		{
			for (int j=x; j<=y; j++)
			{
				wyn+=pot[i][j];
				jeszkol[j][i/dlu]--;
			}
		}
		return;
	}
	//~ if (x==y || (a!=b && (rand()&1)))
	if (a!=b)
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		if (rand()&1)
		{
			szuk(a, s, x, y, p);
			szuk(s+1, b, x, y, w-p);
		}
		else
		{
			szuk(s+1, b, x, y, w-p);
			szuk(a, s, x, y, p);
		}
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		if (rand()&1)
		{
			szuk(a, b, x, s, p);
			szuk(a, b, s+1, y, w-p);
		}
		else
		{
			szuk(a, b, s+1, y, w-p);
			szuk(a, b, x, s, p);
		}
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	for (int i=0; i<n; i++)
		for (int j=0; j<nax; j++)
			if (dlu*j<n)
				jeszkol[i][j]=pyt(dlu*j, min(dlu*j+dlu-1, n-1), i, i);
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef pair<char[105], int> P;
P a[100];
int main()
{
	ios::sync_with_stdio(false);
	//freopen("C:/Users/94726/Desktop/in.txt","r",stdin);
		int n;
		//scanf("%d", &n);
		cin >> n;
		a[0].second = 0;
		for (int i = 1; i <= n; i++) {
			//scanf("%s%d", a[i].first, &a[i].second);
			cin >> a[i].first >> a[i].second;
			a[i].second += a[i - 1].second;
		}
		char tm[105];
		//scanf("%s", tm);
		cin >> tm;
		int i = 1;
		while (strcmp(a[i].first, tm) != 0 and i<=n) i++;
		//printf("%d\n", a[n].second - a[i].second);
		cout << a[n].second - a[i].second << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    string str;
    cin>>str;
    map<char,ll>freq;
    n=str.length();
    for(i=0;i<n;i++)freq[str[i]]++;
    for(i=0;i<26;i++)
    {
        if(freq['a'+i]%2)break;
    }
    if(i>=26)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;

map<LL,LL> myset;

int main() {
	LL n,a,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		cnt+=myset[a-i];
		if(myset.count(-a-i)){
			myset[-a-i]+=1;
		}
		else{
			myset[-a-i]=1;
		}
	}
	cout<<cnt<<endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];
ll B[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(B, 0, sizeof(B));
    REP(i, N) {
        cin >> A[i];
        B[A[i] - 1]++;
    }

    ll ans = 0;
    REP(i, N) {
        ans += B[i] * (B[i] - 1) / 2;
    }

    REP(i, N) {
        ll t = ans;
        t -= std::max(0LL, B[A[i] - 1] - 1);
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
a,b,c=map(int,input().split())
if a <= b and b <= c:
 print(f"{a} {b} {c}")

elif b <= a and a <= c:
 print(f"{b} {a} {c}")

elif b <=  c and c <= a:
 print(f"{b} {c} {a}")

elif a <= c and c <= b:
 print(f"{a} {c} {b}")


elif c <= a and a <= b:
 print(f"{c} {a} {b}")

elif c <= b and b <= a:
 print(f"{c} {b} {a}")




Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,c2=0,c5 =0,tt;
	cin>>n;
	if(n%2==1)
		cout<<0<<endl;
	else
	{
		n = n/2;
		c2 = n;
		tt = n;
		while(tt)
		{
			c2 = c2 + tt/2;
			tt/=2;
		}
		tt = n;
		while(tt)
		{
			c5 = c5 + tt/5;
			tt/=5;
		}
		cout<<min(c2,c5)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>
#include <assert.h>

#define sqr(x) std::pow(x, 2.0)
#define INF 1e10
#define EPS 1e-10
#define REP(i, n) for (int i = 0; i < n; i++)
#define POS_OR_INF(x) (x > 0 ? x : INF)

using namespace std;

using ld = long double;

struct Point {
	Point() = default;
	Point(ld x, ld y) : x(x), y(y) {}
	Point(const Point& s, const Point& e) : x(e.x - s.x), y(e.y - s.y) {}

	Point normalized(void) const {
		return Point(x / norm(), y / norm());
	}

	ld norm(void) const {
		return sqrt(x * x + y * y);
	}

	Point flipped(void) const {
		return Point(-x, -y);
	}

	Point normal_vector(bool normalize = false) const {
		auto vec = Point(-y, x);
		return normalize ? vec.normalized() : vec;
	}

	ld x, y;
};

using Vector = Point;

inline Vector points2vec(const Point& s, const Point& e) {
	return Vector(e.x - s.x, e.y - s.y);
}

inline ld distance(const Point& s, const Point& e) {
	return points2vec(s, e).norm();
}

inline ld distance_square(const Point& s, const Point& e) {
	return pow(points2vec(s, e).norm(), 2.0);
}

inline Vector operator * (const Vector& l, ld r) {
	return Vector(l.x * r, l.y * r);
}

inline Vector operator * (ld l, const Vector& r) {
	return r * l;
}

inline Vector operator / (const Vector& l, ld r) {
	return Vector(l.x / r, l.y / r);
}

inline Point operator + (const Point& l, const Point& r) {
	return Point(l.x + r.x, l.y + r.y);
}

inline Point operator - (const Point& l, const Point& r) {
	return Point(l.x - r.x, l.y - r.y);
}

inline istream& operator >> (istream& is, Point& p) {
	return is >> p.x >> p.y;
}

int main(int argc, char** argv) {
	int N, K;

	cin >> N >> K;
	cout << fixed << setprecision(20);

	vector<pair<double, double>> a(N), b;

	for (int i = 0; i < N; i++) {
		Point p;
		double r;
		cin >> p >> r;

		double theta = asin(r/p.norm());
		double rad = atan2(p.y, p.x);

		if (rad < -M_PI / 2) rad += 2 * M_PI;

		a[i].first = min(M_PI, max(0.0, rad - theta));
		a[i].second = min(M_PI, max(0.0, rad + theta));
	}

	for (int i = 0; i < N; i++) {
		bool included = false;
		for (int j = 0; j < N; j++) {
			if (a[i].first > a[j].first && a[i].second < a[j].second)
				included = true;
		}
		if (!included) {
			b.push_back(a[i]);
		}
	}

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

	int M = b.size();

	vector<vector<double>> dp(K + 1, vector<double>(M + 1, 0));
	double ans = 0;

	for (int i = 1; i <= K; i++) {
		for (int j = 0; j < M; j++) {
			double best = 0;
			int k = 0;

			while (b[k].second < b[j].first) {
				best = max(best, dp[i-1][k]);
				k++;
			}
			
			dp[i][j] = max(dp[i][j], best + b[j].second - b[j].first);
			dp[i][j] = max(dp[i][j], dp[i-1][k] + b[j].second - b[k].second);
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans / M_PI;
}



Measured memory_bytes: 20708
package main

import "fmt"

func main() {
	var m, h, n int
	fmt.Scan(&m, &h, &n)
	var x, y, a, set_x, set_y int
	set_x, set_y = 0, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y, &a)
		switch a {
		case 1:
			if set_x < x {
				set_x = x
			}
		case 2:
			if x < m {
				m = x
			}
		case 3:
			if set_y < y {
				set_y = y
			}
		case 4:
			if y < h {
				h = y
			}
		}
	}

	if h <= set_y || m <= set_x {
		fmt.Print(0)
	} else {
		fmt.Print((m - set_x) * (h - set_y))
	}
}


Measured memory_bytes: 512