akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE MultiWayIf #-}
import Data.Array

main :: IO ()
main = do
  [n, a] <- map read . words <$> getLine
  xl <- map (subtract a . read) . words <$> getLine
  let
    mx = n * maximum (map abs xl)
    yl = listArray (1, n) xl
    dp = array ((0, -mx), (n, mx)) $ do
      j <- [0..n]
      t <- [-mx..mx]
      return . (,) (j, t) $ if
        | j == 0 && t == 0                -> 1
        | j == 0                          -> 0
        | t - yl!j < -mx || t - yl!j > mx -> dp ! (j-1, t)
        | otherwise                       -> dp ! (j-1, t) + dp ! (j-1, t-yl!j)
  print $ dp ! (n, 0) - 1


Measured memory_bytes: 25596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;

int n, w, h, t, c;
int a[11];


double calc(double sum, int idx) {
    if (idx == c) return sum + 0.01;
    double x = ((double)(c-idx)/c) * ((double)a[idx]/h);
    return calc(sum+x, idx+1);
}

int main(void){
    while (cin >> n >> w, n | w) {
        for (int i = 0; i < 11; i++) a[i] = 0;
        for (int i = 0; i < n; i++) {
            cin >> t;
            a[t/w]++;
        }
        h = 0, c = 0;
        for (int i = 0; i < 11; i++) {
            h = max(h, a[i]);
            if (a[i]) c = i;
        }
        printf("%.8lf\n", calc(0,0));
    }
    
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
    #include <queue>
    #include <utility>
    #include <set>
    #include <algorithm>
    using namespace std;
    long long n, m, r, t1, t2, t3, d[205][205], b[205 * 205];
     
    int main()
    {
        cin >> n >> m >> r;
        for (int i = 0; i < r; ++i)
            cin >> b[i];
      
      
      	for (int i = 1; i <= n; ++i)
                for (int j = 1; j <= n; ++j)
                  	if(i != j)
                		d[i][j] = 1e9;
      
        for (int i = 0; i < m; ++i)
        {
            cin >> t1 >> t2 >> t3;
            d[t1][t2] = t3;
            d[t2][t1] = t3;
        }
     
      
        for (int k = 1; k <= n; ++k)
            for (int i = 1; i <= n; ++i)
                for (int j = 1; j <= n; ++j)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
     
        long long mn = 1 << 30;
        sort(b, b + r);
        do
        {
            long long rj = 0, t = b[0];
            for (int i = 1; i < r; ++i)
                rj += d[t][b[i]], t = b[i];
            mn = min(mn, rj);
        } while (next_permutation(b, b + r));
        cout << mn << endl;
    }

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

int main() {
  long long n,a,b;
  cin >> n >> a >> b;
  long long dis=abs(a-b);
  if(dis%2==0) {
    cout << dis/2 << endl;
  }
  else {
    cout << (dis+2*min(min(a-1,b-1),min(n-a,n-b))+1)/2 << endl;
  }
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    bool f = 1;
    while(n--) {
        int x; cin >> x;
        if(!(x&1)) f &= (x%3 == 0 or x%5 == 0);
    }
    cout << (f? "APPROVED" : "DENIED") << endl;
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int K[200001];
int zentai, N;
ll kotae[200001];
int C[200001];
int E[400001], ne[400001], he[200001];
const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
char dn[2400000], * di = dn;
inline void putint(ll X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[15];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

void dfs(int p, int mae) {
	int k = K[C[p]] + zentai;
	int k0 = k;
	for (int to = he[p]; to; to = ne[to]) {
		if (mae != E[to]) {
			dfs(E[to], p);
			int sa = K[C[p]] + zentai - k;
			kotae[C[p]] -= ll(sa) * (sa + 1) >> 1;
			k += sa;
		}
	}
	zentai++;
	K[C[p]] = k0 - zentai;
}


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


	N = getint();
	rep1(i, N) C[i] = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();

		E[k] =b;
		ne[k] = he[a];
		he[a] = k++;
		E[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}

	dfs(1, -1);
	ll n = ll(N) * (N + 1) / 2;
	rep1(i, N) {
		int sa = K[i] + zentai;
		putint(n + kotae[i] - (ll(sa) * (sa + 1) >> 1));
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 26144
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
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;}
int K;
vector<ll> ans;
int main(){
	cin >> K;
	for(int i=1;i<9;i++)ans.pb(i);
	for(ll x=1;x<=10;x++){
		ll base = 1ll;
		for(int i=0;i<x;i++)base *= 10ll;
		for(ll i=x*base;i<=x*base*10ll;i+=base){
			ans.pb(i-1ll);
		}
	}
	for(ll i=1099999999999ll;i<=9999999999999ll;i+=100000000000ll){
		ans.pb(i);
	}
	for(ll i=10999999999999ll;i<=109999999999999ll;i+=1000000000000ll){
		ans.pb(i);
	}
	for(ll i=119999999999999ll;i<=1199999999999999ll;i+=10000000000000ll){
		ans.pb(i);
	}
	for(int i=0;i<K;i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    ll N; cin >> N;
    vel x(N),y(N),h(N); rep(i,N) cin >> x[i] >> y[i] >> h[i];

    ll H;
    rep(cx, 101) rep(cy, 101) {
        for(ll H = max(h[0]-200,1LL); H <= h[0] + 200; H++){
            bool flag = true;
            rep(i,N) if(!(max(H - abs(cx - x[i])-abs(cy - y[i]),0LL)==h[i])) {flag = false; break;}
            if(flag) {cout << cx << " " << cy << " " << H << endl; return 0;}
        }
    }
}



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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

// const i64 mod = 1'000'000'000ll + 7;
const i64 mod = 998244353ll;

//const i64 inf = mod;

const long double eps = 1e-8;

struct segtree {
    typedef i64 type;
    const type zero = 0;

    vector<type> st;

    void init(i64 size) {
        i64 n = 1;
        while (n < size) {
            n *= 2;
        }
        st.assign(n * 2, zero);
    }

    void add(i64 l, i64 r, type v, i64 x, i64 lx, i64 rx) {
        if (r <= lx || rx <= l) {
            return;
        }

        if (l <= lx && rx <= r) {
            st[x] += v;
            st[x] %= mod;
            return;
        }

        i64 mx = (lx + rx) / 2;
        add(l, r, v, 2 * x + 1, lx, mx);
        add(l, r, v, 2 * x + 2, mx, rx);
    }

    void add(i64 l, i64 r, type v) {
        add(l, r, v, 0, 0, st.size() / 2);
    }

    type get(i64 i, i64 x, i64 lx, i64 rx) {
        if (rx - lx == 1) {
            return st[x];
        }

        i64 mx = (lx + rx) / 2;
        if (i < mx) {
            return (get(i, 2 * x + 1, lx, mx) + st[x]) % mod;
        }
        else {
            return (get(i, 2 * x + 2, mx, rx) + st[x]) % mod;
        }
    }

    type get(i64 i) {
        return get(i, 0, 0, st.size() / 2);
    }
};


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n, k;
    cin >> n >> k;

    vector<pair<i64, i64>> a(k);
    for (i64 i = 0; i < k; i++) {
        cin >> a[i].first >> a[i].second;
    }

    segtree st;
    st.init(n + 1);

    st.add(1, 2, 1);

    for (i64 i = 1; i <= n; i++) {
        i64 v = st.get(i);

        for (i64 j = 0; j < k; j++) {
            i64 l = i + a[j].first;
            i64 r = min(i + a[j].second, n) + 1;

            if (l >= r) {
                continue;
            }

            st.add(l, r, v);
        }
    }

    cout << st.get(n) << endl;

    return 0;
}

Measured memory_bytes: 7428
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/

/+---test
3 3
...
.#.
...
---+/
/+---test
6 6
..#..#
......
#..#..
......
.#....
....#.
---+/

void main(string[] args) {
  long H, W;
  readf(" %d %d ", &H, &W);

  auto M = new ubyte[][](H);
  foreach (ref m; M) {
    m = readln.chomp.map!(to!ubyte).array;
  }

  struct Point { long x, y, cnt; }

  DList!Point q;

  foreach (y; 0..H) foreach (x; 0..W) {
    if (M[y][x] == '#') q.insertBack(Point(x, y));
  }

  long ans;
  while (!q.empty) {
    const p = q.front;
    q.removeFront;

    if (p.y < 0 || p.y >= H || p.x < 0 || p.x >= W) continue;
    if (M[p.y][p.x] == '#' && p.cnt > 0) continue;

    M[p.y][p.x] = '#';
    ans.amax(p.cnt);

    q.insertBack(Point(p.x, p.y-1, p.cnt+1));
    q.insertBack(Point(p.x, p.y+1, p.cnt+1));
    q.insertBack(Point(p.x-1, p.y, p.cnt+1));
    q.insertBack(Point(p.x+1, p.y, p.cnt+1));
  }
  ans.writeln;
}


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

int main() {
  int n, r = 0, b = 0;
  string s;
  cin >> n >> s;
  rep(i, n){
    if(s[i] == 'R') ++r;
    else if(s[i] == 'B') ++b;
  }
  if(r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N;
  bool flag = 0;
  cin >> N;

  vector<string> v;

  string w1;
  cin >> w1;

  v.push_back( w1 );

  for ( int i = 0; i < N - 1; i++ ) {
    string w;
    cin >> w;
    string last_w = v.back();
    if ( w[0] == last_w.back() ) {
      for ( int j = 0; j < v.size(); j++ ) {
        if ( v[j] == w ) {
          cout << "No" << endl;
          return 0;
        }
      }
      v.push_back( w );
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

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

  if(s.back() == 's') {
    s += "es";
  } else {
    s += "s";
  }
  cout << s << '\n';
}

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

int main(){
  int N, x[100];
  cin>>N;

  int K[1000], P[1000];
  for(int i=1;i<=N;i++){
    
    cin>>K[i]>>P[i];
    if(K[i]%P[i]==0) x[i] = P[i];
    
  else if( K[i] > P[i]) x[i] = K[i] % P[i];
  else if( K[i] == P[i]) x[i] = P[i];
  else if( K[i] < P[i]) x[i] = K[i];
  }

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

    cout<<x[i]<<endl;
  }

  
  return 0;
}



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

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

    vector<vector<int>> g(N), p(N);
    vector<int> cnt(N);
    for (int i = 0; i < N - 1 + M; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;

        g[a].push_back(b);
        p[b].push_back(a);
        cnt[b]++;
    }

    int root;
    for (int i = 0; i < N; i++) {
        if (cnt[i]) continue;
        root = i;
        break;
    }

    queue<int> q;
    q.push(root);

    vector<int> topo, mem(N);

    while (q.size()) {
        int from = q.front();
        q.pop();
        mem[from] = topo.size();
        topo.push_back(from);
        for (int to : g[from]) {
            cnt[to]--;
            if (!cnt[to]) q.push(to);
        }
    }

    vector<int> ans(N);
    for (int node : topo) {
        int t = -1;
        int idx = -1;
        for (int x : p[node]) {
            if (mem[x] > t) {
                t = mem[x];
                idx = x;
            }
        }
        ans[node] = idx;
    }
    for (int x : ans) cout << x + 1 << endl;

    return 0;
}


Measured memory_bytes: 14968
(A, B), = [list(map(int, s.split())) for s in open(0)]
apples = [B + i for i in range(A)]
apples_abs = [abs(a) for a in apples]
apple_idx = apples_abs.index(min(apples_abs))
apples.pop(apple_idx)
print(sum(apples))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <sstream>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define pri(a) cout << a << endl
#define pri2(a, b) cout << a << " " << b << endl
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>

typedef long long ll;

/*以上テンプレ*/

int main () {
    int a,p;
    in2(a, p);
    int s = (a * 3 + p) / 2;
    pri(s);
}

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

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

  vector<ll> cnt(3);
  rep(i, n) cnt[a[i]]++;

  ll ans = 1;
  rep(i, 3) ans *= cnt[i];

  rep(j, n) rep(i, j) {
    int k = j + (j - i);
    if(k < n) {
      if(a[i] == a[j])
        continue;
      if(a[i] == a[k])
        continue;
      if(a[k] == a[j])
        continue;
      ans--;
    }
  }

  cout << ans;
}


Measured memory_bytes: 3652
S = input()
K = int(input())

left_one_count = 0
first_char_not_one = ""
for c in S:
    if c == "1":
        left_one_count += 1
    else:
        first_char_not_one = c
        break

if left_one_count >= K:
    print("1")
else:
    print(first_char_not_one)

Measured memory_bytes: 3060
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    int n,k,i,h,swaped;
    unsigned min=-1;
    int a[100000];
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    h=(n)/1.3;
    while(h||swaped){
        swaped=0;
        if(h==0) h=1;
        if(h==10||h==9) h=11;
        for(i=0;i<n-h;i++){
            if(a[i]>a[i+h]){
                int tmp=a[i];
                a[i]=a[i+h];
                a[i+h]=tmp;
                swaped=1;
            }
        }
        h=h/1.3;
    }
    for(i=k-1;i<n;i++){
        //printf("%d ",a[i]);
        if((unsigned)(a[i]-a[i-k+1])<min){
            min=a[i]-a[i-k+1];
        }
    }
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int n,l;
	string s;
	cin>>n>>l;
	vector <string> str;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		str.push_back(s);
		
	}
	stable_sort(str.begin(),str.end());
	for(int i=0;i<n;i++)
	{
		cout<<str[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=0;
    vector<int> v;

    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            c++;
        }
        else
        {
            v.push_back(c);
            c=0;
        }
    }
    if(c>0)
    {
        v.push_back(c);
    }

    sort(v.rbegin(),v.rend());
    cout<<v.front()<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(s.at(i)==t.at(i)){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

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

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

    cin >> a >> b >> c;

    if(a == b+c || b == a+c || c == a+b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3524
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 2e5 + 200;
const int MAX = 1e6 + 100;
int n;
ll v[N];
map<int, int> mp[MAX];
map<int, int> gl;
int primes[MAX];
void sieve() {
    for(int i = 1; i < MAX; ++i) primes[i] = i;
    for(ll i = 2; i < MAX; ++i) {
        if(primes[i] == i) {
            for(ll k = i * i; k < MAX; k += i) {
                if(primes[k] == k) {
                    primes[k] = i;
                }
            }
        }
    }
}
void factor(ll d, int idx) {
    while(primes[d] != 1) {
        mp[idx][primes[d]]++;
        gl[primes[d]] = max(gl[primes[d]], mp[idx][primes[d]]);
        d /= primes[d];
    }
    // cout<<mp[idx].size()<<endl;
    /*for(auto i : mp[idx]) {
        gl[i.first] = max(gl[i.first], i.second);
    }*/
}
ll add(ll a, ll b) {
    return ( (a % MOD) + (b % MOD) ) % MOD;
}
ll mul(ll a, ll b) {
    return ( (a % MOD) * (b % MOD) ) % MOD;
}
ll bpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b & 1) ret = mul(ret, a);
        a = mul(a, a);
        b >>= 1;
    }
    return ret;
}
ll inv(ll a) {
    return bpow(a, MOD - 2);
}
int main() {
    sieve();
    scanf("%d", &n);
    forn(i, n) {
        scanf("%lld", &v[i]);
        factor(v[i], i);
    }
    ll ans = 0;
    ll tot = 1;
    for(auto k : gl) {
        ll pw = bpow(k.first, k.second);
        tot = mul(tot, pw);
    }
    forn(i, n) {
        ll cur = 1;
        for(auto k : mp[i]) {
            ll pw = bpow(k.first, k.second);
            cur = mul(cur, pw);
        }
        ll div = inv(cur);
        div = mul(tot, div);
        ans = add(ans, div);
    }
    printf("%lld\n", ans);
    return 0;
}




Measured memory_bytes: 53760
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	for(int i = 0; i < a; ++i) if(!isdigit(s[i])) return cout << "No\n", 0;
	if(s[a] != '-') return cout << "No\n", 0;
	for(int i = a + 1; i < s.size(); ++i) if(!isdigit(s[i])) return cout << "No\n", 0;
	cout << "Yes\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 201
#define MOD 1000000007
#define INF 1000000000000000000
#define lim 20

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}




