akhauriyash/Code-Regression huggingface dataset:
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

long long A,B;

bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}

long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int S,W;cin >> S >> W;
    if(W >= S){
        cout << "unsafe" << endl;
        return 0;
    }
    else {
        cout << "safe" << endl;
        return 0;
    }

    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 3588
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        var k = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        long count = 0;
        if (k % 2 == 0)
        {
            //2の場合
            var ns = s + s;
            long count2 = 0;
            char[] c = ns.ToCharArray();
            for (int i = 1; i < c.Length; i++)
            {
                if (c[i] == c[i - 1])
                {
                    c[i] = '?';
                    count2++;
                }
            }

            //4の場合
            ns = s + s + s + s;
            c = ns.ToCharArray();
            long count4 = 0;
            for (int i = 1; i < c.Length; i++)
            {
                if (c[i] == c[i - 1])
                {
                    c[i] = '?';
                    count4++;
                }
            }

            if (k == 2)
            {
                count = count2;
            }
            else
            {
                count = (count4 - count2) * ((k -1)/ 2) + count2;
            }
        }
        else
        {
            //1の場合
            char[] c = s.ToCharArray();
            long count1 = 0;
            for (int i = 1; i < c.Length; i++)
            {
                if (c[i] == c[i - 1])
                {
                    c[i] = '?';
                    count1++;
                }
            }

            //3の場合
            var ns = s + s + s;
            c = ns.ToCharArray();
            long count3 = 0;
            for (int i = 1; i < c.Length; i++)
            {
                if (c[i] == c[i - 1])
                {
                    c[i] = '?';
                    count3++;
                }
            }

            if (k == 1)
            {
                count = count1;
            }
            else
            {
                count = (count3 - count1) * (k / 2) + count1;
            }
        }


        // 出力
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001; //check the limits, dummy


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

    ll n, m, c;
    cin >> n >> m >> c;
    vl b (m);
    FOR (i, 0, m)  cin >> b[i];

    ll ans = 0;
    FOR (i, 0, n) {
        ll can = c;
        FOR (j, 0, m) {
            ll x;
            cin >> x;
            can += x * b[j];
        }
        ans += (can > 0);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k=nxt();
    if(k<=9)
    {
        cout<<k<<endl;
        return 0;
    }
    ll cur=10;
    k-=10;
    while(k>0)
    {
        k--;
        string s=to_string(cur);
        int n=s.size();
        int i=n-1;
        while(i>=0&&s[i]=='9')
            i--;
        if(i<0)
        {
            cur++;
            continue;
        }
        while(i-1>=0&&s[i-1]<s[i])
            i--;
        s[i]=s[i]+1;
        i++;
        while(i<n)
        {
            s[i]=max(48,s[i-1]-1);
            i++;
        }
        ll temp=0;
        for(int i=0;i<n;i++)
            temp=temp*10+s[i]-48;
        cur=temp;
    }
    cout<<cur<<endl;
   
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#define int long long
using namespace std;

struct Node {
    int x, y;
} a[233];

int n, num, ans = 0x7fffffffffffffff;

int read() {
    int ret, f = 1;
    char ch;
    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);
    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');
    return ret * f;
}

void print(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

bool cmp(Node a, Node b) {
    return a.x < b.x;
}

signed main() {
    n = read(), num = read();
    for(int i = 1; i <= n; ++i) a[i].x = read(), a[i].y = read();
    std::sort(a + 1, a + n + 1, cmp);
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j) {
            int tmx = std::max(a[i].y, a[j].y),
                tmn = std::min(a[i].y, a[j].y);
            for(int k = 1; k <= n; ++k) {
                if(a[k].y > tmx || a[k].y < tmn) continue;
                int cnt = 0;
                for(int l = k; l <= n; ++l) {
                    if(a[l].y > tmx || a[l].y < tmn) continue;
                    if(++cnt >= num) ans = min(ans, (tmx - tmn) * (a[l].x - a[k].x));
                }
            }
        }
    print(ans);
    return 0;
}

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

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

