jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//これはひどい提出だ

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[100001];
	rep(k, 8) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	const int cm = 1 << 21;
	char cn[cm], * ci = cn;
	fread(cn, 1, cm, stdin);

	int N = 0;
	while (*ci >= '0') N = N * 10 + *ci++ - '0';
	ci++;

	ll are[26];
	are[0] = 1;
	rep(i, 25) are[i + 1] = are[i] * 11;

	ll s[100000];
	rep(i, N) {
		ll k = 0;
		rep(j, 10) k += are[*ci++ - 'a'];
		ci++;
		s[i] = k;
	}

	pakuri_sort(N, s);

	ll kotae = 0;
	ll mae = -1;
	ll kazu = 0;
	rep(i, N) {
		if (mae != s[i]) {
			kotae += kazu * (kazu - 1) / 2;
			mae = s[i];
			kazu = 1;
		}
		else kazu++;
	}

	kotae += kazu * (kazu - 1) / 2;

	printf("%lld", kotae);

	Would you please return 0;
}
//  [cpp]
#include <algorithm>
#include <iostream>
#include <random>
#include <string>
#include <vector>

// ハッシュ計算で使う素数
constexpr int prime[] = {2,  3,  5,  7,  11, 13,  17,  19, 23, 29,
                         31, 37, 41, 43, 47, 53,  59,  61, 67, 71,
                         73, 79, 83, 89, 97, 101, 103, 107};

constexpr size_t alphabet = 26;
constexpr size_t str_len = 10;

inline int64_t hash(char *str, int start, int end) {
  int64_t result = 1;

  // アルファベット1文字ごとに素数を割り当てて掛け算結果をハッシュ値にする
  // オーバーフローしない限りは完全ハッシュ
  for (size_t i = start; i < end; ++i) {
    result *= prime[str[i] - 'a'];
  }

  return result;
}

int main() {
  int n;
  scanf("%d", &n);
  std::vector<int64_t> sn(n);

  // 最大入力数*1行の文字数(改行込み)
  char input[100000 * 11 + 5];

  // 文字列の一括入力
  fread(input, sizeof(char), sizeof(char) * 11 * n, stdin);

  for (int i = 0; i < n; ++i) {
    // 一文字目に改行(Nの後の改行のこと)が存在するので+1する
    sn[i] = hash(input, i * 11 + 1, i * 11 + 10 + 1);
  }

  // 文字列ソートではなく、数値ソートになる
  // unorderd_map使えばソートなくなるけど遅くなる
  std::sort(sn.begin(), sn.end());

  // 最後に合算する
  int64_t count = 0;
  int64_t local_count = 0;
  for (int i = 1; i < n; ++i) {
    if (sn[i - 1] == sn[i]) {
      count += (++local_count);
    } else {
      local_count = 0;
    }
  }

  // ldで出力しないとWAする
  printf("%ld\n", count);

  return 0;
}
//  [cpp]
#include <algorithm>
#include <iostream>
#include <random>
#include <string>
#include <vector>

constexpr int prime[] = {2,  3,  5,  7,  11, 13,  17,  19, 23, 29,
                         31, 37, 41, 43, 47, 53,  59,  61, 67, 71,
                         73, 79, 83, 89, 97, 101, 103, 107};

constexpr size_t alphabet = 26;
constexpr size_t str_len = 10;

inline int64_t hash(std::string &str) {
  int64_t result = 1;

  for (size_t i = 0; i < str_len; ++i) {
    result *= prime[str[i] - 'a'];
  }

  return result;
}

inline int64_t hash(char *str, int start, int end) {
  int64_t result = 1;

  for (size_t i = start; i < end; ++i) {
    result *= prime[str[i] - 'a'];
  }

  return result;
}

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

  char input[100000 * 11 + 5];

  fread(input, sizeof(char), sizeof(char) * 11 * n, stdin);

  std::vector<int64_t> sn(n);

  for (int i = 0; i < n; ++i) {
    sn[i] = hash(input, i * 11 + 1, i * 11 + 10 + 1);
  }

  std::sort(sn.begin(), sn.end());

  int64_t count = 0;
  int64_t local_count = 0;
  for (int i = 1; i < n; ++i) {
    if (sn[i - 1] == sn[i]) {
      count += (++local_count);
    } else {
      local_count = 0;
    }
  }

  printf("%ld\n", count);

  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,i=0,j,c=0,p,m=0,max=0;
    string s[100000];
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s,s+n);
    for(i=0;i<n;i++)
    {
        if(s[i]==s[i+1])
        {
            m++;
            c++;
        }
        else
        {
            m=0;
        }
        if(m==2)
        {
            c++;
        }
    }
    cout << c << endl;
    return 0;

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,i=0,j,c=0,p,m=0,max=0;
    string s[100000];
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(s[i]==s[j])
            {
                c++;
            }
        }
    }
    cout << c << endl;
    return 0;

}
//  [cpp]
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep (i, n) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    
    int ans = 0;
    rep (i, n-1) rep (j, i+1, n)
        if (s[i] == s[j]) ans++;
    
    cout << ans << endl;
    
    return 0;
}
//  [c]
#include <stdio.h>

