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

typedef long long ll;

const int N = 1e5 + 5;
int n, m, t;
int A[N];

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

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

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

    cin >> n >> m;
    ll cur = 1;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < n; ++i) {
        cur = lcm(cur,  A[i] / 2);
        if (cur > m) {
            cout << 0 << endl;
            exit(0);
        }
    }
    // check
    for (int i = 0; i < n; ++i) {
        int d = cur / (A[i] / 2);
        if (d % 2 == 0) {
            cout << 0 << endl;
            exit(0);
        }
    }

    cout << (m / cur + 1) / 2 << endl;


    return 0;
}



Measured memory_bytes: 640
def main():
    N, K = map(int, input().split())
    h = [int(input()) for count in range(N)]
    h.sort()
    min_value = min(h[i + K - 1] - h[i] for i in range(N - K + 1))
    print(min_value)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int get_f(int v){
  return to_string(v)[0] - '0';
}

int get_l(int v){
  return to_string(v)[to_string(v).size()-1] - '0';
}

int get_keta(int v){
  return int(to_string(v).size());
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
    // dp_ij := n以下で先頭i尻jな値の個数
  vector<vector<int>> dp(20, vector<int> (20, 0));

  rep(i, n+1){
    int f = get_f(i);
    int l = get_l(i);
    dp[f][l]++;
  }

  int res = 0;
  for (int i = 1; i < 10; ++i) {
    for (int j = 1; j < 10; ++j) {
      res += dp[i][j] * dp[j][i];
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 3712
k = ['N','E','S','W']
v = [[0,1],[1,0],[0,-1],[-1,0]]
while True:
    n = int(input())
    if n==0: break
    x,y = 10,10
    l = [list(map(int,input().split())) for _ in range(n)]
    for d,r in [input().split() for _ in range(int(input()))]:
        dl = v[k.index(d)]
        for _ in range(int(r)):
            x,y = x+dl[0],y+dl[1]
            if [x,y] in l: del l[l.index([x,y])]
    print('No' if l else 'Yes')

Measured memory_bytes: 7564
#define USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<cmath>                    
using namespace std;
int main(){
    

    double p(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679),r,x,y;
    cin>>r;

	x=r*r*p;
	y=r*2*p;

	cout<<fixed<<x<<" "<<y<<endl;

	
   


	 return 0;
}
 


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll INF = (1LL<<60);

int main(){

    ll a1, a2, a3; cin >> a1 >> a2 >> a3;

    cout << (a1+a2+a3>=22?"bust":"win") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

struct UnionFind {
    int N;
    vi dt; // 根なら要素数*(-1), 子なら親の番号が入る
    UnionFind(int n) : N(n), dt(n, -1) {}

    // 根の頂点番号を返す
    int root(int v){
        if (dt[v] < 0) return v;
        return dt[v] = root(dt[v]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x,y);
        dt[x] += dt[y]; // 要素数を増やす (ただし負で計算)
        dt[y] = x; // 小さい方のグループ y の親を大きい方のグループ x に
        return true;
    }

    int size(int v) {return -dt[root(v)];}

    bool isConnect(int x, int y) {return root(x) == root(y);}
};

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

  int N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];
  vi B(N); REP(i,N) cin>>B[i];

  vector<pii> a;
  REP(i,N) a.push_back(pii(A[i], i));
  sort(a.begin(), a.end());
  vector<pii> b;
  REP(i,N) b.push_back(pii(B[i], i));
  sort(b.begin(), b.end());
  REP(i,N) {
    if (a[i].first > b[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }

  UnionFind uf(N);
  REP(i,N) {
    uf.unite(a[i].second, b[i].second);
  }
  set<int> st;
  REP(i,N) st.insert(uf.root(i));

  if (N - st.size() <= N-2) {
    cout << "Yes" << endl;
    return 0;
  }

  REP(i,N-1) {
    if (a[i+1].first <= b[i].first) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3316
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  int count = 0;
  long double sum = 0.0;
  int disx, disy;

  cin >> N;
  vector<int> v(N);
  int x[N], y[N];

  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    v[i] = i + 1;
  }

  do {
    for (int i = 0; i < N-1; i++) {
      disx = (x[v[i]-1] - x[v[i+1]-1]);
      disy = (y[v[i]-1] - y[v[i+1]-1]);
      sum += sqrtl(disx * disx + disy * disy);
    }
    count++;
  } while (std::next_permutation(v.begin(), v.end()));

  printf("%.10Lf\n", sum / count);
  return 0;
}


Measured memory_bytes: 888
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]", Q: int, B: "List[int]", C: "List[int]"):
    cnts = {}
    for v in A:
        if not v in cnts:
            cnts[v] = 0
        cnts[v] += 1
    s = sum(A)
    for i in range(Q):
        b, c = B[i], C[i]
        if not b in cnts:
            cnt = 0
        else:
            cnt = cnts[b]
        s += (c - b) * cnt
        if not c in cnts:
            cnts[c] = 0
        cnts[c] += cnt
        cnts[b] = 0
        print(s)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = int(next(tokens))  # type: int
    B = [int()] * (Q)  # type: "List[int]"
    C = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, A, Q, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int n;
ll solve(){
   ll ans=0;
   

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

    cin>>n;
    int res=n%10;
    if(res==2||res==4||res==5||res==7||res==9){
        cout<<"hon"<<endl;
        return 0;
    }else if(res==0||res==1||res==6||res==8){
        cout<<"pon"<<endl;
    }else {
        cout<<"bon"<<endl;
        return 0;
    }
    //cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3652
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        x: usize,
        n: usize,
        p: [usize; n],
    }
    let mut ans = if n == 0 { x } else { 1000 };

    for i in (0..x).rev() {
        if 0 < p.iter().filter(|&&l| l == i).count() {
            continue;
        }
        ans = i;
        break;
    }

    for i in x..101+1 {
        if 0 < p.iter().filter(|&&l| l == i).count() {
            continue;
        }
        if ans <= x {
            if x - ans == i - x {
                break;
            }

            if x - ans < i - x {
                break;
            }
        }

        ans = i;
        break;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2184
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string ans = "No";

        for(var i = 1; i < 10; ++i)
        {
            for(var j=1; j < 10; ++j)
            {
                if (i * j == n)
                {
                    ans = "Yes";
                }
            }
        }
        Console.WriteLine(ans);
        return;
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            HashSet<string> s = new HashSet<string>();
            for (int i = 0; i < N; i++)
            {
                s.Add(Console.ReadLine());
            }
            Console.WriteLine(s.Count);

            //List<string> str = new List<string>();
            //for (int i = 0; i < N; i++)
            //{
            //    str.Add(Console.ReadLine()); 
            //}
            //List<string> resultStr = str.Distinct().ToList();
            //int message = resultStr.Count;
            //Console.WriteLine(message);
        }
    }
}

//24579 =  hon
//0168 = pon
//3 = bon
//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


Measured memory_bytes: 46968
#include<bits/stdc++.h>
using namespace std;
string S,T;
int dp[1005][1005];
int solve(string a,string b){
  int A=a.size(),B=b.size();
  memset(dp,0,sizeof(dp));
  for(int i=0;i<A;i++){
    for(int j=0;j<B;j++){
      if(a[i]==b[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
  return dp[A][B];
}
 
int main(){
  cin>>S>>T;
  string sa="",sb="";
  for(int i=0;i<(int)S.size();i++){
    if(i%2==0)sa.push_back(S[i]);
    else sb.push_back(S[i]);
  }
  if( solve(sa,T) == (int)sa.size() )cout<<"Yes"<<endl;
  else if( solve(sb,T) == (int)sb.size() )cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

namespace ABC136E
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NK = CIN.LongArray();
            long N = NK[0];
            long K = NK[1];
            long[] A = CIN.LongArray();

            long Sum = A.Sum();
            List<long> Factors = new List<long>();
            var root = Math.Sqrt(Sum);
            for (int i = 1; i <= root; i++)
            {
                if (Sum % i == 0)
                {
                    Factors.Add(i);
                }
            }

            int fs = Factors.Count;
            for (int i = 0; i < fs; i++)
            {
                Factors.Add(Sum / Factors[i]);
            }

            long ans = 1;
            foreach (long factor in Factors)
            {
                if (factor == 1)
                {
                    continue;
                }

                long[] AA = new long[N];
                for (int i = 0; i < N; i++)
                {
                    AA[i] = A[i] % factor;
                }
                Array.Sort(AA);

                long[] Upp = new long[N];
                long[] Low = new long[N];
                Upp[0] = AA[0];
                Low[N - 1] = factor - AA[N - 1];
                for (int i = 1; i < N; i++)
                {
                    Upp[i] = Upp[i - 1] + AA[i];
                }

                for (int i = (int)N - 2; i >= 0; i--)
                {
                    Low[i] = Low[i + 1] + (factor - AA[i]);
                }

                for (int i = 0; i < N - 1; i++)
                {
                    if (Upp[i] == Low[i + 1] && Upp[i] <= K)
                    {
                        ans = Math.Max(factor, ans);
                        break;
                    }

                    if (Low[i] == Upp[i + 1] && Upp[i] <= K)
                    {
                        ans = Math.Max(factor, ans);
                        break;
                    }
                }
            }
            
            Console.WriteLine(ans);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

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

int main(){
    int c[3][3];

    rep(i,3){
        rep(j,3){
            cin >> c[i][j];
        }
    }
    int b[3];
    bool ans=true;

    rep(i,101){
        rep(j,101){
            rep(k,101){
                b[0]=c[0][0]-i;
                b[1]=c[1][0]-i;
                b[2]=c[2][0]-i;
                ans=true;
                rep(l,3){
                    if(b[l]+i!=c[l][0]||b[l]+j!=c[l][1]||b[l]+k!=c[l][2]){
                        ans=false;
                    }
                }
                if(ans){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
// ALDS1_1_C Prime Numbers
import java.io.*;

class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         int cnt = 0;
         int n = Integer.parseInt(br.readLine());
         int[] num = new int[n];
         for (int i = 0; i < n; i++) {
            num[i] = Integer.parseInt(br.readLine());
         }
         for (int x : num) {
            if (isPrime(x)) cnt++;
         }
         System.out.println(cnt);
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static boolean isPrime(int x) {
      if (x == 2) return true;
      if (x < 2 || x % 2 == 0) return false;
      int i = 3;
      while (i <= Math.sqrt(x)) {
         if (x % i == 0) return false;
         i = i + 2;
      }
      return true;
   }
}

Measured memory_bytes: 22840
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

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

void solve()
{
	char ch;
	cin >> ch;
	int a = ch;
	a++;
	cout << (char)a;
}
int main()
{
	 int t = 1;
   	// cin >> t;
	 while (t--)
	 {
		  solve();
	 }
	 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	cout << (c >= a && c <= b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;cin >> s >> t;
    string s2 = s + s;
    ll n = t.size();
    bool ok = false;

    rep(i,n){
        ok |= s2.substr(i, n) == t;   
        debug(s2.substr(i, n));
    }
    YES(ok);
}

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


string S;


void input() {
    cin >> S;
}


int main() {
    input();
    int n = S.size();
    vector<int> w(3, 0);
    for (char c : S) w[c - 'a']++;
    int x = 0;
    rep(i, 3) {
        for (int j = i + 1; j < 3; j++) {
            x = max(x, max(w[i] - w[j], w[j] - w[i]));
        }
    }
    if (x < 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
t1,n1=map(int,input().split())
t2,n2=map(int,input().split())
t3,n3=map(int,input().split())
t4,n4=map(int,input().split())

P=0
for i in range(1,n1+1):
    if t1==1:
        P+=6000
    if t1==2:
        P+=4000
    if t1==3:
        P+=3000
    if t1==4:
        P+=2000

Q=0
for j in range(1,n2+1):
    if t2==1:
        Q+=6000
    if t2==2:
        Q+=4000
    if t2==3:
        Q+=3000
    if t2==4:
        Q+=2000
      
R=0  
for k in range(1,n3+1):
    if t3==1:
        R+=6000
    if t3==2:
        R+=4000
    if t3==3:
        R+=3000
    if t3==4:
        R+=2000
        
S=0
for l in range(1,n4+1):
    if t4==1:
        S+=6000
    if t4==2:
        S+=4000
    if t4==3:
        S+=3000
    if t4==4:
        S+=2000
        
print(P)
print(Q)
print(R)
print(S)


Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int min_i = i;
        for(int j = i+1; j < n; ++j) {
            if (v[min_i] > v[j]) {
                min_i = j;
            }
        }
        if (min_i != i) {
            swap(v[min_i], v[i]);
            cnt++;
        }
    }

    cout << (cnt > 1 ? "NO" : "YES") << endl;
}


Measured memory_bytes: 256
S=input()
l=len(S)
num=int((l-1)/2)

x=True

for i in range(l):
    if not S[i]==S[(l-1-i)]:
        x=False
        break
        
for i in range(num):
    if not S[i]==S[(num-i-1)]:
        x=False
        break
   

for i in range(num+1,l):
    if not S[i]==S[(l+num-i)]:
        x=False
        break
        
if x==True:
    print("Yes")
else:
    print("No")

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

int main() {
  string S; cin >> S;
  int K; cin >> K;

  vector<string> vec;
  for (int i = 0; i < S.size(); i++) {
    for (int k = 1; k <= K; k++) vec.push_back(S.substr(i, k));
  }

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  cout << vec[K - 1] << endl;
}


Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		long v = 1000000000 + 7;

		int n = in.nextInt();
		int m = in.nextInt();
		long[] x = new long[n];
		long[] y = new long[m];
		for (int i = 0; i < x.length; i++) {
			x[i] = in.nextLong();
		}
		for (int i = 0; i < y.length; i++) {
			y[i] = in.nextLong();
		}
		in.close();

		long sumX = 0;
		for (int i = 0; i < x.length; i++) {
			sumX = (sumX-(x.length - i) * x[i] + (x.length - i) * x[x.length - 1 - i]) % v;
		}

		long sumY = 0;
		for (int i = 0; i < y.length; i++) {
			sumY = (sumY-(y.length - i) * y[i] + (y.length - i) * y[y.length - 1 - i]) % v;
		}
		System.out.println((sumX * sumY) % v);
	}
}


Measured memory_bytes: 92292
<?php
  $n = intval(fgets(STDIN));
  $array = explode(" ", trim(fgets(STDIN)));

  $idx1 = -1;
  for($i=0; $i<$n; $i++){
    if($idx1==-1 && $i<$n-1){
      if($array[$i] > $array[$i+1]){
        $idx1 = $i;
      }
    }else if($idx1!=-1){
      if($array[$i] < $array[$idx1+1]){
        $tmp = $array[$i];
        $array[$i] = $array[$idx1];
        $array[$idx1] = $tmp;
        break;
      }
    }
  }

  $result = true;
  for($i=0; $i<$n-1; $i++){
    if($array[$i] > $array[$i+1]){
      $result = false;
      break;
    }
  }

  if($result){
    echo "YES\n";
  }else{
    echo "NO\n";
  }

Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ll long long
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define lowbit(x) (x&-x)
#define ms(x,a) memset(x,a,sizeof x)
using namespace std;
template <class T> inline bool Max(T &x, T y){
	return x<y?x=y,1:0;
}
template <class T> inline bool Min(T &x, T y){
	return x>y?x=y,1:0;
}
template <class T> inline T rd() {
	static char ch;static bool neg;
	static T x=0;
	for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
	for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
	return x=(neg?-x:x);
}
const int mod=1e9+7,oo=1e9,M=1e5+5;

string str[M];
map<string,int>mp;

int main(){
	int n=rd<int>();
	ll ans=0;
	rep(i,1,n){
		cin>>str[i];
		sort(str[i].begin(),str[i].end());
		ans+=1ll*mp[str[i]];
		mp[str[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}



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

#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define ll long long

using namespace std;

#define N 5005
#define M 10000005

int n, tot;
int prime[M], a[N];
bool notprime[M], vis[N];
int odd[N], even[N], cnt[3];
int fir[N], nx[N * N], to[N * N], match[N];

inline void init() {
    int MAX = 1e7;
    notprime[1] = 1;
    notprime[1] = 1;
    for (int i = 2; i <= MAX; ++i) {
        if (!notprime[i]) prime[++tot] = i;
        for (int j = 1; j <= tot && prime[j] * i <= MAX; ++j) {
            notprime[i * prime[j]] = 1;
            if (i % prime[j] == 0) break;
        }
    }
}

inline void Add(int x) { x & 1 ? odd[++cnt[1]] = x : even[++cnt[2]] = x; }

inline void add(int _, int __) {
    nx[++tot] = fir[_];
    fir[_] = tot;
    to[tot] = __;
}

bool dfs(int x) {
    if (vis[x]) return false;
    vis[x] = 1;
    for (int i = fir[x]; i; i = nx[i]) {
        int toi = to[i];
        if (!match[toi] || dfs(match[toi])) {
            match[toi] = x;
            return true;
        }
    }
    return false;
}

int main() {
    init();
    scanf ("%d", &n);
    rep (i, 1, n) scanf ("%d", &a[i]);
    sort(a + 1, a + n + 1);
    int last = a[1];
    rep (i, 2, n) if (a[i] != a[i - 1] + 1) Add(last), Add(a[i - 1] + 1), last = a[i];
    Add(last), Add(a[n] + 1);
//    rep (i, 1, cnt[1]) printf("%d%c", odd[i], " \n"[i == cnt[1]]);
//    rep (i, 1, cnt[2]) printf("%d%c", even[i], " \n"[i == cnt[2]]);
    rep (i, 1, cnt[1]) rep (j, 1, cnt[2]) if (!notprime[abs(odd[i] - even[j])])  add(i, j);
    int res = 0;
    rep (i, 1, cnt[1]) {
        memset(vis, 0, sizeof vis);
        if (dfs(i)) ++res;
    }
    int ans = res; cnt[1] -= res, cnt[2] -= res;
    ans += cnt[1] + cnt[2] + (cnt[1] & 1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> pos, neg;
	ll cntr = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] > 0) {
			pos.push_back(a[i]);
		} else if (a[i] < 0) {
			neg.push_back(-a[i]);
		} else {
			++cntr;
		}
	}
	ll l = -4e18l, r = 4e18l;
	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	vector<ll> r_pos = pos, r_neg = neg;
	reverse(r_neg.begin(), r_neg.end());
	ll answer = -1;
	debug(pos, neg, cntr);
	while (l <= r) {
		ll mid = l + (r - l) / 2;
		ll small = 0;
		if (mid > 0) {
			small += cntr * (cntr - 1) / 2 + cntr * (n - cntr);
		}
		int m = pos.size();
		int p = m - 1;
		for (int i = 0; i < m; ++i) {
			while (p >= 0 && pos[i] * pos[p] >= mid) {
				--p;
			}
			small += max(0, p - i);
		}
		
		//~ debug(mid, small);
		m = neg.size();
		p = m - 1;
		for (int i = 0; i < m; ++i) {
			while (p >= 0 && neg[i] * neg[p] >= mid) {
				--p;
			}
			small += max(0, p - i);
		}
		
		//~ debug(mid, small);
		p = 0;
		m = neg.size();
		int mm = pos.size();
		for (int i = 0; i < mm; ++i) {
			while (p < m && r_pos[i] * r_neg[p] > -mid) {
				++p;
			}
			small += p;
		}
		//~ debug(mid, small);
		
		if (small >= k) {
			answer = mid;
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	cout << answer - 1 << '\n';
	
 	return 0;
}


Measured memory_bytes: 4844
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n, k;
	cin >> n >> k;
	vll arr(n);
	rep(i, 0, n)
	cin >> arr[i];

	rep(i, 0 , n - k) {
		if (arr[i]  <  arr[k + i])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}


	return 0;
}







Measured memory_bytes: 4704
import java.util.Scanner;
import java.util.Arrays;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), Y = sc.nextInt(), x[] = new int[N], y[] = new int[M];
        for (int i = 0; i < N; ++i) x[i] = sc.nextInt();
        for (int i = 0; i < M; ++i) y[i] = sc.nextInt();
        sc.close();
        Arrays.sort(x);
        Arrays.sort(y);
        if (y[0] > x[N - 1] && y[0] > X && Y >= y[0]) System.out.print("No War");
        else System.out.print("War");
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define qwq (cerr<<"qwq"<<endl)
#define orz(x) (cerr<<#x": "<<x<<endl)
#define orzarr(a,n) {cerr<<#a": "; repeat(__,0,n)cerr<<(a)[__]<<" "; cerr<<endl;}
#define orzeach(a) {cerr<<#a": "; for(auto __:a)cerr<<__<<" "; cerr<<endl;}
#define fi first
#define se second
typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;}
typedef double lf; typedef long double llf; const lf err=1e-11; const lf pi=acos(-1); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;}
typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=10;
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int n,m,k;
string s[N];
int ans=inf;
void work(int kljdasdkl){
	bitset<10> x(kljdasdkl);
	int now=x.count();//orz(now);
	vector<int> cnt(10,0),p;
	int top=0;
	repeat(i,0,n){
		p.push_back(top);
		if(x[i])top++;
	}
	//orzeach(p);
	repeat(j,0,m){
		repeat(i,0,n)s[i][j]=='1'?cnt[p[i]]++:0;
		repeat(i,0,n)
		if(cnt[i]>k){
			fill(cnt.begin(),cnt.end(),0);
			repeat(i,0,n)s[i][j]=='1'?cnt[p[i]]++:0;
			now++;//orz(now);
			break;
		}
		repeat(i,0,n)
		if(cnt[p[i]]>k)
			return;
		//orzeach(cnt);
	}
	//now++;
	//orz(now);
	ans=min(ans,now);
}
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m>>k;
	repeat(i,0,n)
		cin>>s[i];
	repeat(i,0,1<<(n-1))
		work(i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
int main(){

  int m,f,r;


  while(true){

    cin >> m>>f>>r;
    if(m==-1&&f==-1&&r==-1) break;
    int sum = m+f;

    if(m==-1 || f==-1) cout << "F";
    else if(sum >= 80) cout << "A";
    else if(sum >= 65) cout << "B";
    else if(sum >= 50) cout << "C";
    else if(sum >= 30){
      if(r >= 50) cout << "C";
      else cout << "D";
    }
    else cout << "F";
    cout << endl;


  }
}




Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;

void code()
{
        string s;
        string t;
        cin>>s>>t;
        int k = s.size();
        int count = 0;
        for(int i=0; i<k; i++)
        {
                if(s[i]==t[i])
                        count++;

        }
        if(count==k)
                cout<<"Yes";
        else cout<<"No";

}
signed main()

{
        FAST_IO;
        int t = 1;

        // cin>>t;

        while(t--)
        {
                code();
        }

        return 0;
}


Measured memory_bytes: 3604
use std::io::Read;

struct Edge {
    from: usize,
    to: usize,
    cost: u64,
}
impl Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.cost.cmp(&other.cost)
    }
}
impl PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cost.cmp(&other.cost))
    }
}
impl Eq for Edge {}
impl PartialEq for Edge {
    fn eq(&self, other: &Self) -> bool {
        self.cost == other.cost
    }
}

struct DisjointSet {
    parent: Vec<usize>,
    size: Vec<usize>,
}
impl DisjointSet {
    fn new(n: usize) -> DisjointSet {
        DisjointSet {
            parent: (0..n).collect(),
            size: vec![1; n],
        }
    }
    fn root(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let tmp = self.parent[x];
            self.parent[x] = self.root(tmp);
            self.parent[x]
        }
    }
    fn merge(&mut self, x: usize, y: usize) {
        let x = self.root(x);
        let y = self.root(y);
        if x == y {
            return;
        }
        if self.size[x] > self.size[y] {
            self.size[x] += self.size[y];
            self.parent[y] = x;
        } else {
            self.size[y] += self.size[x];
            self.parent[x] = y;
        }
    }
    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
}

fn kruskal(edges: &mut Vec<Edge>) -> u64 {
    let n: usize = edges.len();
    edges.sort();

    let mut ds = DisjointSet::new(n);
    let mut res: u64 = 0;
    for e in edges.iter() {
        if ds.same(e.from, e.to) {
            continue;
        }
        ds.merge(e.from, e.to);
        res += e.cost;
    }
    res
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut xs: Vec<(u64, usize)> = vec![];
    let mut ys: Vec<(u64, usize)> = vec![];
    for i in 0..n {
        let x: u64 = itr.next().unwrap().parse().unwrap();
        let y: u64 = itr.next().unwrap().parse().unwrap();
        xs.push((x, i));
        ys.push((y, i));
    }

    let mut edges: Vec<Edge> = Vec::new();
    xs.sort();
    for i in 1..n {
        let (from_x, from_id) = xs[i - 1];
        let (to_x, to_id) = xs[i];
        let edge = Edge {
            from: from_id,
            to: to_id,
            cost: to_x - from_x,
        };
        edges.push(edge);
    }
    ys.sort();
    for i in 1..n {
        let (from_y, from_id) = ys[i - 1];
        let (to_y, to_id) = ys[i];
        let edge = Edge {
            from: from_id,
            to: to_id,
            cost: to_y - from_y,
        };
        edges.push(edge);
    }
    println!("{}", kruskal(&mut edges));
}

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

int main()
{
    int n, answer = 0;
    cin >> n;
    for (int i = 1; i <= n; i += 2)
    {
        int diviser = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
            {
                diviser++;
            }
        }
        if (diviser == 8)
        {
            answer++;
        }
    }

    cout << answer << endl;
}

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

using namespace std;
struct State {
	int c, x, y, s;
	explicit State(int c = 0, int x = 0, int y = 0, int s = 0) :
		c(c), x(x), y(y), s(s)
	{ }
};
const int INF = 1000000000;
const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, -1, 0, 1 };

inline bool between(int a, int b, int c){
	return a <= b && b < c;
}

int dist[10][10][10][1 << 10];

int main(){
	ios_base::sync_with_stdio(false);
	int h, w, n;
	cin >> h >> w >> n;
	vector<string> field(h);
	for(int i = 0; i < h; ++i){
		cin >> field[i];
		for(int j = 0; j < w; ++j){
			if(islower(field[i][j])){ ++field[i][j]; }
			if(field[i][j] == 'S'){ field[i][j] = 'a'; }
			if(isdigit(field[i][j])){ --field[i][j]; }
		}
	}
	int init_s = 0, init_x = 0, init_y = 0;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(field[i][j] == 'a'){ init_x = j; init_y = i; }
			if('b' <= field[i][j] && field[i][j] <= 'f'){
				for(int d = 0; d < 4; ++d){
					const int y = i + dy[d], x = j + dx[d];
					if(!between(0, y, h) || !between(0, x, w)){ continue; }
					if(field[y][x] == field[i][j] - 1){
						init_s |= (d << ((field[i][j] - 'b') * 2));
					}
				}
			}
		}
	}
	vector<int> valid_state(1 << 10);
	for(int i = 0; i < (1 << 10); ++i){
		int bitmap[11][11] = { { 0 } };
		int x = 5, y = 5, valid = 1;
		bitmap[y][x] = 1;
		for(int j = 4; j >= 0; --j){
			const int d = (i >> (j * 2)) & 3;
			x += dx[d];
			y += dy[d];
			if(bitmap[y][x]){ valid = 0; }
			bitmap[y][x] = 1;
		}
		valid_state[i] = valid;
	}
	for(int i = 0; i <= n; ++i){
		for(int y = 0; y < h; ++y){
			for(int x = 0; x < w; ++x){
				for(int s = 0; s < (1 << 10); ++s){ dist[i][y][x][s] = INF; }
			}
		}
	}
	queue<State> q;
	dist[0][init_y][init_x][init_s] = 0;
	q.push(State(0, init_x, init_y, init_s));
	int answer = INF;
	while(!q.empty()){
		const State p = q.front();
		q.pop();
		const int d = dist[p.c][p.y][p.x][p.s];
		if(p.c == n){
			answer = d;
			break;
		}
		for(int dir = 0; dir < 4; ++dir){
			const int nx = p.x + dx[dir], ny = p.y + dy[dir];
			if(!between(0, nx, w) || !between(0, ny, h)){ continue; }
			if(field[ny][nx] == '#'){ continue; }
			const int ns = ((p.s << 2) | dir) & ((1 << 10) - 1);
			const int nc = p.c + (field[ny][nx] == '0' + p.c ? 1 : 0);
			if(valid_state[ns] && d + 1 < dist[nc][ny][nx][ns]){
				dist[nc][ny][nx][ns] = d + 1;
				q.push(State(nc, nx, ny, ns));
			}
		}
	}
	if(answer >= INF){ answer = -1; }
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 5256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	int x = 0, y = 0;
	S2(x, y);
	int ma = x * 4;
	int mi = x * 2;
	if (y % 2 == 0 && y >= mi && y <= ma) Py;
	else Pn;
}

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

