akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef pair<ll,ll> P;
#define se second
#define fi first
struct PP{ll fi;ll se;ll th;};
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[0].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
  ll h,w;cin>>h>>w;
  vvi red(h,vi(w));
  vvi blue=red;
  rep(i,h-2)rep(j,w)j%2 ? red[i+1][j]=1 : blue[i+1][j]=1;
  rep(j,w){
    red[0][j]=1;
    blue[h-1][j]=1;
  }
  rep(i,h){
    string s;cin>>s;
    rep(j,w)if(s[j]=='#')red[i][j]=(blue[i][j]=1);
  }
  rep(i,h){
    rep(j,w){
      if(red[i][j])cout<<'#';
      else cout<<'.';
    }
    cout<<endl;
  }
  cout<<endl;
  rep(i,h){
    rep(j,w){
      if(blue[i][j])cout<<'#';
      else cout<<'.';
    }
    cout<<endl;
  }
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 500050;
const int mod = 1e9+7;
using namespace std;
typedef long long ll;
ll a[maxn],b[maxn];
int main()
{
	int n,m;
	ll k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		b[i]+=b[i-1];
	}
	int ans=0,cnt;
	for(int i=m;i>0;i--){
		if(k>=b[i]){
			ans=i;
			cnt=i;
			break;
		}
	}
	for(int i=1;i<=n;i++){
		while(b[cnt]+a[i]>k){
			cnt--;
		}
		if(cnt<0)
		break;
		ans=max(cnt+i,ans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6760
#include <functional>
#include <iostream>
#include <vector>

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

int N, M;
std::vector<std::vector<int>> G;
int inf = 1 << 30;
std::vector<int> dp;

int rec(int v) {
  if (dp[v] != -inf)
    return dp[v];

  if (G[v].empty())
    return dp[v] = 0;

  int res = -inf;
  for (auto u : G[v])
    chmax(res, rec(u) + 1);
  return dp[v] = res;
}

int main() {
  std::cin >> N >> M;
  G.resize(N);
  for (int i = 0; i < M; ++i) {
    int x, y;
    std::cin >> x >> y;
    G[y - 1].push_back(x - 1);
  }

  dp.assign(N, -inf);
  int res = -inf;
  for (int v = 0; v < N; ++v)
    chmax(res, rec(v));
  std::cout << res << std::endl;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	string s,t;
	cin>>s>>t;
	int ct=0;
	fr(i,0,s.size()){
		if(s[i]==t[i])
			ct++;
	}
	wd(ct);
	NL;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>//37~53
using namespace std;

int main(){
	int n=0;
	int a[600];
	int s[200];
	int i=0;
	int j=0;
	int k=0;
	int m=0;
	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		cin>>a[200+i];
		cin>>a[400+i];
	}
	for(j=0;j<600;j=j+200){
		for(i=j;i<j+n;i++){
			for(k=i+1;k<j+n;k++){
				if(a[i]==a[k]){
					a[k]=0;
					m=1;
				}
			}
			if(m==1){
				a[i]=0;
				m=0;
			}
		}
	}
	for(i=0;i<n;i++){
		s[i]=a[i]+a[200+i]+a[400+i];
		cout<<s[i]<<endl;
	}
}

Measured memory_bytes: 3084
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let ERR = 1.0 / 1000000.0
let r2d t = t * 180.0 / Math.PI

let solve a b x =
    let rec loop l r =
        if r2d r - r2d l <= ERR then
            l
        else
            let m = (l + r) / 2.0
            let c = b * Math.Tan(Math.PI / 2.0 - m)
            let v =
                if c <= a then
                    a * b * c / 2.0
                else
                    let d = a * a * a * Math.Tan m / 2.0
                    a * a * b - d
            if v < x then
                loop l m
            else
                loop m r
    loop 0.0 (Math.PI / 2.0)
    |> r2d

[<EntryPoint>]
let main _ =
    let [A;B;X] = reads float
    printfn "%.7f" (solve A B X)
    0

Measured memory_bytes: 14044
a = int(input())
b = int(input())
c = int(input())

# 500, 100, 50

x = int(input())

def solve():
    ans = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                t = i*500+j*100+k*50
                if t == x: ans += 1
    return ans

print(solve())




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

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

long long int dist[400][400];
int n;
ll ans;

int minKey(int key[], bool mstSet[])
{
   // Initialize min value
   int min = INT_MAX, min_index;
 
   for (int v = 0; v < n; v++)
     if (mstSet[v] == false && key[v] < min)
         min = key[v], min_index = v;
 
   return min_index;
}
 
// A utility function to print the constructed MST stored in parent[]
void printMST(int parent[], int n)
{
   for (int i = 1; i < n; i++)
   	ans += dist[i][parent[i]];
      //printf("%d - %d    %d \n", parent[i], i, dist[i][parent[i]]);
}

void primMST()
{
     int parent[n]; // Array to store constructed MST
     int key[n];   // Key values used to pick minimum weight edge in cut
     bool mstSet[n];  // To represent set of vertices not yet included in MST
 
     // Initialize all keys as INFINITE
     for (int i = 0; i < n; i++)
        key[i] = INT_MAX, mstSet[i] = false;
 
     // Always include first 1st vertex in MST.
     key[0] = 0;     // Make key 0 so that this vertex is picked as first vertex
     parent[0] = -1; // First node is always root of MST 
 
     // The MST will have V vertices
     for (int count = 0; count < n; count++)
     {
        // Pick the minimum key vertex from the set of vertices
        // not yet included in MST
        int u = minKey(key, mstSet);
 
        // Add the picked vertex to the MST Set
        mstSet[u] = true;
 
        // Update key value and parent index of the adjacent vertices of
        // the picked vertex. Consider only those vertices which are not yet
        // included in MST
        for (int v = 0; v < n; v++)
 
           // graph[u][v] is non zero only for adjacent vertices of m
           // mstSet[v] is false for vertices not yet included in MST
           // Update the key only if graph[u][v] is smaller than key[v]
          if (dist[u][v] && mstSet[v] == false && dist[u][v] <  key[v])
             parent[v]  = u, key[v] = dist[u][v];
     }
 
     // print the constructed MST
     printMST(parent, n);
}

int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    long long int total = 0;
    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < n; j++) {
    		cin>>dist[i][j];
    		total +=dist[i][j];
    	}
    }
    total /=2;
    for(int i = 0; i < n; ++i) {
    	for(int j = 0; j < n; ++j) {
    		bool flag= true;
    		for(int k = 0; k < n; ++k) {
    			if(dist[i][k]+dist[k][j] < dist[i][j]) {
    				cout<<-1<<endl;
    				return 0;
    			}else if(dist[i][k]+dist[k][j] == dist[i][j] && i < j && j!=k && i!=k && flag) {
    				total-= dist[i][j];
    				flag = false;
    			}
    		} 
    	}
    }
    //primMST();
    cout<<total<<endl;
}

