akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int y[2], m[2], d[2];
    REP(i,2){
        cin >> y[i] >> m[i] >> d[i];
    }
    if(y[0] < y[1]){
        swap(m[0],m[1]);
        swap(d[0],d[1]);
    }
    if(m[0] == m[1] && d[0] == d[1] || y[0] != y[1] && m[0]*100+d[0] < m[1]*100+d[1]){
        cout << abs(y[0]-y[1]) << endl;
    }
    else{
        cout << abs(y[0]-y[1]) + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
require("fs").readFileSync("/dev/stdin","utf8").split('\n').some(function(i){c=i.split(' ');if(c[2])console.log(((c[3]-c[1])/(c[2]-c[0])).toFixed(6)==((c[7]-c[5])/(c[6]-c[4])).toFixed(6)?'YES':'NO')})

Measured memory_bytes: 7908
n = int(input())
taro = 0
hanako = 0
for i in range(n):
    a, b = input().split()
    if a > b:
        taro += 3
    elif a < b:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)


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

using namespace std;

const int N = int(1e5) + 10;
vector<int> g[N];
int h[N];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) cin >> h[i];
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        bool highest = true;
        for (auto v : g[i]) if (h[v] >= h[i]) highest = false;
        ans += highest;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

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

    cin>>h>>n;
    ll A[n];
    f0(i,n)
    {
        cin>>A[i];
    }
    sort(A,A+n,greater<ll>());
    i=0;
    while(h>0 && i<n)
    {
        h-=A[i++];
    }
    if(h<=0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
         cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    if (N < 105) {
        cout << 0 << endl;
        return 0;
    }
    if (N % 2 == 0) N--;
    int res = 0;
    for (int i = 105; i <= N; i+=2) {
        int c = 0;
        for (int j = 1; j <= i/2; j++) {
            if (i % j == 0) c++;
        }
        if (c + 1 == 8) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = getInputInteger(sc);
		int b = getInputInteger(sc);
 
        // programming
		if (a % 2 == 0 || b % 2 == 0) {
			output("Even");
		} else {
            output("Odd");
		}
	}

	public static String getInputString(Scanner sc) {
		return sc.next();
	}

	public static int getInputInteger(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	public static void output(String... params) {
		boolean isInit = true;
		String str = "";
		for (String s : params) {
			if (!isInit) {
				str += " ";
			}
			str += s;
			isInit = false;
		}
		System.out.println(str);
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;
 
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; }
 

bool cmp(P a, P b)
{
    return a.first < b.first;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
 
    int N; 
    ll M;
 
    cin >> N >> M;

    if(N==1)
    {
        cout  << M << endl;
        return 0;
    }
 
    ll ans=0;
    vector<P> div;
    
    for(ll i=2; i*i<=M; i++)
    {
        ll cnt = 0; 
        if(M%i==0)
        {
            cnt=M/i;
            div.push_back(P(i, cnt));
            div.push_back(P(cnt, i));
        }
    }
 
    sort(div.begin(), div.end(), cmp);
    reverse(div.begin(), div.end());
 
    rep(i, div.size())
    {
        if(div[i].second>=N)
        {
            cout << div[i].first << endl;
            return 0;
        }
    }
 
    cout << 1 << endl;
    
 
 
 
 
 
    return 0;
 
 
}

Measured memory_bytes: 256
using System;
class main{
  public static void Main(string[] args){
    int n = int.Parse(Console.ReadLine());
    
    if(n == 1)Console.WriteLine("1");
    else if(n >= 2 && n < 4)Console.WriteLine("2");
    else if(n >= 4 && n < 8)Console.WriteLine("4");
    else if(n >= 8 && n < 16)Console.WriteLine("8");
    else if(n >= 16 && n < 32)Console.WriteLine("16");
    else if(n >= 32 && n < 64)Console.WriteLine("32");
    else if(n >= 64)Console.WriteLine("64");
  }
}


Measured memory_bytes: 27492
#include<cstdio>
#include<cstring>
using namespace std;
const int mo=1e9+7,MAXN=42,MAXS=1<<17|1;
int n,x,y,z;
int f[MAXN][MAXS],g[MAXS][11];
inline void add(int &x,const int &y)
{
	x+=y;
	x>=mo? x-=mo:0;
}
int main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	y+=x,z+=y;
	int s=1<<z;
	for(int i=1;i<=s;i++)
		for(int j=1;j<=10;j++)
		{
			g[i][j]=1;
			if(i==s)
				g[i][j]=s;
			else
			{
				for(int k=0;k<z;k++)
					if((i>>k&1)&&k+j<=z&&!(k<x&&k+j>x)&&!(k<y&&k+j>y))
						g[i][j]|=1<<k+j;
				if(g[i][j]>=s)
					g[i][j]=s;
			}
		}
	f[0][1]=1;
	for(int i=0;i<n;i++)
		for(int j=1;j<=s;j++)
			if(f[i][j])
				for(int k=1;k<=10;k++)
					add(f[i+1][g[j][k]],f[i][j]);
	printf("%d",f[n][s]);
	return 0;
}

Measured memory_bytes: 26752
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        int a     = int.Parse(spl[0]);
        int b     = int.Parse(spl[1]);

        int k = 1;
        int c = 0;
        while (k<b) {
            k--;
            k += a;
            c++;
        }

        return c;
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct city {
	int P, Y, num;
	bool operator < (const city& b) {
		return P == b.P ? Y < b.Y : P < b.P;
	}
};
city C[100010];
string ans[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> C[i].P >> C[i].Y;
		C[i].num = i;
	}
	sort(C, C + M);
	int cnt = 0;
	for (int i = 0; i < M; i++) {
		//cout << C[i].P << " " << C[i].Y << endl;
		string f, e;
		f = to_string(C[i].P);
		e = to_string(cnt + 1);
		while (f.size() < 6) f = '0' + f;
		while (e.size() < 6) e = '0' + e;
		ans[C[i].num] = f + e;
		if (C[i].P != C[i + 1].P) cnt = 0;
		else cnt++;
		//cout << f + e << endl;
	}
	for (int i = 0; i < M; i++) {
		cout << ans[i] << endl;
	}
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> prime(100);
	for(int i=2;i<=n;++i){
		int k=i;
		for(int j=2;j<=n;++j){
			while(k%j==0){
				prime.at(j)++;
				k/=j;
			}
		}
	}
	int num75=0,num25=0,num15=0,num3=0,num5=0;
	rep(i,100){
		if(prime.at(i)+1>=75) num75++;
		if(prime.at(i)+1>=25) num25++;
		if(prime.at(i)+1>=15) num15++;
		if(prime.at(i)+1>=5) num5++;
		if(prime.at(i)+1>=3) num3++;
	}
	cout << num75+num25*(num3-1)+num15*(num5-1)+num5*(num5-1)*(num3-2)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define INF 999999999
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long unsigned int ll;
using namespace std;

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

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


int main()
{
	char c;
	cin >> c;

	c++;

	cout << c << endl;
	
	return 0;
}


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

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

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

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void solve(){
    int h,w;
    cin >> h >> w;
    vector<string> vs(h);
    rep(y,0,h) cin >> vs[y];

    vector<string> ans1=vs,ans2=vs;
    rep(y,0,h){
        ans1[y][0]='#';
        if(y%2==1) continue;
        rep(x,1,w-1) ans1[y][x]='#';
    }
    rep(y,0,h){
        ans2[y][w-1]='#';
        if(y%2==0) continue;
        rep(x,1,w-1) ans2[y][x]='#';
    }

    rep(y,0,h) cout << ans1[y] << endl;
    rep(y,0,h) cout << ans2[y] << endl;
}

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


Measured memory_bytes: 1536
n = int(input())
t = list(map(int,input().split()))
m = int(input())
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    a.append(arr)
for i in a:
    t_new = [j for j in t]
    if i[0] <= n:t_new[i[0]-1] = i[1]
    print(sum(t_new))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <limits>

using namespace std;

int main() {
	int a, b, c,count=0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0)count++;
	}
	cout << count<<"\n";
	return 0;
}



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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BFizzBuzzSum {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        int res = 0;
        FOR(i, 1, N) {
            if (i % 3 == 0) continue;
            if (i % 5 == 0) continue;
            res += i;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BFizzBuzzSum solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3596
/* Sometimes you win , sometimes you learn . */
/* Sometimes you win , sometimes you learn . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
bool isPalindrome(string s){
  string a = s;
  reverse(a.begin() , a.end());
  if(s == a) return true;
  return false;
}
int main(){
    FAST
    string s;
    cin >> s;
    int n = (int) s.size();
    string a = s.substr(0 ,(n - 1) / 2) , b = s.substr((n + 2) / 2);
    if(isPalindrome(a) && isPalindrome(b) && isPalindrome(s)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0 ;
    }
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d = static_cast<double>(a);
    b_d = static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2700
#AOJ
N,W=map(int,input().split())
data=[]
for i in range(N):
    v,w=map(int,input().split())
    data.append((v,w))
ans={0:0}
for i in data:
    ans1=ans.copy()
    for v in ans:
        if i[1]+v in ans.keys():
            ans1[i[1]+v]=max(ans[i[1]+v],ans[v]+i[0])
        else:
            ans1[i[1]+v]=ans[v]+i[0]
    ans=ans1
maxv=0
for i in ans:
    if i<=W and ans[i]>maxv:
        maxv=ans[i]
print(maxv)


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

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    long[] nums = new long[n];
    for(int i = 0; i < n; i++) {
      nums[i] = sc.nextLong();
    }
    Arrays.sort(nums);
    double sum = 0;
    int[] occurs = new int[a];
    long count = 0;
    for(int i = n-1; i >= n-a; i--) {
      sum += nums[i];
    }
    sum /= a;
    boolean flag = true;
    int index = -1;
    if(nums[n-1] != nums[n-a]) {
      int counts = 0;
      for(int i = n-1; i >= 0; i--) {
        if(nums[i] == nums[n-a]) {
          if(flag) {
            index = i+1;
            flag = false;
          }
          counts++;
        }
      }
      count = combinations(counts, a-(n-index));
    } else {
      int l = 0;
      for(int i = n-1; i >= 0; i--) {
        if(nums[i] == nums[n-1]) {
          l++;
        }
      }
      for(int i = a; i <= b; i++) {
        if(nums[n-1] == nums[n-i]) {
          count += combinations(l, i);
        }
      }
    }
    System.out.println(sum);
    System.out.println(count);
  }
  
  private static long combinations(int n, int k) {
    long ans = 1;
    for(int i = 1; i <= k; i++) {
      ans *= n-k+i;
      ans /= i;
    }
    return ans;
  }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 200000 + 10;
double A[MAX_N];

int main2() {
  int N = nextInt();
  int K = nextInt();

  REP(i, N) {
    double P = nextInt();
    A[i] = (P+1) / 2.0;
  }
  double ans = 0;
  double cur = 0;
  for (int i = 0; i < N; i++) {
    cur += A[i];
    if (i >= K) cur -= A[i-K];
    chmax(ans, cur);
  }
  printf("%.10f\n", ans);
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1792
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque

#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp
		


n=input1()
s=[]
for i in range(n):
	s.append(str(input()))
str_dict={"".join(sorted(s[0])):0}
count=0
for i in range(1,n):
	now_d="".join(sorted(s[i]))
	if now_d in str_dict:
		str_dict[now_d]+=1
		count+=str_dict[now_d]
	else:
		str_dict[now_d]=0
print(count)














Measured memory_bytes: 34300
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<< char(s1[0]-32) << char(s2[0]-32) << char(s3[0]-32) <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	double a, b, C;
	cin >> a >> b >> C;
	C = C / 180 * Pi;
	double s = a * b / 2 * sin(C);
	double c = sqrt(a * a + b * b - 2 * a * b * cos(C));
	double h = s * 2 / a;
	printf("%.15f\n%.15f\n%.15f\n", s, a + b + c, h);
	return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;
const int Nmax=410;
int n,m;
vector<pi> g[Nmax];
bool vis[Nmax][Nmax];

bool dfs(int v,int w,bool (&u)[Nmax]){
	if(u[v])return true;
	u[v]=true;
	for(auto e:g[v]){
		if(e.second>=w)break;
		if(dfs(e.first,e.second,u))return true;
	}
	return false;
}

signed main(){
	n=read(),m=read();
	REP(i,m){
		int x=read()-1,y=read()-1;
		g[x].PB(pi(y,i));
		g[y].PB(pi(x,i));
	}
	REP(i,n)
		if(dfs(i,inf-1,vis[i]))
			memset(vis[i],-1,sizeof(vis[i]));
	int ans=0;
	REP(i,n)FOR(j,i+1,n){
		bool ok=true;
		REP(k,n)if(vis[i][k]&&vis[j][k])ok=false;
		ans+=ok;
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 4992
/* ファイル名：ITP1_7_D.c	*/
/* 内容：n×m  の行列 A と m×l の行列 B を入力し、それらの積である n×l の行列 C を出力する	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:n×l の行列 C を出力する	*/
int main( void )
{
	/* 内部変数定義	*/
	int n;	/* 取得する行(列)数1	*/
	int m;	/* 取得する行(列)数2	*/
	int l;	/* 取得する行(列)数3	*/
	int A[100][100];	/* 行列A	*/
	int B[100][100];	/* 行列B	*/
	
	/* 処理・出力	*/
	int i;	/* ループ用変数1			*/
	int j;	/* ループ用変数2			*/
	int k;	/* ループ用変数3			*/
	long int C[100][100];	/* 行列C	*/
	
	scanf("%d %d %d",&n,&m,&l);	/* n,m,lの取得	*/
	
	/* Aの入力	*/
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d",&A[i][j]);
		}
	}
	
	/* Bの入力	*/
	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			scanf("%d",&B[i][j]);
		}
	}
	
	/* 行列Cの初期化	*/
	for(int i = 0;i < n;i++){
		for(int j = 0;j < l;j++){
			C[i][j] = 0;
		}
	}
	
	/* Cの計算	*/
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			for(k = 0; k < l; k++){
				C[i][k] += (long)A[i][j] * (long)B[j][k];	/* A*Bの積を求める	*/
			}
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			printf("%ld",C[i][j]);
			/* 行の最後の要素ではない場合	*/
			if(j != l - 1){
				printf(" ");	/* 要素を空白で区切る	*/
			}
			/* 行の最後の要素の場合	*/
			else{
				/* 処理なし	*/
			}
		}
		printf("\n");	/* 行毎に改行	*/
	}
	
	return 0;
}




Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A=N%8;
    ll B=N/8;
    vl C;
    if(N==3){
        cout<<2<<" "<<5<<" "<<63<<endl;return 0;
    }
    if(N==4){
        cout<<2<<" "<<5<<" "<<20<<" "<<63<<endl;return 0;
    }
    if(A==0)C={};
    if(A==1)C={6};
    if(A==2)C={6,12};
    if(A==3)C={2,4,6};
    if(A==4)C={2,4,6,12};
    if(A==5)C={3,8,9,10,12};
    if(A==6)C={2,3,4,8,9,10};
    if(A==7)C={2,3,4,8,9,10,12};
    for(auto p: C)cout<<p<<" ";
    C={2,3,4,6,8,9,10,12};
    if(B==2500){
        for(ll i=0;i<B;++i)
            for(ll j=0;j<8;++j)cout<<12*i+C[j]<<" ";
            cout<<endl;return 0;
    }
    for(ll i=0;i<B;++i){
        for(ll j=0;j<8;++j)cout<<12*(i+1)+C[j]<<" ";
    }cout<<endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF (1e9)