#define ll long long 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define push push_back
using namespace std;

int main(){
	fastio
	string a;
	cin >> a;
	if(a[2]==a[3]&&a[4]==a[5]){
		cout << "Yes";
	}else{
		cout << "No";
	}
}

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

int main(){
	char d[1005];
	scanf("%s",d);
	for(int i=0;i<1000;i++){
		if(d[i]==0) break;
		d[i]-=3;
		if(d[i]<'A') d[i]+=26;
		printf("%c",d[i]);
	}
	printf("\n");
}

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


int main() {
	int N;
	cin >> N;
	map<string, long long> s;
	for(int i = 0; i < N; i++){
		string a;
		cin >> a;
		sort(a.begin(), a.end());
		s[a]++;
	}
	long long ans = 0;
	for(auto it = s.begin(); it != s.end(); ++it){
		long long value = it->second;
		value = (value * (value - 1)) / 2;
		ans += value;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-4;

using namespace std;

int combination(int n, int k)
{
	ll res = 1;
	for (int i = 0; i < k; ++i)
		res *= n - i;
	for (int i = 2; i <= k; ++i)
		res /= i;
	return (int)res;
}
int main()
{
	int m;
	while (scanf("%d", &m), m)
	{
		int a[7], b[7];
		for (int i = 0; i < m; ++i)
			scanf("%d %d", a+i, b+i);

		int combi[1001];
		memset(combi, 0, sizeof(combi));
		combi[0] = 1;
		for (int i = 0; i < m; ++i)
		{
			int c[1001];
			memset(c, 0, sizeof(c));
			for (int j = 1; j <= b[i]; ++j)
				for (int k = 1000 - j*a[i]; k >= 0; --k)
					if (combi[k])
						c[k + j*a[i]] += combi[k];
			for (int i = 0; i < 1001; ++i)
				combi[i] += c[i];
		}
		int g;
		scanf("%d", &g);
		while (g--)
		{
			int n;
			scanf("%d", &n);
			printf("%d\n", combi[n]);
		}
	}

	return 0;
}

Measured memory_bytes: 0
using System;
class Program
{
  static void Main(string[] args)
	{
      	// スペース区切りの整数の入力
        string S = Console.ReadLine();
        if (S[0] == S[1] && S[1] == S[2])
        {
            Console.Write("No");
        }
        else
        {
            Console.Write("Yes");
        }
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
string s, t;
char tconn[26], sconn[26];
 
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> s >> t;
 
    bool pos = true;
    for (int i = 0; i < 26; i++) {
        tconn[i] = sconn[i] = '-';
    }
    
    for (int i = 0; i < t.size(); i++) {
        if (tconn[t[i] - 'a'] == '-') {
            tconn[t[i] - 'a'] = s[i];
        } else {
            if (s[i] != tconn[t[i] - 'a']) {
                pos = false;
                break;
            }
        }
        if (sconn[s[i] - 'a'] == '-') {
            sconn[s[i] - 'a'] = t[i];
        } else {
            if (t[i] != sconn[s[i] - 'a']) {
                pos = false;
                break;
            }
        }
 
    }
 
    if (pos) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 916
#include<stdio.h>
int main(void)
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	 if(A==B&&A!=C) printf("Yes\n");
	else if(A==C&&A!=B) printf("Yes\n");
	else if(C==B&&C!=A) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 1600
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        N = cin.nextint;
        var A = new int[114514];
        var B = cin.scanint;
        foreach (var item in B)
        {
            A[item]++;
            A[item + 1]++;
            A[item + 2]++;
        }
        WriteLine(A.Max());
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>s;
  t="ABC";
  if(s=="ABC")t="ARC";
  cout <<t;
}

Measured memory_bytes: 3652
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int n; cin >> n;
  cout << n + (n*n) + (n*n*n) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define MAXN 100010

using namespace std;

int dp[3][MAXN], a[MAXN], b[MAXN], c[MAXN];

int res(int i, int last, int n){
	if(i == n) return 0;
	if(last == -1){
		return max(max(a[i] + res(i+1, 0, n),b[i] + res(i+1, 1, n)),c[i] +res(i+1, 2, n));
	}
	if(dp[last][i] != -1) return dp[last][i];
	if(last == 0){
		return dp[last][i] = max(b[i] + res(i+1, 1, n), c[i] + res(i+1, 2, n));
	}
	else if(last == 1){
		return dp[last][i] = max(a[i] + res(i+1, 0, n), c[i] + res(i+1, 2, n));
	}
	else if(last == 2){
		return dp[last][i] = max(b[i] + res(i+1, 1, n), a[i] + res(i+1, 0, n));
	}
}

int main(){
	memset(dp, -1, sizeof(dp));
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> a[i] >> b[i] >> c[i];
	}
	cout << res(0, -1, n) << endl;	
}

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

int main(){
 int x,a;
 cin >> x >> a;
 if(x<a){
     cout << 0 << endl;
}
else{
    cout << 10 << endl;
}    
}

Measured memory_bytes: 256