int sort(long *vlist,int *plist,int *qlist,int n){
  int i,j,k,l,m,s=0,p;
  for(i=0;i<n;i++){
    plist[i]=-1;
    qlist[i]=i+1;
  }
  qlist[n-1]=-1;
  while(qlist[s]!=-1){
    i=s;
    p=-1;
    while(i!=-1){
      j=i;
      k=qlist[j];
      if(k==-1) break;
      i=qlist[k];
      if(vlist[j]<vlist[k]){
        if(p==-1){
          s=k;
        }else{
          qlist[p]=k;
        }
        l=j;
        j=k;
        k=l;
      }
      qlist[j]=i;
      p=j;
      while(k!=-1){
        if((j==-1)|(vlist[j]<vlist[k])){
          l=plist[k];
          plist[k]=plist[m];
          plist[m]=k;
          m=k;
          k=l;
        }else{
          m=j;
          j=plist[m];
        }
      }
    }
  }
  return(s);
} 

int main(){
  int n,i,k,p[100005],q[100005],c[26];
  long m,j,l[100005],a;
  char s[11];
  for(i=0;i<26;i++){
    c[i]=0;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&s);
    l[i]=0;
    k=0;
    for(j=0;j<10;j++){
      c[s[j]-'a']++;
    }
    for(j=0;j<26;j++){
      for(;c[j]>0;c[j]--){
        l[i]|=j<<k;
        k+=5;
      }
    }
  }
  a=0;
  j=0;
  m=0;
  for(i=sort(&l,&p,&q,n);i!=-1;i=p[i]){
    if(a==l[i]){
      j++;
    }else{
      m+=(j*(j+1))>>1;
      j=0;
    }
    a=l[i];
  }
  m+=(j*(j+1))>>1;
  printf("%ld",m);
  return(0);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

typedef struct List {
	struct List *next;
	char *str;
	long long count;
} list;

int hash_string(char* s)
{
	long long x = 0;
	int i;
	for (i = 0; s[i] != 0; i++)	x += 1 << ((s[i] - 'a') * 2);
	return x % 10007;
}

int anagram(char* s1, char* s2)
{
	int i, count[2][26] = {}, flag = 1;
	for (i = 0; s1[i] != 0; i++) count[0][s1[i] - 'a']++;
	for (i = 0; s2[i] != 0; i++) count[1][s2[i] - 'a']++;
	for (i = 0; i < 26; i++) if (count[0][i] != count[1][i]) break;
	if (i == 26) return 1;
	else return 0;
}

