akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::cmp::Reverse;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
// use superslice::Ext as _;

#[allow(dead_code)]
fn survey(N: usize, v: &Vec<i64>) -> i64 {
    let mut As: Vec<i64> = v.clone();

    As.sort();

    let mut data = As.clone();
    let mut permutations = Vec::new();

    loop {
        permutations.push(data.to_vec());
        if !data.next_permutation() {
            break;
        }
    }

    let mut ans: i64 = 0;
    for permutation in permutations.iter() {
        let mut cand: i64 = 0;
        for i in 1..N {
            cand += (permutation[i] - permutation[i - 1]).abs();
        }

        const ANSWER: i64 = 25;
        if cand == ANSWER {
            dbg!(permutation, cand);
        }
        ans = max(ans, cand);
    }

    return ans;
}

#[fastout]
fn main() {
    input! {
        N: usize,
        mut As: [i64; N],
    }

    As.sort();

    if N == 2 {
        let ans = (As[1] - As[0]).abs();
        println!("{}", ans);
        return;
    }

    // 貪欲に作っていこう
    let mut rest_q: VecDeque<i64> = As.clone().into_iter().collect();
    let mut ans_q = VecDeque::new();

    let a0 = rest_q.pop_front().unwrap();
    ans_q.push_back(a0);

    while !rest_q.is_empty() {
        let rest_fr = *rest_q.front().unwrap();
        let rest_bc = *rest_q.back().unwrap();

        let ans_fr = *ans_q.front().unwrap();
        let ans_bc = *ans_q.back().unwrap();

        let mut cands = vec![
            (ans_fr - rest_fr).abs(),
            (ans_fr - rest_bc).abs(),
            (ans_bc - rest_fr).abs(),
            (ans_bc - rest_bc).abs(),
        ];
        cands.sort_by_key(|&num| Reverse(num));
        let maxx = cands[0];

        if (ans_fr - rest_fr).abs() == maxx {
            rest_q.pop_front();
            ans_q.push_front(rest_fr);
        } else if (ans_fr - rest_bc).abs() == maxx {
            rest_q.pop_back();
            ans_q.push_front(rest_bc);
        } else if (ans_bc - rest_fr).abs() == maxx {
            rest_q.pop_front();
            ans_q.push_back(rest_fr);
        } else if (ans_bc - rest_bc).abs() == maxx {
            rest_q.pop_back();
            ans_q.push_back(rest_bc);
        }
    }

    let mut ans: i64 = 0;
    let v: Vec<i64> = ans_q.into_iter().collect();

    for i in 1..N {
        ans += (v[i] - v[i - 1]).abs();
    }

    println!("{}", ans);

    // survey(N, &As);
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll N = SZ(S);
    vec A(N, 0);
    
    A[0] = 1;
    if(N >= 2) A[1] = (S[0] == S[1]) ? 1 : 2;
    if(N >= 3) A[2] = (S[0] == S[1] || S[1] == S[2]) ? 2 : 3;
    if(N >= 4) {
        REP(i,3,N) A[i] = (S[i-1] == S[i]) ? (A[i-3] + 2) : (A[i-1] + 1);
    }
    
    PR(A[N-1]);

    return 0;
}

/*



*/

