akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
int n;
ll s[maxn];
ll mod,dp[maxn],ans[maxn];
vector<int> g[maxn];
vector<ll> s1[maxn],s2[maxn];
void update(ll &x,ll y) { x=x*y%mod; }
void dfs(int u,int p) {
	dp[u]=1;
	s1[u].resize(g[u].size()+1);
	s2[u].resize(g[u].size()+1);
	for (int i=0;i<g[u].size();i++) {
		int v=g[u][i];
		if (v==p) {
			if (i) s1[u][i]=s1[u][i-1];
			else s1[u][i]=1;
			continue;
		}
		dfs(v,u);
		if (i) s1[u][i]=s1[u][i-1]*(dp[v]+1)%mod;
		else s1[u][i]=dp[v]+1;
		update(dp[u],dp[v]+1);
	}
	for (int i=g[u].size()-1;i>=0;i--) {
		int v=g[u][i];
		if (v==p) {
			if (i<g[u].size()-1)
				s2[u][i]=s2[u][i+1];
			else s2[u][i]=1;
			continue;
		}
		if (i==g[u].size()-1) s2[u][i]=dp[v]+1;
		else s2[u][i]=s2[u][i+1]*(dp[v]+1)%mod;
		s[v]=1;
		if (i) update(s[v],s1[u][i-1]);
		if (i<g[u].size()-1) update(s[v],s2[u][i+1]);
	}
}
ll N[maxn];
void DFS(int u,int p) {
	for (int i=0;i<g[u].size();i++) {
		int v=g[u][i];
		if (v==p) continue;
		N[u]=(N[p]+1)*s[v]%mod;
		ans[v]=(N[u]+1)*dp[v]%mod;
		DFS(v,u);
	}
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(mod); int x,y;
	for (int i=1;i<n;i++) {
		read(x); read(y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int rt=1;
	dfs(rt,0);
	DFS(rt,0);
	ans[rt]=dp[rt];
	for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 28800
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#include <functional>
#include <climits>

//SegmentTree<int> seg(N,[](int a,int b){return min(a,b);},INT_MAX);
template< typename T>
class SegmentTree{
public:

  using F = function<T(T,T)>;

  int n;
  vector<T> tree;
  F operation;
  T def;

  SegmentTree(int size,F _operation,T _def):operation(_operation),def(_def){
    n=1;
    while(n<size) n*=2;
    tree.resize(2*n-1,def);
  }

  SegmentTree(){}

  void embody(int size,F _operation,T _def){
    operation=_operation;
    def=_def;
    n=1;
    while(n<size) n*=2;
    tree.resize(2*n-1,def);
  }

  void initialize(vector<T> v){
    int vSize=v.size();
    n=1;
    while(n<vSize) n*=2;
    tree.resize(2*n-1,def);

    for(int i=0;i<vSize;i++) tree[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--) tree[i]=operation(tree[2*i+1],tree[2*i+2]);
  }

  void update(int index,T value){
    index+=n-1;

    tree[index]+=value;
    while(index>0){
      index=(index-1)/2;
      tree[index]=operation(tree[2*index+1],tree[2*index+2]);
    }
  }

  T query(int a,int b,int k=0,int l=0,int r=-1){//[a,b),getMin(a,b,0,0,-1)
    if(r<0) r=n;

    if(r<=a||b<=l) return def;
    else if(a<=l&&r<=b) return tree[k];
    else{
      T lval=query(a,b,2*k+1,l,(l+r)/2);
      T rval=query(a,b,2*k+2,(l+r)/2,r);
      return operation(lval,rval);
    }
  }

  int find(int x,int k=0,int l=0,int r=-1){// a[0]+...+a[i]>=x (i:minimal)
    if(r<0) r=n;
    if(r-l==1) return k-(n-1);
    if(tree[2*k+1]>=x) return find(x,2*k+1,l,(l+r)/2);
    else return find(x-tree[2*k+1],2*k+2,(l+r)/2,r);
  }
};

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

  int H,W,M;
  cin>>H>>W>>M;
  vector<int> h(M),w(M);
  rep(i,M) cin>>h[i]>>w[i];

  rep(i,M) h[i]--;
  rep(i,M) w[i]--;
  vector<vector<int>> pos(H);
  rep(i,M) pos[h[i]].push_back(w[i]);

  SegmentTree<int> seg(W,[](int a,int b){return max(a,b);},0);
  vector<int> init(W,0);
  rep(i,M) init[w[i]]++;
  seg.initialize(init);

  int ans=0;
  for(int i=0;i<H;i++){
    for(auto p:pos[i]) seg.update(p,-1);
    int res=seg.query(0,W);
    res+=pos[i].size();
    chmax(ans,res);
    for(auto p:pos[i]) seg.update(p,+1);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 28544
N, A, B = map(int, input().split())
s = input()

pass_a = True
cnt = 0
cnt_b = 1
for i in s:

    if cnt < A + B:
        if i == "a":
            print("Yes")
            cnt += 1

        elif i == "b":
            if cnt_b <= B:
                print("Yes")
                cnt += 1
                cnt_b += 1
            else:
                print("No")
        else:
            print("No")
    
    else:
        print("No")

Measured memory_bytes: 50776
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

enum RS = ["AC", "WA", "TLE", "RE"];

void main()
{
    auto N = readln.chomp.to!int;
    int[string] rs;
    foreach (r; RS) rs[r] = 0;
    foreach (_; 0..N) {
        auto r = readln.chomp;
        rs[r] += 1;
    }
    foreach (r; RS) {
        writefln("%s x %d", r, rs[r]);
    }
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <ctime>


#ifndef M_PI
#define M_PI 3.141592653589
#endif
#define int long long
#define double long double
#define f(variable, start, end) for (int variable = start; variable < end; ++variable)
#define be(a) a.begin(), a.end()
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define nor cout << "NO\n"; return
#define yesr cout << "YES\n"; return
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>


using namespace std;


template<typename T, typename E>
vector<T> &operator>>(vector<T> &v, E a) {
    v.push_back(a);
    return v;
}

//pair output
template<typename E>
ostream &operator<<(ostream &os, pair<E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//"map" pair output
template<typename E>
ostream &operator<<(ostream &os, pair<const E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//vector output
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
    for (T i : vec) {
        os << i << ' ';
    }
    return os;
}

//2 dimensional vector output
template<typename T>
ostream &operator<<(ostream &os, vector<vector<T> > &vec) {
    for (vector<T> i : vec) {
        os << i << '\n';
    }
    return os;
}

//vector<pair<T, E>> output
template<typename T, typename E>
ostream &operator<<(ostream &os, vector<pair<T, E>> &vec) {
    for (pair<T, E> i : vec) {
        os << i.first << ' ' << i.second << '\n';
    }
    return os;
}


int32_t main() {
    cin.tie(NULL);
    cout.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(10);
    ios_base::sync_with_stdio(false);
#ifdef TIME
    int32_t start = clock();
#endif

    int n;
    cin >> n;
    vi a(n);
    f(i, 0, n) {
        cin >> a[i];
    }

    sort(a.rbegin(), a.rend());

    int ans = 0;
    int j = 0;
    int slot = 1;

    for (int i = 1; i < n; ++i) {
        if (slot == 1) {
            slot = 2;
            ans += a[j];
            j += 1;
        }
        else if (slot == 2) {
            slot = 1;
            ans += a[j];
        }
    }

    cout << ans;


#ifdef TIME
    cout << "\ntime: " << (clock() - start) / (CLOCKS_PER_SEC * 1.0);
#endif

    return 0;
}

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

int main() {
  int A, i, B, a, b, c, d, e, ans = 0, A1, N;
  cin >> A >> B;
  N = B - A +1;

  for (i = 0; i < N; i++){
    A1 = A;
    a = A1 / 10000;
    A1 -= a * 10000;
    b = A1 / 1000;
    A1 -= b * 1000;
    c = A1 / 100;
    A1 -= c * 100;
    d = A1 / 10;
    e = A1 - d * 10;
    if (a == e && b == d) ans++;
    A++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a1,a2,a3;
  cin>>a1>>a2>>a3;
  int n=a1+a2+a3;
  if(n>=22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b))cout<<"B";
	else cout<<"A";
}

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

constexpr int mod = 2019;

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

    string s;
    cin >> s;


    int n = s.size();
    map<ll,ll> mp;
    mp[0] = 1;

    reverse(s.begin(),s.end());

    int ten = 1;
    int cur = 0;
    for (int i = 0; i < n; i++) {
        cur = cur + (s[i] - '0') * ten;
        cur %= mod;
        mp[cur]++;
        ten *= 10;
        ten %= mod;
    }

    ll ans = 0;
    for (auto it : mp) {
        ans += it.second * (it.second - 1) / 2;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3692
<?php
list($n) = ints();
$dp = array_fill(0, $n + 1, 0);
for ($i = 0; $i < $n; ++$i) {
    list($p) = ints();
    $dp[$p] = $dp[$p - 1] + 1;
}
echo $n - max($dp);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 22152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a=0,b=0,c=0,d=0,i;
    string s;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> s;
        if(s=="AC")
            a++;
        if(s=="WA")
            b++;
        if(s=="TLE")
            c++;
        if(s=="RE")
            d++;
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d);
}


Measured memory_bytes: 3644
import sys
# input = sys.stdin.readline

def main():
    s = list(input().replace("BC", "D"))
    a = 1
    for i in range(len(s)-1):
        w = "".join(s[i:i+2])
        if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1


print(sum(main()))


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 1010;
num fact[MAXN];
num ifact[MAXN];
num dp[MAXN][MAXN];

void precomp() {
	fact[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fact[i] = fact[i-1] * i;
	}
	for (int i = 0; i < MAXN; i++) {
		ifact[i] = 1 / fact[i];
	}
}

num choose(int n, int r) {
	return fact[n] * ifact[r] * ifact[n-r];
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	precomp();

	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	dp[0][0] = 1;
	for (int n = 0; n < N; n++) {
		num s = 0;
		for (int nxt = 0; nxt <= B; nxt++) {
			if (A <= nxt) {
				num prod = 1;
				for (int cnt = 1; n + cnt * nxt <= N && cnt <= D; cnt++) {
					prod *= choose(N - n - (cnt-1) * nxt, nxt);
					if (C <= cnt) {
						dp[n + cnt * nxt][nxt] += s * prod * ifact[cnt];
					}
				}
			}
			s += dp[n][nxt];
		}
	}

	num ans = 0;
	for (int cur = A; cur <= B; cur++) {
		ans += dp[N][cur];
	}
	cout << ans << '\n';

	return 0;
}


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

int main(){
long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double pi=3.1415926535897932384626;
  long double r,s;
s=abs(30*h-5.5*m)/180.0*pi;
  r=sqrt(a*a+b*b-2*a*b*cos(s));
  cout<<fixed;
  cout<<setprecision(10)<<r<<endl;
  return 0;
}

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

void func(int a){
    
}

int main(){
    int n,a[10];
    cin>>n;
    int x=1,y=1;
    for (int i=0; i<n; i++){
        cin>>a[i];
        x*=3;
        if(a[i]%2==0)y*=2;
    }
    cout<<x-y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define inf 100000000000

using namespace std;

int N, M, L, Q;
long long dist[305][305];
int a, b, c;

int main() {
    cin >> N >> M >> L;
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = inf;
        }
    }

    for (int i=0; i<M; i++) {
        cin >> a >> b >> c;
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = (dist[i][j] <= L) ? 1:inf;
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    cin >> Q;
    for (int i=0; i<Q; i++) {
        cin >> a >> b;
        if (dist[a-1][b-1] == inf) {
            cout << "-1\n";
        } else {
            cout << dist[a-1][b-1]-1 << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 1280
import sys
input = sys.stdin.readline

n = int(input())
S = list(map(int, input().split()))
q = int(input())
P = list(map(int, input().split()))
count = 0

for i in P:
    left = 0
    right = n

    while left <= right:
        mid = (left + right) // 2
        # print("-------------------------")
        # print("i:{}".format(i))
        #
        # print("left:{}".format(left))
        # print("right:{}".format(right))
        # print("mid:{}".format(mid))
        # print("S[mid]:{}".format(S[mid]))

        if i == S[mid]:
            count += 1
            # print("found")
            break

        elif i < S[mid]:
            right = mid - 1
        else:
            left = mid + 1

print(count)



Measured memory_bytes: 16176
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    string s;
    cin>>s;
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    int p;
    bool flag=false;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
            p=i;
            flag=true;
        }
    }
    if(!flag){
        cout<<"WA"<<endl;
        return 0;
    }
    for(int i=1;i<s.size();i++){
        if(i==p)continue;
        if(s[i]<'a' || 'z'<s[i]){
            cout<<"WA"<<endl;
            return 0;
        }
    }
    cout<<"AC"<<endl;
}

   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 201000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll b, ll m) {
  if (b == 0) return 1;
  ll ret;
  if (b % 2 == 0) {
    ll t = modpow(a, b / 2, m) % m;
    ret = t * t % m;
  } else {
    ll t = modpow(a, (b - 1) / 2, m) % m;
    ret = a * t % m * t % m;
  }
  ret %= m;
  return ret;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), s(n + 1, 0);
  REP(i, n) { cin >> x[i]; }
  REP(i, n) { s[i + 1] = (s[i] + x[i]) % MOD; }
  COMinit();
  ll ans = 0;
  FOR(k, 1, n - 1) {
    ll t = (s[n - 1] - s[k]) % MOD + (MOD - s[n - 1 - k]) % MOD;
    t = t * fac[n - 1] % MOD * inv[k] % MOD * inv[k + 1] % MOD;
    // DUMP(k);
    // DUMP(t);
    ans += t;
    ans %= MOD;
  }
  FOR(i, 1, n) {
    ll t = (x[n - 1] + (MOD - x[i - 1]) % MOD) % MOD;
    t *= fac[n - 1] * inv[n - i] % MOD;
    t %= MOD;
    // DUMP(i);
    // DUMP(t);
    ans += t;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int a,b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll h,w;

int main(){
    cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = h*w;
    rep(i,w){
        ll MA = max(h*i,(w-i)*(h/2+h%2));
        ll MI = min(h*i,(w-i)*(h/2));
        ans = min(ans,MA-MI);
        MA = max(h*i,h*((w-i)/2+(w-i)%2));
        MI = min(h*i,h*((w-i)/2));
        ans = min(ans,MA-MI);
    }
    rep(i,h){
        ll MA = max(w*i,(h-i)*(w/2+w%2));
        ll MI = min(w*i,(h-i)*(w/2));
        ans = min(ans,MA-MI);
        MA = max(w*i,w*((h-i)/2+(h-i)%2));
        MI = min(w*i,w*((h-i)/2));
        ans = min(ans,MA-MI);
    }
    cout << ans << endl;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    pair<int,int> a[n];
    priority_queue<int> pq;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a,a+n);
    int res=0,j=0;
    for(int i=m-1;i>=0;i--){
        while(j<n && a[j].first<=m-i){
            pq.push(a[j].second);
            j++;
        }
        if(pq.size()){
            res+=pq.top();
            pq.pop();
        }
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 1660
n, k = map(int, input().split())
a = list(map(int, input().split()))
count = {}
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
b = []
for i, j in sorted(count.items(), key=lambda x: x[1]):
    b.append(j)
print(sum(b[0:len(b)-k]))

Measured memory_bytes: 38964
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
string s;

set<int> number(int left,int right){
	set<int>st;
	int tmp=0;
	for(int i=left;i<=right;i++){
		tmp *= 10;
		tmp += s[i]-'0';
	}
	st.insert(tmp);
	return st;
}

set<int> expr(int left,int right){
	set<int>st;
	vector<int> v;
	int depth = 0;
	//cout << left << " " << right << endl;
	for(int i=left;i<=right;i++){
		if(s[i]=='('){
			depth++;
		}
		if(s[i]==')'){
			depth--;
		}
		if(depth==0&&s[i]=='+'){
			v.push_back(i);
		}
		if(depth==0&&s[i]=='-'){
			v.push_back(i);
		}
		if(depth==0&&s[i]=='*'){
			v.push_back(i);
		}
		if(depth==0&&s[i]=='/'){
			v.push_back(i);
		}
	}
	if(v.size()==0&&s[left]=='('){
		return expr(left+1,right-1);
	}
	if(v.size()==0){
		return number(left,right);
	}
	for(int i=0;i<v.size();i++){
		if(s[v[i]]=='+'){
			set<int>tmp,tmp2;
			tmp = expr(left,v[i]-1);
			tmp2 = expr(v[i]+1,right);
			for(int x:tmp){
				for(int y:tmp2){
					st.insert(x+y);
				}
			}
		}
		if(s[v[i]]=='-'){
			set<int>tmp,tmp2;
			tmp = expr(left,v[i]-1);
			tmp2 = expr(v[i]+1,right);
			for(int x:tmp){
				for(int y:tmp2){
					st.insert(x-y);
				}
			}
		}
		if(s[v[i]]=='*'){
			set<int>tmp,tmp2;
			tmp = expr(left,v[i]-1);
			tmp2 = expr(v[i]+1,right);
			for(int x:tmp){
				for(int y:tmp2){
					st.insert(x*y);
				}
			}
		}
		if(s[v[i]]=='/'){
			set<int>tmp,tmp2;
			tmp = expr(left,v[i]-1);
			tmp2 = expr(v[i]+1,right);
			for(int x:tmp){
				for(int y:tmp2){
					if(y!=0){
						st.insert(x/y);
					}
				}
			}
		}
	}
	return st;
}





int main(){
	while(cin >> s &&s!="#"){
		set<int>st;
		st = expr(0,s.size()-1);
		cout << st.size() << endl;

	}
	return 0;
}


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

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	cout << (abs(x - a) > abs(x - b) ? 'B' : 'A') << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define p 1000000007
#define pb push_back
ll dp[3001][3001];

ll points(ll i,ll j,vector<ll> &v,int turn)
{
    if(i>j)
    {
        return 0;
    }
    else if(i==j)
    {
        return dp[i][j]=(turn==1?v.at(i):0);
    }
    else
    {
        if(dp[i][j]!=-1)
        {
            return dp[i][j];
        }
        if(turn==1)
        {
            ll option1=v.at(i)+points(i+1,j,v,0);
            ll option2=v.at(j)+points(i,j-1,v,0);
            
            return dp[i][j]=max(option1,option2);
        }
        else if(turn==0)
        {
            ll option1=points(i+1,j,v,1);
            ll option2=points(i,j-1,v,1);
            
            return dp[i][j]=min(option1,option2);
        }
    }
}

ll solve(ll n,vector<ll> &v)
{
    memset(dp,-1,sizeof(dp));
    return points(1,n,v,1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    ll sum=0;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>v.at(i);
        sum+=v.at(i);
    }
    //cout<<sum<<"\n";
    //cout<<solve(n,v)<<"\n";
    cout<<(2*solve(n,v)-sum)<<"\n";
    return 0;
}

Measured memory_bytes: 74184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		String strNum = null;

		int x = 0;

		try{

			BufferedReader insLine = new BufferedReader(new InputStreamReader(System.in));
			strNum = insLine.readLine();

			x = Integer.parseInt(strNum);

			if (x >=1  && x <= 100) {

				System.out.println(x * x * x);
			}

			//??¨????????????
		}catch (IOException e) {
			System.out.println(e);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}
	}

}

Measured memory_bytes: 24160
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    int a1 = a /k;
    int a2 = a % k;
    if(a2 == 0){
        cout << "OK" <<endl;
    }
    else if(b >= (a1+1)*k) {
        cout << "OK" <<endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let a = read::<i64>();
  println!("{}", if x % 500 <= a { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
#define MOD 1000000007 
using namespace std;
typedef long long LL;

const int PMAX = 9999;
const int offset = 5000;

int main(){
  int N, MA, MB;
  cin >> N >> MA >> MB;
  vector<int> dp(offset * 2 + 1, PMAX);
  REP(i, N) {
    int A, B, C;
    cin >> A >> B >> C;
    int t = MA * B - MB * A;
    vector<int> ndp(dp);
    REP(j, offset * 2 + 1) {
      if(dp[j] < PMAX) {
        ndp[j+t] = min(dp[j+t], dp[j] + C);
      }
    }
    ndp[offset+t] = min(dp[offset+t], C);
    dp = ndp;
  }
  cout << (dp[offset] == PMAX ? -1 : dp[offset]) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll n;
vi v[200005];
ll a[200005];
ll ans[200005];
vi dp;
vi viz(200005,false);
void dfs(ll s){
	viz[s]=true;
	ll val=-1,pos;
	pos = lower_bound(dp.begin(),dp.end() , a[s]) - dp.begin();
	if(pos!=dp.size()){
		val = dp[pos];
		dp[pos] = a[s];
	}
	else dp.pb(a[s]);
	ans[s] = dp.size();
	for(ll i=0;i<v[s].size();i++){
		ll u = v[s][i];
		if(viz[u]) continue;
		dfs(u);	
	}
	if(val==-1) dp.pop_back();
	else  dp[pos] = val;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=1;i<n;i++){
		ll x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1);
	for(ll i=1;i<=n;i++) cout<<ans[i]<<"\n";
	
	return 0;
}

Measured memory_bytes: 30360
A, B, C = map(int, raw_input().split())

#sqrt(A) + sqrt(B) < sqrt(C)
#A + B + 2.sqrt(AB) < C
# 4.AB < (C - A - B) ^ 2

if C - A - B < 0: print "No"
else: print "Yes" if 4 * A * B < (C - A - B) ** 2 else "No"

Measured memory_bytes: 27756
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			Point2 p[]=new Point2[4];
			for(int i=0;i<4;i++)
				p[i]=new Point2(in.nextDouble(), in.nextDouble());
			boolean judge=false;
			if(ccw(p[0],p[3],p[1])==1&&ccw(p[1],p[3],p[2])==1&&ccw(p[2],p[3],p[0])==1
					||ccw(p[0],p[3],p[1])==-1&&ccw(p[1],p[3],p[2])==-1&&ccw(p[2],p[3],p[0])==-1)
				judge=true;
			System.out.println(judge ? "YES":"NO");
		}
	}
	//counterClockWise p1->p2->p3が反時計周りなら正 時計周りなら負を返す 
	static double ccw(Point2 p1,Point2 p2,Point2 p3)
	{
		Point2 a=new Point2(p2.x-p1.x, p2.y-p1.y);
		Point2 b=new Point2(p3.x-p1.x, p3.y-p1.y);
		 if(crossProduct(a, b)>0) return 1;//counter clockwise
		 if(crossProduct(a, b)<0) return -1;//clockwise
		 else return 0;
	}
	//外積
	static double crossProduct(Point2 p2,Point2 p3)
	{
		return p2.y*p3.x-p2.x*p3.y;
	}
}
class Point2
{
	double x;
	double y;
	Point2(double x,double y)
	{
		this.x=x;
		this.y=y;
	}
}

Measured memory_bytes: 23092
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1),A))
import heapq
heapq.heapify(A)

for i in range(M):
    maxA = (((heapq.heappop(A))*(-1))//2)*(-1)
    heapq.heappush(A,maxA)
   
    
print(sum(A)*-1)


Measured memory_bytes: 91692
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
//using ll = long long; using ld = long double;
//using P = pair<int, int>;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << a + b + c + max({a, b, c}) * ((1 << k) -1) << endl;
    return 0;
    //g++ <filename> -std=c++11でコンパイル必要
}



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

int main()
{
  int a1,a2,b1,b2;
  cin>>a1>>a2>>b1>>b2;
  int v2=a1-b1,v1=-1*(a2-b2);
  v1 = -1*v1,v2=-1*v2;
  cout<<v1+b1<<" "<<v2+b2<<" "<<v1+a1<<" "<<v2+a2<<"\n";


  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n), r(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  rep(i,n) r[i] = i+1;
  
  int cnt = 0;
  int qc=0, pc=0;
  bool flgp = true;
  bool flgq = true;
  do{
    cnt++;
    flgp = true;
    flgq = true;
    rep(i,n)
      if(p[i] != r[i]){
        flgp = false;
        break;
      }
    rep(i,n)
      if(q[i] != r[i]){
        flgq = false;
        break;
      }
    if(flgq) qc = cnt;
    if(flgp) pc = cnt;
  }while(next_permutation(r.begin(), r.end()));
  
  cout << abs(qc-pc) << endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- inpi $ splt toDbl
  mapM_ putStrLn $ solve xs

solve :: [[Double]] -> [String]
solve xs = map pint xs

pint :: [Double] -> String
pint [x1, y1, x2, y2, x3, y3, xp, yp]
  | cr1 > 0 && cr2 > 0 && cr3 > 0 = "YES"
  | cr1 < 0 && cr2 < 0 && cr3 < 0 = "YES"
  | otherwise = "NO"
  where
    p1 = Point x1 y1
    p2 = Point x2 y2
    p3 = Point x3 y3
    pp = Point xp yp
    v1 = toVector p1 p2
    v2 = toVector p2 p3
    v3 = toVector p3 p1
    vp1 = toVector p1 pp
    vp2 = toVector p2 pp
    vp3 = toVector p3 pp
    cr1 = cross v1 vp1
    cr2 = cross v2 vp2
    cr3 = cross v3 vp3
    
toDbl :: String -> Double
toDbl s = read s

splt :: (String -> a) -> String -> [a]
splt f = map f . words

inpi :: (String -> a) -> IO [a]
inpi f = map f . lines <$> getContents

data Point = Point {xop :: Double, yop :: Double} deriving Show
data Vector = Vector {xov :: Double, yov :: Double} deriving Show

cross :: Vector -> Vector -> Double
cross v1 v2 = xov v1 * yov v2 - yov v1 * xov v2

toVector :: Point -> Point -> Vector
toVector p1 p2 = Vector (xop p2 - xop p1) (yop p2 - yop p1)

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L+1)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int lds(vector<int> &v){
    int n = v.size();
    vector<int> ans(n, -INF);
    REP(i, n) {
        *(upper_bound(ALL(ans), v[i]-1)-1) = v[i];
    }
    return ans.end() - upper_bound(ALL(ans), -INF);
}

ll lis(vector<ll> &v){
    int n = v.size();
    vector<ll> ans(n, MAXINF);
    REP(i, n) *lower_bound(ALL(ans), v[i]+1) = v[i];
    return lower_bound(ALL(ans), MAXINF) - ans.begin();
}

int main(void)
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
    }
    // pr(lds(A));
    reverse(ALL(A));
    pr(lis(A));
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if(p == 2) {
        rep(i,n) {
            if(!((s[i]-'0')&1)) ans += i+1;
        }
    } else if(p == 5) {
        rep(i,n) {
            if(s[i] == '0' or s[i] == '5') ans += i+1;
        }
    } else {
        int now = 0;
        map<int,int> mp;
        mp[0]++;
        int p10 = 1;
        rrep(i,n) {
            (now += (s[i]-'0')*p10) %= p;
            ans += mp[now];
            mp[now]++;
            (p10 *= 10) %= p;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n,ans=0;cin>>n;
  vector<int> l(n,0);
  REP(i,n) cin>>l.at(i);
  sort(l.begin(),l.end());

  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l.at(k)<l.at(i)+l.at(j)) ans++;
        else break;
      }
    }
  }
  
  cout<<ans;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    cout << s[0] << n-2 << s[n-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <deque>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define mp make_pair
#define fname ""
#define fi first
#define se second
#define sz(a) (int)a.size()
#define pb push_back
#define fo(i,k,n) for(int i=k; (int)i<n; ++i)
#define rep(i,n,k) for(int i=n; (int)i>=k; --i)
#define all(v) v.begin(), v.end()
#define it ::iterator
#define forit(it,v) for(__typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int N = 100100;

string s;
int a[30];

int main(){

    cin>>s;
    
    fo(i,0,sz(s)){
        a[s[i] - 'a']++;
    }
    
    fo(i,0,26){
        if(a[i] == 0){
            char r = i + 'a';
            cout<<r;
            return 0;
        }
    }
    
    cout<<"None";
    

    return 0;
}


Measured memory_bytes: 512
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]
ans = 0
for i in range(D):
    ans += S[i][t[i]-1]
    manzoku_down = 0
    for k in range(26):
        last = 0
        for j in range(0,i+1):
            if t[j] == k+1:
                last = j+1
        manzoku_down += C[k]*((i+1)-last)
    ans -= manzoku_down
    print(ans)