Measured memory_bytes: 1152
#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<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
int main(){
	int n,k;
	cin>>n>>k;
	vi in(n);
	rep(i,n)cin>>in[i];
	map<int,int>ma;
	int m=0;
	for(int i=n-2;i>=0;i--){
		m=max(m,in[i+1]);
		if(in[i]<m)ma[m-in[i]]++;
	}
	cout<<(--(ma.end()))->second<<endl;
}









Measured memory_bytes: 5376
import math
import itertools
n = int(input())

xys = [[] for i in range(n)]

for i in range(n):
    xys[i] = list(map(int,input().split()))


m = math.factorial(n)
c = [i for i in range(n)]
cs = itertools.permutations(c)

s = 0
for d in cs:
    for j in range(len(d)-1):
        x = (xys[d[j]][0] - xys[d[j+1]][0]) ** 2 + (xys[d[j]][1] - xys[d[j+1]][1]) ** 2
        s += x ** (0.5)

print(s/m)


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

int main()
{
	int dog, mon;
	int i;
	int ans;
	scanf("%d %d", &dog, &mon);

	int n = abs(dog - mon);

	if (n > 1)ans = 0;
	else {
		long long int dogcount = 1;
		long long int moncount = 1;

		for (i = 1; i <= dog; i++) {
			dogcount *= i;
			dogcount = dogcount % 1000000007;
		}
		for (i = 1; i <= mon; i++) {
			moncount *= i;
			moncount = moncount % 1000000007;
		}
		if(n==0) ans = (2*dogcount*moncount) % 1000000007;
		else ans= (dogcount*moncount) % 1000000007;
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 100005
using namespace std;
struct edge{
	int t,next;
}e[N*2];int ecnt,head[N],du[N];
void addedge(int f,int t){
	e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;du[f]++;
	e[++ecnt]=(edge){f,head[t]};head[t]=ecnt;du[t]++;
}
int val[N],n;

int DFS(int u,int fr){
	int mx=0,tot=0;
	for(int i=head[u];i;i=e[i].next){
		if(e[i].t!=fr){
			int v=DFS(e[i].t,u);
			mx=max(mx,v);tot+=v;
		}
	}
	if(du[u]==1&&tot==0) return val[u];
	int x=tot-val[u],y=val[u]-x;
	if(x<0||y<0||x>(tot-mx)||x*2>tot) {puts("NO");exit(0);}
	return y;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&val[i]);
	for(int i=1,f,t;i<n;i++){
		scanf("%d%d",&f,&t);addedge(f,t);
	}
	int t=DFS(1,0);
	if(t!=0&&du[1]!=1) puts("NO");
	else puts("YES");
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        string s; cin >> s;
        reverse(all(s));
        const int MOD = 2019;
        vector<int> cnt(MOD);
        int sum = 0, pot = 1;
        ll ans = 0;
        cnt[0] = 1;
        for (int i = 0; i < sz(s); i++) {
                (sum += (s[i] - '0') * pot) %= MOD;
                (pot *= 10) %= MOD;
                ans += cnt[sum]++;
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3700
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 100'009;

bool bad[N];
int f[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(bad, false, sizeof bad);
  for (int i = 0; i < m; ++i) {
    int x;
    scanf("%d", &x);
    bad[x] = true;
  }
  const int mod = 1'000'000'007;
  memset(f, 0, sizeof f);
  f[0] = 1;
  for (int i = 0; i <= n; ++i) {
    if (i + 1 <= n && !bad[i + 1]) {
      f[i + 1] += f[i];
      f[i + 1] %= mod;
    }
    if (i + 2 <= n && !bad[i + 2]) {
      f[i + 2] += f[i];
      f[i + 2] %= mod;
    }
  }
  printf("%d\n", f[n]);
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl
ll n,ruc[100];


int main(){
    cin>>n;
    ruc[0]=2;
    ruc[1]=1;
    for(int i=2;i<100;i++){
        ruc[i]=ruc[i-1]+ruc[i-2];
    }
    cout<<ruc[n]<<endl;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	long long ans = 0;
	for1(i, n){
		for1(j, n){
			for1(k, n){
				ans += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << ans;
	return 0;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;

    cin >> n;

    ll x = (ll)sqrt(n);

    cout << x * x << '\n';

    return 0;
}


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

int main()
{
    int n,x;
    std::cin >> n >> x;
    long long cnt = 0;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    for(int i = 1; i < n; i++){
        if(a[i - 1] + a[i] > x){
            int tmp = a[i];
            a[i] = std::max(a[i] - (a[i] + a[i - 1] - x),0);
            cnt += tmp - a[i];
            if(a[i - 1] > x){
                cnt += a[i - 1] - x;
            }
        }
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 640
n = int(input())
p = list(map(int, input().split()))
x = 0
for i in range(n - 2):
    if p[i + 1] != max(p[i], p[i + 1], p[i + 2]) and p[i + 1] != min(p[i], p[i + 1], p[i + 2]):
        x += 1
print(x)

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

#define int long long
#define inf  1000000007
#define pb push_back
  using namespace std;

void solve(){
	int n,m;
	cin>>n>>m;
	if(n==0 && m==0) exit(0);

	int ans=0;
	int h=m/n;
	for(int i=0;i<n;i++){
		int y;
		cin>>y;
		ans+=min(h,y);
	}
	cout<<ans<<endl;
}

 signed main(){
 	while(1) solve();
 	return 0;

  }
  


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  vector<ll>tmp;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      tmp.push_back(i);
      if(i * i != n) tmp.push_back(n / i);
    }
  }
  rep(i,tmp.size()){
    if(tmp[i] == 1)continue;
    if(n / (tmp[i] - 1) == n % (tmp[i] - 1))ans += tmp[i] - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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



int main(){
  ll n,m; cin >> n >> m;
  vector<vector<ll>> table(m,vector<ll>(n,0));
  vector<ll> onscnt(m);
  vector<ll> switchdefault(m);
  ll cnt = 0;
  
  rep(i,m){
    ll k; cin >> k;
    
    rep(j,k){
      ll num; cin >> num;
      table[i][num-1] = 1;
    }
    
  }
  
  
  rep(i,m) cin >> switchdefault[i];
  
  for(ll bit = 0; bit < (1<<n); ++bit){
    
    rep(i,m){
      onscnt[i] = switchdefault[i];
    }
      
    
    
    for(ll i=0; i < n; i++){
      if(bit & (1<<i)){
       
        rep(j,m){
            if(table[j][i] == 1){
              onscnt[j]++;              
            }
        }
        

      }
    }
    
    
    
      
      bool flag = true;
      rep(i,m){
        if(onscnt[i] % 2 != 0){
          flag = false;
          break;
        }
      }
      
      if(flag) cnt++;
    
  }
      
    cout << cnt << endl;
  
}
  
      
     

  
  
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
bool b[100010] = { false };
int co[100010];
int main() {
	int n, m;
	cin >> n >> m;
	b[1] = true;
	for (int i = 1; i <= n; i++) {
		co[i] = 1;
	}
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		if (b[x]) {
			if (co[x] == 1) {
				b[x] = false;
			}
			b[y] = true;
		}
		co[x]--;
		co[y]++;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (b[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4072
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();

        int ans = 0;
        Boolean chk = true;
        Arrays.sort(a);
        int min = a[0];
        while (min != 0 && chk) {
            for(int i = 0; i < n; i++){
                if(a[i] % 2 == 0)
                    a[i] /= 2;
                else
                    chk = false;
            }
            ans++;
        }

        System.out.println(ans-1);
    }
}


Measured memory_bytes: 23380
import sys
input = sys.stdin.readline
a = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
l = []
for i in range(3):
  t = []
  for j in range(3):
    t.append(a[i][j])
  l.append(t)
for j in range(3):
  t = []
  for i in range(3):
    t.append(a[i][j])
  l.append(t)
l.append([a[0][0], a[1][1], a[2][2]])
l.append([a[0][2], a[1][1], a[2][0]])
for t in l:
  s = [0] * 3
  for x in b:
    for i in range(3):
      if x == t[i]: s[i] = 1
  if sum(s) == 3:
    print("Yes")
    exit(0)
print("No")

Measured memory_bytes: 38384
W,H,N=map(int, input().split())

X_min = 0
X_max = W
Y_min = 0
Y_max = H

for i in range(N):
  x,y,a=map(int, input().split())
  if a==1: X_min = max(X_min, x)
  if a==2: X_max = min(X_max, x)
  if a==3: Y_min = max(Y_min, y)
  if a==4: Y_max = min(Y_max, y)
print(max([(X_max-X_min),0])*max([(Y_max-Y_min),0]))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
char Map[1005][1005]={0};
int con1[1005][1005]={0};
int con2[1005][1005]={0};
int main()
{
    int N,M,ans=0,i,j,k,x1,y1,x2,y2;
    scanf("%d %d\n",&N,&M);
    for(i=301;i<N+301;i++)
    {
        fgets(Map[i]+301,1000,stdin);
    }
    for(i=0;i<=1000;i++)
    {
    	for(j=0;j<=1000;j++)
    	{
    	    //printf("%c",Map[i][j]);
    		con1[i][j]=(Map[i][j]=='#');
    		con2[i][j]=(Map[i][j]=='#');
    		if(i) con1[i][j]+=con1[i-1][j-1];
    		if(i) con2[i][j]+=con2[i-1][j+1];
		}

	}


    for(i=301;i-301<N;i++)
    {
    	for(j=301;j-301<M;j++)
    	{
    	    //printf("%d %d %c\n",i,j,Map[i][j]);
    		if(Map[i][j]=='.') continue;
    		for(k=1;k<max(N,M);k++)
    		{
    		    if(Map[i+k][j-k]=='#')
                {
                    ans+=con2[i+2*k][j]-con2[i+k][j+k]+(Map[i+k][j+k]=='#');
                    //printf("a %d %d\n",k,ans);
                    ans+=con2[i][j-2*k]-con2[i-k][j-k]+(Map[i-k][j-k]=='#');
                    //printf("a %d %d\n",k,ans);

                }

			}

			for(k=2;k<max(N,M);k++)
    		{
    		    if(Map[i+k][j+k]=='#')
                {

                    ans+=con1[i-1][j+2*k-1]-con1[i-k+1][j+k+1]+(Map[i-k+1][j+k+1]=='#');
                    ans+=con1[i+2*k-1][j-1]-con1[i+k+1][j-k+1]+(Map[i+k+1][j-k+1]=='#');
                    //printf("b %d %d\n",k,ans);
                }
			}
            //printf("%d %d %d %c\n",i,j,ans,Map[i][j]);


		}
	}
 	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll n;
  cin >> n;
  cout << (n-1)/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int Q,H,S,D,N;
int64 ans;
int main() {
	read(Q);read(H);read(S);read(D);
	read(N);
	H = min(2 * Q,H);
	S = min(2 * H,S);
	D = min(2 * S,D);
	ans = 1LL * (N / 2) * D + (N & 1) * S;
	out(ans);enter;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		int n=stdin.nextInt();
		int a=n/3;
		int b=n%3;
		 if(a!=0 )
			System.out.println(a);
		else if(a==0)
			System.out.println("0");
	}
}

Measured memory_bytes: 22228
#include <iostream>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a < b){
    cout << "a < b" << endl;
  }else if(a > b){
    cout << "a > b" << endl;
  }else{
    cout << "a == b" << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in); 
		while(sc.hasNext()){
			long hi = sc.nextInt();
			for(int count = 0; count < hi; count ++){
				double x = sc.nextLong();
				double y = sc.nextLong();
				long b = sc.nextLong();
				long p = sc.nextLong();
				if(b >= 5 && p >=2){ x = x * 0.8; y = y * 0.8;} 			
				double cost = x * b + y * p;
					if(b < 5){
						for(;b<=5;b++){
							if(b >= 5 && p >=2){ x = x * 0.8; y = y * 0.8;} 			
							double ans = x * b + y * p;
						if ( ans < cost)cost = ans;
						}
					}
					if(p < 2){
						for(;p<=2;p++){
							if(b >= 5 && p >=2){ x = x * 0.8; y = y * 0.8;} 			
							double ans = x * b + y * p;
						if ( ans < cost) cost = ans;
						}
					}
				long henkan = (long)cost;
				System.out.println(henkan);
			}
		
		}
	}
	
}

Measured memory_bytes: 23376
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

signed main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans << "\n";
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std; 
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007
int x,y,d;
void gcd(int a,int b){
	if(b==0){
		d=a;
		x=1;
		y=0;
		return ;
	}
	gcd(b,a%b);
	int X,Y;
	X=y;
	Y=x-(a/b)*y;
	x=X;  y=Y;
}
int a,b,c,m; 
int exp(int a,int b){
	m=b+1;
	int res=1;
	while(b!=0){
		if(b&1){
			res*=a;
			res%=m;
		}
		b/=2;
		a*=a; a%=m;
	}
	return res;
}
void prime(){
	int n; cin>>n;
	if(n<2){
		cout<<"composite\n";
		return ;
	}else if(n==2){
		cout<<"prime\n";
		return ;
	}else if(n%2==0){
		cout<<"composite\n";
		return ;
	}else {
		for(int i=3;i*i<=n;i+=2){
			if(n%i==0){
				cout<<"composite\n";
				return ;
			}
		}
		cout<<"prime\n";
	}
}
void toutient(int n) {
    vector<int> phi(n + 1);
    phi[0] = 0;
    phi[1] = 1;
    for (int i = 2; i <= n; i++)
        phi[i] = i - 1;

    for (int i = 2; i <= n; i++)
        for (int j = 2 * i; j <= n; j += i)
              phi[j] -= phi[i];
	cout<<phi[n];
}
int pr[11000];
int dig(int a){
	int s=0;
	while(a!=0){
		s+=(a%10);
		a/=10;
	}
	return s;
}
int ans[11000];
void seive(){
	pr[0]=pr[1]=1;
	for(int i=2;i<11000;++i){
		if(pr[i]==0){
			for(int j=2*i;j<11000;j+=i){
				pr[j]=1;
			}
		}
	}
	for(int i=0;i<11000;++i)
		ans[i]=-1;
	for(int i=0;i<11000;++i){
		if(pr[i]==0){
			ans[i]=1;
			if(i<100){
				ans[i*i]=1;
			}
		}
		else if(ans[i]==-1) ans[i]=LLONG_MAX;
	}
	vector<int> v;
	for(int i=0;i<11000;++i)
	if(ans[i]==1)
	v.push_back(i);
	for(int i=0;i<11000;++i){
		if(ans[i]!=LLONG_MAX){
			for(auto it : v){
				ans[i+it]=min(ans[i+it],ans[i]+1);
			}
		}
	}
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//seive();
	int n,x,y; cin>>n>>x>>y;
	int ans[n+1]={0};
	for(int i=1;i<n;++i){
		for(int j=i+1;j<=n;++j){
			int val=abs(i-x)+abs(j-y); ++val;
			int pp=min(val,abs(i-j));
			++ans[pp];
		}
	}
	for(int i=1;i<n;++i)
	cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long N = scan.nextLong();
		long K = scan.nextLong();

		long x = N%K;
		long y = Math.abs(x-K);

		if (x > y) {
			System.out.println(y);
		} else {
			System.out.println(x);
		}
	}

}

Measured memory_bytes: 35868
#include<stdio.h>
void Track(int A[],int N)
{
	for(int i=0;i<N;i++)
  {	if(i>0)printf(" ");
     printf("%d",A[i]);
  }
  printf("\n");
}
	
void Insertsort(int A[],int N)
{
   int i,j,v;
   for(i=1;i<N;i++)
   {
      v=A[i];
	  j=i-1;
     while(j>=0&&A[j]>v)
	 {A[j+1]=A[j];
	    j--;
     }
     A[j+1]=v; 
     Track(A,N);
	}
}   


int main()
{
    int A[100],N;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
		scanf("%d",&A[i]);	
		Track(A,N);
		Insertsort(A,N); 
		return 0;
   
} 	
   


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

const int MAX_N = 100005;
struct edge{int to, cost;};
typedef pair<int, int> P;

vector<edge> G[MAX_N];
long long d1[MAX_N];
long long d2[MAX_N];

/*
   ダイクストラ法による単一始点最短経路問題solver
n : ノード数
s : 開始ノード(0-indexed)
*/
void dijkstra(int n, int s, long long* d){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+n, INF);
	d[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	for(int i=0; i<n-1; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		G[a].pb(edge{b, 1});
		G[b].pb(edge{a, 1});
	}

	dijkstra(n, 0, d1);
	dijkstra(n, n-1, d2);

	ll fennec = 0;
	ll snuke = 0;
	for(int i=0; i<n; i++){
		if(d1[i] <= d2[i]){
			fennec++;
		}else{
			snuke++;
		}
	}

	if(fennec <= snuke){
		puts("Snuke");
	}else{
		puts("Fennec");
	}
	
	return 0;
}


Measured memory_bytes: 8176
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[[] for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1].append([b-1,c])
    path[b-1].append([a-1,c])
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in path[cur]:
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])
    


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

const long long MOD = 1e9+7;

int main() {
    long long n, m;
    cin >> n >> m;

    long long ans = 1;
    if (abs(n - m) < 2) {
        for (int i = 1; i <= n; i++) {
            ans = ans * i % MOD;
        }
        for (int i = 1; i <= m; i++) {
            ans = ans * i % MOD;
        }
        if (n == m) {
            ans = ans * 2 % MOD;
        }
    }
    else ans = 0;

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

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

void solve(){
    string s, t;
    cin >> s >> t;
    if(s.length()+1 != t.length()){
        cout << "No\n";
        return;
    }

    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  CFS;
  int n,q;
  cin >> n >> q;
  vector<pair<int,pair<int,int>>> v(2*n);
  int s,t,x;
  rep(i,n){
    cin >> s >> t >> x;
    v[2*i]={s-x,{x,1}};
    v[2*i+1]={t-x,{x,0}};
  }
  sort(all(v));
  map<int,int> mp;
  int idx=0,d;
  rep(t,q){
    cin >> d;
    while(idx<2*n){
      if(v[idx].first>d) break;
      if(v[idx].second.second){
        mp[v[idx].second.first]++;
      }else{
        auto itr = mp.find(v[idx].second.first);
        itr->second--;
        if(itr->second==0) mp.erase(itr);
      }
      idx++;
    }
    if(mp.size()==0) cout << -1 << "\n";
    else cout << (mp.begin()->first) << "\n";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 15360
def solve(x):
    return 10 ** x - 9 ** x - 9 ** x + 8 ** x


n = int(input())
if n == 1:
    print(0)
    exit()
elif n == 2:
    print(2)
    exit()

print(solve(n) % (10 ** 9 + 7))


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

void solve(int *a,int n)
{
    int dist[n];
    memset(dist,0,sizeof(dist));
    dist[0]=0;
    dist[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
       dist[i]= min(dist[i-2]+abs(a[i]-a[i-2]),dist[i-1]+abs(a[i]-a[i-1]));
    }
    cout<<dist[n-1];
}

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

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

void solve()
{
	double x1, y1, x2, y2, x3, y3, x4, y4;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4)
	{
		if((x1 == x2 && y3 == y4) || (y1 == y2 && x3 == x4))
		{
			cout << "YES" << endl;
		}
		else if(x1 == x2 || x3 == x4)
		{
			cout << "NO" << endl;
		}
		else if(((y2 - y1) / (x2 - x1)) * ((y4 - y3) / (x4 - x3)) == -1)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
long long s,k;
string a;
char o;

int main(){
	cin>>a>>k;
	for(int i=0;i<a.size();i++){
		if(a[i]=='1'){
			o++;
		}else{
			o=i;
			break;
		}
	}
	if(k<=o){
		cout<<"1"<<endl;
	}else{
		cout<<a[o]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int n,k,i,j,m,x[10001][2],p;
	scanf("%d%d%d",&n,&k,&m);
	for(i=0;i<m;i++)scanf("%d%d",&x[i][0],&x[i][1]);
	for(i=1;i<m;i++){
		if((x[i][0]>x[i-1][0]&&x[i][1]>x[i-1][1])||(x[i-1][0]>x[i][0]&&x[i-1][1]>x[i][1])){
			if(abs(x[i][0]-x[i-1][0])>abs(x[i][1]-x[i-1][1]))p-=abs(x[i][1]-x[i-1][1]);
			else p-=abs(x[i][0]-x[i-1][0]);
		}
		p+=abs(x[i][0]-x[i-1][0])+abs(x[i][1]-x[i-1][1]);
	}
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

int main() {
	int N, M;
	cin >> N >> M;
	
	vector<int> oks(N + 1, true);
	for (int i = 0; i < M; i++) {
		int a; cin >> a;
		oks[a] = false;
	}
	
	vector<long long int>dp(N + 1);
	dp[0] = 1;
	for (int now = 0; now < N; ++now) {
		for (int next = now + 1; next <= min(N, now + 2); ++next) {
			if (oks[next]) {
				dp[next] += dp[now];
				dp[next] %= mod;
			}
		}
	}
	
	cout << dp[N] << endl;
	return 0;
}


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

int main() {
  string a,b;
  cin>>a>>b;
  string x=a+b;
  int c=stoi(x);
  for(int i=1;i<=400;i++){
    if(c==i*i) {cout<<"Yes"<<endl; return 0;}
  }
  cout<<"No"<<endl;
}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , A[MAXN] , cnt[MAXN] , ans;

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

    cin >> n;
    for(ll i = 1 ; i <= n ; i++){
        cin >> A[i];
        ans += cnt[A[i]];
        cnt[A[i]]++;
    }

    for(ll i = 1 ; i <= n ; i++)    cout << ans - cnt[A[i]] + 1 << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 7296
#include<iostream>
#include<string>

int main(){
    std::string str,ans;
    
    std::cin>>str>>ans;

    str=str+str;

    int serch = str.find(ans);

    if(serch==std::string::npos){
        std::cout<<"No"<<std::endl;
    }else{
        std::cout<<"Yes"<<std::endl;
    }

    return 0;
}



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

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

int main() {

    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for(int i=0; i<N; i++) cin >> H[i];
    vector<int> A(M);
    vector<int> B(M);
    for(int i=0; i<M; i++) cin >> A[i] >> B[i];
    
    vector<bool> data(N, true);

    for(int i=0; i<M; i++) {
        if(H[A[i]-1] >= H[B[i]-1]) {
            data[B[i]-1] = false;
        }
        if(H[A[i]-1] <= H[B[i]-1]) {
            data[A[i]-1] = false;
        }
    }

    int result = 0;
    for(auto&& d : data) {
        if(d) result++;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

double dist(pair<int,int> a, pair<int,int> b){
  return pow((pow((a.first - b.first),2) + pow((a.second - b.second),2)),0.5);
 
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int x,y;
  cin >> n;
  vector<pair<int ,int> > v;
  REP(i,n){
    cin >> x >> y;
    v.push_back(make_pair(x,y));
  }
  double sm = 0;
  REP(i,n){
    FOR(j,i+1,n){
      sm += dist(v[i],v[j]);
    }
  }
  cout << fixed << setprecision(10) << sm * 2 / n <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  long a,b,c;
  cin>>a>>b>>c; 
  long n=a*b;
  if(c-a-b<=0){
    cout<<"No"<<endl;
  }
  else{
  if(4*n<(c-a-b)*(c-a-b)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  }
}



Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    set<ll> st;
    for(ll x:a)st.insert(x);

    ll ans=st.size();
    if(ans%2==0)--ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
n = int(input())
start = []
for i in range(n):
    x, l = list(map(int, input().split()))
    start.append([x-l, x+l])
start.sort(key=lambda x: x[1])
# print(start)
counter = 1
time = start[0][-1]
for s in start[1:]:
    # print(time, s)
    if time <= s[0]:
        counter += 1
        time = s[1]
print(counter)


Measured memory_bytes: 21800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;
      
int A[105];
int main(){
  int n,k;
  cin>>n>>k;
  rep(i,k){
    int d;
    cin>>d;
    rep(j,d){
      int a;
      cin>>a; a--;
      A[a]++;
    }
  }
  int ans=0;
  rep(i,n){
    if(A[i]==0) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int n,a,b,c;
int l[10];

int dfs(int la,int lb,int lc,int cnt,int cost){
    if(cnt==n){
        if(la==0||lb==0||lc==0){
            return MAXS;
        }
        else{
            return cost+abs(a-la)+abs(b-lb)+abs(c-lc)-30;
        }
    }
    else{
        int ua=dfs(la+l[cnt],lb,lc,cnt+1,cost+10);
        int ub=dfs(la,lb+l[cnt],lc,cnt+1,cost+10);
        int uc=dfs(la,lb,lc+l[cnt],cnt+1,cost+10);
        int un=dfs(la,lb,lc,cnt+1,cost);
        return min({ua,ub,uc,un});
    }
}
signed main(){
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++)cin>>l[i];
    cout<<dfs(0,0,0,0,0)<<endl;
}

Measured memory_bytes: 256
a, b = gets.chomp.split(" ").map(&:to_i)

if  (a - b) % 2 == 0 &&  a <= b
  puts a += (b-a)/2
elsif (a - b) % 2 == 0 &&  a > b
  puts a -= (a-b)/2
else
  puts "IMPOSSIBLE"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


int check(string S, string T, int X, int W){
  int N = S.size();
  reverse(S.begin(), S.end());
  reverse(T.begin(), T.end());
  T[0] = '.';
  //pr(S, T, X, W);
  
  int l = 1, r = W;
  for(int i=0;i<N;i++){

    //落とされたくない
    if(T[i] == 'R') l--; 
    if(T[i] == 'L') r++;

    Max(l, 1);Max(r, 1);Min(l, W);Min(r, W);
    
    //落としたい
    if(S[i] == 'R') r--;
    if(S[i] == 'L') l++;
    
    //pr(i, l, r, X, W, S[i], T[i]);
    if(r < 1 || l > W || l > r) return 0;
  }
  return (l <= X && X <= r);
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int H, W, N;
  cin>>H>>W>>N;
  int sy, sx;
  cin>>sy>>sx;

  string S, T;
  cin>>S>>T;

  string Sx, Sy, Tx, Ty;

  for(int i=0;i<N;i++){
    if(S[i] == 'L' || S[i] == 'R') Sx += S[i], Sy += '.';
    else Sy += S[i] == 'U'? 'L':'R', Sx += '.';
    
    if(T[i] == 'L' || T[i] == 'R') Tx += T[i], Ty += '.';
    else Ty += T[i] == 'U'? 'L':'R', Tx += '.';
  }
  
  int a = check(Sy, Ty, sy, H);
  int b = check(Sx, Tx, sx, W);
  int ans = a & b;
  //pr(a, b);
  cout<<(ans? "YES":"NO")<<endl;
  
  return 0;
}


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

int main() {
  int n, a;
  cin >> n;
  cin >> a;
  if (n % 500 <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	REP(i,n){
		ll x = n / i;
		ans += i*x*(x+1)/2;
	}
	cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3620