akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#include<iostream>
using namespace std; 

int maxhappy(vector<int> a,vector<int> b,vector<int> c,int n)
{
	int dp[3][n];
	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];
	for(int i=1;i<n;i++)
	{
		dp[0][i] = max(dp[1][i-1],dp[2][i-1])+a[i];
		dp[1][i] = max(dp[0][i-1],dp[2][i-1])+b[i];
		dp[2][i] = max(dp[0][i-1],dp[1][i-1])+c[i];
	}
	return max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}
int main()
{
	int n;
	cin>>n;
	vector<int> a(n);vector<int> b(n);vector<int> c(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	cout<<maxhappy(a,b,c,n)<<endl; 
}


Measured memory_bytes: 3712
#include<cstdio>
#include<cstdlib>
#include<cmath>
int main()
{
int i;
float j;
long long x,y,z;
scanf("%lld%lld%lld",&x,&y,&z);
    y+2*z<=x;
j=(float)(x-z)/(y+z);
i=j;
printf("%d\n",i);
return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int month = sc.nextInt();
    int day = sc.nextInt();
    if (day >= month) {
      System.out.println(month);
    } else {
      System.out.println(month - 1);
    }
    
  }
}

Measured memory_bytes: 21332
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << (h) << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << (h) << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

ll N, M;
vector<pr<ll>> R;

void Main()
{
	cin >> N >> M;
	R.resize(M);
	rep(i, M)
	{
		cin >> R[i].second >> R[i].first;
	}

	//sort(all(R), cmp_2nd<ll>);
	sort(all(R));
	/**
	rep(i, M)
	{
		debug("R" + to_string(i));
		debug_tabheadcout(1, "1st", R[i].first);
		debug_tabheadcout(1, "2nd", R[i].second);
	}
	/**/

	/**
	R.erase(unique(all(R), eq), R.end());
	M = R.size();
	/**/

	ll ret = 0, end = -1;
	rep(i, M)
	{
		if (R[i].second >= end)
		{
			ret++;
			end = R[i].first;
		}
	}

	cout << ret;
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


Measured memory_bytes: 1920
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        ArrayList<Integer> Y = new ArrayList<>();
        ArrayList<Integer> H = new ArrayList<>();
        int candX = 0;
        int candY = 0;
        int candH = 0;
        for(int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int h = sc.nextInt();
            if(h != 0) {
                X.add(x);
                Y.add(y);
                H.add(h);
                candX = x;
                candY = y;
                candH = h;
            }
        }
        for(int x = 0; x <= 100; x++) {
            for(int y = 0; y <= 100; y++) {
                int height = H.get(0) + Math.abs(X.get(0) - x) + Math.abs(Y.get(0) - y);
                for(int i = 1; i < H.size(); i++) {
                    int tempHeight = H.get(i) + Math.abs(X.get(i) - x) + Math.abs(Y.get(i) - y);
                    if(height != tempHeight) break;
                    if(i == H.size()-1) {
                        System.out.println(x + " " + y + " " + height);
                        return;
                    }
                }
            }
        }
        System.out.println(candX + " " + candY + " " + candH);
    }
}


Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();

			if (s[0] == 'a' || s[0] == 'e' || s[0] == 'i' || s[0] == 'o' || s[0] == 'u')
			{
				Console.WriteLine("vowel");
			}
			else
			{
				Console.WriteLine("consonant");
			}
		}
	}
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

    vector<lint> cnt(40);
    rep(i, n){
        rep(j, 40){
            if(a[i] >> j & 1LL){
                ++cnt[j];
            }
        }
    }

    vector< LLP > g1, g2;
    rep(i, 20){
        g1.push_back({1LL << i, (n - cnt[i] * 2LL) * 1LL << i});
    }
    REP(i, 20, 40){
        g2.push_back({1LL << i, (n - cnt[i] * 2LL) * 1LL << i});
    }

    vector< LLP > v1, v2;
    rep(i, 1 << 20){
        LLP tmp1 = {0, 0}, tmp2 = {0, 0};
        rep(j, 20){
            if(i >> j & 1){
                tmp1.first += g1[j].first;
                tmp1.second += g1[j].second;
                tmp2.first += g2[j].first;
                tmp2.second += g2[j].second;
            }
        }
        v1.push_back(tmp1);
        v2.push_back(tmp2);
    }

    SORT(v2);
    REP(i, 1, 1 << 20){
        v2[i].second = max(v2[i].second, v2[i - 1].second);
    }

    lint val = -LLINF;
    rep(i, 1 << 20){
        auto it = upper_bound(v2.begin(), v2.end(), make_pair(k - v1[i].first, LLINF));
        if(it == v2.begin()){
            continue;
        }
        --it;
        val = max(val, v1[i].second + (*it).second);
    }

    ans += val;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 33956