int main()
{
	int i, N;
	char s[100001][11] = {};
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%s", s[i]);

	int k;
	long long sum = 0;
	list *p, *hash[10007] = {}, data[100001];
	for (i = 1; i <= N; i++) {
		k = hash_string(s[i]);
		for (p = hash[k]; p != NULL; p = p->next) {
			if (anagram(s[i], p->str) == 1) break;
		}
		if (p == NULL) {
			data[i].str = s[i];
			data[i].count = 1;
			data[i].next = hash[k];
			hash[k] = &(data[i]);
		} else (p->count)++;
	}
	for (k = 0; k < 10007; k++) {
		for (p = hash[k]; p != NULL; p = p->next) sum += p->count * (p->count - 1) / 2;
	} 
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char **GET_ARRAY_CHAR2(long row, long col);
int compare_string(const void *a, const void *b);
void SORT(char s[]);
int main(void) {
   
   int N;
   
   scanf("%d",&N);
  
   char **S = GET_ARRAY_CHAR2(N, 11);
   
   int i,j;
   
   for (i = 0; i < N; i++) {
      scanf("%s",S[i]);
      SORT(S[i]);
   }
   
   qsort(S, N, sizeof *S, compare_string);

   /*
   for (i = 0;i < N;i++) {
      printf("%s\n",S[i]);
   }
    */
   
   long Ans[N];

   
   for (i = 0; i < N; i++) {
      Ans[i] = 1;
   }
   
   int count = 0;
   for (i = 0; i < N - 1; i++) {
      if (strcmp(S[i], S[i+1]) == 0) {
         Ans[count]++;
      }
      else {
         count++;
      }
   }
   
   long ans = 0;
   for (i = 0; i < N; i++) {
      ans = ans + Ans[i]*(Ans[i] - 1)/2;
   }
   

   printf("%ld\n", ans);
   
   return 0;
}

void SORT(char str[]) {
   
   int i,j;
   char a;
   
   for (i = 0; str[i] != 0; i++) {
      for (j = i+1; str[j] != 0; j++) {
         if(str[i] > str[j]){
            a = str[i];
            str[i] = str[j];
            str[j] = a;
         }
      }
   }
}

int compare_string(const void *a, const void *b) {
   return strcmp(*(const char **)a, *(const char **)b);
}



char **GET_ARRAY_CHAR2(long row, long col) {
   
   long i,j;
   
   char **Matrix;
   Matrix = malloc(sizeof(char*)*row);
   if (Matrix == NULL) {
      printf("Error in GET_ARRAY_CHAR2\n");
      printf("Need More Memory(row=%ld)\n",row);
      exit(1);
   }
   for (i = 0; i < row; i++) {
      Matrix[i] = malloc(sizeof(char)*col);
      if(Matrix[i] == NULL){
         printf("Error in GET_ARRAY_CHAR2\n");
         printf("Need More Memory(col=%ld)\n", col);
         exit(1);
      }
   }
   
   /*
   for (i = 0; i < row; i++) {
      for (j = 0;j < col; j++) {
         Matrix[i][j] = 0;
      }
   }
   */
   
   return Matrix;
   
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmp(const void * a, const void * b)
{
  return strcmp((char *)a,(char *)b);
}

int main(){
  long long N;
  long long ans =0,j,k,l;

  scanf("%lld", &N);
  char s[N+1][11];

  for(int i=0; i<N; i++)
  {
    scanf("%s",s[i]);
    qsort(s[i],10, sizeof(char), cmp);
  }

  qsort(s,N,sizeof(s[0]),cmp);

  while(j < N){
    if(strcmp(s[j],s[k+1]) == 0){
      ans++;
      ans += l;
      k++;
      l++;
    }else{
      j= k+1;
      k= j;
      l= 0;
    }
  }

  printf("%lld", ans);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int asc(const void *a,const void *b){return (*(char*)a-*(char*)b);}

int main()
{
  int n;
  scanf("%d", &n);
  char s[n][11];
  int i;
  char str[11];
  for (i = 0; i < n; i++)
  {
    scanf("%s", str);
    qsort(str, 10, sizeof(char), asc);
    strcpy(s[i], str);
  }
  qsort(s, n, sizeof(char)*11, asc);
  long ans = 0, cnt = 0;
  for (i = 0; i < n - 1; i++)
  {
    if (strcmp(s[i], s[i+1]) == 0)
    {
      cnt++;
      ans += cnt;
    }
    else
      cnt = 0;
  }
  printf("%ld", ans);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>

#define lli long long int
int c_f(const void *a, const void *b)
{
	return(*(char*)a - *(char*)b);
}

int s_f(const void *a, const void *b)
{
	return(strcmp(*(char **)a, *(char **)b));
}
int main(void)
{
	int n;
	scanf("%d",&n);
	char **s;
	s = (char**)malloc(sizeof(char *)*(n));
	int i = 0;
	while (i < n)
	{
		s[i] = (char *)malloc(sizeof(char)*(12));
		scanf("%s",s[i]);
		qsort(s[i],10,sizeof(char),c_f);
		i++;
	}
	i = 0;
	qsort(s,n,sizeof(char *),s_f);
	//printf("degbug001000\n");
	i = 0;
	int j = 0;
	lli cnt = 0;
	while (i < n-1)
	{
		j = i+1;
		while (j < n && strcmp(s[i],s[j]) == 0 && j < n)
		{
			//printf("debug:i:%d, j:%d\n",i,j);
			//printf("debug:s_i:%s\n",s[i]);
			//printf("debug:s_j:%s\n",s[j]);
			cnt++;
			j++;
		}
		i++;
	}
	printf("%lld\n",cnt);

	return(0);
}
//  [javascript]
function main(input) {
  const tmp = input.trim().split('\n')
  const n = parseInt(tmp[0])

  const m = new Map()

  for (let i = 1; i <= n; i++) {
    const s = tmp[i]
    const ss = s.split('').sort().join('')

    if (m.has(ss)) {
      m.set(ss, m.get(ss) + 1)
    } else {
      m.set(ss, 1)
    }
  }

  let answer = 0
  m.forEach((v, _) => {
    answer += (v - 1) * v / 2
  })

  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function Main(input){
    const sn = input.split('\n');
    const N = sn.shift();
    let answer = 0;
    let box = new Map();
    for(let i=0; i<sn.length; i++){
        const sortStr = sn[i].split('').sort().join('').trim();
        if(box.has(sortStr)){
            answer += box.get(sortStr);
            box.set(sortStr, box.get(sortStr)+1)
        } else{
            box.set(sortStr, 1);
        }
    }
    console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]

function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var strings=input.slice();
  strings.shift();
  strings=strings.map(e=>{
    return e.split('').sort().join('');
  });
  strings.sort();
  var temp=1;
  var ans=0;
  var previous=strings[0];
  for(var i=1;i<strings.length;i++){
    if(previous===strings[i]){
      temp++;
    }else{
      ans+=temp*(temp-1)/2;
      temp=1;
    }
    previous=strings[i];
  }
  ans+=temp*(temp-1)/2;
  console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input){
    const sn = input.split('\n');
    const N = sn.shift();
    let answer = 0;
    let box = new Map();
    for(let i=0; i<sn.length; i++){
        const sortStr = sn[i].split('').sort().join('');
        if(box.has(sortStr)){
            answer++;
        }
        box.set(sortStr);
    }
    // answer += box.size-1
    console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function Main(input){
    const sn = input.split('\n');
    const N = sn.shift();
    let answer = 0;
    let box = new Map();
    for(let i=0; i<sn.length; i++){
        const sortStr = sn[i].split('').sort().join('');
        if(box.has(sortStr)){
            answer++;
        }
        box.set(sortStr);
    }
    // answer += box.size-1
    console.log(answer);
}
//  [javascript]
function Main(input){
    const sn = input.split('\n');
    const N = sn.shift();
    let answer = 0;
    let box = new Map();
    for(let i=0; i<sn.length; i++){
        const sortStr = sn[i].split('').sort().join('');
        if(box.has(sortStr)){
            answer++;
        }
        box.set(sortStr);
    }
    answer += box.size-1
    console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	n := scanInt()
	anagrams := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s := sort(scanText())
		anagrams[s]++
	}

	ans := 0
	for _, v := range anagrams {
		ans += (v * (v - 1)) / 2
	}

	fmt.Println(ans)
}

func sort(s string) string {
	len := len(s)
	b := []byte(s)
	for i := 0; i < len; i++ {
		min := i
		for j := (i + 1); j < len; j++ {
			if b[j] < b[min] {
				min = j
			}
		}
		b[i], b[min] = b[min], b[i]
	}
	return string(b)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

func min(n []int) (min, idx int) {
	min = math.MaxInt64
	for i := 0; i < len(n); i++ {
		if n[i] < min {
			min = n[i]
			idx = i
		}
	}
	return
}

func max(n []int) (max, idx int) {
	max = math.MinInt64
	for i := 0; i < len(n); i++ {
		if n[i] > max {
			max = n[i]
			idx = i
		}
	}
	return
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := SScan(n)
	d := make(map[[26]int]int)
	for i := 0; i < n; i++ {
		x := [26]int{}
		for _, v := range s[i] {
			x[int(v)-97]++
		}
		d[x]++
	}
	ans := 0
	for _, v := range d {
		ans += v * (v - 1) / 2
	}
	fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
	"sort"
	"strings"
)

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

	dic := make(map[string]int , n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)

		ss := split(s)
		sort.Strings(ss)
		//si = append(si, strings.Join(ss,""))
		str := strings.Join(ss,"")
		curCnt := dic[str]
		if  curCnt == 0 {
			dic[str]++
			continue
		}
		dic[str] +=  curCnt
	}

	cnt := 0
	for _, v := range dic {
		cnt+= v * (v-1) / 2
	}

	fmt.Println(cnt)
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}
//  [go]
package main

import (
	"fmt"
	"sort"
	"strings"
)

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

	dic := make(map[string]int , n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)

		ss := split(s)
		sort.Strings(ss)
		//si = append(si, strings.Join(ss,""))
		str := strings.Join(ss,"")
		curCnt := dic[str]
		if  curCnt == 0 {
			dic[str]++
			continue
		}
		dic[str] +=  curCnt
	}

	cnt := 0
	for _, v := range dic {
		if v - 1 > 0 {
			cnt+= v-1
		}
	}

	fmt.Println(cnt)
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}
//  [go]
package main

import (
	"fmt"
	"sort"
	"strings"
)

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

	dic := make(map[string]int , n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)

		ss := split(s)
		sort.Strings(ss)
		//si = append(si, strings.Join(ss,""))
		cur := dic[strings.Join(ss,"")]
		if  cur == 0 {
			dic[strings.Join(ss,"")]++
			continue
		}
		dic[strings.Join(ss,"")] +=  dic[strings.Join(ss,"")]
	}

	cnt := 0
	for _, v := range dic {
		if v - 1 > 0 {
			cnt+= v-1
		}
	}

	fmt.Println(cnt)
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}
//  [ruby]
n = gets.to_s.to_i
words = Array.new(n){ gets.to_s.chomp.bytes.sort.pack("U*") }

