akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  int a=0,w=0,t=0,r=0;
  while(n--)
  {
    
    string s;
    cin>>s;
    if(s=="AC")
    a++;
    else if(s=="WA")
    w++;
    else if(s=="TLE")
    t++;
    else
    r++;
 
  }
  cout<<"AC x "<<a<<"\n";
     cout<<"WA x "<<w<<"\n"; 
     cout<<"TLE x "<<t<<"\n";
     cout<<"RE x "<<r<<"\n";
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int long long
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for(; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
namespace {
  const int mo = 1e9 + 7;
  inline int add(int x, int y) {
    if((x += y) >= mo) x -= mo;
    return x;
  }
  inline int sub(int x, int y) {
    if((x -= y) < 0) x += mo;
    return x;
  }
  inline int mul(int x, int y) {
    return x * y % mo;
  }
  inline int pw(int a, int k, int mo) {
    int ans = 1;
    for(; k; k >>= 1, a = mul(a, a))
      if(k & 1) ans = mul(ans, a);
    return ans;
  }
  inline void U(int &x, int y) {
    x = add(x, y);
  }
}

const int N = 3e5 + 233;
map<int, int> mp[N];
vector<pair<int, int> > vec[N];
int fac[N], fac_inv[N];
int c[N], w[N], pre[N];
int n, X, Y, ans = 1;
inline void init(void) {
  fac[0] = 1;
  for(int i = 1; i < N; i ++)
    fac[i] = mul(fac[i - 1], i);
  fac_inv[N - 1] = pw(fac[N - 1], mo - 2, mo);
  for(int i = N - 2; i >= 0; i --)
    fac_inv[i] = mul(fac_inv[i + 1], i + 1);    
}

inline int find(int x) {
  return pre[x] == x ? x : pre[x] = find(pre[x]);
}

inline void uni(int x, int y) {
  // cout << x << " " << y << "\n";
  int fx = find(x), fy = find(y);
  if(fx == fy) return ;
  if((int) mp[fx].size() < (int) mp[fy].size())
    swap(fx, fy);
  pre[fy] = fx;
  for(auto v: mp[fy])
    mp[fx][v.first] += v.second;
  mp[fy].clear();
}

inline int gao(int id) {
  int ans = 1;
  int tot = 0;
  for(auto v: mp[id]) {
    ans = mul(ans, fac_inv[v.second]);
    tot += v.second;
  }
  ans = mul(ans, fac[tot]);
  return ans;
}

main(void) {
  init();
  read(n); read(X); read(Y);
  for(int i = 1; i <= n; i ++) {
    read(c[i]); read(w[i]);
    vec[c[i]].push_back({w[i], i});
    pre[i] = i; mp[i][c[i]] = 1;
  }
  int id = -1, mn = 1e11;
  int seid = -1, semn = 1e11;
  for(int i = 1; i <= n; i ++) if((int) vec[i].size()) {
      auto &v = vec[i];
      sort(v.begin(), v.end());
      int sz = v.size();
      if(sz > 1) {
        for(int k = 1; k < sz; k ++)
          if(v[0].first + v[k].first <= X)
            uni(v[0].second, v[k].second);
      }
      if(mn > v[0].first) {
        id = i; mn = v[0].first;
      }
    }
  id = -1; mn = 1e11;
  for(int i = 1; i <= n; i ++) if((int) vec[i].size()) {
      auto &v = vec[i];
      sort(v.begin(), v.end());
      if(mn > v[0].first) {
        seid = id; semn = mn;
        id = i; mn = v[0].first;
      }
      else if(semn > v[0].first) {
        seid = i; semn = v[0].first;
      }
    }
  if(id != -1) {
    int pid = vec[id][0].second;
    for(int i = 1; i <= n; i ++)
      if(w[i] + w[pid] <= (c[i] == c[pid] ? X : Y))
        uni(pid, i);
  }
  if(seid != -1) {
    swap(seid, id);
    int pid = vec[id][0].second;
    for(int i = 1; i <= n; i ++)
      if(w[i] + w[pid] <= (c[i] == c[pid] ? X : Y))
        uni(pid, i);
  }
  for(int i = 1; i <= n; i ++)
    if(pre[i] == i)
      ans = mul(ans, gao(i));
  cout << ans << "\n";
}


Measured memory_bytes: 52224
import sys
input = sys.stdin.buffer.readline

#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n = int(input())
h = list(map(int, input().split()))
dp=[0]+[1000000000]*(n-1)
for i in range(1,n):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>=2:
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 12328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a;cin>>a;
	cout<<3*a*a<<endl;































	
}

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

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    return a % b == 0 ? b : gcd(b, a % b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a ,b);
    ll len = sqrt(g) + 1;
    ll c = 1;
    for (ll i = 2; i <= len; i++)
        if (g % i == 0) {
            c++;
            while (g % i == 0) g /= i;
        }
    if (g != 1) c++;
    cout << c << endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> vec1(n);
	for (int i = 0; i < n; i++) {
		cin >> vec1.at(i);
	}
	int q;
	cin >> q;

	vector<int> vec2(q);
	for (int i = 0; i < q; i++) {
		cin >> vec2.at(i);
	}

	int result = 0;

	for (int x : vec2) {
		for (int y : vec1) {
			if (x == y) {
				result++;
				break;
			}
		}
	}

	cout << result << endl;
}



