akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
const string akiba[16] = {
"KIHBR", "KIHBRA", "KIHBAR", "KIHBARA",
"KIHABR", "KIHABRA", "KIHABAR", "KIHABARA",
"AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA",
"AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA"
};

int main(){

    // 1. 入力情報.
    char c[55];
    scanf("%s", c);
    string S(c);
    
    // 2. 比較.
    bool ok = false;
    rep(i, 16){
        if(S == akiba[i]){
            ok = true;
            break;
        }
    }
    
    // 3. 出力.
    if(ok) puts("YES");
    else   puts("NO");
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define get(i,x) get<i>(x)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c; cin>>a>>b>>c;
	if(a==b && c==b) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e17;
struct UnionFind{
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}
    bool unionSet(ll x,ll y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(ll x,ll y){
        return root(x)==root(y);
    }
    ll root(ll x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    ll size(ll x){
        return -data[root(x)];
    }
};
class KRK{//c++11
	public:
	struct edge{
		ll from,to,cost;
	};
	vector<edge>G;
	vvp tG;
	vvi dp;
	vi used;
	ll n;
	KRK(ll size){
		n=size;
	}
	void add_edge(ll a,ll b,ll c){
		edge e={a,b,c};
		G.pb(e);
	}
	ll krk(){
		ll sum=0;
		sort(all(G),[](edge a,edge b){
			return a.cost<b.cost;
		});
		UnionFind uf(n);
		rep(i,G.size()){
			edge e=G[i];
			if(!uf.findSet(e.from,e.to)){
				sum+=e.cost;
				tG[e.from].pb(pii(e.to,e.cost));
				tG[e.to].pb(pii(e.from,e.cost));
				uf.unionSet(e.from,e.to);
			}
		}
		return sum;
	}
	void dfs(ll a,ll b,ll c){
		rep(i,tG[a].size())if(used[tG[a][i].first]==0){
			used[tG[a][i].first]=true;
			ll t=max<ll>(b,tG[a][i].second);
			dp[c][tG[a][i].first]=t;
			dfs(tG[a][i].first,t,c);
		}
	}
	void solve(){
		tG=vvp(n);
		ll out=krk();
		dp=vvi(n,vi(n));
		rep(i,n){
			used=vi(n);
			used[i]=1;
			dfs(i,0,i);
		}
//		rep(i,n){rep(j,n)cout<<" "<<dp[i][j];cout<<endl;}
		
		ll q;
		cin>>q;
		while(q--){
			ll a,b;
			cin>>a>>b;
			a--;b--;
			cout<<out-dp[a][b]<<endl;
		}
	}
};
int main(){
	ll n,m;
	cin>>n>>m;
	KRK krk(n);
	while(m--){
		ll a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		krk.add_edge(a,b,c);
	}
	krk.solve();
}









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

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> a(n, vector<int>(m+1));
  for(int i = 0; i < n; i++){
  	int k;
  	cin >> k;
  	for(int j = 0; j < k; j++){
    	cin >> a.at(i).at(j);
    	a.at(i).at(j);
    }
  }
  vector<int> b(m+1);
  for(int i = 0; i < n; i++){
  for(int j = 0; j < m+1; j++){
  	b.at(a.at(i).at(j))++;
  }
  }
  int ans = 0;
  for(int i = 1; i < m+1; i++){
  	if(b.at(i) == n){
    ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 2 == 1 && b % 2 == 1)
    {
        cout << "Odd" << endl;
    }
    else
    {
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String str = sc.next();
		String ans="No";
		
		for(int i=0; i<a; i++){
		    if(Character.isDigit(str.charAt(i))){
		        ans = "Yes";
		    }
		}
		
		if(str.substring(a,a+1).equals("-") && ans=="Yes"){
		    ans = "Yes";
		}else{
		    ans = "No";
		}
		
		for(int i=a+1; i<a+b+1; i++){
		    if(Character.isDigit(str.charAt(i)) && ans=="Yes"){
		        ans = "Yes";
		    }else{
		        ans = "No";
		    }
		}
		
        System.out.println(ans);
	}
}


Measured memory_bytes: 35660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifdef local
	#include "debug/debug.h"
#endif


#ifndef local
	#define deb(x...) ;	
#endif

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------


void solve()
{
	int n, arr[200005], pref[200005];
	cin >> n;
	rep(i,0,n) cin >> arr[i];
	pref[0] = arr[0];
	rep(i,1,n) pref[i] = max(pref[i-1], arr[i]);
	int ans = 0;
	rep(i,0,n) ans += pref[i] - arr[i];
	cout << ans << "\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	// cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

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

int main () {
  string S, T;
  cin >> S >> T;
  int s = S.size();
  vector<int> X(s), Y(s), x(26), y(26);
  for (int i = 0; i < s; i++) {
    X.at(i) = S.at(i)-'a';
    int a = X.at(i);
    x.at(a)++;
    Y.at(i) = T.at(i)-'a';
    int b = Y.at(i);
    y.at(b)++;
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  for (int i = 0; i < 26; i++) {
    if (x.at(i) != y.at(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
  

Measured memory_bytes: 2312
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gosu_Hiroo
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

//#define int ll

class CNotSoDiverse {
public:
    int N, K;
    map<int, int> M;
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N >> K;
    ll ans = 0;
    _for(i,N)M[readint] ++;
    vector<int> V;
    for(auto p : M)V.emplace_back(p.second);
    sort(all(V));
//    error(V);
    if(M.size() > K)
        _for(i,M.size() - K)ans += V[i];


    cout << ans << endl;
}


};


#undef int
int main() {


	CNotSoDiverse solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


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

#define ll long long

int main(){
  int n;
  cin >> n;
  ll mon[100005], her[100005];
  for (int i = 0; i < n + 1; i++){
    cin >> mon[i];
  }
  for (int i = 0; i < n; i++){
    cin >> her[i];
  }
  ll res = 0;
  for (int i = 0; i < n; i++){
    ll tmp = min(mon[i], her[i]);
  	res += tmp;
    if (tmp < her[i]) {
    	ll tmp1 = min(mon[i + 1], her[i] - tmp);
      mon[i + 1] -= tmp1;
      res += tmp1;
    }
  }
  cout << res << endl;
}

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

using namespace std;

int main(){

    int N, K;
    cin >> N >> K;
    vector<char> S(N);
    for(int i = 0; i < N; i++){
	cin >> S.at(i);
    }

    vector<int> nums;

    int cur = 1;
    int cnt = 0;
    for(int i = 0;i < N; i++){
	if(S.at(i) == '0'+cur){
	    cnt++;
	}else{
	    nums.push_back(cnt);
	    cnt = 1;
	    cur = 1 - cur; // 0 -> 1, 1 -> 0
	}
    }
    if(cnt > 0){
	nums.push_back(cnt);
    }
    // 1-0-1-0-1-0-1
    if(nums.size() % 2 == 0) nums.push_back(0);
    /*
    for(int i = 0; i < nums.size(); i++){
	cout << nums.at(i);
    }
    cout << endl;
    */

    int ADD = 2 * K + 1;
    
    int ans = 0;

#if 0
    int left = 0;
    int right = 0;
    int tmp = 0; // [left, right)

    for(int i = 0; i < nums.size(); i+=2){
	int next_left = i;
	int next_right = min(i + ADD, (int)nums.size());

	while(next_left > left){
	    tmp -= nums.at(left);
	    left++;
	}
	while(next_right > right){
	    tmp += nums.at(right);
	    right++;
	}
	
	if(tmp > ans) ans = tmp;
    }
#endif

    vector<int> sum(nums.size() + 1, 0);
    for(int i = 0; i < nums.size(); i++){
	sum.at(i+1) = sum.at(i) + nums.at(i);
    }

    for(int i = 0; i < nums.size(); i += 2){
	int left = i;
	int right = min(left+ADD, (int)nums.size());
	int tmp = sum.at(right) - sum.at(left);
	ans = max(tmp, ans);
    }
    
    
    cout << ans << endl;

    
}


Measured memory_bytes: 1272
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(n):
    a[i],b[i],c[i] = map(int,input().split())
dp=[[0]*3 for _ in range(n)]
dp[0]= [a[0],b[0],c[0]]
for i in range(1,n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i]
    dp[i][1] = max(dp[i-1][2], dp[i-1][0])+b[i]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c[i]
print(max(dp[-1]))

Measured memory_bytes: 60888
num1 = 1
num2 = 1

loop{
  loop{
    puts num1.to_s + "x" + num2.to_s + "=" + (num1*num2).to_s
    num2 = num2 + 1
    if num2 > 9 then
     num2 = 1
     break
    end
  }


  num1 = num1 + 1

  if num1 > 9 then
    break
  end
}

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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;
vector<pair<int, int>> a;
int n, m;

bool solvable(int toGain)
{
	set<int> S;
	for (int i = 1; i <= m; ++i)
		S.insert(i);
	for (int i = 0; i < n; ++i)
	{
		auto it = S.lower_bound(a[i].s);
		if (it != S.end())
		{
			S.erase(it);
			toGain -= a[i].f;
		}
		if (toGain <= 0)
			return true;
	}
	return toGain <= 0;
}

ll solver()
{
	int low = 0, high = mod, ans;
	ans = 0;
	while (low <= high)
	{
		int mid = (low + high) / 2;
		if (solvable(mid))
		{
			ans = mid;
			low = mid + 1;
		}
		else
			high = mid - 1;
	}
	return ans;
}

bool cmp(pair<int, int> a, pair<int, int> b)
{
	if (a.f == b.f)
		return a.s < b.s;
	return a.f > b.f;
}

void solve()
{
	cin >> n >> m;
	a = vector<pair<int, int>>(n);
	for (int i = 0; i < n; ++i)
		cin >>
			a[i].s >> a[i].f;
	sort(a.begin(), a.end(), cmp);
	// cout << solve(0, 0) << '\n';
	cout << solver();
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

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

struct Edge
{
    int to, a, b;
    Edge(int to, int a, int b) : to(to), a(a), b(b) {}
};
typedef tuple<int64_t, int, int> state;
const int S_MAX = 2500;
const int64_t INF = 1e18;

int main()
{
    int N, M, S;
    cin >> N >> M >> S;
    vector<int> U(M), V(M), A(M), B(M);
    for (int i = 0; i < M; i++)
    {
        cin >> U.at(i) >> V.at(i) >> A.at(i) >> B.at(i);
    }
    vector<int> C(N), D(N);
    for (int i = 0; i < N; i++)
    {
        cin >> C.at(i) >> D.at(i);
    }

    vector<vector<Edge>> graph(N);
    for (int i = 0; i < M; i++)
    {
        int u = U.at(i) - 1, v = V.at(i) - 1;
        int a = A.at(i), b = B.at(i);
        graph.at(u).push_back(Edge(v, a, b));
        graph.at(v).push_back(Edge(u, a, b));
    }

    vector<vector<int64_t>> dp(N, vector<int64_t>(S_MAX + 1, INF));
    priority_queue<state, vector<state>, greater<state>> q;
    S = min(S, S_MAX);
    dp.at(0).at(S) = 0;
    q.push(make_tuple(0, 0, S));
    while (!q.empty())
    {
        int64_t t = get<0>(q.top());
        int v = get<1>(q.top()), s = get<2>(q.top());
        q.pop();

        if (dp.at(v).at(s) < t)
            continue;

        {
            int sn = min(s + C.at(v), S_MAX);
            int64_t tn = t + D.at(v);
            if (tn < dp.at(v).at(sn))
            {
                dp.at(v).at(sn) = tn;
                q.push(make_tuple(tn, v, sn));
            }
        }

        for (auto e : graph.at(v))
        {
            int vn = e.to, a = e.a, b = e.b;
            int sn = s - a;
            if (sn < 0)
                continue;
            int64_t tn = t + b;
            if (tn < dp.at(vn).at(sn))
            {
                dp.at(vn).at(sn) = tn;
                q.push(make_tuple(tn, vn, sn));
            }
        }
    }

    for (int i = 1; i < N; i++)
    {
        int64_t res = INF;
        for (int s = 0; s <= S_MAX; s++)
            res = min(res, dp.at(i).at(s));
        cout << res << endl;
    }
    return 0;
}


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

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

const int N = 100005;

int n, q;
int dat[N];
vi boundaries;
vll answers;

int main() {
	scanf("%d %d", &n, &q);
	ll t = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &dat[i]);
		if (n % 2 == i % 2) t += dat[i];
	}
	answers.push_back(t);
	int lo = n-2, hi = n-1;
	for (int i = 1; i <= (n-1)/2; i++) {
		int mid = (dat[lo]+dat[hi]) >> 1;
		// printf("mid = %d\n", mid);
		boundaries.push_back(mid);
		t = t - dat[lo] + dat[hi];
		answers.push_back(t);
		// printf("mid = %d, answers = %lld\n", mid, t);
		lo -= 2;
		hi--;
	}
	reverse(all(boundaries));
	reverse(all(answers));
	while (q--) {
		int x;
		scanf("%d", &x);
		int idx = lower_bound(all(boundaries), x) - boundaries.begin();
		printf("%lld\n", answers[idx]);
	}
	return 0;
}

Measured memory_bytes: 2936
import math

def main():
    n = int(input())
    A = list(map(int, input().split()))

    max_node = [0 for i in range(n+1)]
    min_node = [0 for i in range(n+1)]
    res = 0

    for i in range(n, -1, -1):
        if i == n:
            max_node[i] = A[i]
            min_node[i] = A[i]
        elif i == 0:
            max_node[i] = 1
            min_node[i] = 1
        elif i == 1 and n != 1:
            max_node[i] = 2
            min_node[i] = math.ceil(min_node[i+1] /2) + A[i]
        else:
            max_node[i] = max_node[i+1] + A[i]
            min_node[i] = math.ceil(min_node[i+1] / 2) + A[i]

    for i in range(n):
        if i == 0:
            if n != 0 and A[i] != 0:
                res = -1
                break
        else:
            if max_node[i] > 2 * (max_node[i-1] - A[i-1]):
                max_node[i] = 2 * (max_node[i-1] - A[i-1])
            if max_node[i] < min_node[i]:
                res = -1
                break
    
    if res == -1:
        print(res)
    else:
        if n == 0 and A[i] != 1:
            print(-1)
        else:
            print(sum(max_node))

if __name__ == '__main__':
    main()

Measured memory_bytes: 22700
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(a%2==0 or b%2==0 or c%2==0){
		cout<<0;
	}
	else{
		ll ans;
		ans=min(a*b,a*c);
		ans=min(ans,b*c);
		cout<<ans;
	}
}



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

int main(void){
    string S, T;
    cin >> S;
    cin >> T;
    
    int t_size = T.size();
    int loop_num = S.size()-t_size +1;
    int loop_num2 = t_size;
    int ans = t_size;

    rep(i, loop_num){
        int change_count = t_size;
        rep(j, loop_num2){
            if(S.at(i+j) == T.at(j)) change_count--;
        }
        ans = min(ans, change_count);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;

void rec(string s, char c){
  if (s.size() == N){
    cout <<s <<endl;
    return;
  }
  for (char i = 'a'; i <= c + 1; i++){
    rec(s+i, max(i, c));
  }
}

int main() {
  cin >>N;
  rec("a", 'a');
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

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

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long

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

int main(void){
    int n;
    while(cin >> n && n){
        ll evens[n];
        ll odds[n*(n-1)/2];
        ll g,tmp;
        ll oindex=0, eindex=0;
        for(int i=0;i<n*(n+1)/2;i++){
            cin >> tmp;
            tmp%2?odds[oindex++] = tmp:evens[eindex++] = tmp;
        }
        sort(evens, evens+n);
        sort(odds, odds + n * (n-1)/2);
        tmp = gcd(evens[0], odds[0]);
        g = (ll)sqrt(evens[0] / tmp * (evens[1] / (odds[0] / tmp)));
        cout << g << endl;
        for(int i=0;i<n-1;i++){
            cout << (ll)round((double)evens[i]/g) << " ";
        }
        cout << (ll)round((double)evens[n-1]/g) << endl;
    }
}

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

int main() {
  bitset<3> s;
  cin >> s;
  
  int count = 0;
  for(int i = 0; i < 3; i++) {
    if(s.test(i)) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 19260817
using namespace std;
char s[5005];
int n;
bool check(int len)
{
 set<long long> se,se2,se3;
 for(int i=1;i+len-1<=n;i++)
 {
  long long sum=0,sum2=0,sum3=0;
  if(i-len>0)
  {
   for(int j=i-len;j<i;j++)
    sum=(sum*97+s[j]-'a')%MOD,sum2=(sum2*97+s[j]-'a')%MOD2,sum3=(sum3*97+s[j]-'a')%MOD3;
   se.insert(sum),se2.insert(sum2),se3.insert(sum3);
  }
  sum=0,sum2=0,sum3=0;
  for(int j=i;j<=i+len-1;j++)
   sum=(sum*97+s[j]-'a')%MOD,sum2=(sum2*97+s[j]-'a')%MOD2,sum3=(sum3*97+s[j]-'a')%MOD3;
  if(se.count(sum)&&se2.count(sum2)&&se3.count(sum3))return true;
 }
 return false;
}
int main()
{
 scanf("%d",&n);
 scanf("%s",s+1);
 int l=0,r=n/2;
 while(l<r)
 {
  int mid=(l+r+1)>>1;
  if(check(mid))l=mid;
  else r=mid-1;
 }
 printf("%d\n",l);
 return 0;
}

Measured memory_bytes: 896
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int A, B, M;
int a[100001], b[100001];

int main() {
    cin >> A >> B >> M;
    int min_a = INF;
    REP (i, A) {
        cin >> a[i];
        if (a[i] < min_a) {
            min_a = a[i];
        }
    }
    int min_b = INF;
    REP (i, B) {
        cin >> b[i];
        if (b[i] < min_b) {
            min_b = b[i];
        }
    }
    int ans = min_a + min_b;
    REP (i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        int t = a[x - 1] + b[y - 1] - c;
        if (t < ans) {
            ans = t;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input N H1 H2 ... HN
        Scanner sc = new Scanner(System.in);
        int numNum = sc.nextInt();
        int tempNum = 0;
        int tempMax = sc.nextInt();
        String result = "Yes";
        for(int i = 1; i < numNum; i++){
            tempNum = sc.nextInt();
            if(tempNum < tempMax - 1){
                result = "No";
                break;
            } else if(tempMax < tempNum){
                tempMax = tempNum;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 48860
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <functional>
#include <string>
#include <stack>
#include <queue>
#include <map>

typedef long long ll;
ll mod = 1e9 + 7;
  
using namespace std;

int main()
{
    int s = 0;
    int n;
    cin >> n;
    vector <int> v (n, 0);
 
    for(int i = 0; i < n; ++i)
    {
        int w;
        cin >> w;
        s += w;
        v[i] = s;
    }

    int min = s;
    for(int i = 0; i < n; ++i)
    {
        int sa = abs(v[i] * 2 - s);
        if(sa < min)
            min = sa;
    }


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6;
int x,y,ans,top,n;
int a[MAXN],b[MAXN],count1[MAXN],count2[MAXN],fa[MAXN];
map<int,int>mapp;
void push(int x) {if(!mapp.count(x)) mapp[x]=++top;}
int find(int x){if (x==fa[x]) return x; else return fa[x]=find(fa[x]);}
int main() {
    cin>>n;
    for (int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        x^=a[i];
    }
     
    for (int i=1;i<=n;++i){
        scanf("%d",&b[i]);
        y^=b[i];
    }
    bool flag=true;
    for (int i=1;i<=n;++i)
        if (a[i]!=b[i]){
            flag=false;
            break;
        }
    if (flag){printf("0");exit(0);}
    for (int i=1;i<=n;++i) {
        if (a[i]==b[i])continue;
        ans++;push(a[i]);push(b[i]);
        count1[mapp[a[i]]]++;count2[mapp[b[i]]]++;
    }
    push(x);push(y);
    count1[mapp[x]]++;count2[mapp[y]]++;
    for(int i=1;i<=top;i++){
        if (count1[i]==count2[i]) continue;
        printf("-1");
        exit(0);
    }
    for(int i=1;i<=top;i++)fa[i]=i;
    for (int i=1;i<=n;++i) if(a[i]!=b[i]) fa[find(mapp[a[i]])]=find(mapp[b[i]]);
    if(x!=y) fa[find(mapp[x])]=find(mapp[y]);
      
    for(int i=1;i<=top;i++)
        if(i==find(i)) ans++;
    printf("%d",ans-1);
}
//he

Measured memory_bytes: 19200
a, b = map(int, input().split())

table = []

whites = 1
blacks = 1

# black bg, white holes
for i in range(50):
  table += [[]]
  if i % 2 == 1:
    table[i] = ['#' for i in range(100)]
    continue
  
  for j in range(100):
    if whites < a and j % 2 == 0:
      table[i] += ['.']
      whites += 1
    else:
      table[i] += ['#']
  
  if whites >= a:
    break

table += [['#' for i in range(100)]]

parity = len(table) % 2
for i in range(len(table), 100):
  table += [[]]
  if i % 2 == parity:
    table[i] = ['.' for i in range(100)]
    continue

  for j in range(100):
    if blacks < b and j % 2 == 0:
      table[i] += ['#']
      blacks += 1
    else:
      table[i] += ['.']
  
  if blacks >= b:
    break

print(len(table), 100)
for i in range(len(table)):
  print("".join(table[i]))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		System.out.println(a / 10 % 111 == 0 || a % 1000 % 111 == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int H,N;
	cin>>H>>N;
	vector<int>A(N);
	int sum=0;
	for(int i=0; i<N; i++)
	{
		cin>>A[i];
	}
	for(int i=0; i<N; i++)
	{
		sum+=A[i];
	}
	if(sum<H){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	return 0;
}

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

typedef long long LL;

int main() {
    int N;
    LL L;
    cin >> N >> L;
    vector<LL> a(N);
    for (int i = 0;i < N;i++)
    {
        cin >> a[i];
        if (i > 0)
        {
            if (a[i] + a[i -1] >= L)
            {
                cout << "Possible" << endl;
                for (int j = 1;j < i;j++)
                    cout << j << endl;
                for (int k = N - 1; k >= i; k--)
                    cout << k << endl;
                return 0;
            }

        }

    }

    cout << "Impossible";
    return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

ll m, k;
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> m >> k;

    if (m == 1) {
        if (k == 0)
            std::cout << "0 0 1 1" << std::endl;
        else
            std::cout << -1 << std::endl;
    }
    else {
        ll p = (ll)std::pow(2, m);

        if (k >= p)
            std::cout << -1 << std::endl;
        else {
            for (ll i = 0; i < p; ++i)
                if (i != k)
                    std::cout << i << " ";
            std::cout << k << " ";
            for (ll i = p - 1; i >= 0; --i)
                if (i != k)
                    std::cout << i << " ";
            std::cout << k << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int A,B;
    cin >> A >> B;
    if(1<=A && A <=9 && 1<=B && B<=9){
        cout << A*B << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 888
while True:
    score = 0
    h = int(input())
    if h == 0: break
    w = 5

    field = [list(map(int, input().split())) for x in range(h)]

    def delete(field):
        flg = True
        for row in field:
            target = None
            cnt = 0
            fs = []
            f = None
            t = None
            for i, cell in enumerate(row):
                if target != None and cell == target:
                    cnt += 1
                else:
                    if cnt >= 2:
                        f = fs[-1]
                        t = i - 1
                    fs.append(i)
                    target = cell
                    cnt = 0
            if cnt >= 2:
                f = fs[-1]
                t = i

            if f != None:
                global score
                score += (t - f + 1) * row[f]
                for i in range(f, t + 1):
                    row[i] = None
                flg = False
        if flg: return flg
        return field


    def drop(field):
        for y, row in enumerate(field[:-1]):
            for x, cell in enumerate(row):
                if field[y + 1][x] == None:
                    for n in range(y + 1, 0, -1):
                        field[n][x] = field[n - 1][x]
                    else:
                        field[0][x] = None
        return field

    while True:
        field = delete(field)
        if field == True:
            break
        field = drop(field)
        # for x in field: print(*map(lambda x: "X" if x == None else x, x))
        # print("===========")
    print(score)

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

int main(){
        int h,w;
        string s;

        cin >> h >> w;
        rep(i,h){
                cin >> s;
                cout << s << endl;
                cout << s << endl;
        }
        return 0;
}


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

using namespace std;
using ll = long long int;
using ld = long double;

int main() {
    ld a, b, c;
    cin >> a >> b >> c;
    ld k = (c - a - b);
    ld l = a * b * 4;
    if (0 < c - a - b && k * k > l){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define ll long long
#define ar array

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string n;
	cin >> n;
	for(int i=0;i<n.size();i++) {
		if(n[i]=='7') {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<int(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using ld = long double;
constexpr ld eps = 1e-8;

using P = array<ld, 3>;
P operator+(P l, P r) {
  return {l[0] + r[0], l[1]+r[1], l[2]+r[2]};
}
P operator-(P l, P r) {
  return {l[0] - r[0], l[1]-r[1], l[2]-r[2]};
}
P operator*(ld l, P r) {
  return {l * r[0], l * r[1], l * r[2]};
}
ld dot(P l, P r) {
  return inner_product(ALL(l), begin(r), 0.0);
}
ld norm(P p) {
  return dot(p, p);
}
ld abs(P p) {
  return sqrt(norm(p));
}

struct L { P a, b; };
struct S { P p; ld r; };

P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_sp(L l, P p) {
  P f = proj(l, p);
  if (abs(f-l.a) + abs(f-l.b) - abs(l.a-l.b) < eps) return abs(f - p);
  return min(abs(p-l.a), abs(p-l.b));
}

bool isis_seg_sph(L l, S s) {
  if (abs(l.a - s.p) <= s.r && abs(l.b - s.p) <= s.r) return false;
  return dist_sp(l, s.p) <= s.r;
}

int main() {
  while(1){
    int n,m,R;
    cin>>n>>m>>R;
    if(!n) break;
    vector<S> vs;
    REP(i,n) {
      ld x,y,z,r;
      cin>>x>>y>>z>>r;
      vs.push_back((S){{x,y,z},r});
    }
    vector<tuple<P, ld>> vl;
    REP(i,m) {
      ld x,y,z,b;
      cin>>x>>y>>z>>b;
      vl.emplace_back((P){x, y, z}, b);
    }
    ld ex, ey, ez;
    cin>>ex>>ey>>ez;
    P e = {ex,ey,ez};
    vector<bitset<2000>> v(m);
    vector<ld> vb(m);
    REP(i,m) {
      P p; ld b;
      tie(p, b) = vl[i];
      L seg = {e, p};
      REP(j,n) {
        if (isis_seg_sph(seg, vs[j])) v[i].set(j);
      }
      vb[i] = b / norm(e - p);
    }
    ld res = 0;
    REP(i,1<<m) {
      bitset<2000> s;
      ld br = 0;
      REP(j,m) {
        if ((i>>j)&1) {
          s |= v[j];
          br += vb[j];
        }
      }
      if ((int)s.count() <= R) res = max(res, br);
    }
    cout << fixed << setprecision(10) << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3340
words = {}

N = int(input())
for i in range(N):
    s = input()
    point = words.get(s, 0)
    words[s] = point+1

M = int(input())
for i in range(M):
    s = input()
    point = words.get(s, 0)
    words[s] = point-1

result = max(words.items(), key=lambda x:x[1])[1]
if result < 0:
    print(0)
else:
    print(result)

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad

main = do
  [a, b] <- map (\x -> read x :: Int) . words <$> getLine
  when (a == b) $ do putStrLn "a == b"
  when (a < b) $ do putStrLn "a < b"
  when (a > b) $ do putStrLn "a > b"

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n; cin >> n;
	vector<pair<int, int> > p(n);

	rep(i, n) {
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(a + b, a);
	}
	sort(all(p), greater<pair<int, int> >());

	ll ans = 0;
	rep(i, n) {
		if (i % 2) ans -= p[i].first - p[i].second;
		else ans += p[i].second;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int on = 0;
  int af = 0;
  string S;
  cin >> S;
  int kj = 0;
  for (int i = 0; i < N; i ++) {
    if (S[i] == '(') {
      kj --;
    }
    else {
      kj ++;
      if (kj == 1) {
        on ++;
        kj = 0;
      }
    }
  }
  kj = 0;
  for (int i = N - 1; i >= 0; i --) {
    if (S[i] == ')') {
      kj --;
    }
    else {
      kj ++;
      if (kj == 1) {
        af ++;
        kj = 0;
      }
    }
  }
  for (int i = 0; i < on; i ++) cout << '(';
  cout << S;
  for (int i = 0; i < af; i ++) cout << ')';
  cout << endl;
}



Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (i = 0; i < n; i++)

using namespace std;

using ll = long long;

const int N = 2e5 + 10;

ll n, i;
ll a[N], cnt[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	rep(i, n) {
		cin >> a[i], a[i]--;
		cnt[a[i]]++;
	}
	
	ll res = 0;
	rep(i, n) {
		res += cnt[i] * (cnt[i] - 1);
	}
	
	rep(i, n) {
		ll prev = cnt[a[i]] * (cnt[a[i]] - 1);
		ll now = (cnt[a[i]] - 1) * (cnt[a[i]] - 2);
		cout << (res + now - prev) / 2 << '\n';
	}
	
	return 0;
}

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

int
main(int argc, char* argv[]) {
  int _a, i;
  vector<int> A;

  for(i=0; i<3; i++) {
    cin >> _a;
    A.push_back(_a);
  }
  sort(A.begin(), A.end());

  cout << A.back() - *A.begin() << endl;

  return 0;
}


Measured memory_bytes: 256
class UnionFindNode:
    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.rank_ = 1

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        root = self.root()
        return root.group_id_

    def rank(self):
        root = self.root()
        return root.rank_

    def unite(self, unite_node):
        root = self.root()
        unite_root = unite_node.root()

        if root.group_id_ != unite_root.group_id_:
            if root.rank() > unite_root.rank():
                unite_root.parent_ = root
                root.rank_ = max(root.rank_, unite_root.rank_ + 1)
            else:
                root.parent_ = unite_root
                unite_root.rank_ = max(root.rank_ + 1, unite_root.rank_)


if __name__ == "__main__":
    N,M=[int(i) for i in input().strip().split(" ")]
    node_list = [UnionFindNode(i) for i in range(N)]
    import sys
    for line in sys.stdin:
        x,y,z=[int(i) for i in line.strip().split(" ")]
        x -= 1
        y -= 1
        node_list[x].unite(node_list[y])
    counter = 0
    for node in node_list:
        if not node.parent_:
            counter += 1
    print(counter)


Measured memory_bytes: 61088
#include <bits/stdc++.h>
//#include <ios>     // std::left, std::right
//#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;
 
int main() {
  
  int a;
  string s;

  cin >> a;
  if(a < 1000){
      s = "ABC";
  }else{
      s = "ABD";
  }
  cout << s << endl;
  //std::cout << s << std::setfill('0') << std::right << std::setw(3) << a << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

using i64=int64_t;

void solve(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A<=C and C<=B) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ushiro=[a[i] for i in range(n) if i%2==0]#if_n%2==0_it_will_be_behind
mae=[a[i] for i in range(n) if i%2==1]
p=mae[::-1]+ushiro
if n%2==0:
    print(*p)
else:
    print(*p[::-1])

Measured memory_bytes: 26016
import math

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

c = 0
ans = -1
for i in range(1,10**7) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans > math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Measured memory_bytes: 64376
from collections import deque
import numpy as np

H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0

INF = -1
dist = [[INF for i in range(W)] for j in range(H)]

q = deque([(0, 0)])
dist[0][0] = 0

dy = (-1, 0, 1, 0)
dx = (0, 1, 0, -1)

while q:
    y, x = q.popleft()
    for k in range(4):
        ny = y + dy[k]
        nx = x + dx[k]

        if (ny < 0 or ny >= H or nx < 0 or nx >= W): continue
        if grid[ny][nx] == "#": continue
        if dist[ny][nx] != INF: continue

        dist[ny][nx] = dist[y][x] + 1
        q.append((ny, nx))

block = 0
for h in range(H):
    block += grid[h].count("#")



if dist[H-1][W-1] == INF:
    print(-1)
    exit()
else:
    ans = (H * W) - block - (dist[H-1][W-1] + 1)
    print(ans)



Measured memory_bytes: 27128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ARegularTriangle {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int A, B, C;
        in>>A>>B>>C;
        if(A==B and B==C) out<<"Yes\n";
        else out<<"No\n";
    }
};


int main() {
	ARegularTriangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

class DisjointSet{
public:
	vector<int> rank, p;
	DisjointSet(){}
	DisjointSet(int size){
		rank.resize(size, 0);
		p.resize(size, 0);
		for(int i=0; i<size; i++)
			makeSet(i);
	}
	void makeSet(int x){
		p[x]=x;
		rank[x]=0;
	}
	bool same(int x, int y){
		return findSet(x)==findSet(y);
	}
	void unite(int x, int y){
		link(findSet(x), findSet(y));
	}
	void link(int x, int y){
		if(rank[x]>rank[y]){
			p[y]=x;
		}
		else{
			p[x]=y;
			if(rank[x]==rank[y])
				rank[y]++;
		}
	}
	int findSet(int x){
		if(x!=p[x]){
			p[x]=findSet(p[x]);
		}
		return p[x];
	}
};

int main(){
	int n,a,b,q;
	int t;
	cin>>n>>q;
	DisjointSet ds=DisjointSet(n);
	for(int i=0; i<q; i++){
		cin>>t>>a>>b;
		if(t==0)
			ds.unite(a, b);
		else if(t==1){
			if(ds.same(a, b))
				cout<<1<<endl;
			else
				cout<<0<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3188