#define sz(a) int((a).size())
#define pb push_back
#define all(C) C.begin(),C.end()
#define fai(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define repl(i,a,b) for(ll i=a; i<=b; i++)
#define fal(i,n) for(ll i=0; i<n; i++)
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
// *it or it->second.first

ll getSum(ll n) 
 { 
    ll sum; 
  
    for (sum = 0; n > 0; sum += n % 10, n /= 10); 
  
    return sum; 
 } 


int main()
{	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);

    int t;
    cin>>t;
    map<int,int> mp;
    while(t--){
        int k;
        cin>>k;
        mp[k]++;
    }
    int ans=0;
    for(auto it: mp){
       
        if(it.second > it.first){
            ans+= it.second-it.first;
        }
        else if(it.second< it.first){
            ans+= it.second;
        }
        
    }
    cout<<ans;
   
    return 0;
}


Measured memory_bytes: 8096
def main():
    A, B, K= [int(x) for x in input().split()]
    A -= K
    left = A
    if left < 0:
        A = 0
    else:
        print(A, B)
        return

    B += left
    if B < 0:
        B = 0

    print(A, B)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
ar = [0,0,0,0]

arr = gets.chomp!.split(" ")
ar[arr[0].to_i-1] += 1
ar[arr[1].to_i-1] += 1

arr = gets.chomp!.split(" ")
ar[arr[0].to_i-1] += 1
ar[arr[1].to_i-1] += 1

arr = gets.chomp!.split(" ")
ar[arr[0].to_i-1] += 1
ar[arr[1].to_i-1] += 1

flag = 1
ar.each do|i|
    if i == 3 || i == 0 then
        flag = 0
        break
    end
end

if flag == 1 then puts "YES"
else puts "NO"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    char c;
    cin>>c;
    for(char i=c+1;i<=c+1;++i) {
        cout<<i<<endl;
    }
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a,int64_t b) {
    if(a < b) {
        swap(a,b);
    }
    while(b != 0) {
        int64_t tmp = a;
        a = b;
        b = tmp % b;
    }
    return a;
}
int64_t lcm(int64_t a,int64_t b) {
    return a * b / gcd(a,b);
}
int64_t func(int64_t n,int64_t m,int64_t l) {
    if(n == -1) {
        return 0;
    }else {
        return n - ((n / m + 1) + (n / l + 1) - (n / lcm(m , l) + 1));
    }
}
int main() {
    int64_t a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << func(b,c,d) - func(a - 1,c,d) << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int n =scane.nextInt();

		int[] a = new int[n];

		for(int i =0; i <n; i++){
			a[i] = scane.nextInt();
		}

		for(int i =a.length-1; i>=0; --i){
			if(i !=0){
			System.out.print(a[i]+" ");
			}else{
				System.out.println(a[i]);
			}
		}

	}
}

Measured memory_bytes: 26392
#include<stdio.h>
int main(){
  int n,x[20]={},d[100001]={},e[100001]={},i,j,t,k,r=0;
  scanf("%d",&n);
  for(t=1,k=0;t<100001;t*=6){x[k]=t;k++;}for(t=9;t<100001;t*=9){x[k]=t;k++;}
  d[0]=1;
  while(1){
    r++;
    for(i=0;i<100001;i++)e[i]=0;
    for(i=0;i<100001;i++)if(d[i])for(j=0;j<k;j++)if(i+x[j]<100001)e[i+x[j]]=1;
    for(i=0;i<100001;i++)d[i]=e[i];
    if(d[n]){printf("%d",r);return 0;}
  }
}