h = Hash.new()
ans = 0
words.each do |s|
  
  if h.has_key?(s)
    ans += (h[s] += 1)
  else
    h[s] = 0
  end
end

puts ans
//  [ruby]
n = gets.to_i
words = Array.new(n){ gets.chomp.bytes.sort.pack("U*") }

h = Hash.new
ans = 0
words.each do |s|
  
  if h.has_key?(s)
    h[s] += 1
    ans += h[s]
    p 
  else
    h[s] = 0
  end
end

puts ans
//  [ruby]
n = gets.chomp.to_i
ss = n.times.map { gets.chomp }

dict = {}
ss.each do |s|
  key = s.chars.sort.join
  dict[key] = (dict[key] || 0) + 1
end

cnt = 0
dict.each do |k, v|
  next if v <= 1
  cnt += (v * (v - 1)) / 2
end

puts cnt
//  [ruby]
n=gets.to_i
s=[]
n.times do |i|
  s[i]=gets.chomp.chars
  s[i].sort!
end
s.sort!
a=s.uniq
ans=[]
for i in 0...a.size
  wa=s.count(a[i])
  ans << wa-1 if wa>1
end
for i in 0...ans.size
  ans[i]=(1..ans[i]).inject(0){|sum,k|sum+=k} if ans[i]>1