Measured memory_bytes: 3136
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int d;
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = 0;
		}
		for(int i = 0; i < k; i++) {
			d = sc.nextInt();
			for(int j = 0; j < d; j++) {
				int l = sc.nextInt();
				a[l-1] = 1;
			}
		}
		
		int count = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] == 0) {
				count++;
			}
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 46464
#include <iostream>

using namespace std;
int s[100010],t[100010];
int main(){
	int i,a,b,m,mn1 = 10000000,mn2 = 10000000,ans;
	cin >> a >> b >> m;
	for(i=0;i<a;i++){
		cin >> s[i];
		mn1 = min(mn1,s[i]);
	}
	for(i=0;i<b;i++){
		cin >> t[i];
		mn2 = min(mn2,t[i]);
	}
	ans = mn1 + mn2;
	for(i=0;i<m;i++){
		int x,y,c;
		cin >> x >> y >> c;
		x--; y--;
		ans = min(ans,s[x] + t[y] - c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

signed main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;

    return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size()-1;i++){
        cout<<s[i]<<t[i];
    }
    cout<<s[s.size()-1];
    if(s.size()==t.size())cout<<t[t.size()-1];
    cout<<endl;
}


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

int a, b;
string s = "";

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

  int x = max(a, b);
  int y = min(a, b);
  // 小さい方を並べた方が辞書順に前
  for (int i = 0; i < x; i++) {
    s += '0' + y;
  }

  printf("%s", s.c_str());

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <numeric>
#include <tuple>

using namespace std;
using board_t = array<int8_t, 64>;

void put(board_t &board, int32_t r, int32_t c) {
    for (int32_t i = 0; i < 8; i++) {
        board[i*8+c] = -1;
        board[r*8+i] = -1;
        if (0 <= i+c-r && i+c-r < 8) board[i*8+i+c-r] = -1;
        if (0 <= r+c-i && r+c-i < 8) board[i*8+r+c-i] = -1;
    }

    board[r*8+c] = 1;

    return;
}

void show(const board_t &board) {
    for (int32_t r = 0; r < 8; r++) {
        for (int32_t c = 0; c < 8; c++) {
            cout << ((board[r*8+c] == 1) ? "Q" : ".");
        }
        cout << endl;
    }

    return;
}

bool dfs(const board_t &board, int32_t r) {
    if (r == 8) {
        show(board);
        return true;
    }

    for (int32_t c = 0; c < 8; c++) {
        if (board[r*8+c] == 1) {
            return dfs(board, r+1);
        } else if (board[r*8+c] == 0) {
            board_t board_new = board;
            put(board_new, r, c);
            if (dfs(board_new, r+1)) return true;
        }
    }

    return false;
}

int main() {
    int32_t k;
    cin >> k;

    board_t board;
    fill(board.begin(), board.end(), 0);

    for (int32_t i = 0; i < k; i++) {
        int32_t r, c;
        cin >> r >> c;
        put(board, r, c);
    }

    dfs(board, 0);

    return 0;
}

Measured memory_bytes: 3092
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int L = sc.nextInt();
        final long INF = 1L << 60;
        long[][] G = new long[N][N];
        int[][] D = new int[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(G[i], INF);
            Arrays.fill(D[i], 9999);
            G[i][i] = 0;
            D[i][i] = 0;
        }
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt() - 1;
            int B = sc.nextInt() - 1;
            int C = sc.nextInt();
            G[A][B] = G[B][A] = C;
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < N; k++) {
                    G[j][k] = Math.min(G[j][k], G[j][i] + G[i][k]);
                }
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (G[i][j] <= L) {
                    D[i][j] = D[j][i] = 1;
                }
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < N; k++) {
                    D[j][k] = Math.min(D[j][k], D[j][i] + D[i][k]);
                }
            }
        }
        int Q = sc.nextInt();
        PrintWriter writer = new PrintWriter(System.out);
        for (int i = 0; i < Q; i++) {
            int S = sc.nextInt() - 1;
            int T = sc.nextInt() - 1;
            writer.println(D[S][T] > 999 ? -1 : D[S][T] - 1);
        }
        writer.flush();
    }

}