#define M 666001
using namespace std;
int P,d[6],c[6]={1,5,10,50,100,500};
int f,ans,sum,z[M];

int cal(int x){
  int res=0;
  for(int i=5;i>=0;i--)
    res+=x/c[i],x=x%c[i];
  return res;
}

int cal2(int x){
  int res=0;
  for(int i=5;i>=0;i--){
    int p=min(x/c[i],d[i]);
    res+=p;
    if(p)x-=p*c[i];
  }
  if(!x)return res;
  return -1;
}

int main(){
  for(int i=0;i<M;i++)
    z[i]=cal(i);
  while(1){
    cin>>P;
    f=sum=0;
    for(int i=0;i<6;i++){
      cin>>d[i],sum+=d[i]*c[i];
      if(d[i])f=1;
    }
    if(!f)break;
    ans=INF;
    for(int i=P;i<=sum;i++){
      int r=cal2(i);
      if(r!=-1)ans=min(ans,r+z[i-P]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

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

Measured memory_bytes: 512
#include <iostream>

using namespace std;

//typedef unsigned long long ull;

int main()
{ //double c,a,b;
    long long int a;
    float b;
    cin>>a>>b;
  //c=(a*(b*100+0.1))/100;
    cout<<(a*(int)(100*b+.5))/100<<endl;
return 0;


}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<N; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    int N;
    cin >> N;
    print(N * N * N);
}

int main() {

    solve();
    return 0;
}

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

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

#define rrep(i,n) for(int i =n; i >=0; --i)

#define rep_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

const ll MOD = 1000000007;

const  long double PI=(acos(-1));

const  long double EPS=0.0000000001;

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

    for (int i = 0; i < s[i] != '\0' ;++i){
        cout << "x";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

bool is_valid(int h,int w,int x,int y){
    return 1<x&&x<w&&1<y&&y<h;
}

void run(){
    int h,w,n;
    cin>>h>>w>>n;
    vi a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    map<pi,int> mp;
    int dx[]={0,0,1,1,1,0,-1,-1,-1},dy[]={0,-1,-1,0,1,1,1,0,-1};
    rep(i,n){
        rep(j,9){
            int nx=b[i]+dx[j],ny=a[i]+dy[j];
            if(is_valid(h,w,nx,ny)){
                mp[{nx,ny}]++;
            }
        }
    }
    vi ans(10);
    for(auto p:mp)ans[p.se]++;
    ans[0]=(h-2)*(w-2)-mp.size();
    rep(i,10)cout<<ans[i]<<endl;
}

Measured memory_bytes: 58112
# -*- coding: utf-8 -*-
import sys
from itertools import combinations
# 標準入力を受け取る
n = int(input())
### 奇数処理
if n % 2 == 1:
    ### NGな組み合わせは奇数の時{i,N-i}
    ### (1，N-1),(２，N-2),(3，N-3)・・・(i，N-i)・・・,(N-1,1),N
    ### NGな組み合わせは全部でN個、最後はN単独なので除外(-1)。半分は入れ替わっただけで同じ組み合わせなので半分。
    ### NGな組み合わせの数を計算する
    # ng = (n-1)/2
    # m = n(n-1)/2 - ng
    ## 上の式を整理して下記
    m = (n-1)*(n-1)/2
    print(int(m))
    ### グラフを表示する
    for i, j in combinations(range(1,n+1),2):
        if (i + j) != n:
            print(i, j)
### 偶数処理
else:
    ### NGな組み合わせは偶数の時{i,N-i+1}
    ### (1,N),(2,N-1),(3,N-2)・・・(i，N-i+1)・・・,(N-1,2),(N,1)
    ### NGな組み合わせは全部でN個、半分は入れ替わっただけで同じ組み合わせなので半分。
    ### NGな組み合わせの数を計算する
    #ng = n/2
    #m = n(n-1)/2 - ng
    ## 上の式を整理して下記
    m = (n-2)*n/2
    print(int(m))
    ### グラフを表示する
    for i, j in combinations(range(1,n+1),2):
        if (i + j) != n+1:
            print(i, j)


Measured memory_bytes: 3612
import collections
import functools

import sys

input = lambda: sys.stdin.readline()


def cin_int_list():
    return [int(x) for x in input().split()]


def cin_int_iter():
    return (int(x) for x in input().split())


def cin_int():
    return int(input())


def cout_int_iter(a):
    print(' '.join(map(str, a)))


def iota(n, start=0):
    return list(range(start, n))


def cin_digits_list():
    return [ord(x) - ord('0') for x in input()]


def main():
    n, m, x = cin_int_iter()

    c = [0] * n
    a = [[0] * m for _ in range(n)]

    cnt = collections.Counter()

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

        c[i] = tmp[0]

        for alg, level in enumerate(tmp[1:]):
            a[i][alg] = level

            cnt[alg] += level

    for alg in range(m):
        if cnt[alg] < x:
            print('-1')
            return

    mem = {}

    def search(i, read, levels, cost):
        if all(level >= x for level in levels):
            return cost

        if i == n:
            return float('inf')

        key = (i, read)
        if key in mem:
            return mem[key]

        ret = min(
            search(i + 1, read | 1 << i, [levels[j] + a[i][j] for j in range(m)], cost + c[i]),
            search(i + 1, read, levels, cost)
        )

        mem[key] = ret

        return ret

    print(search(0, 0, [0 for i in range(m)], 0))


main()


Measured memory_bytes: 73348
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){for(var r=e[0],n=r.length,t=new Array(n).fill(0),o=[],u=0;u<n-1;u++)"R"==r[u]&&"L"==r[u+1]&&o.push(u);for(var i=0,f=0,l=o[0],c=0;c<n;c++)c!=l?"R"==r[c]?(l-c)%2==0?t[l]+=1:t[l+1]+=1:(c-i)%2==0?t[i]+=1:t[i+1]+=1:(t[c]+=1,i=l,l=o[++f]);console.log(t.join(" "))}},function(e,r){e.exports=require("fs")}]);

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll m, n, ansx, ansy;
  map<P, bool> ch;
  while(cin >> m, m) {
    ansx = 0, ansy = 0;
    P s[m];
    ch.clear();
    rep(i, m) cin >> s[i].first >> s[i].second;
    cin >> n;
    P h[n];
    rep(i, n) {
      cin >> h[i].first >> h[i].second;
      ch[h[i]] = true;
    }
    rep(i, n) {
      ll j;
      ll xx = h[i].first - s[0].first;
      ll yy = h[i].second - s[0].second;
      for(j = 0; j < m; j++) {
        P p = P(s[j].first + xx, s[j].second + yy);
        if(!ch[p]) break;
        if(j == m - 1) ansx = xx, ansy = yy;
      }
    }
    cout << ansx << " " << ansy << endl;
  }
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1)return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