end
puts ans.sum
//  [ruby]
n=gets.to_i
s=[]
n.times do |i|
  s[i]=gets.chomp.chars
  s[i].sort!
end
s.sort!
s=s.select{|e|s.count(e)>1}
ans=0
for i in 0...s.size
  j=i+1
  while s[j-1]==s[j]
    j+=1
    ans+=1
  end
end
puts ans
//  [ruby]
n=gets.to_i
s=[]
n.times do |i|
  s[i]=gets.chomp.chars
  s[i].sort!
end
s.sort!
ans=0
for i in 0...n-1
  j=i+1
  while s[j-1]==s[j]
    j+=1
    ans+=1
  end
end
puts ans
//  [rust]
use std::collections::HashMap;

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn read_stdin() -> String {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

fn count(s: &str) -> [u8; 26] {
    let mut a = [0; 26];
    for c in s.chars() {
        a[(c as u8 - 'a' as u8) as usize] += 1;
    }
    a
}

fn comb2(n: u64) -> u64 {
    n * (n - 1) / 2
}

fn main() {
    read_line();
    let mut h = HashMap::new();
    for s in read_stdin().lines() {
        let c = h.entry(count(s)).or_insert(0);
        *c += 1;
    }
    
    println!("{}", h.into_iter().map(|(_, n)| comb2(n)).sum::<u64>());
}
//  [rust]
use std::io::{self, Write};
use parse::ParseNext;
use std::collections::HashMap;

fn main() {
    let str_count: Vec<u64> = {
        let stdin = io::stdin();
        let mut r = read::Reader::new(io::BufReader::new(stdin));
        let n = r.read_line().unwrap().parse().unwrap();
        let mut str_count = HashMap::with_capacity(n);
        for _ in 0..n {
            let mut s = r.read_line().unwrap().as_bytes().to_vec();
            s.sort();

            let mut count = str_count.entry(s).or_insert(0u64);
            *count += 1;
        }
        str_count.values().map(|x| *x).collect()
    };

    let mut sum = 0;
    for count in str_count {
        sum += count * (count - 1) / 2;
    }

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

/// 文字列のパースの補助モジュール.
pub mod parse {
    use std::error;
    use std::fmt;
    use std::str::FromStr;

    #[derive(Eq, PartialEq, Copy, Clone, Hash, Debug)]
    pub enum Error<E> {
        GetNextError,
        ParseErr(E),
    }

    impl<E: fmt::Display> fmt::Display for Error<E> {
        #[inline]
        fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
            match self {
                &Error::GetNextError => f.write_str("Iterator has no next element"),
                &Error::ParseErr(ref e) => write!(f, "{}", e)
            }
        }
    }

    impl<E: error::Error> error::Error for Error<E> {
        #[inline]
        fn description(&self) -> &str {
            match self {
                &Error::GetNextError => "Iterator error",
                &Error::ParseErr(ref e) => e.description()
            }
        }
    }

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> Result<F, Error<F::Err>>;
    }

    impl<'a, S: AsRef<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> Result<F, Error<F::Err>> {
            if let Some(s) = self.next() {
                match s.as_ref().parse() {
                    Ok(x) => Ok(x),
                    Err(e) => Err(Error::ParseErr(e))
                }
            } else {
                Err(Error::GetNextError)
            }
        }
    }
}