void solve(){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++)cin >> a[i];

    ll dp[3][n+1];
    memset(dp, 0, sizeof(dp));
  dp[0][0] = a[0];
  for (int i = 1; i < n/2; i++) {
    dp[0][i] = dp[0][i-1] + a[i*2];
  }
  dp[1][0] = a[1];
  for (int i = 1; i < n/2; i++) {
    dp[1][i] = max(dp[0][i-1], dp[1][i-1]) + a[i*2+1];
  }
  dp[2][0] = a[2];
  for (int i = 1; i < n/2; i++) {
    dp[2][i] = max(max(dp[0][i-1], dp[1][i-1]), dp[2][i-1]) + a[i*2+2];
  }

  ll ans = max(dp[0][n/2-1], dp[1][n/2-1]);
  if (n % 2 == 1) ans = max(ans, dp[2][n/2-1]);

  cout << ans << endl;

}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 9868
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int p[100000+10];
set<int> lo,Minus;
int is[100000+10];
LL res=0;
int main(){
	int n;
	cin>>n;
	rb(i,1,n) cin>>p[i],is[p[i]]=i;
	lo.insert(is[n]),Minus.insert(-is[n]);
	rl(i,n-1,1){
		int l=INF,r=INF;
		set<int> :: IT ite;
		ite=lo.lower_bound(is[i]);
		int r1;
		if(ite==lo.end()) r1=n+1;
		else{
			r1=*ite;
			ite=lo.lower_bound((*ite)+1);
				if(ite==lo.end()) r=n;
				else r=*ite-1;
		}
		ite=Minus.lower_bound(-is[i]);
		int l1;
		if(ite==Minus.end()) l1=0;
		else 
		{
			l1=-*ite;
			ite=Minus.lower_bound((*ite)+1);
			if(ite==Minus.end()) l=1;
			else l=(-*ite)+1;
		}
//		cout<<i<<" "<<l<<" "<<l1<<" "<<r1<<" "<<r<<endl;
		if(l==INF) l=l1;
		if(r==INF) r=r1;
		if(r>n) r--;
		if(l<1) l++; 
//		if(l1==1) l1--;
//		if(r1==n) r1++;
//		cout<<i<<" "<<l<<" "<<l1<<" "<<r1<<" "<<r<<endl;
		res+=(LL)(i)*(LL)(is[i]-l1)*(r-r1+1);
		res+=(LL)(i)*(LL)(l1-l+1)*(r1-is[i]);
//		cout<<res<<endl;
		lo.insert(is[i]);
		Minus.insert(-is[i]); 
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;


void solve(){
    double a, b;
    cin >> a >> b;
    cout << a/b << endl;
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int A,B;
    int N,M;
    int i,j;
    ULL ans;
    int bef_size;
    vector<int> searchs;
    searchs.clear();
    vector<vector<int> > reward;

    cin >> N >> M;
    
    for(i=0;i<M;i++){
        reward.push_back(vector<int>());
        reward[i].clear();
    }
    for(i=0;i<N;i++){
        cin >> A >> B;
        if( A <= M){
            reward[A-1].push_back(B);
        }
    }
    ans = 0;
    /* 
    cout << endl;
    for(i=0;i<M;i++){
        for(j=0;j<reward[i].size();j++){
            cout << reward[i][j] << " ";
        }
        cout << endl;
    }
    */
    for(i=0;i<M;i++){
        sort(reward[i].begin(),reward[i].end(),std::greater<int>());
        for(j=0;j < M - i && j < reward[i].size(); j++){
            searchs.push_back(reward[i][j]);
        }
        if( searchs.size() > bef_size ){
            sort(searchs.begin(),searchs.end());
        }
        if( searchs.size() > 0 ){
            ans = ans + searchs.back();
            searchs.pop_back();
        }
        bef_size = searchs.size();
        
    }
    cout << ans << endl;
}


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

int n;
ll a[101010], b[101010];

int main(){
  cin >> n;
  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll res = 0;
  rep(i, n){
    ll tmp1 = min(a[i], b[i]);
    ll tmp2 = min(b[i] - tmp1, a[i + 1]);
    a[i + 1] -= tmp2;
    res += tmp1 + tmp2;
  }
  cout << res << endl;
  return 0;
}

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

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

Measured memory_bytes: 3636
// assuming you live in an expensive city, anyway!  but if you live in a really cheap area of the planet then you may find it hard to relate to the talking dinosaurs in this code strip today
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i], a[i]--;
    int res = 0;
    rep(i, 0, n) if (a[a[i]] == i) res++;
    cout << (res / 2) << endl;
    return 0;
}


