akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*
int pow(int a,int b){
    int R=1;
    while(b){
        if(b&1) R=(R*a);
        a=(a*a);
        b>>=1;
    }
    return R;
}
*/
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int e;
	while(cin >> e , e){
		int m=1e+9;
		/*
		for(int z=0 , z1=0 ; z<=e; ++z1 , z=z1*z1*z1){
			for(int y=0 , y1=0 ; y<=e; ++y1 , y=y1*y1){
				int x=e-y-z;
				if(x>=0) m = min(m , x+(int)sqrt(y)+(int)cbrt(z));
			}
		}
		*/
		for(int z=0 ; z*z*z<=e ; ++z){
			for(int y=0 ; y*y<=e ; ++y){
				int x=e-z*z*z-y*y;
				if(x>=0) m = min(m , x+y+z);
			}
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

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



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

	cout << "ABC";
	if (a >= 100) {
		cout << a << endl;
	}
	else {
		cout << 0 << a << endl;
	}



	return 0;
}


Measured memory_bytes: 256
N = int(input())
cake = 4
dounute = 7
if N < cake and N < dounute:
    print("No")
    exit() 
for i in range(N):
    for j in range(N):
        if (dounute * i + cake * j) == N:
            print("Yes")
            exit()
        elif (dounute * j + cake * i) == N:
            print("Yes")
            exit()
        else:
            continue
print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>

int main (int argc, char **argv)
{
  int n = 0;
  int p = 0;
  int d = 0;
  int i = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
  {
    scanf("%d", &p);
    if((i + 1) != p)
    {
      d++;
    }
  }

  printf("%s\n", ((d > 2) ? "NO" : "YES"));
  return 0;
}


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

struct SegTree {
  SegTree *sl, *sr; // left & right child.
  int l, r;         // the interval of current node.
  ll sum;           // the sum of elements in this node.
  ll lazy;          // value to be added to each value in the range.

  // create the segment tree node
  SegTree(int *init, int l, int r) : l(l), r(r), lazy(0) {
    // leaf node, no need to build children nodes
    if (l == r) {
      sum = init[l];
      return;
    }

    int m = l + r >> 1;

    // create the two children nodes
    sl = new SegTree(init, l, m);
    sr = new SegTree(init, m + 1, r);

    // calculate the current node
    sum = sl->sum + sr->sum;
  }

  // query the sum of a[ql..qr]
  ll query(int ql, int qr) {
    // current node is exactly what is needed
    if (ql == l && qr == r)
      return sum + lazy * (r - l + 1);

    int m = l + r >> 1;
    int v = (qr - ql + 1) * lazy;

    if (qr <= m) // query range is in left node
      return v + sl->query(ql, qr);
    else if (ql > m) // query range is in right node
      return v + sr->query(ql, qr);
    else // query range crosses both nodes
      return v + sl->query(ql, m) + sr->query(m + 1, qr);
  }

  // helper function to get the sum of the current node
  ll get() { return lazy * (r - l + 1) + sum; }

  // set a[ql..qr] += v
  void update(int ql, int qr, int v) {
    // current node is exact match
    if (ql == l && qr == r) {
      lazy += v;
      return;
    }

    int m = l + r >> 1;

    // pushdown: push the lazy value to a level lower
    sl->lazy += lazy, sr->lazy += lazy;
    lazy = 0;

    if (qr <= m) // update range is in left node
      sl->update(ql, qr, v);
    else if (ql > m) // update range is in right node
      sr->update(ql, qr, v);
    else // update range crosses both nodes
      sl->update(ql, m, v), sr->update(m + 1, qr, v);

    // recalculate current node
    sum = sl->get() + sr->get();
  }
};

int arr[100005];

int main() {
  // write your solution here...
  int n, q;
  cin >> n >> q;
  SegTree *tree = new SegTree(arr, 1, n);
  for (int i = 0; i < q; i++) {
    int y, s, t, x;
    cin >> y >> s >> t;
    if (y == 0)
      cin >> x;
    if (y == 0) {
      tree->update(s, t, x);
    } else {
      cout << tree->query(s, t) << endl;
    }
  }
}


Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 10;
const ll mod = 1e9 + 7;
int main(){
ll n,k;
cin >> n >> k;
vector<ll>pre(n+10);
vector<ll>suf(n+10);
ll sum = 0;
for(ll i = 0;i<=n+1;i++){
     sum += i;
     pre[i] = sum;
}
sum = 0;
for(ll i = n+1;i>=0;i--){
    sum += i;
    suf[n+2-i] = sum;
}
ll ans = 0;
for(ll i = k;i<=n+1;i++){
    ans += (suf[i] - pre[i]+1ll)%mod;
    ans %= mod;
}
cout << ans;
return 0;
}

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

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;
double pi = 3.141592653589793;

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M);
  vector<vector<int>> e(N+1);
  rep(i,M) {
    cin >> A[i] >> B[i];
    e[A[i]].push_back(B[i]);
    e[B[i]].push_back(A[i]);
  }
  
  vector<int> sign(N+1);
  queue<int> que;
  que.push(1);
  while(que.size()>0) {
    int q=que.front();
    que.pop();
    for(int x:e[q]) {
      if(!sign[x]&&x!=1) {
        sign[x]=q;
        que.push(x);
      }
    }
  }
  bool flag=true;
  rep(i,N-1) {
    if(!sign[i+2]) flag=false;
  }
  if(flag) {
    cout << "Yes" << endl;
    rep(i,N-1) cout << sign[i+2] << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 11680
N = int(input())
T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
mountain = [T[0]]
for i in range(1, N):
    if T[i] > T[i - 1]:
        mountain.append(T[i])
    else:
        mountain.append(-T[i])
ans = 1
if N == 1:
    if T[0] != A[0]:
        print(0)
        exit()
for i in range(N - 1, -1, -1):
    if i == N - 1:
        if (A[i] > mountain[i]) & (mountain[i] > 0):
            ans = 0
            break
        mountain[i] = A[i]
    elif mountain[i] <= 0:
        if A[i] > A[i + 1]:
            if - mountain[i] >= A[i]:            
                mountain[i] = A[i]
            else:
                ans = 0
                break
        else:
            mountain[i] = -min(A[i], -mountain[i])
    else:
        if A[i] >= mountain[i]:
            continue
        else:
            ans = 0
            break
    if mountain[i] < 0:
        ans = (- ans * mountain[i]) % mod
print(ans)                

Measured memory_bytes: 25356
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i,j,k,n,m,l,count1=0;
void ABC150(void);
void ABC151(void);
void ABC152(void);
void ABC153(void);
void ABC154(void);
void ABC155(void);
void ABC156(void);
void ABC157(void);
void ABC158(void);
void ABC159(void);

int main(void){
    ABC150();
}

void ABC150(){
    cin>>n;
    string s,a="ABC";
    cin>>s;
    for(i=0;i<n-2;i++){
        if(a==s.substr(i,3))count1++;
    }
    cout<<count1<<endl;
}

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

long long int facctorialMethod(int k){
        long long int sum = 1;
        for (long long int i = 1; i <= k; i++)
        {
                sum *= i;
                sum%=mod;
        }
        return sum;
}

int main(){
        long long int n,m;
        cin>>n>>m;
        if(n==m) cout<<(2*facctorialMethod(n)*facctorialMethod(m))%mod<<endl;
        else if((n+1==m)||(n==m+1)) cout<<facctorialMethod(n)*facctorialMethod(m)%mod<<endl;
        else cout<<0<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,q; cin >> k >> q;
    vector<ll> d(k);
    rep(i,k) cin >> d[i];
    vector<ll> a(k);
    ll sum,cnt,nn,cnt2,cnt3;
    rep(i,q){
        ll n,x,m; cin >> n >> x >> m;
        sum=0,cnt=x%m,cnt2=0;
        rep(j,k){
            a[j]=d[j]%m;
            sum+=a[j];
            if (a[j]==0) ++cnt2;
        }
        cnt+=sum*((n-1)/k);
        nn=(n-1)%k;
        cnt3=0;
        rep(j,nn){
            cnt+=a[j];
            if (a[j]==0) ++cnt3;
        }
        ll ans=n-1-cnt/m-cnt2*((n-1)/k)-cnt3;
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
//
// Created by kuroneko on 2019-07-27.
//

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<ll> a(N+1), b(N);
    for (int i = 0; i < N+1; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > b[i]) ans += b[i];
        else {
            ans += a[i];
            if (b[i] - a[i] > a[i+1]) {
                ans += a[i+1];
                a[i+1] = 0;
            } else {
                ans += b[i] - a[i];
                a[i+1] = a[i+1] - (b[i] - a[i]);
            }

        }
    }
    cout << ans << endl;
    return 0;
}





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

int main() {
  int n,l,h = 10000;
  cin >> n >> l;
  for(int i = 1;i <= n;i++){
    if(abs(l+i-1) < h){
      h = abs(l+i-1);
    }
  }
  if(n*l+n*(n+1)/2-n > 0){
    cout << n*l+n*(n+1)/2-n-h << endl;
  }
  else{
    cout << n*l+n*(n+1)/2-n+h << endl;
  }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> pq;
  vector<P> job;
 
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    job.emplace_back(make_pair(a, b));
  }
  sort(job.begin(), job.end(), greater<P>());
  int res = 0;
  for (int i = 1; i <= m; i++) {
    auto p = job.back();
    while (i >= p.first && job.size() > 0) {
      job.pop_back();
      pq.push(p.second);
      p = job.back();
    }
    if (!pq.empty()) {
      res += pq.top();
      pq.pop();
    }
  }
  cout << res << endl;
  return 0; 
} 