/// 標準入力読み取りモジュール.
pub mod read {
    use std::io::{BufRead, Result};

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[inline]
        pub fn read_line(&mut self) -> Result<&str> {
            self.buf.clear();
            self.inner.read_line(&mut self.buf)?;
            Ok(self.buf.trim_right())
        }
    }
}
//  [rust]
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    use std::collections::HashMap;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut count = HashMap::new();
    for _ in 0..n {
        let s: String = scan(tokens);
        let mut s = s.into_bytes();
        s.sort();
        *count.entry(s).or_insert(0) += 1;
    }
    let mut ans: usize = 0;
    for &c in count.values() {
        ans += c * (c - 1) / 2;
    }
    println!("{}", ans);
}
//  [rust]
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, s: [Chars; n]};
    let s: Vec<Vec<char>> = s;
    let mut v: Vec<String> = vec![];

    for i in s.iter() {
        let mut c = i.clone();
        c.sort();
        v.push(c.iter().collect::<String>());
    }

    v.sort();

    let mut index = 0;
    let mut count = 0;
    let mut result = 0;

    for i in 1..n {
        if v[i] == v[index] {
            count += 1;
        } else {
            index = i;
            if count > 0 {
                for j in 1..=count {
                    result += j;
                }
            }
            count = 0;
        }

        if i == n - 1 {
            if count > 0 {
                for j in 1..=count {
                    result += j;
                }
            }
        }
    }

    println!("{}", result);
}
//  [rust]
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, s: [Chars; n]};
    let s: Vec<Vec<char>> = s;
    let mut v: Vec<String> = vec![];

    for i in s.iter() {
        let mut c = i.clone();
        c.sort();
        v.push(c.iter().collect());
    }

    v.sort();

    let mut index = 0;
    let mut count = 0;
    let mut result = 0;

    for i in 1..n {
        if v[i] == v[index] {
            count += 1;
        } else {
            index = i;
            if count > 0 {
                if count > 0 {
                    for j in 1..=count {
                        result += j;
                    }
                }
            }
            count = 0;
        }
    }
    if count > 0 {
        for j in 1..=count {
            result += j;
        }
    }

    println!("{}", result);
}
//  [rust]
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, s: [Chars; n]};
    let s: Vec<Vec<char>> = s;
    let mut v: Vec<String> = vec![];

    for i in s.iter() {
        let mut c = i.clone();
        c.sort();
        v.push(c.iter().collect());
    }

    v.sort();

    let mut index = 0;
    let mut count = 0;
    let mut result = 0;

    for i in 1..n {
        if v[i] == v[index] {
            count += 1;
        } else {
            index = i;
            if count > 0 {
                let mut sum = 1;
                if count > 1 {
                    for j in 1..count {
                        sum += 2 + j - 1;
                    }
                }
                result += sum;
            }
            count = 0;
        }
    }
    if count > 0 {
        let mut sum = 1;
        if count > 1 {
            for j in 1..=count {
                sum += j;
            }
        }
        result += sum;
    }

    println!("{}", result);
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryInput = [String]()
    var ans = 0
    
    for _ in 1...n {
        let str = readLine()!
        var aryStr = [String]()
        for s in str {
            aryStr.append(String(s))
        }
        aryStr.sort()
        aryInput.append(aryStr.reduce("") { $0 + $1 })
    }
    
    aryInput.sort()
    var left = 0
    var right = 1
    while right < n {
        while right < n && aryInput[left] == aryInput[right] {
            ans += right - left
            right += 1
        }
        left = right
        right += 1
    }
    print(ans)
}
main()
//  [swift]
let a=Int(readLine()!)!
var s : [String] = []
//var anag : [Character:Int] = [:]
//var chars : [[Character]] = []
var hashchar : [String:Int] = [:]
//var anaglist : [[Character:Int]] = []
//var kotae : [[Character:Int]:Int] = [] 
var tmps : String 