Measured memory_bytes: 93456
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define pb push_back
#define fi first
#define sc second
using namespace std;
int main()
{
	while(1)
	{
		int n; cin >> n;
		if(n == 0) return 0;
		map<long long,vector<int> >ma;
		for(int i=0;i<n;i++)
		{
			long long a,b,c;
			cin >> a >> b >> c;
			ma[b*2].push_back(a);
			ma[c*2-1].push_back(a);
		}
		int cur = 0;
		for(map<long long,vector<int> >::iterator it = ma.begin();it!=ma.end();++it)
		{
			if((it->fi)%2==0) for(int i=0;i<(it->sc).size();i++) cur += (it->sc)[i];
			else for(int i=0;i<(it->sc).size();i++) cur -= (it->sc)[i];
			if(cur>150) goto dead;
		}
		puts("OK"); continue; dead:; puts("NG");
	}
}

Measured memory_bytes: 1200
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))
#define each(itr,v) for(auto (itr):(v))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

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

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[N];
	REP(i, N) {
		cin >> A[i];
	}
	ll sum = 0;
	REP(i, N) {
		sum += A[i];
	}
	int ave[2];
	ave[0] = sum / N;
	ave[1] = ave[0] + 1;
	ll ans[2] = {};
	REP(i, 2) {
		REP(j, N) {
			ans[i] += (A[j] - ave[i])*(A[j] - ave[i]);
		}
	}
	sort(ans, ans + 2);
	cout << ans[0] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    int[] size;
    int[] parent;
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        size = new int[n];
        parent = new int[n];
        for(int i = 0; i < n; i++){
            size[i] = 1;
            parent[i] = i;
        }
        int q = scan.nextInt();
        for(int i = 0; i < q; i++){
            int t = scan.nextInt();
            int u = scan.nextInt();
            int v = scan.nextInt();
            if(t == 0){
                unite(u, v);
            }else{
                System.out.println(same(u, v) == true ? 1 : 0);
            }
        }
    }

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

    boolean same(int x, int y){
        return root(x) == root(y);
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(size[x] < size[y]){
            parent[x] = y;
        }else{
            parent[y] = x;
            if(size[x] == size[y]) size[x]++;
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 69436
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int)

dp = np.zeros((N, 2), dtype=int)
dp[0] = 1
D = np.diff(A) <= 0
U = np.diff(A) >= 0

for i, (d, u) in enumerate(zip(D, U), 1):
    if u and d:
        dp[i] = dp[i - 1]
    if u and not d:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1].min() + 1
    if not u and d:
        dp[i][0] = dp[i - 1].min() + 1
        dp[i][1] = dp[i - 1][1]