Measured memory_bytes: 2500
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int,int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, l;
    cin >> n >> l;
    int p[n];
    for(int i = 0; i < n; i++) {
        p[i] = i + l;
    }
    int sum = 0;
    for(int i = 0; i < n; i++) {
        sum += p[i];
    }
    int mn = INT64_MAX;
    for(int i = 0; i < n; i++) {
        if(abs(p[i]) < abs(mn)) {
            mn = p[i];
        } 
    }
    cout << sum - mn << "\n";
}

Measured memory_bytes: 256
L = list(map(int, input().split()))
L.sort()

ans = L[2]-L[1]
L[0] = L[0]+ L[2]-L[1]
L[1] = L[2]
if L[0]%2 == L[2]%2:
    ans += (L[2]-L[0])//2
else:
    ans += 1 + (L[2]+1-L[0])//2
print(ans)


Measured memory_bytes: 61960
n = int(input())
a = list(map(int, input().split()))
a.sort()

cnt = 0
for i in range(n):
    if a[i] == a[0]:
        cnt = i+1
    else:
        break

if a[-1] - a[0] > 1:
    print('No')
    exit()
elif a[-1] - a[0] == 1:
    actual = a[-1]
    if actual >= n:
        print('No')
    elif cnt <= actual - 1 and actual <= cnt  + (n - cnt) // 2:
        print('Yes')
    else:
        print('No')
    exit()
elif a[-1] - a[0] == 0:
    solve = False
    actual = a[0]
    if n >= actual * 2 or n-1 == actual:
        solve = True
    if solve:
        print('Yes')
    else:
        print('No')
    exit()
else:
    print('No')

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

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

const long long INF = 1LL << 60;

int main()
{
    string S, T;
    cin >> S >> T;

    int ans = -1;

    rep(i, S.size()) {
        int len = i + (int)T.size();
        if (len > S.size()) continue;
        int index = 0, cnt = 0, lex = 0;
        repd(j, i, len) {
            if (S[j] == '?' || S[j] == T[index]) cnt++;
            if (S[j] == T[index]) lex++;
            index++;
        }
        if (cnt == (int)T.size()) ans = i;
        if (lex == (int)T.size()) {
            ans = i;
            break;
        }
    }

    //cout << ans << endl;

    if (ans != -1) {
        rep(i, S.size()) {
            if (ans <= i && i - ans < (int)T.size()) S[i] = T[i - ans];
            else if (S[i] == '?') S[i] = 'a';
        }
    }
    else {
        S = "UNRESTORABLE";
    }

    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Fri Dec 28 15:16:32 2018
//
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)

	a, b := arr[len(arr)-1], 0
	mid := float64(a) / 2.0
	dist := math.Abs(mid - float64(arr[0]))
	for i := range arr {
		d := math.Abs(mid - float64(arr[i]))
		if d < dist {
			dist = d
			b = arr[i]
		}
	}
	fmt.Println(a, b)
}


Measured memory_bytes: 5504
#include<stdio.h>
int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	
	
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
	printf("%d %d %f\n",d,r,f);
	
	
	 return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define p pair<int,int>
template<class T> void chmax(T& a, T b){if(a < b) a = b;}
template<class T> void chmin(T& a, T b){if(a > b) a = b;}
string S, ans;
int main(){
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] != 'B') ans += S[i];
        else if(ans.size() != 0) ans.erase(ans.end() - 1, ans.end());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;
//互いに最も差の大きいものをとればよい??
// -> 相手がべらぼうに多い
//差がない場合は、一番大きいもの?
//50 50 
//60 0