void solve()
{
  ll n, m, a, b;
  cin >> n >> m;
  vector<P> br(m);
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b;
    a--; b--;
    br[i] = P(a, b);
  }

  reverse(br.begin(), br.end());
  UnionFind uf(n);

  stack<ll> ans;
  ll e_cnt = n * (n - 1) / 2;
  for(const auto& p : br)
  {
    ans.push(e_cnt);
    if (!uf.same(p.first, p.second))
    {
      e_cnt -= uf.size(p.first) * uf.size(p.second);
      uf.unite(p.first, p.second);
    }
  }

  while(!ans.empty())
  {
    cout << ans.top() << endl;
    ans.pop();
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

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



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<char> all;
    for (char c = 'A'; c <= 'Z'; c++) {
        all.push_back(c);
    }
    string s; cin >> s;
    for (char c : s) {
        int i = (int) (c - 'A');
        cout << all[(i + n) % 26];
    }
    cout << "\n";
}


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
def calc_possible_alter(upper, middle, lower):
  cnt = 0
  for m in middle:
    # choose a part that is smaller than m from upper
    # choose a part that is larger than m from lower
    cnt += bisect_left(upper, m) * (len(lower) - bisect_right(lower, m))
  return cnt


N = int(input())
upper_part = sorted(list(map(int, input().split())))
middle_part = sorted(list(map(int, input().split())))
lower_part = sorted(list(map(int, input().split())))