print(dp[-1].min())


Measured memory_bytes: 22480
listA=list(map(int,input().split()))
if listA[0] == 5 and listA[1] == 5 and listA[2] == 7:
    print('YES')
elif listA[0] == 5 and listA[1] == 7 and listA[2] == 5:
    print('YES')
elif listA[0] == 7 and listA[1] == 5 and listA[2] == 5:
    print('YES')
else:
    print('NO')
 

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

using ordered_set = tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
struct CMP {
	bool operator() (const T& lhs, const T& rhs) const{
		return lhs < rhs;
	}
};

template <typename T>
T power(T a, T n){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a);
		a = (a * a);
		n >>= 1;
	}
	
	return res;
}

template <typename T>
T power(T a, T n, long long mm){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a) % mm;
		a = (a * a) % mm;
		n >>= 1;
	}
	
	return res;
}

const ll N = 3e3+7;
const ll MOD = 1e9+7;
const ll INF = 2e14+7;

ll arr[N];
ll dp[N][N][2];

ll solve(int i, int j, int turn){
	if(i > j){
		return 0;
	}
	
	if(dp[i][j][turn] != -1) return dp[i][j][turn];
	
	if(turn == 0){
		return dp[i][j][turn] = max(arr[i] + solve(i + 1, j, 1), arr[j] + solve(i, j - 1, 1));
	}
	
	return dp[i][j][turn] = min(solve(i + 1, j, 0) - arr[i], solve(i, j - 1, 0) - arr[j]);
	
}

void testcase(){
	
	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	memset(dp, -1, sizeof(dp));
	ll ans = solve(0, n - 1, 0);
	
	cout<<ans<<'\n';
	
}

signed main(){
	fast;
	
	int t = 1;
	//cin>>t;
	while(t--){
		testcase();
	}
	
	return 0;
}


Measured memory_bytes: 141696
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;
void raushan_kumar(){
	int n;cin>>n;int a[n];fo0(i,n) cin>>a[i];
	map<int,int> m;
	fo0(i,n){
		m[a[i]]++;
	}
	int ans=0;
	for(auto j: m){
		ans+=j.second*(j.second-1)/2;
	}
	int final=ans;
	fo0(i,n){
		int temp=m[a[i]];
		ans-=temp*(temp-1)/2;
		temp--;
		ans+=temp*(temp-1)/2;

		cout<<ans<<endl;
		ans=final;
	}
}

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

}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int H, W;
vector<string> ts;
vector< vector<bool> > done;

void dfs(int y, int x) {
        if (done[y][x]) return;
        done[y][x] = true;

        for (int dx = -1; dx <= 1; dx++) {
                for (int dy = -1; dy <= 1; dy++) {
                        if (!(!dy ^ !dx)) continue;

                        int nx = x + dx;
                        int ny = y + dy;

                        if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
                        if (ts[y][x] != ts[ny][nx]) continue;

                        dfs(ny, nx);
                }
        }
}

int main(void) {
        while (cin >> H >> W, H) {
                ts = vector<string>(H);
                done = vector< vector<bool> >(H, vector<bool>(W));

                for (int y = 0; y < H; y++) cin >> ts[y];

                int cnt = 0;

                for (int y = 0; y < H; y++) {
                        for (int x = 0; x < W; x++) {
                                if (!done[y][x]) {
                                        dfs(y, x);
                                        cnt++;
                                }
                        }
                }

                cout << cnt << endl;
        }

        return 0;
}

Measured memory_bytes: 2516
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