ans = 0

for i in range(int(input())):
    t_i, a_i = list(map(lambda x: int(x), input().split()))

    if i == 0:
        t, a = t_i, a_i

    else:
        n = max((t + t_i - 1) // t_i, (a + a_i - 1) // a_i)
        t = n*t_i
        a = n*a_i

    ans = t + a

print(ans)


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

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 main(){
    ll n, r;
    cin >> n >> r;

    if(n>=10){
        cout << r << endl;
    }else{
        cout << r + 100*(10-n) << endl;
    }

    return 0;
}  


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

using namespace std;


int a,b,c;

typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<double> vdb;
typedef vector<bool> vbol;
typedef vector<string> vstr;

#define vvll(a,b,c) vector<vector<long long>> c(a,vector<long long>(b,0))
#define vvit(a,b,c) vector<vector<int>> c(a,vector<int>(b,0))
#define vvstr(a,b,c) vector<vector<string>> c(a,vector<string>(b,0))
#define vvbol(a,b,c) vector<vector<bool>> c(a,vector<bool>(b,0))
#define vvdb(a,b,c) vector<vector<double>> c(a,vector<double>(b,0))
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=0;i<=b;i++)
#define f_j(a,b) for(int j=0;j<=b;j++)


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

    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*c,max(a*d,max(b*c,b*d))) << endl;
    
    return(0);

}

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