Measured memory_bytes: 68988
#include <iostream>

using namespace std;

main(){
    int N,M,L,R,min_x,max_x;
    cin >> N >> M;

    min_x = 1;
    max_x = N;

    for(int j=1;j<M+1;j++)
    {
        cin >> L >> R;

        if(R < min_x || L > max_x)
        {
            cout << 0 << endl;
            exit(0);
        }

        if(L >= min_x) min_x = L;
        if(R <= max_x) max_x = R;

    }

    cout << max_x - min_x + 1 <<endl;

}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n,k; cin >> n >> k;
  vector<lint> a(n); for(int i=0;i<n;i++) { cin >> a[i]; }

  for(int i=0;i<k;i++) {
    vector<lint> c(n+1,0);
    for(int j=0;j<n;j++) {
      c[max(0LL,j-a[j])]++;
      c[min(j+a[j]+1,n)]--;
    }

    a[0] = c[0];
    for(int j=1;j<n;j++) { a[j] = c[j]+a[j-1]; }

    int check=1;
    for(int j=0;j<n;j++) { if(a[j] != n){ check *= 0;} }
    if(check == 1) { break; }
  }

  for(int i=0;i<n;i++) { cout << a[i] << " "; }
  cout << endl;
  return 0;
}


Measured memory_bytes: 6404
using System;
using System.Collections.Generic;