string itob(int a) {
  string ret;
  for(int i=16; i>0; i/=2) {
    if (a>=i) {
      ret+='1';
      a-=i;
    } else
      ret+='0';
  }
  return ret;
}

int main() {
  string hoge = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
  map<string, string> m;
  REP(i,hoge.length()) {
    string hage;
    hage = hoge[i];
    m.insert(make_pair(itob(i),hage));
  }
  hoge = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string hoge2[] = {"101","000000","000011","10010001","010001","000001","100101","10011010"
                 ,"0101","0001","110","01001","10011011","010000","0111","10011000"
                 ,"0110","00100","10011001","10011110","00101","111","10011111","1000"
                 ,"00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
  map<char,string> m2;
  REP(i,hoge.length())
    m2.insert(make_pair(hoge[i],hoge2[i]));
  string line;
  while(!cin.eof()) {
    getline(cin,line);
    if (cin.eof()) break;
    string a;
    REP(i,line.length())
      a += m2[line[i]];
    int aa = a.length()%5;
    if(aa)
      a+=string(5-aa,'0');
    string ans;
    for (int i=0; i<a.length(); i+=5) {
      ans += m[a.substr(i,5)];
    }
    //cout << a << endl;
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;



Int dp[110000][2];
vector<int> edge[110000];
int n, u, v;

//0 white
//1 black

void dfs(int x, int last = -1){
    dp[x][0] = dp[x][1] = 1;
    for(auto to: edge[x]){
        if(to == last)continue;
        dfs(to, x);
        dp[x][0] = dp[x][0] * ((dp[to][0] + dp[to][1]) % MOD) % MOD;
        dp[x][1] = dp[x][1] * dp[to][0] % MOD;
    }
}

int main(){
    cin >> n;
    for(int i = 0;i < n-1;i++){
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    dfs(1);
    cout << (dp[1][0] + dp[1][1]) % MOD << endl;
    
    return 0;
}

Measured memory_bytes: 14464
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        X: usize, Y: usize,
    }
    let mut ans = false;
    for i in 0..=X {
        if i * 2 + (X - i) * 4 == Y {
            ans = true;
            break;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 2196
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m,x;
  cin>>n>>m>>x;
  int l=0,r=0;
  FOR(i,0,m){
	int a;
    cin>>a;
    if(a<x) l++;
    else r++;
  }
  cout<<min(l,r)<<endl;
  return 0;
}


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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 1000;
int n,k;
i64 a[MAX_N];
i64 psum[MAX_N+1];

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

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

  vector<i64> li;
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      li.pb(psum[r+1] - psum[l]);
    }
  }

  i64 x = 0;
  for (int i = 45; i >= 0; i--) {
    vector<i64> li2;
    for (i64 v : li)
      if (v & (1LL << i)) li2.pb(v);
    if ((int)li2.size() >= k) {
      x |= (1LL << i);
      li = li2;
    }
  }

  cout << x << endl;

  return 0;
}


Measured memory_bytes: 6384
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    int x;
    cin >> x;
    cout << (x / 500) * 1000 + (x % 500) / 5 * 5;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int X,A,B;
    cin>>X>>A>>B;

    if(A>=B){
        cout<<"delicious"<<endl;
    }
    else if(B-A<=X){
        cout<<"safe"<<endl;
    }
    else{
        cout<<"dangerous"<<endl;
    }
}



Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define W 4
#define H 5
#define NOTEXIST -1
int ans;
int board[H][W];
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
struct point{
    int x, y;
};

void remove_cards(point a, point b){
    board[a.y][a.x] = NOTEXIST;
    board[b.y][b.x] = NOTEXIST;
    vector<int> v, u;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (board[i][j] == NOTEXIST) {
                u.push_back(NOTEXIST);
                continue;
            }
            v.push_back(board[i][j]);
        }
    }
    for (int i = 0; i < u.size(); i++) {
        v.push_back(u[i]);
    }
    for (int i = 0; i < v.size(); i++) {
        board[i / 4][i % 4] = v[i];
    }
}