int main() {
  int N,L;
  cin >> N >> L;
  string s[N];
  for(int i=0; i<N; i++) cin >> s[i];
  
  sort(s,s+N);
  
  for(int i=0; i<N; i++){
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}

int main() {
	COME_LET_THE_GAMES_BEGIN();
	ll N, A, B;
	cin >> N >> A >> B;
	cout << min(B, A * N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    string S; cin >> S;
    string T; cin >> T;
    vector<string> ans;
    string tmp = "";
    bool flag;
    if (S.length() < T.length()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for (int i = 0; i <= S.length() - T.length(); i++) {
        flag = true;
        for (int j = 0; j < T.length(); j++){
            if (S[i+j] != '?' && S[i+j] != T[j]){
                flag = false;
                break;
            }
        }
        if (flag){
            for (int j = 0; j < i; j++){
                if (S[j] == '?') {
                    tmp += 'a';
                }
                else {
                    tmp += S[j];
                }
            }
            tmp += T;
            for (int j = i + T.length(); j < S.length(); j++){
                if (S[j] == '?') {
                    tmp += 'a';
                }
                else {
                    tmp += S[j];
                }
            }
            ans.push_back(tmp);
        }
        tmp = "";
        flag = true;
    }
    if (ans.size() > 0) {
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
        return 0;
    }
    cout << "UNRESTORABLE" << endl;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A, B; cin >> A >> B;
	if(A<=8 and B<=8) cout << "Yay!" << endl;
	else cout << ":(" << endl;


	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	vector<vector<int>> bingo(3, vector<int>(3));
	for(int i = 0; i < 3; i++){
    	for(int j = 0; j < 3; j++){
        	cin >> bingo[i][j];
        }
    }
  	int N;
  	cin >> N;
  	for(int i = 0; i < N; i++){
      	int b;
    	cin >> b;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
				if(b == bingo[i][j]) bingo[i][j] = 101;
            }
        } 
    }
    bool ans = false;
    bool ans2 = false;
  	for(int i = 0; i < 3; i++){
  		ans = true;
      	ans2 = true;
      	for(int j = 0; j < 3; j++){
        	if(bingo[i][j] != 101){
            	ans = false;
            }
        	if(bingo[j][i] != 101){
            	ans2 = false;
            }
        }
      	if(ans || ans2) break;
    }
	bool ans3 = false;
  	if(bingo[0][0] == 101 && bingo[1][1] == 101 && bingo[2][2] == 101){
    	ans3 = true;
    }
  	if(bingo[0][2] == 101 && bingo[1][1] == 101 && bingo[2][0] == 101){
    	ans3 = true;
    }
  	if(ans || ans2 || ans3) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

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

int main(){
  char S[200000],T[200000];
  int sa[26],sac[26],ta[26],tac[26];
  char offset='a';
  cin >> S >> T;
  for(int i=0; i < 200000; i++){
    if(S[i] == 0) break;
    sa[S[i] - offset]++;
    ta[T[i] - offset]++;
    memcpy(sac, sa, sizeof(sa));
    memcpy(tac, ta, sizeof(ta));
    sort(sac, sac + sizeof(sac)/sizeof(int));
    sort(tac, tac + sizeof(tac)/sizeof(int));
    for(int i=0; i < 26; i++){
      if(sac[i] != tac[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  int a[501][501] = {};
  for(int i = 0; i < m; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    a[l][r]++;
  }
  for(int i = 1; i <= n; i++)
    for(int j = 0; j < n; j++) a[i][j + 1] += a[i][j];
  for(int i = 1; i <= n; i++)
    for(int j = 0; j < n; j++) a[j + 1][i] += a[j][i];
  for(int i = 0; i < q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%d\n", a[r][r] - a[r][l - 1] - a[l - 1][r] + a[l - 1][l - 1]);
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16

ll mod_pow(ll a,ll n,ll m){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%m;
    a=a*a%m;
    n>>=1;
  }
  return res;
}

ll calc_order(ll X, const vector<P>& ps, ll M){
  ll g = 1;
  rep(i, ps.size()){
    ll mx = 0, r = M - 1;
    rep(j, ps[i].se){
      r /= ps[i].fi;
      if(mod_pow(X, r, M) != 1){
        mx = ps[i].se - j; break;
      }
    }
    ll t = mod_pow(ps[i].fi, mx, M);
    g *= t;
  }
  return g;
}

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

  ll M,T;
  cin>>M>>T;

  vector<P> ps;
  ll tmp=M-1;
  for(ll i=2;i*i<=tmp;i++){
    if(tmp%i!=0)continue;
    P p=P(i,0);
    while(tmp%i==0){
      tmp/=i; p.se++;
    }
    ps.push_back(p);
  }
  if(tmp!=1){
    P p=P(tmp,1);
    ps.push_back(p);
  }

  while(T--){
    int N;
    cin>>N;
    ll a=-1,b=0;
    rep(i,N){
      ll X;
      cin>>X;
      b=__gcd(b,(M-1)/calc_order(X,ps,M));
    }
    {
      ll A;
      cin>>A;
      a=(M-1)/calc_order(A,ps,M);
    }
    if(a%b==0)cout<<1<<endl;
    else cout<<0<<endl;
  }

  return 0;
}



Measured memory_bytes: 3196
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	set<int> check; forl(i, 0, n) { int a; cin >> a; check.insert(a); }
	if(check.size() != n) println("NO");
	else println("YES");
}


Measured memory_bytes: 9600
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int N, T;

  cin >> N >> T;
  const int TLE = 1001;
  int ans = TLE;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t > T) continue;
    ans = min(ans, c);
  }
  if (ans < TLE)
    cout << ans << endl;
  else
    cout << "TLE" << endl;
  return 0;
}


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

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



Measured memory_bytes: 3116
//************************
    //*  Date: 2018.8.25     *
    //*  Problem:            *
    //*  Author: xuziyuan    * 
    //************************
     
    #include <bits/stdc++.h>
     
    #define rt0 return 0
    #define rep(i,n) for(int i=0;i<n;i++)
    #define repn(i,n) for(int i=1;i<=n;i++)
    #define LL long long
    #define pii pair<int,int>
    #define pb push_back
    #define fi first
    #define se second
    #define mpr make_pair
     
    using namespace std;
     
    const LL MOD=1e9+7;
     
    int n,m,w,pos;
    string s[110];
    bool com=true,col[110][2],row[110][2],vis[110][110];
    vector <string> ans;
     
    int main()
    {
    	cin>>n>>m;
    	rep(i,n) cin>>s[i];
    	rep(i,n)
    	{
    		rep(j,m)
    		{
    			if(vis[i][j]) continue;
    			if(s[i][j]=='.')
    			{
    				row[i][0]=true;
    				col[j][0]=true;
    			}
    			else
    			{
    				row[i][1]=true;
    				col[j][1]=true;
    			}
    		}
    	}
    	rep(i,n)
    	{
    		if(row[i][0]&& !row[i][1])
    		{
    			com=true;
    			rep(j,m) vis[i][j]=true;
    		}
    	}
    	rep(i,m)
    	{
    		if(col[i][0]&& !col[i][1])
    		{
    			com=true;
    			rep(j,n) vis[j][i]=true;
    		}
    	}
    	rep(i,n)
    	{
    		string tmp="";
    		rep(j,m) if(!vis[i][j]) tmp.pb(s[i][j]);
    		if(tmp.size()>0) ans.pb(tmp);
    	}
    	rep(i,ans.size())
    	{
    		printf("%s\n",ans[i].c_str());
    	}
    	rt0;
    }

Measured memory_bytes: 256
import math

def sqrtable(x):
	if(x//math.sqrt(x)==math.sqrt(x)):
		return True
	else:
		return False
	

def dist(a,b):
	d=0
	for (i,it) in enumerate(a):
		d+=(it-b[i])*(it-b[i])
	return d

N=int(input().split(" ")[0])
r=[]
for i in range(N):
	r.append(list(map(int,input().split(" "))))
count=0
for i in range(N):
	for j in range(i):
		
		if (sqrtable(dist(r[i],r[j]))==True):
			count+=1
print(count)




Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 100
#define M_MAX 1000
#define INF 10000000
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int d[M_MAX];
int n, m;

int i, j, k;

int e[M_MAX][2];

int edge[N_MAX][N_MAX];
int path[N_MAX][N_MAX];
void wf(){
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			path[i][j] = edge[i][j];
		}
	}

	for (k = 0; k < n; k++) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				if (path[i][j] > path[i][k] + path[k][j])
					path[i][j] = path[i][k] + path[k][j];
			}
		}
	}
	return;
}