print(calc_possible_alter(upper_part, middle_part, lower_part))


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w, a, b; cin>>h>>w>>a>>b;
	rep(i, h){
		if (i>=b){
			rep(j, w){
				if (j>=a){
					cout << 0;
				}else{
					cout << 1;
				}
			}
		}else{
			rep(j, w){
				if (j>=a){
					cout << 1;
				}else{
					cout << 0;
				}
			}
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>

using namespace std;

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

	vector<vector<int>> g(n);
	int uu, vv;
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		g[u - 1].push_back(v - 1);
		g[v - 1].push_back(u - 1);
		uu = u - 1;
		vv = v - 1;
	}

	vector<bool> used(n);
	
	function<void(vector<int> &, int)> dfs = [&](vector<int> &path, int u) {
		path.push_back(u);
		used[u] = true;
		for (int v : g[u]) {
			if (!used[v]) {
				dfs(path, v);
				break;
			}
		}
	};

	used[uu] = true;
	used[vv] = true;

	vector<int> pathA, pathB;
	dfs(pathA, uu);
	dfs(pathB, vv);

	reverse(pathA.begin(), pathA.end());

	cout << pathA.size() + pathB.size() << endl;

	for (int e : pathA) {
		cout << e + 1 << ' ';
	}
	for (int e : pathB) {
		cout << e + 1 << ' ';
	}
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, x;
	cin >> n >> x;
	int ans = 1, now = 0;
	while (n--) {
		int l;
		cin >> l;
		now += l;
		if (now <= x) ans++;
		else break;
	}
	cout << ans << "\n";
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    string s; cin>>s;
    int n=s.size();
    int ans=1e9;
    for(int i=0; i+2<n; i++){
        string t=s.substr(i, 3);
        int m=stoi(t);
        int num=abs(753-m);
        chmin(ans, num);
    }
    cout << ans << endl;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// sieve(upto) returns the list of prime numbers up to upto.
//   Size: upto(1e8).size() ... 5.7e6,  upto(1e9).size() ... 5.1e7
//   Performance: upto(1e8) ... 0.7sec,   upto(1e9) ... 9.2sec
vector<int> sieve(int upto) {
  vector<int> res;
  vector<bool> tbl(upto+1);
  ll lim = (int)(sqrt((double)upto)) + 1;
  for (int x = 2; x <= upto; x++) {
    if (tbl.at(x))  continue;
    res.push_back(x);
    if (x > lim)  continue;
    for (int y = x * 2; y <= upto; y += x) tbl.at(y) = true;
  }
  return res;
}

/*
  Prime Factorization
    Two versions:
      - prfac(n)
      - prfac(n, primes)
 */

vector<pair<ll, int>> prfac(ll n, const vector<int>& primes) {
  //      primes should contain prime numbers at least up to sqrt(n)
  vector<pair<ll, int>> res;
  ll x = n;
  for (ll p : primes) {
    if (x == 1)  break;
    if (p * p > x)  break;
    if (x % p != 0)  continue;
    int c = 1;
    x /= p;
    while (x % p == 0) {
      c += 1;
      x /= p;
    }
    res.push_back(make_pair(p, c));
  }
  if (x != 1)  res.push_back(make_pair(x, 1));
  return res;
}

vector<pair<ll, int>> prfac(ll n) {
  return prfac(n, sieve((int)(sqrt((double)n)) + 1));
}

/*
    List of divisors
      - getDivisors(n)
    Note: the results are NOT sorted
 */

// gdsub ... aux function used in getDivisors()
vector<ll> gdsub(int i, int n, auto fs) {
  if (i == n) { return vector<ll>({1}); }
  auto part = gdsub(i+1, n, fs);
  ll p  = fs.at(i).first;
  int r = fs.at(i).second;
  ll pp = p;    // pp = p^m, for m \in [1, r]
  int partOrigLen = part.size();
  for (int m = 1; m <= r; m++) {
    for (int j = 0; j < partOrigLen; j++) {
      part.push_back(pp * part.at(j));
    }
    pp *= p;
  }
  return part;
}

vector<ll> getDivisors(ll n) {
  auto fs = prfac(n);
  return gdsub(0, fs.size(), fs);
}


// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);
  
  ll N; cin >> N;
  auto ds = getDivisors(N);
  ll answer = LLONG_MAX;
  for (ll d : ds) {
    ll e = N / d;
    answer = min(answer, d + e - 2);
  }
  cout << answer << endl;

  return 0;
}



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