Measured memory_bytes: 768
fun main (args : Array<String>) {
	val n = readLine()!!
	val N : String = n.toString()
	var list : MutableList<Int> = mutableListOf()
	for (i in N) {
		list.add(i.toString().toInt())
	}
	if ( (list[0] == list[1]) && (list[0] == list[2]) ) {
		return println("${N}")
	} else if ( (list[0] > list[1]) || ( (list[0] == list[1]) && (list[1] > list[2]) ) ) {
		val result = list[0] * 100 + list[0] * 10 + list[0]
		return println("${result}")
	} else {
		val calc : Int = list[0] + 1
		val result = calc * 100 + calc * 10 + calc
		return println("${result}")
	}
}

Measured memory_bytes: 33404
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 111;
     
using namespace std;

int dp[3120][3120], q, p[3120][3120];
string s, t, ans;

void solve(){    
	cin >> s >> t;

	int n = sz(s), m = sz(t);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++){
			if (s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				if (dp[i - 1][j] > dp[i][j - 1])
					p[i][j] = 1;
				else
					p[i][j] = 2;
			}
		}

	int x = n, y = m, cnt = dp[n][m];
	while (cnt > 0){
		if (p[x][y] == 1)
			x--;
		else if (p[x][y] == 2)
			y--;
		else{
			ans += s[x - 1];
			x--;
			y--;
			cnt--;
		}
	}

	rev(all(ans));

	cout << ans;
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}