void deb(){
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			printf("%d %d %d\n", i, j, path[i][j]);
		}
	}
	return;
}

void solve(){
	int result = 0;
	wf();

	// deb();

	// Saitanro ni fukumareru hen ha sono 2-chouten wo musubu saitanro
	for (i = 0; i < m; i++) {
		if (edge[e[i][0]][e[i][1]] == path[e[i][0]][e[i][1]]) result++;
	}

	printf("%d\n", m - result);
	return;
}

int main (void) {
	scanf("%d%d", &n, &m);

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			edge[i][j] = ((i == j) ? 0 : INF);
		}
	}
	for (i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		e[i][0] = a;
		e[i][1] = b;
		edge[a][b] = edge[b][a] = c;
	}

	solve();
	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,u,v,a[3100];
int edgenum,vet[6100],Next[6100],Head[3100];
void addedge(int u,int v){
	vet[++edgenum]=v;
	Next[edgenum]=Head[u];
	Head[u]=edgenum;
}
bool dfs(int u,int fa){
	for (int e=Head[u];e;e=Next[e])
		if (vet[e]!=fa&&!dfs(vet[e],u)&&a[vet[e]]<a[u]) return true;
	return false;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	for (int i=1;i<=n;i++)
		if (dfs(i,0)) printf("%d ",i);
	return 0;
}