Measured memory_bytes: 4848
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>

using namespace std;
const int N=2e5+10,inf=1e9;
int dp[N][2];
char s[N];

int main(){
    int x,a,ans;
	cin >> x >> a;
    if(x<a){
        ans = 0;
    }else{
        ans = 10;
    }

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sf(a) scanf("%d",&a)
#define MX 100000
#define inf 1e9
#define m_p make_pair
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))
#define MOD 100000



int main() {

    int q;
    sf(q);
    vector<LL> vec;
    while(q--){
        int a;
        cin >> a;
        LL x;
        if(a==0){
            scanf("%lld",&x);
            vec.push_back(x);
        }
        else if(a==2) vec.pop_back();
        else if(a==1){
            scanf("%lld",&x);
            cout << vec.at(x) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 4984
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit(0)
l = list(map(int, input().split()))

n = 0
while True:
    candidate = X - n
    if candidate not in l:
        print(candidate)
        break
    candidate = X + n
    if candidate not in l:
        print(candidate)
        break
    n += 1

Measured memory_bytes: 61656
n = int(input())
m = n
a = 0

i = len(str(n))

if i == 2:
    print(9)
elif i == 4:
    print(909)
elif i == 1:
    print(m)
elif i == 3:
    print(9 + n-99)
elif i == 5:
    print(909 + n-9999)
elif i == 6:
    print(90909)


Measured memory_bytes: 3060
import heapq as h

N=int(input())
u=[0 for i in range(0,N-1)]
v=[0 for i in range(0,N-1)]
w=[0 for i in range(0,N-1)]
for i in range(0,N-1):
    u[i],v[i],w[i]=map(int,input().split())
w=[w[i]%2 for i in range(0,N-1)]
hen=[[] for i in range(0,N+1)]
for i in range(0,N-1):
    hen[u[i]].append([v[i],w[i]])
    hen[v[i]].append([u[i],w[i]])
ans=[[0,0] for i in range(0,N+1)]
ans[1]=[0,1]
q=[]
q.append(1)
h.heapify(q)
sub=[]
h.heapify(sub)
while q!=[]:
    while q!=[]:
        x=h.heappop(q)
        if ans[x][0]==0:
            for p in hen[x]:
                s=p[0]
                t=p[1]
                if ans[s][1]==0:
                    if p[1]==0:
                        ans[s][0]=0
                    else:
                        ans[s][0]=1
                    h.heappush(sub,s)
                    ans[s][1]=1
        else:
            for p in  hen[x]:
                s=p[0]
                t=p[1]
                if ans[s][1]==0:
                    if p[1]==0:
                        ans[s][0]=1
                    else:
                        ans[s][0]=0
                    h.heappush(sub,s)
                    ans[s][1]=1
        if q==[]:
            q=sub
            sub=[]
            h.heapify(sub)
            break
ans[0]=100
ans.remove(100)
for i in range(0,N):
    print(ans[i][0])


Measured memory_bytes: 110096
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll q;
  cin >> q;
  vector<set<ll>> st(26);
  REP(i, 26) st[i].insert(INF);

  REP(i, n) { st[s[i] - 'a'].insert(i); }

  while (q--) {
    ll qn;
    cin >> qn;
    if (qn == 1) {
      ll i;
      char c;
      cin >> i >> c;
      --i;
      st[s[i] - 'a'].erase(i);
      s[i] = c;
      st[s[i] - 'a'].insert(i);
    } else {
      ll ans = 0;
      ll l, r;
      cin >> l >> r;
      --l, --r;
      REP(k, 26) {
        auto itl = st[k].lower_bound(l);
        if (*itl <= r) ++ans;
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
const int MOD = 1000000007;
const int INF = 1001001001;
using namespace std;

struct Edge {
    int n1, n2, cost;
    Edge(int n1_, int n2_, int cost_) {
        n1 = n1_;
        n2 = n2_;
        cost = cost_;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    int a, b, c;
    vector<vector<int>> g(n, vector<int>(n, INF));
    vector<Edge> e;

    rep(i,m) {
        cin >> a >> b >> c;
        a--; b--;
        g[a][b] = g[b][a] = c;
        e.emplace_back(a, b, c);
    }

    rep(i,n) g[i][i] = 0;

    rep(k,n) {
        rep(i,n) {
            rep(j,n) {
                g[i][j] = min(g[k][j]+g[i][k], g[i][j]);
            }
        }
    }

    int ans = 0;
    for (auto edge: e) {
        if (g[edge.n1][edge.n2] < edge.cost) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

typedef complex<double> P;

double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

// ???p2?????????p0, p1???????????´???????°???±?????????
P projection(const P& p0, const P& p1, const P& p2) {
    // ???????????????????????´???
    P vec1 = p1 - p0;
    P vec2 = p2 - p0;
    return p0 + vec1 * dot(vec1, vec2) / dot(vec1, vec1);
}

int main(){
    double x, y;

    // ??´???????§??????¨??????
    cin >> x >> y;
    P p0(x, y);
    cin >> x >> y;
    P p1(x, y);

    int Q;
    cin >> Q;
    REP(q, Q) {
        cin >> x >> y;
        P p2(x, y);
        P ret = projection(p0, p1, p2);
        printf("%.10lf %.10lf\n", ret.real(), ret.imag());
    }
    
    return 0;
}

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

typedef long long ll;
 
int main(){
  #define TASK "ABC"
  //freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
  ios_base::sync_with_stdio(0);
 
  int n;
  cin >> n;
 
  vector < pair < int, int > > a(n);
 
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i] = {x, i};
  }
 
  sort(a.begin(), a.end());
 
  vector < vector < ll > > d(n, vector < ll >(n, 0));
 
  d[0][n - 1] = 0;
  for (int len = n - 1; len > 0; --len)
    for (int i = 0; i + len < n; ++i) {
      int j = i + len;
 
      d[i][j - 1] = max(d[i][j - 1], d[i][j] + ll(abs(a[len].second - j)) * a[len].first);
      d[i + 1][j] = max(d[i + 1][j], d[i][j] + ll(abs(a[len].second - i)) * a[len].first);
    }
 
  ll ans = 0;
 
  for (int i = 0; i < n; ++i)
    ans = max(ans, d[i][i] + ll(abs(a[0].second - i)) * a[0].first);
 
  cout << ans;
  return 0;
}

Measured memory_bytes: 34676
#include<stdio.h>

int main(void){
    int A;
    int B;

    scanf("%d %d", &A, &B);

    if(A >= 13){
        printf("%d\n", B);
    }else if(A < 13 && A > 5){
        printf("%d\n", B/2);
    }else{
        printf("0\n");
    }

}

Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

bool cmpr(const pair<ll, ll> & a, const pair<ll, ll> & b) {
    return a.first == b.first ? a.second < b.second : a.first < b.first;
}

int main()
{
    ll H, W, N;
    cin >> H >> W >> N;
    vector <pair <ll, ll> > v;
    ll ans[10] = {};

    if (N > 0) {
        for (ll i = 0; i < N; i++) {
            ll a, b;
            cin >> a >> b;
            for (ll x = a - 1; x <= a + 1; x++) {
                for (ll y = b - 1; y <= b + 1; y++) {
                    if (x >= 2 && x <= H - 1 && y >= 2 && y <= W - 1) {
                        v.push_back(make_pair(x, y));
                    }
                }
            }
        }
        sort(v.begin(), v.end(), cmpr);

        ll pre_a = v[0].first;
        ll pre_b = v[0].second;
        ll count = 1;

        for (ll i = 1; i < v.size(); i++) {
            if (pre_a == v[i].first && pre_b == v[i].second) {
                count++;
            }
            else {
                ans[count]++;
                count = 1;
            }
            pre_a = v[i].first;
            pre_b = v[i].second;
        }
        ans[count]++;

        ans[0] = (H - 2) * (W - 2);
        for (int i = 1; i <= 9; i++) ans[0] -= ans[i];
    }
    else { // N == 0
        ans[0] = (H - 2) * (W - 2);
    }

    for (int i = 0; i <= 9; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 18664
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll BIG=1e9;

int main(){
    string S; ll K; cin>>S>>K;
    bool tb=false;
    ll N=S.size();
    if(S.at(N-1)==S.at(0)) tb=true;
    vector<int> d;
    int count=1, memory=S.at(0);
    for(int i=1;i<N;i++){
        if(S.at(i)==memory) count++;
        else {
            d.push_back(count);
            count=1; memory=S.at(i);
        }
    }
    d.push_back(count);
    ll ans=0;
    
    if(d.size()==1) ans=(K*N)/2;
    else{
        for(int i=0;i<d.size();i++) ans+=d.at(i)/2;
        ans*=K;
        if(tb && d.at(0)%2==1 && d.at(d.size()-1)%2==1) ans+=(K-1);
    }
    cout<<ans<<endl;
}

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

#define INF ((int)1e9+100)

int main(){
  int n, b, r, ans = -INF, mi = INF;

  cin>>n;
  
  for(int i = 0; i < n; i++){
    cin>>r;
    if(i)ans = max(ans,r-mi);
    mi = min(r,mi);
  }

  cout<<ans<<endl;
}



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

int main(){
	int N,K;
	cin>>N>>K;
	int h[N]={0};
	int cost[N];
	memset(cost, INT_MAX, N);
	for(int i=0; i<N; i++){
		cost[i] = INT_MAX;
	}
	for(int i=0; i<N; i++){
		cin>>h[i];
	}
	cost[0] = 0;
	for(int i=1;i<N;i++){
		for(int j=1; j<=K; j++){
			if(i-j>=0)
				cost[i] = std::min(cost[i-j] + abs(h[i] - h[i-j]), cost[i]);
			else
				break;
		}
	}
	// for(int i=0; i<N; i++){
	// 	cout<<cost[i]<<" ";
	// }
	cout<<cost[N-1];
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string a,b; cin >> a >> b;
  bool equal = false;
  if(a.size()<b.size()){
    cout << "LESS" << endl;
    return 0;
  }
  else if(a.size()>b.size()){
    cout << "GREATER" << endl;
    return 0;
  }
  else{
    rep(i,a.size())
      if(a[i]>b[i]){
	cout << "GREATER" << endl;
	return 0;
      }
      else if(a[i]<b[i]){
	cout << "LESS" << endl;
	return 0;
      }
      else{
	equal = true;
      }
  }
	
  if(equal) cout << "EQUAL" << endl;
  
  return 0;
}


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

int main(void){
	int x = 0;
	char s[100];
	int stack[100];
	int *ps;
	ps = stack;

	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			ps--;
			*(ps-1) = *(ps-1) + *ps;
		}else if(s[0] == '-'){
			ps--;
			*(ps-1) = *(ps-1) - *ps;
		}else if(s[0] == '*'){
			ps--;
			*(ps-1) = *(ps-1) * *ps;
		}else{
			x = atoi(s);
			*ps = x;
			ps++;
		}
	}
	printf("%d\n", *(ps-1));

	return 0;
}

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

char mp[400][400];
bool used[400][400];
int h, w;
char c[2] = {'#', '.'};
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> mp[i][j];
        }
    }
    ll ans = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (used[i][j] == true)
                continue;
            if (mp[i][j] == '.')
                continue;
            queue<pair<int, int>> q;
            used[i][j] = true;
            q.push({i, j});
            ll cur = 0, cw = 0, cb = 0; //白黒のどちらか,白の数,黒の数
            while (!q.empty())
            {
                ll len = q.size(); //次に行ける色の数
                if (cur % 2 == 0)
                    cb += len;
                else
                    cw += len;
                cur = (cur == 0 ? 1 : 0);
                for (int a = 0; a < len; a++)
                {
                    pair<int, int> p = q.front();
                    q.pop();
                    for (int k = 0; k < 4; k++)
                    {
                        int nx = p.first + dx[k];
                        int ny = p.second + dy[k];
                        if (nx < 0 || ny < 0 || nx >= h || ny >= w)
                            continue;
                        if (used[nx][ny] == true)
                            continue;
                        if (mp[nx][ny] != c[cur])
                            continue;
                        q.push({nx, ny});
                        used[nx][ny] = true;
                    }
                }
            }
            ans += cw * cb;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

//#define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#include <bits/stdc++.h>
using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
// find_by_order(), order_of_key() 

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int 
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592653589793238463;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&

void solve(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n + 1);
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	vector<int> cyc;
	cyc.push_back(1);
	set<int> s;
	s.insert(1);
	int id = 1;
	while(!s.count(a[id])){
		cyc.push_back(a[id]);
		s.insert(a[id]);
		id = a[id];
	}
	int repel = a[id];
	int idcyc = 0;
	while(idcyc < sz(cyc) and cyc[idcyc] != repel){
		idcyc++;
	}
	if(k < idcyc){
		cout << cyc[k] << '\n';
	} else {
		k -= idcyc;
		vector<int> nn;
		//debug(repel, idcyc, k);
		while(idcyc < sz(cyc)){
			nn.push_back(cyc[idcyc++]);
		}
		/*for(auto &x: nn)
			cout << x << " ";
		cout << '\n';*/
		k %= sz(nn);
		cout << nn[k] << '\n';
	}


}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    //cin >> T;
    for(int i = 1; i <= T; ++i){
        solve();
    }
    return 0;
}
/*
Sample inp
*/

Measured memory_bytes: 16516
let () = Scanf.scanf "%d" @@ fun n ->
  let dp = Array.make (n + 1) 0 in
  let rec outer x =
    if x * x <= n then
      let rec inner y =
        if x * x + y * y + x * y <= n then
          let rec loop z =
            let i = x * x + y * y + z * z + x * y + y * z + x * z in
            if i <= n then
              (dp.(i) <- 1 + dp.(i); loop (z + 1)) in
          (loop 1; inner (y + 1)) in
      (inner 1; outer (x + 1)) in
  outer 1;
  for i = 1 to n do
    Printf.printf "%d\n" dp.(i)
  done

Measured memory_bytes: 5932
#include <string>
#include <algorithm>
#include <limits.h>
#include <iostream>

using namespace std;

int main()
{
	long long i, j=0, k;
	string A, B;

	cin >> A; cin >> B;

	while (A[0]!=NULL) {
		if (B[0] == NULL) {
			cout << "GREATER" << endl;
			return 0;
		}

		if (j == 0)
			j = A[0] - B[0];

		A.erase(A.begin());
		B.erase(B.begin());
	}

	if (B[0] == NULL) {
		if (j > 0)
			cout << "GREATER" << endl;
		else if (j < 0)
			cout << "LESS" << endl;
		else
			cout << "EQUAL" << endl;
	}
	else
		cout << "LESS" << endl;

	return 0;
}

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

using namespace std;

int main(){
	string s,out;
	cin >> s;
	int num = 0;
	
	for(int i =0; i <s.size(); i++){
		if(s[i] == '0'){
			out[num] = '0';
		//		cout << out[num] << " " << num << endl;
			num++;
		}else if(s[i] == '1'){
			out[num] = '1';
		//		cout << out[num] << " " << num <<endl;
			num++;
		}else if(s[i] == 'B'){
			num--;
			if(num < 0)num =0;
		}
	
	}
	out[num] = '\0';
	
	for(int i =0; i <num; i++)cout << out[i];
	cout <<endl;
	return 0;
}

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

lint h, n;
vector<lint> a, b;

template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    cin >> h >> n;
    a.resize(n), b.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<lint> dp(h + 1, LLONG_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= h; j++) {
            if (dp[j] == LLONG_MAX) continue;
            chmin(dp[min(j + a[i], h)], dp[j] + b[i]);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

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

    int sum = 0;
    vector<int> s(n);
    rep(i, n) {
        cin >> s[i];
        sum += s[i];
    }

    srt(s);

    if (sum % 10 == 0) {
        rep(i, n) {
            if (s[i] % 10 != 0) {
                cout << sum - s[i] << endl;
                return 0;
            }
        }

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

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,P,Pm,sum=1;
  cin >> N;
  for(int i=1;i<=N;i++){
    cin >> P;
    if(i==1){
      Pm=P;
      continue;
    }else{
      if(P<Pm){
        sum++;
        Pm=P;
      }else{
        continue;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MOD=1e9+7;

int dif(vi v){
	int l=sz(v);
	sort(v.begin(),v.end());
	int d=50;
	rep(i,l-1)d=min(d,v[i+1]-v[i]);
	d=min(d,24-v[l-1]);
	return d;
}

int main(){
	int N;
	cin>>N;
	int ct[13];
  	rep(i,13)ct[i]=0;
	rep(i,N){
		int D;
		cin>>D;
		ct[D]++;
	}
	bool pos=true;
	if(ct[0]>0)pos=false;
	rep1(i,11)if(ct[i]>2)pos=false;
	if(ct[12]>1)pos=false;
	
	if(!pos){
		cout<<0<<endl;
		return 0;
	}
	int ans=0;
	vi t;
	t.push_back(0);
	if(ct[12])t.push_back(12);
	rep(b,1<<11){
		vi u=t;
		rep1(i,11){
			if(ct[i]==2){
				u.push_back(i);
				u.push_back(24-i);
			}
			if(ct[i]==1){
				if((b>>(i-1))&1)u.push_back(i);
				else u.push_back(24-i);
			}
		}
		int k=dif(u);
		ans=max(ans,k);
	}
	cout<<ans<<endl;
}

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

int main() {
  int d,n; cin>>d>>n;
  int ans = n*pow(100,d);
  if (n==100) ans += pow(100,d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3780
from collections import deque
N, Q = map(int, input().split())
Graph = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Graph[a].append(b)
    Graph[b].append(a)

counter_list = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    counter_list[p] += x

# 各頂点に counter を持たせて，幅優先探索で足していく
dist = [-1 for _ in range(N)]
dist[0] = 1
que = deque()
que.append(0)
while que:
    v = que[0]
    que.popleft()
    for new_v in Graph[v]:
        if dist[new_v] != -1:
            continue
        dist[new_v] = 1
        que.append(new_v)
        counter_list[new_v] += counter_list[v]

print(" ".join(map(str, counter_list)))

Measured memory_bytes: 67168
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S[3];
    REP(i, 3) {
        cin >> S[i];
    }
    REP(i, 3) {
        cout << S[i][i];
    }
    cout << endl;
    return 0;
}


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


#define ll long long
#define pb push_back

#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const ll inf = 2e18+5;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll h,a;
    cin>>h>>a;
    ll ans;
    ans = (h+a-1)/a; //This is the proper way to do ceil(h/a);
    cout<<ans<<endl;
    return 0;
}   

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=105;
int s[N][N];
int n,m,c;
void go(int &x,int &y)
{
	if(x&1)
	{
		y++;
		if(y>m)y=m,x++;
	}
	else 
	{
		y--;
		if(!y)y=1,x++;
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&c);
	for(int i=1,cnt,x=1,y=1;i<=c;i++)
	{
		for(scanf("%d",&cnt);cnt--;go(x,y))
			s[x][y]=i;
	}
	for(int i=1;i<=n;i++,printf("\n"))
		for(int j=1;j<=m;j++)printf("%d ",s[i][j]);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int n;
	int min = 2000000000;
	int cnt = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int dat;
		scanf("%d", &dat);
		if (min > dat) {
			min = dat;
			cnt++;
		}
	}

	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        n: usize,
    }

    let mut ans = 0;
    for i in 1..n {
        let mut t = n/i;
        if i * t == n {
            t -= 1;
        }

        ans += t;
    }

    println!("{}", ans);
}

Measured memory_bytes: 2116
#include<stdio.h>

int main(){
    long K=0;
    long X=0;
    long kai=0;
    long n=0;

    scanf("%ld %ld",&K,&X);

    kai=X-K+1;
    n=(K-1)*2+1;

    for(int i=0;i<n;i++){
        printf("%d ",kai);
        kai++;
    }

    return 0;
}

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

int num[10];
int B[10];
int C[10];
bool flag;
void solve(int, int, int);

int main(void){
	int N;
	cin >> N;
	for(int k = 0; k < N; k++){
		flag = false;
		fill_n(B , 10, -1);
		fill_n(C , 10, -1);
		for(int i = 0; i < 10; i++){
			cin >> num[i];
		}
		solve(0, 0, 0);
		if(flag){cout << "YES" << endl; continue;}
		cout << "NO" << endl;
	}

	return 0;
}

void solve(int cnt,int right, int left){
	if(cnt == 10){
		flag = true;
		return;
	}
	if(num[cnt] > right) solve(cnt+1, num[cnt], left);
	if(num[cnt] > left) solve(cnt+1, right, num[cnt]);
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         int N=gi();
         long K=gl();
         long[] P=new long[N];
         long[] C=new long[N];
         for (int i=0; i<N;i++) {
        	 P[i]=gl()-1;
         }
         for (int i=0; i<N;i++) {
        	 C[i]=gl();
         }

         long ans=Long.MIN_VALUE;

         for (int s=0; s<N;s++) {
        	 long pos=s;
        	 long tmp=0;
        	 long roop=0;
        	 long max=C[(int)P[s]];
        	 do {
        		 roop++;
        		 pos=P[(int)pos];
        		 tmp+=C[(int)pos];
        		 max=Math.max(max, tmp);
        	 } while(pos!=s && roop<K);

        	 if(tmp>0 && roop!=K) {
        		 long r=Math.floorDiv(K, roop);
        		 long z=K%roop;
        		 z+=roop;
        		 long mm=tmp*(r-1);
        		 pos=s;
        		 tmp=0;
        		 max=0;
        		 for (int i=0; i<z;i++) {
        			 pos=P[(int)pos];
        			 tmp+=C[(int)pos];
        			 max=Math.max(max, tmp);
        		 }
        		 max+=mm;
        	 }
        	 ans=Math.max(ans, max);
         }

         System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 43536
#include <iostream>

int main(){
  int n, m, c;
  std::cin >> n >> m >> c;
  int b[m], a[n][m];
  for(int i = 0; i < m; i++)
    std::cin >> b[i];

  for(int i = 0; i < n; i++){
    for(int j= 0; j < m; j++){
      std::cin >> a[i][j];
    }
  }

  int ret = 0;
  int sum;
  for(int i = 0; i < n; i++){
    sum = c;
    for(int j = 0; j < m; j++){
      sum += a[i][j]*b[j];
    }
    if(0 < sum) ret++;
  }

  std::cout << ret << std::endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

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

    ll w,h;cin>>w>>h;
    // pair(cost, p or q)
    priority_queue<P,vector<P>,greater<P>> pq;
    ll res=0, pnum=h+1,qnum=w+1;
    for(int i=0;i<w;i++){
        ll p;cin>>p;
        pq.push(P(p,1));
    }
    for(int j=0;j<h;j++){
        ll q;cin>>q;
        pq.push(P(q,0));
    }
    while(!pq.empty()){
        ll v=pq.top().first,f=pq.top().second;
        pq.pop();
        if(f){
            res += v * pnum;
            qnum--;
        }
        else{
            res += v * qnum;
            pnum--;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6384
import numpy as np

N = int(input())
XY = np.empty([N,2])
for i in range(N):
    XY[i] = list(map(int, input().split()))

ans = 0.0
for i in range(N):
    for j in range(i+1,N):
        ans += np.sqrt(np.sum(np.square(XY[i]-XY[j])))
ans = ans*2/N

print(ans)

Measured memory_bytes: 21664
#include <iostream>
#define N_MAX 100
#include <string>
#include <cmath>
using namespace std;

int N,B,i,j,k;
double A;
string S,Sa;
int x[N_MAX];
int y[N_MAX];
int num[N_MAX] = {0};
double ans=0;

int main(){
  cin >> S;
  bool u = true;
  for (i=0;i<S.size();i++){
    for (j=i+1;j<S.size();j++){
      if (S[i] == S[j]) u = false;
    }
  }
  if (u) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
//#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,ok;

bool judge(int x)
{
	if(x%3 == 0) return true;
	if(x%5 == 0) return true;
	return false;
}

signed main()
{
	cin>>n;
	ok = 1;
	for(int i = 1,x; i <= n && ok; i++) 
	{
		cin>>x;
		if(x%2 == 0) ok = judge(x);
	}
	if(ok) puts("APPROVED");
	else puts("DENIED");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ceil(u, d) ((u) / (d) + ((u) % (d) == 0 ? 0 : 1))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main()
{
    int n;
    long long t_ratio, a_ratio, t = 1, a = 1, n_min;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> t_ratio >> a_ratio;
        n_min = max(ceil(t, t_ratio), ceil(a, a_ratio));
        t = n_min * t_ratio;
        a = n_min * a_ratio;
    }
    cout << t + a << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <algorithm> 
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int j=0;
    for(int i=a;i<=b;i++)
    {
        if(c%i==0)
        j+=1;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3112
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int d = sc.nextInt();

        if(d == 25){
            System.out.println("Christmas");
        }else if(d == 24){
            System.out.println("Christmas Eve");
        }else if(d == 23){
            System.out.println("Christmas Eve Eve");
        }else if(d == 22){
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int dp[101][10001];

int main()
{
    int k, x;
    cin >> k >> x;

    vector<int> ans;
    for (int i = (x - k + 1); i <= (x + k - 1); i++) {
        if (i >= -1000000 && i <= 1000000) {
            ans.push_back(i);
        }
    }
    rep(i, ans.size()) {
        if (i == ans.size() - 1) cout << ans[i] << endl;
        else cout << ans[i] << " ";
    }
    return 0;
}

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

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

const int mx = 3234566667;
int n, a[N];
string s, t;

vector<int> v;
void bfs(int s){
   queue<int> q;
   q.push(s);

   while(!q.empty()){
      int x = q.front();
      v.push_back(x);
      q.pop();

      int d = x % 10;
      int a = x * 10 + d - 1;
      int b = x * 10 + d;
      int c = x * 10 + d + 1;
      if (d-1 >= 0 and a <= mx){
         q.push(a);
      }
      if(b <= mx){
      q.push(b);
      }
      if (d+1 <= 9 and c <= mx){
         q.push(c);
      }
   }
}

int32_t main(){_
   
   int k;
   
   cin >> k;   
   for (int i = 1; i <= 9; ++i)
   {
      bfs(i);
   }

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

   tr(v, (int)(v.size()));
   cout<<v[k-1];


   return 0;
}

Measured memory_bytes: 1368
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	ll k;
	cin >> k;
	const int mod = 1e9 + 7;
	using Mat = vector<vi>;
	Mat a(n, vi(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	function<Mat(Mat, Mat)> mul = [&](const Mat& a, const Mat& b) {
		int n = sz(a);
		int m = sz(b);
		int k = sz(b[0]);
		Mat ret(n, vi(k));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < k; j++) {
				for (int u = 0; u < m; u++) {
					ret[i][j] = (ret[i][j] + (ll)a[i][u] * b[u][j]) % mod;
				}
			}
		}
		return ret;
	};
	function<Mat(Mat, ll)> pow = [&](Mat a, ll k) {
		if (k == 1) {
			return a;
		}
		if (k & 1) {
			return mul(a, pow(a, k - 1));
		}
		a = pow(a, k / 2);
		return mul(a, a);
	};
	a = pow(a, k);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans = (ans + a[i][j]) % mod;
		}
	}
	cout << ans;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int             long long
#define endl            '\n'
#define ff              first
#define ss              second
#define ull        unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si                 set<int>        
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)        for(int i=a;i<n;++i)
#define repd(i,a,n)        for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}


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

int32_t main()
{
    c_p_p();
    int n;
    cin>>n;
    int sum=0;
    rep(i,1,n+1)
    {
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum;
    return 0;
}
    

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
using namespace std;
int w[100005],v[100005];
int f[104][100005];
int maxx=0;
main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for(int j=1;j<=m;j++)
    {
//        cout<<"j: "<<j<<"    ";
        for(int i=1;i<=n;i++)
        {
            if(j>=w[i])
            f[i][j]=max(f[i-1][j-w[i]]+v[i],f[i-1][j]);
            else f[i][j]=f[i-1][j];
            maxx=max(f[i][j],maxx);
//            cout<<f[i][j]<<" ";
        }
//        cout<<endl;
    }
    cout<<maxx;
}


Measured memory_bytes: 81408