var o = 0

for var i  in 0..<a {
  //s.append(readLine()!)
  //var arr2 = Array(readLine()!.characters )
  //arr2 = arr2.sort()
  tmps = String( readLine()!.characters.sort() )
  //print( String(arr2) )

  //print(chars)
  /*
  for var j in 0..<arr2.count {
    if(  anag[arr2[j]] == nil ) {
      anag[arr2[j]] = 1
    } else {
      anag[arr2[j]] = (anag[arr2[j]])! + 1
    }
  }*/
  
  //print( hashchar[String(arr2)] )
  if( hashchar[tmps] == nil ) {
    hashchar[tmps] = 0
  } else {
    var tmp = ( hashchar[tmps] )! + 1
    hashchar[tmps] = tmp
    o += tmp
  }
  
  //var z = 0

  //chars.append(arr2)
  //anaglist.append( anag )
  
  //print( anag )
  //anag = [:]
}
/*
for var k in 0..<anaglist.count {
  for var x in k+1..<(anaglist.count) {
    if( anaglist[x] == anaglist[k] ){
      o += 1
    }
  }
}
*/
  
print( o )
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])
const [_, ...s] = stdin.split('\n')

const ans = () => {
  let res = 0

  let sortedList = []
  for (let i = 0; i < n; i++) {
    const str = s[i]

    const sorted = str
      .split('')
      .sort()
      .join('')

    sortedList.push(sorted)
  }

  let obj = {}
  for (let i = 0; i < n; i++) {
    const str = sortedList[i]

    obj[str] = obj[str] === undefined ? 0 : obj[str] + 1

    res += obj[str]
  }

  console.log(res)
}

ans()
//  [typescript]
'use strict'
function main(input: string) {
    const std = input.split('\n');
    const n: number = Number(std[0]);
    const s: string[] = std.slice(1).map(v => v.split('').sort().join(''));
    let r = 0;
    let tmp = new Map();
    s.forEach(v => {
        if (tmp.has(v)) {
            r += tmp.get(v);
            tmp.set(v, tmp.get(v)+1);
        } else {
            tmp.set(v, 1);
        }
    })
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const ss = input.slice(1);
  const map = {};
  for (let i = 0; i < n; i++) {
    const char = ss[i];
    const sortedChar = char.split("").sort().join("");
    if (!map[sortedChar]) {
      map[sortedChar] = 1;
      continue;
    }
    map[sortedChar]++;
  }
  let result = 0;
  Object.keys(map).forEach(key => {
    const num = map[key];
    if (num !== 1) {
      result += combination(num, 2);
    }
  });
  console.log(result);
}
function permutation(n, r) {
for(var i = 0, res = 1; i < r; i++) {
res *= n - i;
}
return res;
}

function combination(n, r) {
return permutation(n, r) / permutation(r, r);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let sr=[],c=0
  for(let i=0;i<n;i++){
    sr.push(ts().split('').sort().join(''))
  }
  sr=sr.sort()
  for(let i=0;i<n-1;i++){
    if(sr[i]==sr[i+1])c++
    if(i!=0){
      if(sr[i]==sr[i+1]&&sr[i]==sr[i-1]){
        c++
      }
    }
  }
  to(c)
}
main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let sr=[],c=0
  for(let i=0;i<n;i++){
    sr.push(ts().split('').sort().join(''))
  }
  sr=sr.sort()
  to(sr)
  for(let i=0;i<n-1;i++){
    if(sr[i]==sr[i+1])c++
    if(i!=0){
      if(sr[i]==sr[i+1]&&sr[i]==sr[i-1]){
        c++
      }
    }
  }
  to(c)
}
main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let sr=[],c=0
  for(let i=0;i<n;i++){
    sr.push(ts().split('').sort().join(''))
  }
  // for(let i=0;i<n-1;i++){
  //   for(let j=i+1;j<n;j++){
  //     if(sr[i]==sr[j])c++
  //   }
  // }
  to(c)
}
main()
//  [python]
a = list(map(int,input().split())) #input from array of integer like "1 2 3"

if a[0]>12:
  ans = a[1]
elif a[0]>5:
  ans = a[1]/2
else:
  ans = 0

print(int(ans))
//  [python]
A,B=map(int,input().split())
if A>=13:
  print(B)