Measured memory_bytes: 384
#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 argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

struct edge{
	ll to, idx;
};

using Graph = vector<vector<edge>>;

bool visited[202020];
int dir[202020];


ll dfs(ll now, ll par, Graph &G){
	if(visited[now]) return 0;
	//dump(now)
	visited[now] = true;
	for(auto next: G[now]){
		dfs(next.to, now, G);
	}

	ll dezi = 0;
	ll par_idx = -1;
	for(auto next: G[now]){
		if(next.to == par){
			par_idx = next.idx;
			continue;
		}
		if(now < next.to && dir[next.idx]==1) dezi++;
		if(now > next.to && dir[next.idx]==0) dezi++;
	}

	//dump(dezi)

	if(par_idx == -1) return dezi;

	if(dezi%2==0){
		if(now > par) dir[par_idx] = 1;
		else dir[par_idx] = 0;
	}else{
		if(now > par) dir[par_idx] = 0;
		else dir[par_idx] = 1;
	}

	return 0;
}

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

    ll N, M;
    cin >> N >> M;

    Graph G(N);

    REP(i, M){
    	ll A, B;
    	cin >> A >> B;
    	A--, B--;
    	G[A].push_back((edge){B, i});
    	G[B].push_back((edge){A, i});
    }

    REP(i, N) visited[i] = false;
    REP(i, N) dir[i] = 1;

    ll dig = dfs(0, -1, G);

    //REP(i, N) cerr << dir[i] << endl;
    //cerr << endl;

    if(dig&1){
    	cout << -1 << endl;
    }else{
    	REP(i, N){
    		for(auto e: G[i]){
    			if(i < e.to){
    				if(dir[e.idx]) cout << i+1 << " " << e.to+1 << endl;
    				else cout << e.to+1 << " " << i+1 << endl;
    			}
    		}
    	}
    }

    return 0;
}

Measured memory_bytes: 15232
import heapq

N,M = (int(x) for x in input().split())
AB = []
sum = 0

for i in range(N):
    a,b = (int(x) for x in input().split())
    AB.append([a,b])

AB = sorted(AB , key = lambda x : x[0])
heap = []
j = 0

for i in range(M+1):
    while j<N and AB[j][0] < i+1:
        heapq.heappush(heap,-AB[j][1])
        j += 1

    if len(heap):
        sum += -heapq.heappop(heap)
                           
print(sum)
    


Measured memory_bytes: 24148
# coding: utf-8
# Your code here!
import math 
a, b = map(int,input().split())
Flg = True
for i in range(10**5+2):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        Flg = False
        break