Measured memory_bytes: 147712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
//#define int long long  
signed main(){
	int A,B,X;
	cin >> A >> B >> X;
	if(A<=X&&X<=A+B){
	    cout << "YES" << endl;
	}else{
	    cout << "NO" << endl;
	}
	return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara,x) memset((ara),x,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





ll int arr[g_size],arr1[1001][1001];



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

	int n,m;



	int i,j;



	cin>>n>>m;

	string s1[n];

	for(i=0;i<n;i++){
        cin>>s1[i];
	}

	for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(s1[i][j]=='#') arr1[i][j]=-1;
        }
	}

	for(i=0;i<n;i++) {
       if(s1[i][0]=='#') break ;
       else arr1[i][0]=1;

	}
	for(i=0;i<m;i++) {
        if(s1[0][i]=='#') break;
        else arr1[0][i]=1;;
	}

//	f(i,0,n-1){
//        f(j,0,m-1) cout<<arr1[i][j]<<" ";
//        cout<<endl;
//	}



	for(i=1;i<n;i++){
        for(j=1;j<m;j++){
            if(arr1[i][j]!=-1){
                ll int x,y;
                x=arr1[i-1][j];
                y=arr1[i][j-1];
                if(x>-1 && y<0) arr1[i][j]=x%mod;
                else if(x<0 && y>-1) arr1[i][j]=y%mod;
                else if(x>-1 && y>-1) arr1[i][j]=(x+y)%mod;
            }
        }
	}