elif A<=5:
  print(0)
else:
  print(int(B/2))
//  [python]
from sys import stdin

a, b = [int(x) for x in stdin.readline().rstrip().split()]

if a >= 13:
  print(b)
elif a >= 6 and a <= 12:
  print(b//2)
else:
  print(0)
//  [python]
if a>=13:
  print(b)
elif a>=6 and a<=12:
  print(int(b/2))
else:
  print(0)
//  [python]
a, b = int(input))
if a <= 5:
    print(0)
elif a <= 12:
    print(b//2)
else:
    print(b)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        System.out.println(problem127a(a, b));
    }

    private static int problem127a(int a, int b) {
        if (a >= 13) {
            return b;
        } else if (a <= 5) {
            return 0;
        }
        return (b / 2);
    }
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int a = reader.nextInt();
		int b = reader.nextInt();
      	if (a <= 5) b = 0;
        else if (a <= 12) b /= 2;
      	System.out.println(b);
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}
//  [java]


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner  = new Scanner(System.in);
		final var r = scanner.nextInt();
		final var D = scanner.nextInt();
		var x = scanner.nextInt();
		for(int i = 0; i < 10; i++) {
			x =  r * x - D;
			System.out.println(x);
		}
		scanner.close();
	}

}
//  [java]
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a<6)
            System.out.println("0");
        else if (a<13)
            System.out.println("b/2");
        else
            System.out.println(b);
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int A = ni();
        int B = ni();
        if(A>=13) out.println(B);
        else if(A>=6) out.println(B/2);
        else put.println(0);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
//  [cpp]
#include<cstdio>
using namespace std;

int main(void) {
	int A, B;
	scanf("%d %d", &A, &B);
	if (A >= 13) {
		printf("%d", B);
	} else if (A >= 6) {
		printf("%d", B / 2);
	} else {
		printf("%d", 0);
	}

	return 0;
}
//  [cpp]
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d%d",&A,&B);
    if(A>=13)
    { C=B;
      printf("%d",B);
    }
    else if(A>=6 && A<=12 )
    {   C=(int)(0.5*B);
        printf("%d",C);
    }
    else
        printf("0");
    return 0;


}
//  [cpp]
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if(a >= 13){
        cout << b;
    }
    else if(a >= 6){
        cout << b/2;
    }
    else{
        cout << 0;
    }

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
  	if(a>=13) cout << b << endl;
  	else if(a>=5) cout << b/2 << endl;
  	else cout << 0 << endl;
}
//  [cpp]
#include <iostream>
using namespace std;

int solve(int A, int B) {
    if (A >= 13)
        return B;
    else if (A <= 12)
        return B/2;
    else
        return 0;
}

int main() {
    int A, B;

    cin >> A >> B;

    int answer = solve(A, B);
    cout << answer;

    return 0;
}
//  [cpp]
#include <iostream>
using namespace std;

int solve(int A, int B) {
    if (A < 6)
        return 0;
    else if (A >= 6)
        return 50;
    else
        return B;
}

int main() {
    int A, B;

    cin >> A >> B;

    int answer = solve(A, B);
    cout << answer;

    return 0;
}
//  [c]
#include <stdio.h>

int main()
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a >= 13)
		printf("%d", b);
	else if (a >= 6)
		printf("%d", b / 2);
	else
		printf("0");
	
	return 0;
}
//  [c]
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a >= 13)
		printf("%d\n", b);
	else if (a >= 6)
		printf("%d\n", b / 2);
	else
		printf("0\n");
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(){
  int A; scanf("%d", &A);
  int B; scanf("%d", &B);

  if(A >= 13) printf("%d\n", B);
  else if(A <= 12 && A >= 6) printf("%d\n", B / 2);
  else printf("%d\n", 0);
  
  return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>=13){
    printf("%d\n",b);
  }else if(a<=5){
    printf("0\n");
  }else{
    pritnf("%d\n",b/2);
  }
  return 0;
}
//  [c]
#include <stdio.h>
int main(){
	int n, m;
	int a, b;
	int l=0, r;
	scanf("%d %d", &n, &m);
	r = n;
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a, &b);
		if (l < a)
			l = a;
		if (r > b)
			r = b;
	}
	if (l > r) {
		l = 1;
		r = 0;
	}
	l--;
	printf("%d\n", r - l);
	return 0;
}
//  [c]
#include <stdio.h>
int main(void)
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(B >= 13){
        printf("%d",B);
    }else if(B >= 6){
        printf("%d",B/2);
    }else{
        printf("%d",0);
    }
}