if Flg:
    print(-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
double n,d,x,ans=0;
int main() {
    cin>>n>>d>>x;
    for(int i=n;i;i--) {
        double sum=(d+d+(2*n-1)*x)*n;
        ans+=sum/2/n;
        double d2=(d*(2*n-2)+d+2*x+3*d+3*x)/(2*n),sum2=sum-((d+d+x)+(d+(2*n-2)*x+d+(2*n-1)*x))/2/n;
        n--;x=(sum2/n-2*d2)/(2*n-1);d=d2;sum=sum2;
    }
    printf("%.10lf\n",ans);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 256
n,m=map(int,input().split())
A=[[0 for aa in range(m)]for bb in range(n)]
b=[0 for cc in range(m)]
for zz in range(n):
	unko=list(map(int,input().split()))
	for yy in range(m):
		A[zz][yy]=unko[yy]
for dd in range(m):
	b[dd]=int(input())
for aaa in range (n):
	ole=0
	for bbb in range(m):
		ole=ole+(A[aaa][bbb]*b[bbb])
	print(ole)


Measured memory_bytes: 5956
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n;
  cin >> n;
  vi p(n);
  rep(i, n) cin >> p[i];
  vi q(n);
  rep(i,n) cin >> q[i];
  vi v(n);
  rep(i,n) v[i] = i + 1;
  int count = 0;
  int ans1, ans2;
  do {
    count++;
    if (v == p) ans1 = count;
  } while (next_permutation(v.begin(), v.end()));

  sort(v.begin(), v.end());
  count = 0;
  do {
    count++;
    if (v == q) ans2 = count;
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(ans1 - ans2) << endl;
}

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

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

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int>x(m);
	
	rep(i, m)cin >> x[i];

	sort(x.begin(),x.end());
	vector<int>d(m - 1);
	rep(i, m - 1)
		d[i] = x[i + 1] - x[i];

	sort(d.begin(), d.end());

	int ans = 0;
	rep(i, m - n)
		ans += d[i];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
from math import factorial 
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,r,mod):
  r=min(r,n-r)
  x=1
  y=1
  
  for i in range(r):
    x = x* (n-i) % mod
    y = y* (1+i) % mod
  y=pow(y,mod-2,mod)

  return(x*y%mod)

ans = pow(2,n, mod)-1-comb(n,a,mod)-comb(n,b,mod)

print(int(ans % (10**9+7)))

Measured memory_bytes: 3064
s = input()
if 'eraser' in s:
    s = s.replace('eraser','')
if 'erase' in s:
    s = s.replace('erase','')
if 'dreamer' in s:
    s = s.replace('dreamer','') 
if 'dream' in s:
    s = s.replace('dream','') 
emp = len(s)
if emp == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;

public class Main {
  private static boolean solve(int[] as) {
    Arrays.sort(as);
    return as[0] == 5 && as[1] == 5 && as[2] == 7;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int[] as = reader.nextInt(3);
    out.println(solve(as) ? "YES" : "NO");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

int main() {
  int n;
  std::cin >> n;

  string p,q;p="";q="";
  int temp;

  for (int i = 0; i < n; i++) {
    std::cin >> temp;
    p+=temp+'0';
  }
  for (int i = 0; i < n; i++) {
    std::cin >> temp;
    q+=temp+'0';
  }

  string s="";
  for (int i = 1; i <= n; i++) {
    s+=(i+'0');
  }

  int pnum=0;
  int qnum=0;
  int cnt=0;
  if(p!=q){
    while (next_permutation(s.begin(), s.end()))
    {
      cnt++;
      if(s==p)
      {
        pnum=cnt;
      }
      if(s==q)
      {
        qnum=cnt;
      }
      if(pnum!=0 && qnum!=0)break;
    }
  }


  std::cout << abs(pnum-qnum) << '\n';
  return 0;
}


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

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    if(abs(A-B)%2==0){
        cout << abs(A-B)/2 << endl;
    }else{
        // 片方が端まで行って1回その場に留まる
        ll l = A-1;
        ll r = N-B;
        if(l<=r){
            // 左端でAが留まる.Bは左端に向かう
            ll ans = l+1; //左端に来て1回留まった状態
            ans += (B-l-2)/2;
            cout << ans << endl;
        }else{
            ll ans = r+1;
            ans += (N-(A+r+1))/2;
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
int main()
{
    io
    int n;
    cin >> n;
    int **mat = new int*[n];
    for(int i = 0; i < n; i++)
    {
        mat[i] = new int[3];
        for(int j = 0; j < 3; j++)
        {
            int num;
            cin >> num;
            mat[i][j] = num;
        }
    }
    ll **dp = new ll*[n];
    for(int i = 0; i < n; i++)
    {
        dp[i] = new ll[3];
        for(int j = 0; j < 3; j++)
        {
            dp[i][j] = 0;
        }
    }
    dp[n-1][0] = mat[n-1][0];
    dp[n-1][1] = mat[n-1][1];
    dp[n-1][2] = mat[n-1][2];
    for(int i = n-2; i >= 0; i--)
    {
        dp[i][0] = mat[i][0] + max(dp[i+1][1],dp[i+1][2]);
        dp[i][1] = mat[i][1] + max(dp[i+1][0],dp[i+1][2]);
        dp[i][2] = mat[i][2] + max(dp[i+1][0],dp[i+1][1]);
    }
    // for(int i = 0; i < n; i++)
    // {
    //     for(int j = 0; j < 3; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    ll ans = max(dp[0][0],max(dp[0][1],dp[0][2]));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8064
require "prime"
n = gets.to_i
arr = Prime.prime_division(n)
list = []
arr.each{|r|
  num = r[0]
  r[1].times{|i|
    list << num
    num *= r[0]
  }
}
ans = 0
list.each{|li|
  if n%li==0  
    n /= li
    ans += 1
  end
}
p ans

Measured memory_bytes: 14484
#include<iostream>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int i,d;
  for (i=0; max(a,b)*i < c; i++){
    d = i;
  }
  cout << d+1 << endl;
  return 0;
}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int N, L;

int v[100002];
int memo[100002];

int dfs(int n){
	if(memo[n]) return memo[n];
	int res = L - v[n];
	int wait = 0;
	if(v[n] < v[n+1]) wait = dfs(n+1);
	if(v[n] < v[n-1]) wait = max(wait, dfs(n-1));
	return memo[n] = res+wait;
}

int main(){
	cin >> N >> L;
	for(int i = 1; i <= N; i++) cin >> v[i];
	int ans = 0;
	for(int i = 1; i <= N; i++){
		ans = max(ans, dfs(i));
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3900
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/
 
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()
 
const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
 
template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}
 
int h, w, a, b;
int f[MXN];
 
inline int Add(int a, int b) {
	a += b;
	if(a > mod) a -= mod;
	if(a < 0) a += mod;
	return a;
}
 
inline int Mul(int a, int b) {
	return (a*1ll*b)%mod;
}
 
inline int Pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b&1) res = Mul(res,a);
		b >>= 1;
		a = Mul(a,a);
	}
	return res;
}
 
inline int Div(int a, int b) {
	return Mul(a,Pow(b,mod-2));
}
 
inline int Cnk(int n, int k) {
	return Div(f[n],Mul(f[k],f[n-k]));
}
 
int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> h >> w >> a >> b;
	f[0] = 1;
	rep(i,1,200050) f[i] = Mul(f[i-1],i);
	int res = Cnk(h+w-2,h-1);
	rep(i,0,b-1) res = Add(res,-Mul(Cnk(h-a+i-1,h-a-1),Cnk(w+a-i-2,a-1)));
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
def solve(string):
    n = int(string)
    if n % 2:
        return "0"
    else:
        ans = 0
        base = 10
        while base <= n:
            ans += n // base
            base *= 5
        return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


struct UnionFind {
  vll rank, par, data;

  UnionFind(ll x = MAX) {
    rank.resize(x + 1, 0);
    par.resize(x + 1, 0);
    data.resize(x + 1, 1);
    rep(i, x + 1) par[i] = i;
  }

  ll root(ll x) {
    if (x != par[x]) par[x] = root(par[x]);
    return par[x];
  }

  ll size(ll x) {
    return data[root(x)];
  }

  void unite(ll a, ll b) {
    ll x = root(a);
    ll y = root(b);
    if (x == y) return;
    if (rank[x] > rank[y]) {
      par[y] = x;
      data[x] += data[y];
    }
    else {
      par[x] = y;
      data[y] += data[x];
      if (rank[x] == rank[y]) rank[y]++;
    }
  }

  bool same(ll a, ll b) {
    return root(a) == root(b);
  }
};


ll a[MAX], b[MAX];

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


  cin >> n >> m;
  rep(i, m) cin >> a[i] >> b[i];
  vll an;
  ans = n * (n - 1) / 2;
  UnionFind u(MAX);
  rrep(i, m) {
    an.pb(ans);
    if (u.same(a[i], b[i])) continue;
    ans -= (u.size(a[i]))*(u.size(b[i]));
    u.unite(a[i], b[i]);
  }

  rrep(i, an.size()) cout << an[i] << endl;



  return 0;
}

Measured memory_bytes: 9076
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 998244353
#define MOD 998244353
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	LLI n, k;
	cin >> n >> k;

	vector<pair<LLI, LLI>> lr;

	vector<LLI> v(n + 1);
	vector<LLI> sum(n + 1);
	v[1] = 1;
	sum[1] = 1;
	REP(i, k)
	{
		LLI l, r;
		cin >> l >> r;
		lr.push_back(make_pair(l, r));
	}
	SORT(lr);

	FOR(i, 2, n + 1)
	{
		REP(j, k)
		{
			LLI l, r;
			l = _max(0, i - lr[j].second - 1);
			r = _max(0, i - lr[j].first);
			v[i] += (sum[r] - sum[l] + MOD) % MOD;
			v[i] %= MOD;
		}
		sum[i] = sum[i - 1] + v[i];
		sum[i] %= MOD;
	}
	cout << v[n] % MOD;
	return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    printf("%.10f ", w * h / 2.0);
    if (((2 * x) == w) && ((2 * y) == h)) {
        printf("1\n");
    }
    else {
        printf("0\n");
    }
    return 0;
}


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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  string N;
  cin >> N;
  int ans = 0;
  if (N.at(0) == '2') {
    ans++;
  }
  if (N.at(1) == '2') {
    ans++;
  }
  if (N.at(2) == '2') {
    ans++;
  }
  if (N.at(3) == '2') {
    ans++;
  }
  cout << ans << endl;
}
  
  
  
  
  
  

Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int gcd(int x, int y){
    return x%y ? gcd(y, x%y) : y;
}