bool invalid(int mx, int my){
    return (mx < 0 || mx >= W || my < 0 || my >= H);
}

void dfs(int count){
    ans = max(ans, count);
    if (ans == 20) {
        return;
    }
    int board_cp[H][W];
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if (board[y][x] == NOTEXIST) {
                break;
            }
            for (int i = 0; i < 8; i++) {
                int mx = x + dx[i];
                int my = y + dy[i];
                if (invalid(mx, my)) {
                    continue;
                }

                if (board[my][mx] == NOTEXIST) {
                    continue;
                }
                
                if (board[y][x] == board[my][mx]) {
                    memcpy(board_cp, board, sizeof(board));
                    remove_cards(point({x, y}), point({mx, my}));
                    dfs(count + 2);
                    memcpy(board, board_cp, sizeof(board));
                }
            }
        }
    }
    return;
}

int main()
{

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < H; j++) {
            for (int k = 0; k < W; k++) {
                cin >> board[j][k];
            }
        }
        ans = 0;
        dfs(0);
        cout << 20 - ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(s: chars);
    let mut answer: String = "".to_string();
    for item in s {
        match item {
            '1' => answer.push(item),
            '0' => answer.push(item),
            'B' => {
                answer.pop();
                ()
            }
            _ => (),
        }
    }
    println!("{}", answer);
}


Measured memory_bytes: 4352
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;

class Main{
	void run()throws IOException{
		for(int a,b;hasNext();){
			a=nextInt();
			b=nextInt();
			writer.println(a+b);
		}
	}
	