Measured memory_bytes: 5240
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
		ArrayList<Integer>array=new ArrayList<>();
		int N=sc.nextInt();
		int count=0;
		int notCount=0;
		
		for(int i=0;i<N;i++) {
			array.add(sc.nextInt());
			if(array.get(i)%2==0) {
				if(array.get(i)%3==0||array.get(i)%5==0) {
					count++;
				}else {
					notCount++;
				}
			}
		}
		
		if(notCount!=0) {
			System.out.println("DENIED");
		}else {
			System.out.println("APPROVED");
		}
	}

}


Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;
int main() {
    ll x, y;
    cin >> x >> y;
    ll ans = 1001001001001001001;
    if (y - x >= 0)
        ans = min(ans, y - x);
    if (y - (-x) >= 0)
        ans = min(ans, y - (-x) + 1);
    if (-y - x >= 0)
        ans = min(ans, -y - x + 1);
    if (-y - (-x) >= 0)
        ans = min(ans, -y - (-x) + 2);
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s; 
int main()
{
	cin>>s;
	if(s.size()%2==1)
	{
		cout<<"No"<<endl;
	}
	else
	{
		bool ok=true;
		for(int i=0;i<s.size();i+=2)
		{
			if(s[i]!='h' || s[i+1]!='i')
			{
				ok=false;
			}
		}
		if(ok)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

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

int main(void)
{
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    descending = sorted(A, reverse=True)
    maximum = descending[0]
    second = descending[1]
    for a in A:
        if a == maximum:
            print(second)
        else:
            print(maximum)
main()

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int b = 0, w = 0;
    rep(i, N) if (S[i] == '.') w++;

    int ans = w;
    rep(i, N) {
        if (S[i] == '.') w--;
        else b++;
        ans = min(ans, b + w);
    }
    cout << ans << endl;
    return 0;
}

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


struct dice{
    int top;
    vector<int> d;
    void set(){
        for(int i=0;i<6;i++){
            cin >> d.at(i);
        }
        return;
    }
    void roll(char c){
        if(c=='E'){
            top=d.at(0);
            d.at(0)=d.at(3);
            d.at(3)=d.at(5);
            d.at(5)=d.at(2);
            d.at(2)=top;//ここをtopにすることで配列の更新が行われるようになる
        }
        else if(c=='N'){
            top=d.at(0);
            d.at(0)=d.at(1);
            d.at(1)=d.at(5);
            d.at(5)=d.at(4);
            d.at(4)=top;
        }
        else if(c=='W'){
            top=d.at(0);
            d.at(0)=d.at(2);
            d.at(2)=d.at(5);
            d.at(5)=d.at(3);
            d.at(3)=top;
        }
        else if(c=='S'){
            top=d.at(0);
            d.at(0)=d.at(4);
            d.at(4)=d.at(5);
            d.at(5)=d.at(1);
            d.at(1)=top;
        }
        else if(c=='R'){
            roll('N');
            roll('W');
            roll('S');
        }
        else if(c=='L'){
            roll('N');
            roll('E');
            roll('S');
        }
        return;
    }
    void settf(int t,int f){
        int i;
        for(i=0;i<6;i++) if(d.at(i)==t) break;
        if(i==1) roll('N');
        else if(i==2) roll('W');
        else if(i==3) roll('E');
        else if(i==4) roll('S');
        else if(i==5){
            roll('N');
            roll('N');
        }
        for(i=1;i<5;i++) if(d.at(i)==f) break;
        if(i==2) roll('R');
        else if(i==3) roll('L');
        else if(i==4){
            roll('R');
            roll('R');
        }
        return;
    }
};

int main() {
    vector <dice> D(2);
    D.at(0).d={0,0,0,0,0,0};
    D.at(1).d={0,0,0,0,0,0};
    bool flag=true;
    D.at(0).set();D.at(1).set();
    int i;
    for(i=1;D.at(0).d.at(0)==D.at(0).d.at(1)&&i<5;i++){
         D.at(0).roll('R');
    }
    if(D.at(0).d.at(0)==D.at(0).d.at(1)){
        for(flag=false,i=1;D.at(0).d.at(5)==D.at(0).d.at(1)&&i<5;i++){
             D.at(0).roll('R');
        }
    }
    if(!flag){
        D.at(0).settf(D.at(0).d.at(5),D.at(0).d.at(1));
        flag=true;
    }
    D.at(1).settf(D.at(0).d.at(0),D.at(0).d.at(1));
    for(int i=0;i<6;i++){
        if(D.at(0).d.at(i)!=D.at(1).d.at(i))flag=false;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;

void sayNo() {
	cout << "No" << endl;
}

void sayYes() {
	cout << "Yes" << endl;
}


int main() {
	 int N, K;
	 cin >> N >> K;

	 ll dp[N + 1][N + 1][K + 1];
	 for (int i = 0; i <= N; i++) {
		 for (int j = 0; j <= N; j++) {
			 for (int k = 0; k <= K; k++) {
				 dp[i][j][k] = 0;
			 }
		 }
	 }
	 dp[0][0][0] = 1;

	 for (int i = 0; i < N; i++) {
		 for (int j = 0; j <= i; j++) {
			 for (int k = 0; k <= K; k++) {
				 if (k + 2 * j <= K) {
					 dp[i + 1][j][k + 2 * j] += dp[i][j][k] * (2 * j + 1);
					 dp[i + 1][j][k + 2 * j] %= mod;

					 dp[i + 1][j + 1][k + 2 * j] += dp[i][j][k];
					 dp[i + 1][j + 1][k + 2 * j] %= mod;

					 if (j > 0) {
						 dp[i + 1][j - 1][k + 2 * j] += dp[i][j][k] * j * j;
						 dp[i + 1][j - 1][k + 2 * j] %= mod;
					 }
				 }
				 // cout << "(" << i << ", " << j << ", " << k << ") : " << dp[i][j][k] << endl;
			 }
		 }
	 }

	 cout << dp[N][0][K] << endl;

	 return 0;
}


Measured memory_bytes: 51072
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> pii;
const int inf = 1e9;
const double EPS = 1e-8;

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<pii>> adj(n);
    for(int i=0; i<m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        adj[a].emplace_back(b, c);
        adj[b].emplace_back(a, c);
    }
    vector<int> s(k);
    for(int i=0; i<k; i++){
        cin >> s[i];
        s[i]--;
    }

    priority_queue<pii> wait;
    vector<int> mincost(n, inf);
    for(int i: s){
        mincost[i] = 0;
        wait.push(pii(0, i));
    }
    while(!wait.empty()){
        int cost = -wait.top().first;
        int pos = wait.top().second;
        wait.pop();
        if(cost > mincost[pos]) continue;
        for(auto next: adj[pos]){
            int npos = next.first;
            int ncost = next.second +cost;
            if(ncost < mincost[npos]){
                mincost[npos] = ncost;
                wait.push(pii(-ncost, npos));
            }
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(auto p: adj[i]){
            int j = p.first;
            int d = p.second;
            int diff = abs(mincost[i] -mincost[j]);
            if(diff == d){
                ans = max(ans, max(mincost[i], mincost[j]));
            }else{
                ans = max(ans, max(mincost[i], mincost[j]) +(d-diff+1)/2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5972
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on
int x, y;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> y;
  int arr[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

  if (arr[x] == arr[y]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
N=int(input())
a_list=[]
a_list = list(map(int, input().split())) # "1 2 3"と入力
min_num=min(a_list)
nokori_list=[i%min_num for i in a_list if i%min_num!=0]
if len(nokori_list)==0:
    print(min_num)
else:    
    while len(nokori_list)!=0:
        if len(nokori_list)==0:
            answer=min_num
            break
        else:
            nokori_list.append(min_num)
            min_num=min(nokori_list)
            new_list=[i%min_num for i in nokori_list if i%min_num!=0]
            nokori_list=new_list
        answer=min_num
    print(answer)

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

typedef struct P{
    int key,pri;
    struct P *left,*right,*parent;
}Node;

Node *root,*NIL;

void pre(Node *node){
    if(node==NIL){return;}
    printf(" %d",node->key);
    pre(node->left);
    pre(node->right);
}

void ino(Node *node){
    if(node==NIL){return;}
    ino(node->left);
    printf(" %d",node->key);
    ino(node->right);
}

Node* rightRotate(Node* t){
    Node* s = t->left;
    t->left = s->right;
    s->right = t;
    return s;
}

Node* leftRotate(Node* t){
    Node* s = t->right;
    t->right = s->left;
    s->left = t;
    return s;
}

Node* insert(Node* t, int key, int pri){
    Node *z;
    if(t == NIL){
        z = (Node*)malloc(sizeof(Node));
        z->key=key; z->pri=pri; z->left = NIL; z->right=NIL;
        return z;
    }
    if( key < t->key){
        t->left = insert(t->left, key, pri);
        if(t->pri < t->left->pri){
            t = rightRotate(t);
        }
    }else{
        t->right = insert(t->right, key, pri);
        if(t->pri < t->right->pri){
            t = leftRotate(t);
        }
    }
    return t;
}

Node* find(Node *node,int k){
    while(node!=NIL){
        if(k < node->key){node = node->left;}
        else if(k>node->key){node = node->right;}
        else{return node;}
    }
    return NIL;
}

Node* Sdelete(Node*,int);

Node* delete(Node* t, int key){
    if(t == NIL){
        return NIL;
    }
    if(key < t->key){
        t->left = delete(t->left, key);
    }else if(key > t->key){
        t->right = delete(t->right, key);
    }else{
        return Sdelete(t, key);
    }
    return t;
}

Node* Sdelete(Node* t,int key){
    if(t->left == NIL && t->right == NIL){
        free(t);
        return NIL;
    }else if(t->left == NIL){
        t = leftRotate(t);
    }else if(t->right == NIL){
        t = rightRotate(t);
    }else{
        if(t->left->pri > t->right->pri){
            t = rightRotate(t);
        }else{
            t = leftRotate(t);
        }
    }
    return delete(t, key);
}

int main(void){
    int n,i,j,x,y;
    char str[7];
    Node *node;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",str);
        if(str[0]=='i'){
            scanf("%d %d",&x,&y);
            root=insert(root,x,y);
            x++;
        }else if(str[0]=='f'){
            scanf("%d",&y);
            node = find(root,y);
            if(node!=NIL){printf("yes\n");}
            else{printf("no\n");}
        }else if(str[0]=='d'){
            scanf("%d",&y);
            root=delete(root,y);
        }else{
            ino(root);
            printf("\n");
            pre(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 11140
def main
  s = readlines.map {|l| l.chomp }[0]
  k = 0
  a = s.chars
  pre_s = ""
  cur_s = ""
  len = s.size
  flag = false
  a.each_with_index do |c, i|
    if i == (len - 4)
      if s[i..(len)].chars.uniq == 1
        k += 3
        flag = true
        break
      end
    end
    cur_s += c
    if pre_s != cur_s
      k += 1
      pre_s = cur_s
      cur_s = ""
    end
  end
  puts k
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 16764
n = int(input())
a = []
x = []
ans = 0
for i in range(n):
    a.append(int(input()))
    x.append([[0, 0] for _ in range(a[i])])
    for j in range(a[i]):
        e1, e2 = map(int,input().split())
        x[i][j][0] = e1
        x[i][j][1] = e2
for i in range(2**n):
    h = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            h[j] = 1
    if ans >= sum(h): 
        continue
    flag = 1
    for j in range(n):
        if h[j] == 1:
            for k in x[j]:
                if h[k[0]-1] != k[1]:
                    flag = 0
                    break
    if flag == 1:
        ans = max(ans, sum(h))
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int , int>
#define vi vector<int>
#define inf 1e18 //(10^18
#define pqmax priority_queue<int>
#define mii map<int , int>
#define ps(x, y) fixed<<setprecision(y)<<x
// double ans = 1.012345668992
//cout<<ps(ans , 6)
// ans = 1.012345 // 6 decimal places
#define pqmin priority_queue<int , vi , greater<int> >
#define mk(arr , n , type) type *arr = new type[n];
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
// 48->11000(4) (returns no. of zeros after first one)
#define mod 1000000007 //1e9 +7
#define w(t) int t; cin>>t;while(t--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//shuffle(arr , arr +n , rng)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;
//pbds s;
//s.order_of_key(4);
//*s.find_by_order(4);




int32_t main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r", stdin);
	//freopen("output.txt" , "w", stdout);
#endif

	//w(t) {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << "\n";
	}
	else {
		cout << "ABC" << "\n";
	}

	//}


	return 0;


}





Measured memory_bytes: 3656
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N, M;
    cin >> N >> M;
    vector<vector<lint> > A(M);
    REP(i, M){
        lint k; cin>>k;
        A[i].resize(k);
        REP(j, k) cin >> A[i][j];
    }
    vector<lint> P(M);
    REP(i, M) cin>>P[i];
    lint res=0;
    for(lint bit=0; bit<(1<<N); bit++){
        vector<lint> b(N,0);
        for(lint i=0; i<N; i++){
            if((1<<i) & bit){
                // tatteiru
                b[i]=1;
            }
        }
        bool ok = true;
        REP(i, M){
            lint cnt = 0;
            for(lint j=0, k=A[i].size(); j<k; j++){
                if(b[A[i][j]-1]) cnt++;
            }
            if(cnt%2 != P[i]){
                ok=false;
                break;
            } 
        }
        if(ok) res++;
    }
    cout << max(0LL, res) <<endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N, A, B; cin >> N >> A >> B;
    string S; cin >> S;

    int pass_n = 0, kaigai_n = 0;
    rep(i,N) {
        switch(S[i]){
        case 'a':
            if(pass_n < A+B) {
                cout << "Yes" << endl;
                pass_n++;
            } else cout << "No" << endl;
            break;
        case 'b':
            if(pass_n<A+B && kaigai_n < B) {
                cout << "Yes" << endl;
                pass_n++; kaigai_n++;
            } else cout << "No" << endl;
            break;
        case 'c':
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 848
struct Process {
    name: String,
    time: i32,
}

struct Queue<T> {
    data: std::collections::VecDeque<T>,
}

impl<T> Queue<T> {
    fn new() -> Self {
        Self {
            data: std::collections::VecDeque::new(),
        }
    }

    fn push(&mut self, data: T) {
        self.data.push_back(data);
    }

    fn pop(&mut self) -> Option<T> {
        self.data.pop_front()
    }

    fn size(&self) -> usize {
        self.data.len()
    }
}

fn main() {
    let mut q: Queue<Process> = Queue::new();
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("Input error");
    let data = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().expect("Error parsing"))
        .collect::<Vec<i32>>();
    let (total, quantum) = (data[0], data[1]);
    for _ in 0..total {
        input = String::new();
        std::io::stdin().read_line(&mut input).expect("Input error");
        let data = input.trim().split_whitespace().collect::<Vec<&str>>();
        q.push(Process {
            name: String::from(data[0]),
            time: data[1].parse().expect("Error parsing"),
        });
    }
    let mut p_temp: Process;
    let mut total_time = 0;
    while q.size() > 0 {
        p_temp = q.pop().expect("Empty process");
        if p_temp.time - quantum > 0 {
            total_time += quantum;
            q.push(Process {
                time: p_temp.time - quantum,
                ..p_temp
            })
        } else {
            total_time += p_temp.time;
            println!("{} {}", p_temp.name, total_time);
        }
    }
}



Measured memory_bytes: 7080
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int w[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int cnt = 0, p = 0;
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x;
    string s;
    cin>>x>>s;
    if(w[x]==-1)continue;
    if(s[0]=='A'){
      cnt++;
      p+=w[x];
      w[x] = -1;
    } else {
      w[x]++;
    }
  }
  cout<<cnt<<" "<<p<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int count[5]={};
	rep(i,3){
		int hoge;
		scan(hoge);
		count[hoge]++;
		scan(hoge);
		count[hoge]++;
	}
	int onenum=0;
	rep1(i,4) if(count[i]==1) onenum++;
	if(onenum==2) prin("YES");
	else prin("NO");
	return 0;
}


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

int main() {
	int count=0;
	string t,w;
	cin >> w;
	while(1){
		cin >> t;
		if(t=="END_OF_TEXT")break;
		rep(i,0,t.length()){
			t[i] = tolower(t[i]); 
		}
		if(t==w)count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    multiset<int> rest;
    for(int i=0;i<pow(2,N);i++){
        int A;
        cin >> A;
        rest.insert(A);
    }
    auto it=rest.end();
    it--;
    multiset<int> done;
    done.insert(*it);
    rest.erase(it);
    rep(i,N){
        multiset<int> killed;
        for (auto x=done.begin();x!=done.end();x++){
            auto itr=rest.lower_bound(*x);
            if (itr==rest.begin()){
                cout << "No" << endl;
                return 0;
            }
            itr--;
            killed.insert(*itr);
            rest.erase(itr);
        }
        for (auto x=killed.begin();x!=killed.end();x++){
            done.insert(*x);
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 18688
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, N;
    long long x, a, prev, v = 0;
    scanf("%d %lld", &N, &x);
    scanf("%lld", &prev);

    if ( prev > x ){
        v = prev - x;
        prev = x;
    }

    for ( i = 1; i < N; i++ ){
        scanf("%lld", &a);
        if ( prev + a > x ){
            v += prev + a - x;
            prev = x - prev;
        } else {
            prev = a;
        }
    }
    printf("%lld\n", v);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>
#define MAX_M 105
#define MAX_N 105
#define INF (1<<30)
using namespace std;

int M, N;
int X1[MAX_M], Y1[MAX_M];
int X2[MAX_N], Z2[MAX_N];

double width(int X[], int Y[], int n, double x){
  double lb = INF, ub = -INF;
  for(int i = 0; i < n; i++){
    double x1 = X[i], y1 = Y[i];
    double x2 = X[(i + 1) % n], y2 = Y[(i + 1) % n];
    if((x1 - x) * (x2 - x) <= 0 && x1 != x2){
      double a = (y1 - y2) / (x1 - x2);
      double b = (y1 * x2 - y2 * x1) / (x2 - x1);
      double y = a * x + b;
      lb = min(lb, y);
      ub = max(ub, y);
    }
  }
  return max(0.0, ub - lb);
}

void solve(){
  int min1 = *min_element(X1, X1 + M), max1 = *max_element(X1, X1 + M);
  int min2 = *min_element(X2, X2 + N), max2 = *max_element(X2, X2 + N);
  vector<int> xs;
  for(int i = 0; i < M; i++) xs.push_back(X1[i]);
  for(int i = 0; i < N; i++) xs.push_back(X2[i]);
  sort(xs.begin(), xs.end());

  double res = 0;
  for(int i = 0; i < xs.size() - 1; i++){
    double a = xs[i], b = xs[i + 1], c = (a + b) / 2;
    if(min1 <= c && c <= max1 && min2 <= c && c <= max2){
      double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
      double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
      double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
      res += (b - a) / 6 * (fa + 4 * fc + fb);
    }
  }

  printf("%.10f\n", res);
}

int main(){
  while(true){
    scanf("%d %d", &M, &N);
    if(M == 0 && N == 0) break;

    for(int i = 0; i < M; i++) scanf("%d %d", &X1[i], &Y1[i]);
    for(int i = 0; i < N; i++) scanf("%d %d", &X2[i], &Z2[i]);

    solve();
  }
}


Measured memory_bytes: 2708
from collections import deque
n = int(input())

l = [0] * 10 ** 5
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            sum = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            l[sum-1] += 1

for p in l[:n]:
    print(p)


Measured memory_bytes: 75404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s second
const ll INF=(1LL<<60)-1;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
li pow(li a,li b,li mo)
{
    if(a==0)
    return 1;
    li u=pow(a,b/2,mo);
    u=(u%mod*u%mod)%mo;
    if(b%2==1)
    u=(u%mod*a%mod)%mod;
    return u;
}
ll power(ll a,ll b)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s > j.s;
    else
    return i.f<j.f;
    
}

void solve()
{
    
    li n;
    cin>>n;
    map<string,li>mp;
    string s;
    rep(i,n)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    
}
int main()
{
    FAST_IO;
    li t;
    t=1;
  
    while(t--)
    {
        solve();
        cout<<endl;
        
    }
    
}


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

int main(void){
    int X;
    cin >> X;
    if(400<=X && X<=599){cout << "8\n";}
    if(600<=X && X<=799){cout << "7\n";}
    if(800<=X && X<=999){cout <<"6\n";}
    if(1000<=X && X<=1199){cout << "5\n";}
    if(1200<=X && X<=1399){cout<<"4\n";}
    if(1400<=X && X<=1599){cout<<"3\n";}
    if(1600<=X && X<=1799){cout <<"2\n";}
    if(1800<=X && X<=1999){cout<<"1\n";}
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
const int MAX=100000;
const int NIL=-1;
int n;
vector<int>G[MAX]; //頂点を100000とする
                   //隣接リスト
int color[MAX];
void dfs(int r,int c){
  stack<int>S;
  S.push(r); //始点rをスタックに追加
  color[r]=c; //色を入れる
  while(!S.empty()){ //スタックが空でない間
    int u=S.top();
    S.pop();
    for(int i=0;i<G[u].size();i++){
      //頂点uに隣接する頂点vを探索
      int v=G[u][i];
      if(color[v]==NIL){
	color[v]=c;
	S.push(v); //id(色)は変わらない
      }
    }
  }
}
int main(){
  int s,t,m,q;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d%d",&s,&t);
    G[s].push_back(t); //sからtへ辺
    G[t].push_back(s); //tからsへ辺
  }
  int id=1; //colorに入れる色(情報)
  for(int i=0;i<n;i++){
    color[i]=NIL; //すべてにNIL
  }
  for(int u=0;u<n;u++){
    if(color[u]==NIL) dfs(u,id++); //id(色)にかぶりがないように
  }
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d%d",&s,&t);
    if(color[s]==color[t]) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 9000
def streamline(N: int, M: int, X: list) -> int:
    # 隣の点との距離を大きい順に N-1 こ選ぶ.
    # 選んだ部分で N 区間に分割する。
    # 各部分の和が解答
    # => つまり、総距離から N-1 個の最大距離を引けば良い
    _X = sorted(X)
    dist = [_X[i+1] - _X[i] for i in range(M-1)]
    max_dist = sorted(dist, reverse=True)[:N-1]
    return sum(dist) - sum(max_dist)


if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    X = [int(s) for s in input().split()]

    ans = streamline(N, M, X)
    print(ans)


Measured memory_bytes: 13840
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int n;
  cin >> n;
  int m = pow(2, n);
  vl s(m);
  rep (i, m) cin >> s[i];
  sort(all(s));
  if (s[m - 1] == s[m - 2]) {
    cout << "No" << endl;
    return 0;
  }
  
  vl now(1, s.back());
  set<pii> st;
  int i = 1;
  int x = s[0];
  int cnt = 1;
  while (i < m - 1) {
    if (x == s[i]) {
      cnt++;
    }
    else {
      st.insert(pii(x, cnt));
      x = s[i];
      cnt = 1;
    }
    i++;
  }
  st.insert(pii(x, cnt));
  /*
  for (auto itr = st.begin(); itr != st.end(); itr++) {
    pii p = *itr;
    DEBUG(p);
  }
  //*/
  
  rep (i, n) {
    sort(all(now));
    reverse(all(now));
    int temp = now.size();
    rep (j, temp) {
      auto itr = st.lower_bound(pii(now[j], 0));
      if (itr == st.begin()) {
        cout << "No" << endl;
        return 0;
      }
      itr--;
      pii p = *itr;
      st.erase(itr);
      //DEBUG(pii(now[j], p.first));
      now.push_back(p.first);
      p.second--;
      if (p.second > 0) {
        st.insert(p);
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 14592
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<Int, P> T;
#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class UnionFind{
public:
  int n;
  vector<int> u;
  UnionFind(int _n = 0){
    n = _n;
    u = vector<int>(n);
    for(int i = 0;i < n;i++)u[i] = i;
  }
  int r(int x){
    if(u[x] == x)return x;
    return u[x] = r(u[x]);
  }
  int unite(int x, int y){
    x = r(x);
    y = r(y);
    if(x != y)u[x] = y;
  }
};

Int  res, n, m, s, t, w ;
UnionFind uf;
vector<T> edges;
int main(){
  cin >> n >> m;
  uf = UnionFind(n);
  for(int i = 0;i < m;i++){
    cin >> s >> t >> w;
    edges.push_back(T(w, P(s, t)));
  }
  sort(edges.begin(), edges.end());
  for(auto e:edges){
    s = e.second.first;
    t = e.second.second;
    if(uf.r(s) != uf.r(t)){
      res +=e.first;
      uf.unite(s, t);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6012
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

ll a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) puts("0");
	else {
		ll sum = a + b + c;
		ll mini = min(a, min(b, c));
		ll maks = max(a, max(b, c));
		ll mid = sum - mini - maks;
		printf("%lld\n",mid * mini);
	}
	return 0;
}


Measured memory_bytes: 256
def g_c_d(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    else:
        return g_c_d(y, x % y)


def l_c_m(x, y):
    return x * y // g_c_d(x, y)


a = int(input())
b = [int(input()) for _ in range(a)]
c = 1
for i in range(a):
    c = l_c_m(c, b[i])
print(c)


Measured memory_bytes: 3060
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var N = parseInt(input[0],10);
    var K = parseInt(input[1],10);
	var xs = input[2].split(" ").map((x) => parseInt(x,10));
    var diffs = xs.map((x) => {
        var kDiff = Math.abs(x - K);
        var diff = x < kDiff ? x : kDiff;
        return 2*diff;
    })
    var ans = diffs.reduce((pre, current) => {
        return pre + current;
    });
	console.log('%d',ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n,p=map(int,input().split())
a=[int(i) for i in input().split()]


ki=0

for i in a:
    if i%2 != 0:
        ki=1
        break

if ki==0:
    if p==0:
        ans=2**n
    else:
        ans=0
else:
    ans=2**(n-1)
print(ans)
        

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    l = []
    for _ in range(n):
        s = input().rstrip()
        s = sorted(s)
        s = ''.join(s)
        l.append(s)
    c = Counter(l)
    res = 0
    for k, v in c.items():
        res += (v-1)*v//2
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19756
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int A[200000+10];
int main(void) {
    int N;
    cin>>N;

    map<Int,Int> dic;
    for(int i = 1;i <= N;i++) {
        cin>>A[i];
        dic[i+A[i]]++;
    }

    //|i-j| == Ai+Aj
    //--> j-Aj, i+Ai
    Int ans = 0;
    for(Int i = 1;i <= N;i++) {
        ans += dic[i-A[i]];
    }
   
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 27404
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int A, B;
	cin >> A >> B;
	A--;
	B--;

	Int ans = (B + A - 1) / A;

	cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

class UnionFind {
    vector<int> data;
public:
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(){
    
    int n,q;
    cin>>n>>q;
    
    UnionFind inst(10010);
    REP(i,q){
        int s,x,y; cin>>s>>x>>y;
        if(s==0){
            inst.unionSet(x,y);
        }else{
            cout<<inst.findSet(x,y)<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3120
import sys

def calc_flag(b,a,flag):
    if b in a:
        # flag[a.index(b)] = 1
        l_index = [i for i, x in enumerate(a) if x == b]
        for l in l_index:
            flag[l]=1
    return flag

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

flag1 = [0,0,0]
flag2 = [0,0,0]
flag3 = [0,0,0]

for i in range(n):
    b = int(input())
    flag1 = calc_flag(b,a1,flag1)
    flag2 = calc_flag(b,a2,flag2)
    flag3 = calc_flag(b,a3,flag3)

# print(flag1,flag2,flag3)

for i in range(3): #tate
    if flag1[i]+flag2[i]+flag3[i]==3:
        print('Yes')
        sys.exit()

if flag1[0]+flag2[1]+flag3[2]==3 or flag1[2]+flag2[1]+flag3[0]==3: #naname
    print('Yes')
elif sum(flag1)==3 or sum(flag2)==3 or sum(flag3)==3: #yoko
    print('Yes')
else:
    print('No')







Measured memory_bytes: 38256
#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>;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b*100+0.5;
  a *= ib;
  a /= 100;
  printf("%lld\n", a);
  return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 105
int n,N,d;
vector<int> t[MAX_N];
int m[MAX_N];
int f[MAX_N];

bool check(int x,int y){
  if(t[x].size()>t[y].size())swap(x,y);
  vector<int> &X=t[x];
  vector<int> &Y=t[y];
  int j=0;
  /*
  cout<<endl;
  cout<<x<<' '<<y<<endl;
  for(int i=0;i<(int)X.size();i++)cout<<X[i]<<' ';cout<<endl;
  for(int i=0;i<(int)Y.size();i++)cout<<Y[i]<<' ';cout<<endl;
  cout<<endl;
  */
  for(int i=0;i<(int)X.size();i++){
    if(abs(X[i]-Y[j]) > d)return false;
    while(j+1<=m[y]&& abs(X[i]-Y[j+1]) <= d)j++;
  }
  return (Y[j]==0);
}

bool solve(){
  for(int i=0;i<n-1;i++)
    for(int j=i+1;j<n;j++)
      if(!check(i,j))return false;
  return true;
}

void init(){

  for(int i=0;i<MAX_N;i++){
    t[i].clear();

  }
}

int main(){
  while(1){
    cin>>n>>d;
    if(n==0&&d==0)break;
    init();
    for(int i=0;i<n;i++){
      cin>>m[i];
      t[i].resize(m[i]);
      for(int j=0;j<m[i];j++){
	cin>>t[i][j];
      }
      reverse(t[i].begin(),t[i].end());
      for(int j=m[i]-2;j>=0;j--)t[i][j]+=t[i][j+1];
      t[i].push_back(0);
    }
    cout<<(solve()?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1372