int main(){
    int n; cin >> n;
    vector<int> as(n);
    for(int i=0; i<n; ++i){
        cin >> as[i];
    }
    int ans=as[0];
    for(int i=1; i<n; ++i){
        ans=gcd(ans, as[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
N = input()

if int(N) < 9:
  print(N)
  
elif len(N) == 1 or len(N) == 2:
  print(9)

elif len(N) ==3:
  print(9+int(N)-99)
  
elif len(N) == 4:
  print(9 + 900)
  
elif len(N) == 5:
  print(9+900+int(N)-9999)
  
else:
  print(90909)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N; i++) {
        int u, k; cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v; cin >> v;
            v--;
            G[u].push_back(v);
        }
    }

    queue<int> que;
    vector<int> dist(N, -1);
    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int u = que.front(); que.pop();
        
        for (auto nv : G[u]) {
            if (dist[nv] != -1) continue;

            dist[nv] = dist[u] + 1;
            que.push(nv);
        }
    }

    for (int i = 0; i < N; i++) {
        cout << i + 1 << " " << dist[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    buf=0
    a=list(map(int,input().split()))
    for j in range(m):
        buf+=a[j]*b[j]
    if buf+c>0:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#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){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll w = a * c, x = a * d, y = b * c, z = b * d;
    cout << max({w, x, y, z}) << endl; 
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,a[15];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int p=0;
	for(int i=0;i<n-1;i++)
		p+=a[i];
	if(a[n-1]<p)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    ll n;cin>>n;
    l_l a[2*n];
    rep(i,0,n-1){
        ll b;cin>>b;a[i]=i_i(b,1);
    }
    rep(i,0,n-1){
        ll b;cin>>b;a[i+n]=i_i(b,2);
    }
    sort(a,a+2*n);
    ll ans=1;
    int c=0;
    rep(i,0,2*n-1){
        if(a[i].second==1){
            if(c<0){
                ans=mod(ans*(-c));
            }
            c++;
        }else{
            if(c>0){
                ans=mod(ans*c);
            }
            c--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
// B - Frog 2
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N, K; cin>>N>>K;

	vector<int> h(N); for(int i=0; i<N; i++) cin>>h[i];

	vector<int> dp(N);
	for(int n=1; n<N; n++){
		dp[n] = INT_MAX;
		for(int k=1; k<=min(n,K); k++) dp[n] = min(dp[n], dp[n-k] + abs(h[n] - h[n-k]));
	}
	cout<< dp[N-1] <<endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x;
    cin >> x;

    ll ans = (x/11)*2;
    if (x%11 != 0) {
        ans++;
        if (x%11 > 6) {
            ans++;
        }
    }

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

Measured memory_bytes: 256