	// ---------- begin template ----------
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	boolean hasNext()throws IOException{
		while(tokenizer==null || !tokenizer.hasMoreTokens()){
			String s=reader.readLine();
			if(s==null)
				return false;
			tokenizer=new StringTokenizer(s);
		}
		return true;
	}
	String next()throws IOException{
		while(tokenizer==null || !tokenizer.hasMoreTokens())
			tokenizer=new StringTokenizer(reader.readLine());
		return tokenizer.nextToken();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(next());
	}
	long nextLong()throws IOException{
		return Long.parseLong(next());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(next());
	}
	BigInteger nextBigInteger()throws IOException{
		return new BigInteger(next());
	}
	void main(){
		try{
			reader=new BufferedReader(new InputStreamReader(System.in));
			tokenizer=null;
			writer=new PrintWriter(System.out);
			run();
			reader.close();
			writer.close();
		}
		catch(Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public static void main(String[] args){
		new Main().main();
	}
	// ---------- end template ----------
}

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

#define ll long long
#define s(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)

int main()
{
    int t, i, j, n=0, a, b,sum=1;
    //cout << "Hello" << endl;
    cin >> a >> b;
    while(sum<b){
        sum+=a-1;
        n++;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n, x;
  int m[105];
  int sum = 0;
  int cnt = 0;
  cin >> n >> x;
  for(int i = 0; i < n; i++){
    cin >> m[i];
    sum += m[i];
    cnt++;
  }
  sort(m, m+n);
  x -= sum;
  while(true){
    x -= m[0];
    if(x < 0) break;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
//int kansu(int a,int b) ;
int main(void)
{
	int n,i;
	
	cin >> n ;
	i = (n + 4) % 7 ;
	switch(i){
	case 1:
		cout << "mon" << endl ;
		break ;
	case 2:
		cout << "tue" << endl ;
		break ;
	case 3:
		cout << "wed" << endl ;
		break ;
	case 4:
		cout << "thu" << endl ;
		break ;
	case 5:
		cout << "fri" << endl ;
		break ;
	case 6:
		cout << "sat" << endl ;
		break ;
	default:
		cout << "sun" << endl ;
		break ;
	}
	
	return 0 ;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main() {
  int K; cin>>K;
  ll sum =0;
  for(int i=1; i<=K;i++) for(int j=1;j<=K;j++) for(int k=1; k<=K;k++) {
    ll left = gcd(i,j);
    ll right = gcd(left, k);
    sum+=right;
  }
cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3620
n, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0
for i in range(n-1):
    num = a[i] + a[i+1]
    if num > x:
        if a[i+1] >= (num - x):
            a[i+1] -= num - x
        else:
            a[i+1] = 0
        count += num - x

print(count)

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

int main() {
  int n;
  cin >> n;
  vector<double> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
  dp[0][0] = 1.0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i + 1; j++) {
      dp[i + 1][j + 1] += dp[i][j] * p[i];
      dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
    }
  }
  double ans = 0.0;
  for (int i = (n + 1) / 2; i < n + 1; i++) {
    ans += dp[n][i];
  }
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 70784
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a == b)
                out.println("Draw");
            else if (a == 1 || b == 1)
                out.println(a == 1 ? "Alice" : "Bob");
            else
                out.println(a > b ? "Alice" : "Bob");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    char last='A';
    int cnt=0;
    for(int i=0;i<s.length();i++){
        if(last!=s[i]){
            cnt++;
        }
        last=s[i];
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

using namespace std;

#define left(x)  (2*(x)+1)
#define right(x) (2*(x)+2)

void maxHeapify(int *heap, int i, int last_index)
{
    int l = left(i);
    int r = right(i);
    int largest = i;

    if (l <= last_index && heap[l] > heap[largest])
        largest = l;
    if (r <= last_index && heap[r] > heap[largest])
        largest = r;

    if (largest != i) {
        swap(heap[i], heap[largest]);
        maxHeapify(heap, largest, last_index);
    }
}

void buildMaxHeap(int *heap, int last_index)
{
    for (int i = (last_index - 1) / 2; i >= 0; i--)
        maxHeapify(heap, i, last_index);
}

void print_heap(int *heap, int h)
{
    for (int i = 0; i < h; i++)
        printf(" %d", heap[i]);
    puts("");
}

int main(void)
{
    int h;
    cin >> h;
    int heap[h];
    for (int i = 0; i < h; i++) 
        cin >> heap[i];

    buildMaxHeap(heap, h - 1);

    print_heap(heap, h);

    return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main(void)
{

 int a,b;
 scanf("%d %d",&a,&b);
 
if(a<b)
  printf("a < b\n");

else if(a>b)
  printf("a > b\n");

else
 printf("a == b\n");

 return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	for(mpint i = 0; i < 1001; i++) {
		for(mpint j = -1000; j < i; j++) {
			mpint x1 = i * i * i * i * i;
			mpint x2 = j * j * j * j * j;
			// cout << i << ", " << j << " " << x1 << " : " << x2 << " = " << (x1 - x2) << endl;
			// cout << i << ", " << j << " " << x3 << " : " << x4 << " = " << (x3 - x4)  << endl;
			if ((x1 - x2) == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define miaojie
#ifdef miaojie
  #define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#else
  #define dbg(...)
#endif
using namespace std;
const int maxn=30005;

int n,ans,st[20],nextc[maxn][12];
char s[maxn];

void init_xulie(){
    for (int i = n; i >= 1; i--) {
        for (int j = 0; j < 10; j++) {
            nextc[i - 1][j] = nextc[i][j]; 
        }
        nextc[i - 1][s[i] - '0'] = i; 
    }
}

int main(){
	scanf("%d%s",&n,s+1);
	init_xulie();
	for(int i=1;i<=n;i++){
		if(!st[s[i]-'0']) st[s[i]-'0']=i;
	}
	
	for(int i=0;i<=9;i++){
		if(!st[i]) continue;
		for(int j=0;j<=9;j++){
			for(int k=0;k<=9;k++){
				if(!nextc[st[i]][j]) continue;
				if(nextc[nextc[st[i]][j]][k]){
				//	dbg(i,st[i],j,nextc[st[i]][j],k);
					ans++;
				}
			}
		} 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664