//	f(i,0,n-1){
//        f(j,0,m-1) cout<<arr1[i][j]<<" ";
//        cout<<endl;
//	}


	//if(arr1[n-1][m-1]==-1) cout<<0<<endl,exit(0);
    //if(arr1[0][0]==-1) cout<<0<<endl,exit(0);
    cout<<arr1[n-1][m-1]<<endl;

}


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

using namespace std;
typedef long long ll;
#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 INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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

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

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

int ni() {
    int i;
    cin >> i;
    return i;
}

ll A[(int)2e5] = {};

int main() {
    int N = ni();
    REP(i, N) A[i+1] += A[i] + ni();

    ll sum = A[N];
    ll ans = INF;
    FOR(i, 1, N) {
        ans = min(ans, abs((sum-A[i]) - A[i]));
    }

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

Measured memory_bytes: 1920
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=2e3+10;
int a[N],n,vis[N],cnt,dag[N];
vector<int> g[N],v[N];
void dfs(int x){
	vis[x]=1;
	for(auto to:g[x])	if(!vis[to]){
		dag[to]++;	v[x].push_back(to);	dfs(to);
	}	
}
void top_sort(){
	priority_queue<int> q;
	for(int i=1;i<=n;i++)	if(!dag[i])	q.push(i);
	while(q.size()){
		int u=q.top();	q.pop();
		cout<<a[u]<<' ';
		for(auto to:v[u])	q.push(to);
	}
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)	for(int j=i+1;j<=n;j++)	if(__gcd(a[i],a[j])!=1){
		g[i].push_back(j),g[j].push_back(i);
	}	
	for(int i=1;i<=n;i++)	if(!vis[i])	dfs(i);
	top_sort();
	return 0;
}