int main(){
    ll N;
    cin >> N;
    vector <ll> a(N);
    vector <ll> b(N);
    vector <ll> ab(N);

    REP(i,N)
    {
        cin >> a[i] >> b[i];
        ab[i] = a[i] + b[i];
    }
    sort(ab.rbegin(), ab.rend());

    ll res = 0;
    for(int i = 0; i < N; i += 2)
    {
        res += ab[i];
    }
    for(int i = 0; i < N; ++i)
    {
        res -= b[i];
    }
    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 2560
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  int h, w, a, b; readV(h, w, a, b);

  auto fact = new mint[](h+w+1);
  fact[0] = 1;
  foreach (i; 1..h+w+1) fact[i] = fact[i-1]*i;
  auto invFact = new mint[](h+w+1);
  invFact[h+w] = fact[h+w].inv;
  foreach_reverse (i; 1..h+w+1) invFact[i-1] = invFact[i]*i;

  auto r = mint(0);
  foreach (k; 0..w-b) {
    auto c1 = fact[(h-a-1)+(b+k)]*invFact[h-a-1]*invFact[b+k];
    auto c2 = fact[(a-1)+(w-1-b-k)]*invFact[a-1]*invFact[w-1-b-k];
    r += c1*c2;
  }

  writeln(r);
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }

  pure auto opBinary(string op: "/")(FR r) { return FR(mod(vl*r.inv.vi)); }
  pure auto opBinary(string op: "/")(int r) { return opBinary!op(FR(r)); }
  ref auto opOpAssign(string op: "/")(ref FR r) { vi = mod(vl*r.inv.vi); return this; }
  ref auto opOpAssign(string op: "/")(int r) { return opOpAssign!op(FR(r)); }

  pure auto inv()
  {
    int x = vi, a, b;
    exEuclid(x, m, a, b);
    return FR(mod(a));
  }
}

pure T exEuclid(T)(T a, T b, ref T x, ref T y)
{
  auto g = a;
  x = 1;
  y = 0;
  if (b) {
    g = exEuclid(b, a%b, y, x);
    y -= a/b*x;
  }
  return g;
}


Measured memory_bytes: 4220
class UnionFind():
    def __init__(self,n):
        self.n = n
        #self.root < 0 であれば根で、かつ絶対値が要素数。
        self.root = [-1]*(n+1)
        self.rank = [0]*(n+1)

    def findroot(self,x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.findroot(self.root[x])
            return self.root[x]
    
    def unite(self,x,y):
        x = self.findroot(x)
        y = self.findroot(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x]==self.rank[y]:
                self.rank[x] += 1
    
    def groupjudge(self,x,y):
        return self.findroot(x)==self.findroot(y)
        
    def count(self,x):
        return -self.root[self.findroot(x)]


## abc120 d

def combination(n,m):
    res = 1
    if m > n//2:
        m = n-m
    for i in range(m):
        res *= (n-i)
    for i in range(m):
        res //= (i+1)
    return res


n, m = map(int,input().split())
a = []
b = []
for i in range(m):
    c,d = map(int,input().split())
    a.append(c)
    b.append(d)
a = a[::-1]
b = b[::-1]

ref = UnionFind(n)
unrun = combination(n,2)
out = [unrun]*m

for i in range(m-1):
    if ref.groupjudge(a[i],b[i]):
        out[i+1] = out[i]
    else:
        ac = ref.count(a[i])
        bc = ref.count(b[i])
        ref.unite(a[i],b[i])
        out[i+1] = out[i] - ac*bc
        if c == n:
            break

for i in out[::-1]:
    print(i)



Measured memory_bytes: 18512
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

vector<long long> PF(long long N){
    vector<long long> res;
    for(long long i=2;i*i<=N;i++){
        if(N%i==0){
            res.push_back(i);
            N/=i;
            i--;
        }
    }
    res.push_back(N);
    return res;
}

long long N;
long long ans;
void g(long long a,long long n){
    //cout<<a<<" "<<n<<endl;
    while(n%a==0){
        n/=a;
    }

    if(n%a==1){
        ans++;
    }
    return;
}

void f(map<long long,int>& m,long long a,long long b){
    if(m.upper_bound(b)==m.end()){
        for(int i=0;i<=m[b];i++){
            if(a!=1){
                g(a,N);
            }
            a*=b;
        }
        return;
    }else{
        for(int i=0;i<=m[b];i++){
            auto p=*m.upper_bound(b);
            f(m,a,p.first);
            a*=b;
        }
    }

}

int main(){
    cin>>N;
    if(N==2){
        cout<<1<<endl;
        return 0;
    }

    auto v_m=PF(N-1);
    auto v_n=PF(N);
    /*
    for(auto p:v_m){
        cout<<p<<" ";
    }
    cout<<endl;
    for(auto p:v_n){
        cout<<p<<" ";
    }
    cout<<endl;
    //*/

    long long pro=1;
    long long tmp=0;
    long long cnt=0;
    for(auto p:v_m){
        if(tmp==p){
            cnt++;
        }else{
            pro*=cnt+1;
            cnt=1;
        }
        tmp=p;
    }
    pro*=cnt+1;
    ans=pro-1;
    //cout<<ans<<endl;

    map<long long,int> m;
    for(auto p:v_n){
        m[p]++;
    }
    f(m,1,v_n[0]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

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

struct edge {
	int from, to, d, c, i;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< vector< int > > G(N);
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	auto f = [&](auto &&f, int x, int p) -> int {
		int ret = 1;
		for (auto j : G[x]) {
			if (j == p)
				continue;
			int r = f(f, j, x);
			if (r == 1) {
				if (ret) {
					ret = 0;
				} else {
					return -1;
				}
			} else if (r == -1)
				return -1;
		}
		return ret;
	};
	int ans = f(f, 0, -1);
	if (ans == 1 || ans == -1) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
	return 0;
}

Measured memory_bytes: 9348
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))

Measured memory_bytes: 12028
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

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

using namespace std;

int v[200010];

bool match(int index)
{
    return v[index] == index;
}

void solve()
{
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> v[i];
    }
    int c = 0;
    for(int i = 1;i < n;i++)
    {
        if(match(i))
        {
            swap(v[i], v[i+1]);
            c++;
        }
    }
    if(match(n))
    {
        for(int i = n;i > 1;i--)
        {
            if(match(i))
            {
                swap(v[i], v[i-1]);
                c++;
            }
        }
    }
    cout << c << endl;
}

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