struct UnionFind {
	vector<int> p, s;
	
	UnionFind(int n) : p(n), s(n) {
		for (int i = 0; i < n; i++) {
			p[i] = i;
			s[i] = 1;
		}
	}
	
	int root(int x) {
		return p[x] == x ? x : p[x] = root(p[x]);
	}
	
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (s[x] < s[y]) swap(x, y);
		s[x] += s[y];
		p[y] = x;
	}
	
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	
	int size(int x) {
		return s[root(x)];
	}
};

int main() {
	ll n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	
	UnionFind uf(n);
	vector<ll> ans(m);
	ans[m - 1] = (ll)n * (n - 1) / 2;
	for (int i = m - 1; i > 0; i--) {
		ans[i - 1] = ans[i];
		if (!uf.same(a[i], b[i])) {
			ll as = uf.size(a[i]);
			ll bs = uf.size(b[i]);
			ans[i - 1] = ans[i] - as * bs;
			uf.unite(a[i], b[i]);
		}
	}
	
	rep(i, m) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 5584
h, w = map(int, input().split())
ans = ''
for i in range(h):
  s = list(map(str, input().split()))
  if 'snuke' in s:
    ans += str(i + 1)
    a = s.index('snuke') + 1
    abc = {1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'F', 7: 'G', 8: 'H', 9: 'I', 10: 'J', 11: 'K', 12: 'L', 13: 'M', 14: 'N', 15: 'O', 16: 'P', 17: 'Q', 18: 'R', 19: 'S', 20: 'T', 21: 'U', 22: 'V', 23: 'W', 24: 'X', 25: 'Y', 26: 'Z'}
    ans = abc[a] + ans
print(ans)

Measured memory_bytes: 9216
#include <cstdio>
#include <algorithm>

using namespace std;

int P[105];

int main(){

    int X,N;
    scanf("%d%d",&X,&N);
    for(int i=0;i<N;i++) scanf("%d",&P[i]);

    sort(P,P+N);

    for(int i=0;;i++){
        if (!binary_search(P,P+N,X-i)) {printf("%d\n",X-i);break;}
        else if (!binary_search(P,P+N,X+i)) {printf("%d\n",X+i);break;}
        
    }

    return 0;
}

Measured memory_bytes: 1736