<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Conference
{
    class ConferenceExam
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').ToArray();
            var devCount = int.Parse(input[0]);
            var inputLinesCount = int.Parse(input[1]);

            var companies = new List<int>();
            companies.Add(-1);

            var devs = new int[devCount];
            for (int i = 0; i < inputLinesCount; i++)
            {
                var nextCommand = Console.ReadLine().Split(' ');
                var empA = int.Parse(nextCommand[0]);
                var empB = int.Parse(nextCommand[1]);

                var empACompanyIndex = devs[empA];
                var empBCompanyIndex = devs[empB];

                if (empACompanyIndex == 0 && empBCompanyIndex == 0)
                {
                    var nextCompanyIndex = companies.Count;
                    devs[empA] = nextCompanyIndex;
                    devs[empB] = nextCompanyIndex;
                    companies.Add(2);
                }
                else if (empACompanyIndex != 0 && empBCompanyIndex != 0)
                {
                    for (int k = 0; k < devs.Length; k++)
                    {
                        if (devs[k] == empACompanyIndex)
                        {
                            devs[k] = empBCompanyIndex;
                            companies[empBCompanyIndex]++;
                        }
                    }

                    companies[empACompanyIndex] = -1;
                }
                else if (empACompanyIndex == 0 && empBCompanyIndex != 0)
                {
                    devs[empA] = empBCompanyIndex;
                    companies[empBCompanyIndex]++;
                }
                else if (empBCompanyIndex == 0 && empACompanyIndex != 0)
                {
                    devs[empB] = empACompanyIndex;
                    companies[empACompanyIndex]++;
                }
                else
                {
                    throw new ArgumentException();
                }
            }

            foreach (var dev in devs)
            {
                if (dev == 0)
                {
                    companies.Add(1);
                }
            }

            var result = 0;
            var multiplier = devCount;
            for (int nextCompanyIndex = 0; nextCompanyIndex < companies.Count; nextCompanyIndex++)
            {
                if (companies[nextCompanyIndex] <= 0)
                {
                    continue;
                }

                multiplier -= companies[nextCompanyIndex];
                result += companies[nextCompanyIndex] * multiplier;
            }

            //var result = 0;
            //for (int firstIndex = 0; firstIndex < companies.Count; firstIndex++)
            //{
            //    if (companies[firstIndex] < 0)
            //    {
            //        continue;
            //    }

            //    for (int secondIndex = firstIndex + 1; secondIndex < companies.Count; secondIndex++)
            //    {
            //        if (companies[secondIndex] < 0)
            //        {
            //            continue;
            //        }

            //        var nextValue = companies[firstIndex] * companies[secondIndex];
            //        result += nextValue;
            //    }
            //}


            //companies.Sort();

            //var toBreak = false;
            //var initial = devCount;
            //var result = 0;
            //for (int i = 1; i < companies.Count; i++)
            //{
            //    var currentValue = companies[i];
            //    if (currentValue < 0)
            //    {
            //        continue;
            //    }

            //    while (currentValue > 0)
            //    {
            //        initial -= currentValue;
            //        if (initial < 0)
            //        {
            //            initial += currentValue;
            //            result += initial;

            //            toBreak = true;
            //            break;
            //        }

            //        result += initial;
            //        currentValue--;
            //    }

            //    if (toBreak)
            //    {
            //        break;
            //    }
            //}

            Console.WriteLine(result);
        }
    }
}
<commit_msg>conference100<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Conference
{
    class ConferenceExam
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').ToArray();
            var devCount = int.Parse(input[0]);
            var inputLinesCount = int.Parse(input[1]);

            var companies = new List<int>();
            companies.Add(-1);

            var devs = new int[devCount];
            for (int i = 0; i < inputLinesCount; i++)
            {
                var nextCommand = Console.ReadLine().Split(' ');
                var empAIndex = int.Parse(nextCommand[0]);
                var empBIndex = int.Parse(nextCommand[1]);

                var empACompanyIndex = devs[empAIndex];
                var empBCompanyIndex = devs[empBIndex];

                if (empACompanyIndex == 0 && empBCompanyIndex == 0)
                {
                    var nextCompanyIndex = companies.Count;
                    devs[empAIndex] = nextCompanyIndex;
                    devs[empBIndex] = nextCompanyIndex;
                    companies.Add(2);
                }
                else if (empACompanyIndex != 0 && empBCompanyIndex != 0)
                {
                    var reassignedEmployeesCounter = 0;
                    for (int k = 0; k < devs.Length; k++)
                    {
                        if (devs[k] == empACompanyIndex)
                        {
                            devs[k] = empBCompanyIndex;
                            reassignedEmployeesCounter++;
                        }
                    }

                    companies[empBCompanyIndex] += reassignedEmployeesCounter;
                    companies[empACompanyIndex] -= reassignedEmployeesCounter;
                }
                else if (empACompanyIndex == 0 && empBCompanyIndex != 0)
                {
                    devs[empAIndex] = empBCompanyIndex;
                    companies[empBCompanyIndex]++;
                }
                else if (empBCompanyIndex == 0 && empACompanyIndex != 0)
                {
                    devs[empBIndex] = empACompanyIndex;
                    companies[empACompanyIndex]++;
                }
                else
                {
                    throw new ArgumentException();
                }
            }

            foreach (var dev in devs)
            {
                if (dev == 0)
                {
                    companies.Add(1);
                }
            }

            // long == 100
            long result = 0;
            var multiplier = devCount;
            for (int nextCompanyIndex = 1; nextCompanyIndex < companies.Count; nextCompanyIndex++)
            {
                if (companies[nextCompanyIndex] <= 0)
                {
                    continue;
                }

                multiplier -= companies[nextCompanyIndex];
                result += companies[nextCompanyIndex] * multiplier;
            }

            //var result = 0;
            //for (int firstIndex = 0; firstIndex < companies.Count; firstIndex++)
            //{
            //    if (companies[firstIndex] < 0)
            //    {
            //        continue;
            //    }

            //    for (int secondIndex = firstIndex + 1; secondIndex < companies.Count; secondIndex++)
            //    {
            //        if (companies[secondIndex] < 0)
            //        {
            //            continue;
            //        }

            //        var nextValue = companies[firstIndex] * companies[secondIndex];
            //        result += nextValue;
            //    }
            //}


            //companies.Sort();

            //var toBreak = false;
            //var initial = devCount;
            //var result = 0;
            //for (int i = 1; i < companies.Count; i++)
            //{
            //    var currentValue = companies[i];
            //    if (currentValue < 0)
            //    {
            //        continue;
            //    }

            //    while (currentValue > 0)
            //    {
            //        initial -= currentValue;
            //        if (initial < 0)
            //        {
            //            initial += currentValue;
            //            result += initial;

            //            toBreak = true;
            //            break;
            //        }

            //        result += initial;
            //        currentValue--;
            //    }

            //    if (toBreak)
            //    {
            //        break;
            //    }
            //}

            Console.WriteLine(result);
        }
    }
}

{'fraction_non_alphanumeric': 0.1043169340079664, 'fraction_numerical': 0.007535795026375283, 'mean_word_length': 0.9083812654067379, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4611804', 'n_tokens_mistral': 2369, 'n_tokens_neox': 2205, 'n_words': 455}