public class A_B_Problem
{
    //????????????????????????????¨?????¨?????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        int leftNum;
        int rightNum;
        string[] unitNum;
        /*---??£?¨???¨---*/

        /*????????????????????????????????§??????*/
        unitNum = Console.ReadLine().Split(' ');
        leftNum = int.Parse(unitNum[0]);
        rightNum = int.Parse(unitNum[1]);


        /*-----------?¨??????¨------------*/
        /*[a/b] d(??´??°)*/
        Console.Write("{0} ", leftNum / rightNum);

        /*[a%b] r(??´??°)*/
        Console.Write("{0} ", leftNum % rightNum);

        /*[a/b] f(???????°???°????¬¬5????????§)*/
        Console.Write("{0}", (((double)leftNum / rightNum)).ToString("F5"));

        /*-----------?¨??????¨------------*/
    }
}

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

public class Main {

	static int[][] map;
	static int[][] directions8 = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 },
			{ 1, 1 } };
	static int[][] directions4 = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			int e = sc.nextInt();

			if (e == 0) {
				break;
			}
			int min = Integer.MAX_VALUE;
			for (int z = 0; z <= 100; z++) {
				for (int y = 0; y <= 1000; y++) {
					int x = e - z * z * z - y * y;

					if (x < 0) {
						continue;
					}

					min = Integer.min(min, x + y + z);
				}
			}
			System.out.println(min);
		}
	}

	// 素数判定
	static boolean isPrime(long n) {
		if (n == 2)
			return true;
		if (n < 2 || n % 2 == 0)
			return false;

		int i = 3;
		while (i <= Math.sqrt(n)) {
			if (n % i == 0)
				return false;
			else
				i += 2;
		}
		return true;
	}

	// BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	// //二分探索
	// k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// 二分探索
	// k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}



Measured memory_bytes: 33728
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 A, B;
	cin >> A >> B;
	cout << (abs(A - B) < 2 ? "Yay!" : ":(") << endl;
	return 0;
}


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

int main() {
	int a, b;
	while (~scanf("%d%d", &a, &b)) {
		if (a != b) {
			printf("%s\n", a < b ? "a < b" : "a > b");
		}
		else printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1008
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        
        for(int i = 0; i < S.length(); i++) {
            for(int j = 0; j < S.length(); j++) {
                if(i != j && S.charAt(i) == S.charAt(j)) {
                    System.out.println("no");
                    return;
                }
            }
                
        }
        System.out.println("yes");
    }
}


Measured memory_bytes: 21844
x=int(input())
 
if x<100:
	print("0")
	exit()

while 1:
	tm=(str(x)[-2:])
	if int(tm) > 5:
		x-=105
	else:
		print("1")
		exit()
		
	if x<100:
		print("0")
		exit()


Measured memory_bytes: 9172