Measured memory_bytes: 17664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int count = 0;
    for (int i = 0; i < 1000; i++) {
      String target = String.format("%03d", i);
      for (int j = 0, k = 0; j < n; j++) {
        if (s.charAt(j) == target.charAt(k)) k++;
        if (k == 3) {
          count++;
          break;
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 41508
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n+1);
  for (int i= 1; i< n+1; i++) {
    int num;
    cin >> num;
    h.at(i) = num;
  }
  h.at(0) = -100;
  vector<int> a(m);
  vector<int> b(m);
  rep(i, m) {
    int aa, bb;
    cin >> aa >> bb;
    a.at(i) = aa;
    b.at(i) = bb;
  }
  vector<bool> check(n+1, true);
  check.at(0) = false;
  rep(i, m) {
    if (h.at(a.at(i)) == h.at(b.at(i))) {
      check.at(a.at(i)) = false;
      check.at(b.at(i)) = false;
    }
    else {
      int numa = h.at(a.at(i));
      int numb = h.at(b.at(i));
      int mini = min(h.at(a.at(i)), h.at(b.at(i)));
      if (mini == numa) {
        check.at(a.at(i)) = false;
      }
      else if (mini == numb) {
        check.at(b.at(i)) = false;
      }
    }
  }
  int count = 0;
  rep(i, n+1) {
    //cout << i << check.at(i) << endl;
    if (check.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 4552
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s[0]==s[1]&&s[1]==s[2]) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


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

vector<int> v[100000];
int n;

int dfs(int x){
    vector<int> tmp;
    for(int j : v[x])   tmp.push_back(dfs(j));
    sort(tmp.rbegin(), tmp.rend());
    int ret = 0;
    for(int i = 0; i < tmp.size(); i++){
        ret = max(ret, tmp[i]+i+1);
    }
    return ret;
}

int main(){
    cin >> n;
    for(int i = 1; i < n; i++){
        int x;  cin >> x;
        v[--x].push_back(i);
    }
    cout << dfs(0) << endl;
    return 0;
}

Measured memory_bytes: 15104
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	int x = 700;
	for (int i = 0; i < s.length(); i++)
	{
		x += s.substr(i, 1) == "o" ? 100 : 0;
	}

	cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;

  rep(i, n) {
    if (s[i] == "01"[i%2]) cnt++;
  }
  cout << min(cnt, n-cnt) << endl;
}


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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];
  for(int i=0; i<n; i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  for(int i=0; i<n; i++){
    ll ai = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll ci = n-(upper_bound(c.begin(), c.end(), b[i]) -c.begin());
    ans += ai * ci;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560