Measured memory_bytes: 640
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n, k = map(int, input().split())
    aa = list(map(int, input().split()))
    ac = Counter(aa)
    now = len(ac)
    del_n = now - k
    ans = 0
    for v in sorted(ac.values()):
        if del_n <= 0:
            break
        ans += v
        del_n -= 1
    print(ans)

main()


Measured memory_bytes: 32564
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
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 main(){
	int A,B;
	cin >> A >> B;
	cout << max(max(A+B,A-B),A*B) << endl;
	return 0;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;


using Graph = vector<string>;
typedef pair<i64, int> Result;
Result visit(int p, int v, const Graph &g) {
  Result r(0, v);
  REP(q, g.size()) {
    if (v < q && g[v][q] == '1') {
      Result t = visit(v, q, g);
      t.first += 1;
      if (r.first < t.first) r = t;
    }
  }
  return r;
}
i64 diameter(const Graph &g) {
  Result r = visit(-1, 0, g);
  Result t = visit(-1, r.second, g);
  return t.first; // (r.second, t.second) is farthest pair
}

using P = pair<i64, i64>;
signed main() {
  i64 N;
  cin >> N;
  vector<i64> L(N);
  cin >> L;
  sort(ALL(L));
  i64 s = 0;
  FOR(i, 0, N) {
    FOR(j, i + 1, N) {
      s += lower_bound(ALL(L), L[i] + L[j]) - L.begin() - (j + 1);
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char s[1];
  scanf("%s",s);
  if(s[0]>='a' && s[0]<='z')
  {
    printf("a");
  }
  else if(s[0]>='A' && s[0]<='Z')
  {
  	printf("A");
  }
  
}

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

int H, W, N;
int R, C;
string S, T;

void input_init(void) {
	cin >> H >> W >> N;
	cin >> R >> C;
	cin >> S >> T;
}

string solve(void) {
	int lp, rp, up, dp;
	string ret = "YES";
	lp = rp = C;
	up = dp = R;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'L') {
			if (lp == 1) {
				ret = "NO";
				break;
			}
			--lp;
		}
		if (T[i] == 'R' && lp < W)
			++lp;

		if (S[i] == 'R') {
			if (rp == W) {
				ret = "NO";
				break;
			}
			++rp;
		}
		if (T[i] == 'L' && rp > 1)
			--rp;

		if (S[i] == 'U') {
			if (up == 1) {
				ret = "NO";
				break;
			}
			--up;
		}
		if (T[i] == 'D' && up < H)
			++up;

		if (S[i] == 'D') {
			if (dp == H) {
				ret = "NO";
				break;
			}
			++dp;
		}
		if (T[i] == 'U' && dp > 1)
			--dp;
	}
	return ret;
}

int main(void) {
	input_init();
	string ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 900
n = int(input())
d = dict()

for i in range(n):
    s = str(input())
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())
ans = []
for k,v in d.items():
    if v == M:
        ans.append(k)

ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 32096
main = do
  ab_in <- (return . words) =<< getLine
  let a:b:[] = map (read::String->Int) ab_in
  if a < b then putStrLn "a < b" else return ()
  if a > b then putStrLn "a > b" else return ()
  if a == b then putStrLn "a == b" else return ()


Measured memory_bytes: 3616
const main = (inputs) => {
  var array = inputs[0].split(" ");
  var A = array[0] - 0;
  var B = array[1] - 0;
  var C = array[2] - 0;
  var D = array[3] - 0;
  var taka = A;
  var ao = C;

  while (1) {
    ao = ao - B;
    if (ao <= 0) {
      console.log('Yes');
      break;
    }
    taka = taka - D;
    if (taka <= 0) {
      console.log('No');
      break;
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

Measured memory_bytes: 29624
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.ascii, std.regex, std.conv, std.stdio, std.typecons;

void main()
{
  auto s = readln.chomp;

  dchar swapCase(dchar c) {
    if (c.isLower) return std.ascii.toUpper(c);
    else if (c.isUpper) return std.ascii.toLower(c);
    else return c;
  }

  writeln(s.map!(swapCase));
}

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

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007

using namespace std;

class BBiteEating {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n,l,ans=0;
		in >> n >> l;
		int mi=1e9;
		f(i,0,n)
		{
			ans+=i+l;
			if(abs(i+l)<abs(mi))
				mi=i+l;
		}
		out << ans-mi << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	BBiteEating solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split(" ")))

l = [0]*N
p = []
for i in range(N-1, -1, -1):
    m = sum(l[i::i+1])%2
    if A[i] == m:
        continue
    l[i] = 1
    p.append(i)

print(len(p))
for p_i in p:
    print(p_i+1)

Measured memory_bytes: 13156
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long int ll;

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

int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> xs;
  ll x;
  for (ll i = 0; i < N; ++i) {
    cin >> x;
    xs.push_back(abs(X - x));
  }

  ll ans = gcd(xs[0], xs[1]);
  for (int i = 2; i < N; ++i) {
    ans = gcd(ans, xs[i]);
  }

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


Measured memory_bytes: 1400
using System;
namespace kozaiyApp
{
    public class B
    {
        static void Main()
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            int l = S.Length;

            if (l <= K)
            {
                Console.WriteLine(S);
            }
            else
            {
                string ans = S.Substring(0, K);
                Console.WriteLine(ans + "...");
            }
        }
    }
}


Measured memory_bytes: 27540
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    int n=s.size();
    int i,count=0;
    for(i=0;i<n/2;i++) {
        if(s[i]!=s[n-i-1]) {
            count++;
        }
    }
    cout<<count<<"\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

// ree always check bounds
// int vs long long
// bitset cheese <3

long long get_sum(long long n, long long a){

    if(n & 1 == 0){
        return mult_mod(n >> 1, 2 * a + mult_mod(n - 1, 2));
    }

    long long inv = fast_exp(2, MOD - 2);

    return inv * mult_mod(n, 2 * a + mult_mod(n - 1, 2));

}

map<string, long long> d;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;
    string s;

    for(int i = 0; i < n; ++i){
        cin >> s;
        sort(s.begin(), s.end());
        ++d[s];
    }

    long long tot = 0;

    for(auto i : d){
        tot += i.second * (i.second - 1) / 2;
    }

    cout << tot;

    return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>
#include <stdlib.h>

int pos,postnum;

int search(int a[],int n,int s){
    int i;
    for(i=0;i<n;i++){
        if(a[i]==s){
            return i;
        }
    }
    return -1;
}

void rec(int l,int r,int n,int pre[],int in[],int post[]){
    int root,k;
    if(l>=r){return;}
    root = pre[pos];pos++;
    k = search(in,n,root);
    rec(l,k,n,pre,in,post);rec(k+1,r,n,pre,in,post);
    post[postnum]=root;postnum++;
}

void solve(int n,int pre[],int in[],int post[]){
    int i;
    pos=0;postnum=0;
    rec(0,n,n,pre,in,post);
    printf("%d",post[0]);
    for(i=1;i<n;i++){
        printf(" %d",post[i]);
    }
    printf("\n");
}

int main(void){
    int n,i;
    int *pre,*in,*post;
    scanf("%d",&n);
    pre = (int*)malloc(sizeof(int)*n);
    in = (int*)malloc(sizeof(int)*n);
    post = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        scanf("%d",&pre[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&in[i]);
    }
    solve(n,pre,in,post);
}


Measured memory_bytes: 2092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

string S[109], T[109];

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

	int N, M;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> S[i];
	cin >> M;
	for (int i = 0; i < M; i++) cin >> T[i];

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) if (S[i] == S[j]) cnt++;
		for (int j = 0; j < M; j++) if (S[i] == T[j]) cnt--;
		ans = max(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int n;

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

	cin >> n;
	
	int ans;
	for (int a = 111; a <= 999; a += 111) {
		if (n > a) continue;
		ans = a;
		break;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

vector<ll>F, T, W;
ll N;
void push(ll f, ll t, ll w){
    F.push_back(f);
    T.push_back(t);
    W.push_back(w);
}
void show(){
    cout << N << " " << F.size() << endl;
    for(ll i = 0; i < F.size(); i++){
        cout << F[i] << " " << T[i] << " " << W[i] << endl;
    }
}

int main(){

    ll L;
    cin >> L;
    ll mx[22] = {};
    for(ll i = 2; i <= 21; i++){
        mx[i] = (1LL << (i - 1)) - 1;
    }
    for(N = 1; ;N++)if(mx[N + 1] >= L)break;
    for(ll i = 1; i < N; i++){
        push(i, i + 1, 0);
        push(i, i + 1, 1 << (i - 1));
    }
    for(ll i = mx[N] + 1; i < L; i++){
        ll sz = L - i;
        ll from = 1;
        for(;;from++)if(i + mx[from + 1] >= L)break;
        push(from, N, i);
        i += mx[from];
    }
    show();
    
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::collections::{HashSet,HashMap};
#[allow(unused_imports)]
use std::collections::{BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::collections::BinaryHeap;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
        N:usize, M:usize,
        A: [chars; N],
        B: [chars; N],
    }
    let mut ans = 0;
    for i in 0..N {
        for j in 0..M {
            if A[i][j] != B[i][j]{
                ans += 1;
            }
        }
    }
    println!("{}", ans);

}


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

int main() {
    int n;
    cin >> n;
    int array[n];
    for(int i=0; i<n;i++) {
        cin >> array[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i==0) cout << array[i] << endl;
        else cout << array[i] << " ";
    }
}



Measured memory_bytes: 3100