akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    int a[10010];
    int field[101][101];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int position = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= a[i]; j++){
            if(((position / w) % 2) == 1){
            field[position / w][position % w] = i;
            } else {
                field[position / w][(w - 1) - (position % w)] = i;
            }
            position++;
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << field[i][j];
            if(j < w - 1){
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	string s;  cin >> s;
    int n = s.size();
    rep(i,0,n - 8){
        cout << s[i];
    }
    cout << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; ll x, ans = 0; cin >> n >> x;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  for(int i = 0; i < n-1; i++){
    if(v[i]+v[i+1] > x){
      ans += (v[i]+v[i+1])-x;
      v[i+1] = max(ll(0), v[i+1]-(v[i+1]+v[i]-x));
    }
  }
  cout << ans << endl;
  system("pause");
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

vector<char> pm = {'-', '+'};

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

    string S;
    cin >> S;
    vector<ll> x(4);
    REP(i, 4) x[i] = S[i] - '0';
    REP(i, 2){
    	REP(j, 2){
    		REP(k, 2){
    			ll tmp = 0;
    			tmp += x[0];
    			tmp += (2*i-1)*x[1];
    			tmp += (2*j-1)*x[2];
    			tmp += (2*k-1)*x[3];
    			if(tmp==7){
    				cout << x[0];
    				cout << pm[i];
    				cout << x[1];
    				cout << pm[j];
    				cout << x[2];
    				cout << pm[k];
    				cout << x[3];
    				cout << "=7\n";
    				return 0;
    			}
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
typedef int64_t i64;

int main(void){
    i64 n, s = 1;
    int count = 1, i;
    char alpha[27] = "abcdefghijklmnopqrstuvwxyz";
    scanf("%ld", &n);
    while(n > 26*(26*s-1)/25){
        s *= 26;
        count++;
    };
    n -= 26*(s-1)/25+1;
    for(i = 0; i < count; i++){
        putchar(alpha[n/s]);
        n %= s;
        s /= 26;
    }
    return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  //for(int i=0;i<n;i++) cout<<v[i]<<" \n"[i==n-1];
  int cnt=0;
  for(int i=0;i<n;i++){
    while(i+1<n&&v[i]==v[i+1]){
      i++;
      cnt++;
    }
  }
  int tmp=0,ans=0;
  for(int i=0;i<n;i++){
    if(!(i<cnt-tmp||n-1-i<tmp)) ans=max(ans,n-2*max(tmp,cnt-tmp));
    while(i+1<n&&v[i]==v[i+1]){
      i++;
      tmp++;
      //cout<<tmp<<" "<<cnt-tmp<<endl;
      if(i<cnt-tmp||n-1-i<tmp) continue;
      ans=max(ans,n-2*max(tmp,cnt-tmp));
    }
    if(!(i<cnt-tmp||n-1-i<tmp)) ans=max(ans,n-2*max(tmp,cnt-tmp));
  }
  cout<<ans<<endl;
  return 0;
}


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

void insert_sort(int *a,int l,int r){
    for(int i = l;i < r;i++){
        int temp = a[i];
        int j = i-1;
        while(j >= l&&a[j] > temp){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = temp;
        for(int k = l;k < r;k++){
            if(k != r-1)
                printf("%d ",a[k]);
            else
                printf("%d\n",a[k]);
        }
    }
}

int main()
{
    int a[110],N;
    scanf("%d",&N);
    for(int i = 0;i < N;i++)
        scanf("%d",&a[i]);
    insert_sort(a,0,N);

    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int count = 0;
  for(int j = 0; j < N-1; j++){
    if(S.at(j) == S.at(j+1)){
      count++;
    }
  }
  int ans;
  ans = N - count;
  cout << ans << endl;
}
 
 

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic

typedef int Weight;
typedef int Flow;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addArc(Graph &g, int s, int d, int w = 1) {
    g[s].push_back(Edge(s, d, w));
}
void addEdge(Graph &g, int a, int b, int w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

//???????§????????????????(???????????????)
//Dijkstra O((|E|+|V|)log|V|)
//dist: ?§????????????????????????§??????????????¢
//?????????: ??????????????¨????????????(??????-1)
vector<int> dijkstra(const Graph &g, int s, Array &dist) {
    int n = g.size();
    assert(s < n);
    enum { WHITE, GRAY, BLACK };
    vector<int> color(n, WHITE); color[s] = GRAY;
    vector<int> prev(n, -1);
    dist.assign(n, INF); dist[s] = 0;
    using State = tuple<Weight, int, int>; //?§????????????????????????¢ ??? ???
    priority_queue<State, vector<State>, greater<State>> pq;
    pq.emplace(0, s, -1);
    while (pq.size()) {
        Weight d; int v, u; tie(d, v, u) = pq.top(); pq.pop();
        if (dist[v] < d)continue;
        color[v] = BLACK; prev[v] = u;
        for (auto &e : g[v]) {
            if (color[e.d] == BLACK)continue;
            if (dist[e.d] > dist[v] + e.w) {
                dist[e.d] = dist[v] + e.w;
                pq.emplace(dist[e.d], e.d, v);
                color[e.d] = GRAY;
            }
        }
    }
    return prev;
}

signed main()
{
    int2(n, m);
    Int(st);
    Graph g(n);

    rep(i, m) {
        int2(s, t);
        Int(c);
        addArc(g, s, t, c);
    }

    vi dist;
    dijkstra(g, st, dist);
    rep(i, n) {
        if (dist[i] == INF) {
            std::cout << "INF" << std::endl;
        } else {
            std::cout << dist[i] << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 32068
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Scanner{
  string[] s;
  int i;
 
  char[] cs = new char[] { ' ' };
 
  public Scanner(){
    s = new string[0];
    i = 0;
  }
 
  public string next(){
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }
 
  public int nextInt(){
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0){
    int[] Array = new int[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextInt() + add;
    }
    return Array;
  }
 
  public long nextLong(){
    return long.Parse(next());
  }
 
  public long[] ArrayLong(int N, long add = 0){
    long[] Array = new long[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextLong() + add;
    }
    return Array;
  }
 
  public double nextDouble(){
    return double.Parse(next());
  }

  public double[] ArrayDouble(int N, double add = 0){
    double[] Array = new double[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}

public class procon {
  public procon(){}
  
  Scanner cin;
  public static int Main(){
    new procon().calc();
    return 0;
  }
  
  void calc(){
    cin=new Scanner();
    int N=cin.nextInt();
    int L=cin.nextInt();
    
    string[] S=new string[N];
    for(int i=0; i<N; ++i){
      S[i]=cin.next();
    }
    Array.Sort(S);
    
    Console.WriteLine(string.Join("",S));
  }
}





















Measured memory_bytes: 13408
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, k = input_a
mod = 10 ** 9 + 7
sum = 0

(k..(n+1)).each do |i|
  first = i * (i - 1) / 2
  last = (n * 2 - i + 1) * i / 2
  add = last - first + 1
  sum = (sum + add) % mod
end
puts sum

Measured memory_bytes: 14444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int n, p;
    vector<int> vc;
    cin >> n;
    while(n--) {
        cin >> p;
        vc.push_back(p);
    }
    sort(vc.begin(), vc.end());
    int total = accumulate(vc.begin(), prev(vc.end()), 0);
    total += vc[vc.size()-1]/2;
    cout << total << "\n";
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(all(a));
    if(a[0]==a[1]&&a[1]==a[2]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N, M;
int X[100005];

void solve() {
	if (N >= M) {
		cout << 0 << endl;
		return;
	}
	sort(X, X + M);
	vector<int> bets;
	rep (i, M - 1) bets.pb(X[i + 1] - X[i]);
	sort(rrng(bets));
	ll ans = 0;
	rep2 (i, N - 1, M - 1) ans += bets[i];
	cout << ans << endl;
}

int main() {
	cin >> N >> M;
	rep (i, M) cin >> X[i];
	solve();
	
	return 0;
}

Measured memory_bytes: 4288
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <string>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <cstring>
#define int long long
#define pii pair<int, int>
#define double long double
#define pdd pair<double, double>
#define mp make_pair
#define debug(x) std::cout << #x << ": " << x << '\n';
using namespace std;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
} 

/*const int N = 1e5 + 10;
int f[N], rf[N];*/
const int mod = 1e9 + 7;
/*
int binpow(int a, int b) {
	if (b == 0) return 1;
	if (b & 1) return a * binpow(a, b - 1) % mod;
	int u = binpow(a, b / 2);
	return u * u % mod;
}

void rev(int x) {
	return binpow(x, mod - 2);
}

void prec() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = f[i - 1] * i % mod;
	}
	rf[N - 1] = rev(f[N - 1]);
}
*/
int cnt[26];

signed main() {
	fast();
	//prec();
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	int p = 1;
	for (int i = 0; i < 26; i++) {
		p = p * (cnt[i] + 1) % mod; 
	}
	p--;
	if (p < 0) p += mod;
	cout << p;
	return 0;
}

Measured memory_bytes: 512
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

A,B,C=rl()
print(C if B>=A*C else B//A)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
	cMax := b / c
	cMin := (a - 1) / c
	dMax := b / d
	dMin := (a - 1) / d
	cd := lcm(c, d)
	cdMax := b / cd
	cdMin := (a - 1) / cd
	fmt.Println(b - (a - 1) - ((cMax - cMin) + (dMax - dMin) - (cdMax - cdMin)))
}

func gcd(i, j int) int {
	if i > j {
		i, j = j, i
	}
	for i > 0 {
		i, j = j%i, i
	}
	return j
}

func lcm(i, j int) int {
	return i * j / gcd(i, j)
}


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

#define rep(i,N) for(int i=0; i<(N); i++)
#define pb push_back

typedef long long ll;
typedef pair<int,int> P;
const ll mod=1e9+7;

string s;

int main(){ 

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

cin>>s;

s[5]=' ';
s[13]=' ';

cout<<s<<endl;

}


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

int main(){
  int p,q,r;
  char s[4];
  cin>>p>>q>>r;
  if(p<r){
    if(q<r)cout<<p+q;
    else cout<<p+r;
  }else{
    if(p<q)cout<<r+p;
    else cout<<r+q;
  }
}

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

int search_GCD(int x, int y) //GCD = Greatest Common Divisor
{
    int tmp;

    if (x == y)
    {
        return x;
    }
    else if (x < y)
    {
        tmp = x;
        x = y;
        y = tmp;
    }

    tmp = x % y;

    while (tmp != 0)
    {
        x = y;
        y = tmp;
        tmp = x % y;
    }
    return y;
}

int main()
{
    int x, y;
    cin >> x >> y;
    int gcd = search_GCD(x, y);
    cout << gcd << endl;
}



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

using namespace std;

const int N = 1e5 + 10;
typedef long long ll;
ll val[N];
bool res[N];
ll sum[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> val[i];
    }
    sort(val, val + n);
    for (int i = 0; i < n; i++) {
        sum[i] = i == 0 ? val[i] : val[i] + sum[i - 1];
        if (i == n - 1 || 2 * sum[i] >= val[i + 1])
            res[i] = true;
    }
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (res[i])
            ans++;
        else
            break;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1920
( i => {
  i = i.split('\n').map((val, index) => !index ? val.split('').sort().join('') : val.split('').sort().reverse().join(''));
  console.log(i[0] < i[1] ? 'Yes' : 'No')
})(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7500
n=int(input())

def judge(n):
    preword = input()
    words=[preword]

    for _ in range(n-1):
        word = input()
        if word[0] != preword[-1]: return "No"
        elif word in words: return "No"
        else:
            words.append(word)
            preword=word
    return "Yes"
        
print(judge(n))

Measured memory_bytes: 3060
import java.util.Scanner

fun main(args :Array<String>){
    val cin = Scanner(System.`in`)
    var index = 1
    
    while(true){
	val data = cin.nextInt()
	if(data == 0){
	    break
	}else{
	    println("Case $index: $data")
	    index++
	}
    }
}



Measured memory_bytes: 45808
n,c = map(int,input().split())
l = [[0]*(10**5+5) for _ in range(c)]
for i in range(n):
    s,t,k = map(int,input().split())
    l[k-1][s-1] += 1
    l[k-1][t-1] -= 1
for i in range(c):
    for j in range(1,10**5+2):
        l[i][j] += l[i][j-1]

for i in range(c):
    for j in range(10**5+2):
        if l[i][j] == 0 and l[i][j+1] == 1:
            l[i][j] = 1
ans = 0
for j in range(10**5+1):
    s = 0
    for i in range(c):
        s += l[i][j]
    ans = max(ans,s)

print(ans)

Measured memory_bytes: 98108
#include <iostream>
using namespace std;
int main()
{
    int a=0, b, c, d, z[11], i;
    string s;
    getline(cin, s);
    for (i=0; i<s.length(); i++)
    {
        if (49<=s[i]+0<=57)
        {
            z[i]=s[i]-48;
            a++;
        }
    }
    c=1001;
    for (i=0; i<a-2; i++)
    {
        b=z[i]*100+z[i+1]*10+z[i+2]-753;
        if (b<0)
        {
            b=-b;
        }
        if (b<c)
        {
            c=b;
            d=z[i]*100+z[i+1]*10+z[i+2];
        }
    }
    if (d-753<0)
    {
        cout << 753-d;
    }
    else
    {
        cout << d-753;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string S;
    string str = "CODEFESTIVAL2016";
    cin >> S;
    int counter = 0;
    for(int i = 0; i < str.length(); ++i) {
        if(str[i] != S[i]) {
            ++counter;
        }
    }
    printf("%d\n", counter);
    return 0;
}

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

using namespace std;

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

    int H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<vector<int>> res(H, vector<int>(W));
    for (int i = 0; i < A; ++i) {
        for (int j = 0; j < B; ++j) {
            res[j][i] = 1;
        }
    }
    for (int i = A; i < W; ++i) {
        for (int j = B; j < H; ++j) {
            res[j][i] = 1;
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << res[i][j];
        }
        cout << "\n";
    }


    return 0;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  cin.ignore();
  if((s == "AAA") || (s == "BBB")){
    cout << "No" << endl;
    return 0;
  } else {
    cout << "Yes" << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////
struct RMQRAQ{
    ll n;
    vector<ll>data,lazy;
    RMQRAQ(ll vs){
        n=1;
        while(n<vs)n*=2;
        data.resize(2*n-1,0);
        lazy.resize(2*n-1,0);
    }
    void eval(ll k,ll l,ll r){
        if(lazy[k]!=0){
            data[k]+=lazy[k];
            if(r-l>1){
                lazy[2*k+1]+=lazy[k];
                lazy[2*k+2]+=lazy[k];
            }
            lazy[k]=0;
        }
    }
    void add(ll a,ll b,ll x,ll k,ll l,ll r){
        eval(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            lazy[k]+=x;
            eval(k,l,r);
        }else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            data[k]=min(data[2*k+1],data[2*k+2]);
        }
    }
    void add(ll a,ll b,ll x){add(a,b,x,0,0,n);}//[a,b)にxを加える
    ll query(ll a,ll b,ll k,ll l,ll r){
        eval(k,l,r);
        if(r<=a||b<=l)return inf;
        if(a<=l&&r<=b){
            return data[k];
        }else{
            ll vl=query(a,b,2*k+1,l,(l+r)/2);
            ll vr=query(a,b,2*k+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
    ll query(ll a,ll b){return query(a,b,0,0,n);}//[a,b)の最小値
};

int main(){fastio
    ll n,d,a;cin>>n>>d>>a;
    l_l x[n];rep(i,0,n-1)cin>>x[i].fi>>x[i].se;
    rep(i,0,n-1){
        x[i].se=(x[i].se+a-1)/a;
    }
    sort(x,x+n);
    
    RMQRAQ u(n);
    rep(i,0,n-1){
        u.add(i,i+1,x[i].se);
    }
    ll y[n];rep(i,0,n-1)y[i]=x[i].fi;
    ll ans=0;
    rep(i,0,n-1){
        ll now=u.query(i,i+1);
        if(now<0)continue;
        ll pos=upper_bound(y,y+n,y[i]+2*d)-y;
        ans+=now;
        u.add(i,pos,-now);
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

const long long MX = 1e18;

int main() {
  int n;
  long long a, ans;
  cin >> n;
  bool ng = false;
  ans = 1;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 0) {
      cout << '0' << '\n';
      return 0;
    }
    if (ng || a > MX / ans) {
      ng = true;
    } else {
      ans *= a;
    }
  }
  if (ng) cout << -1 << endl;
  else cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> x(n),y(n),h(n);
	rep(i,n)cin >> x[i] >> y[i] >> h[i];
	auto check = [&](int cx,int cy){
		map<int,int> mp;
		rep(i,n){
			if(h[i] == 0)continue;
			int tmp = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
			mp[tmp]++;
		}
		
		if(mp.size() != 1)return false;
		int H = (*mp.begin()).first;
		if(H < 1)return false;
		rep(i,n){

			int tmp = max(0ll,H - abs(x[i] - cx) - abs(y[i] - cy));
			//trace(tmp,h[i],H);
			if(tmp != h[i])return false;
		}
		return true;
	};
	rep(cx,101){
	 	rep(cy,101){
	 		
	 		if(check(cx,cy)){
	 		   rep(i,n){
					if(h[i] == 0)continue;
					int tmp = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					cout << cx << " " << cy << " " << tmp << endl;
					return 0;
				}
	 		}
	 	}
	}
	
	return 0;
}

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

using namespace std;

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

  int a, b, m;
  cin >> a >> b >> m;
  vector<int> A(a);
  vector<int> B(b);
  vector<vector<int> > M(m);
  rep(i, a)
    cin >> A[i];
  rep(i, b)
    cin >> B[i];

  int minA = *min_element(A.begin(), A.end());
  int minB = *min_element(B.begin(), B.end());
  int ans = minA + minB;

  rep(i, m){
    int x, y, c;
    cin >> x >> y >> c; x--; y--;
    ans = min(ans, A[x] + B[y] - c);
  }

  cout << ans << endl;
}

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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
 
using namespace std;

using ll = long long;

vector<int> v, v1;

int main(){
	for(int i = 1;i * (i + 1) * (i + 2) / 6 <= 1e6;i++){
		v.push_back(i * (i + 1) * (i + 2) / 6);
	}
	for(int i = 1;i * (i + 1) * (i + 2) / 6 <= 1e6;i++){
		//cout<<i*(i+1)*(i+2)/6<<endl;
		if(i * (i + 1) * (i + 2) / 6 % 2 == 1)v1.push_back(i * (i + 1) * (i + 2) / 6);
	}
	int n = 1e6;
	vector<vector<int>> dp(2, vector<int>(n + 1, 1e9));
		dp[0][0] = 0;
		for(int i = 0;i < v.size();i++){
			for(int j = 0;j < n + 1;j++){
				dp[(i + 1)%2][j] = min(dp[i%2][j], dp[(i + 1)%2][j]);
				if(j + v[i] > n){
					continue;
				}

				dp[(i + 1)%2][j + v[i]] = min(dp[(i + 1)%2][j + v[i]], dp[i % 2][j] + 1);
				dp[(i + 1)%2][j + v[i]] = min(dp[(i + 1)%2][j] + 1, dp[(i + 1)%2][j + v[i]]);
			}
		}
		vector<vector<int>> dp1(2, vector<int>(n + 1, 1e9));
		dp1[0][0] = 0;
		for(int i = 0;i < v1.size();i++){
			for(int j = 0;j < n + 1;j++){
				dp1[(i + 1)%2][j] = min(dp1[i%2][j], dp1[(i + 1)%2][j]);
				if(j + v1[i] > n){
					continue;
				}

				dp1[(i + 1)%2][j + v1[i]] = min(dp1[(i + 1)%2][j + v1[i]], dp1[i%2][j] + 1);
				dp1[(i + 1)%2][j + v1[i]] = min(dp1[(i + 1)%2][j] + 1, dp1[(i + 1)%2][j + v1[i]]);
			}
		}
	while(cin >> n){
		if(n == 0)return 0;
		
		cout<<dp.back()[n]<<" "<<dp1.back()[n]<<endl;
	}
}



Measured memory_bytes: 22156
N = int(input())
S = [input() for i in range(N)]

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

condition = lambda maxium: lambda item: item[1] == maximum
condition = condition(maximum)

answer = filter(condition, table.items())
answer = dict(answer)
answer = list(answer.keys())
answer.sort()
answer = "\n".join(answer)

print(answer)


Measured memory_bytes: 53520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		
		int n = Integer.parseInt(input);
		
		int[] array = new int[n];
		
		String[] tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			array[i] = Integer.parseInt(tmpArray[i]);
		}
		
		int result = 0;
		//色を変えながら進んでいく
		for(int i = 1; i < n; i++){
			if(array[i] == array[i - 1]){
				array[i] = -1;
				result++;
			}
		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;

void print(vll vec){
  for(auto& v : vec){
    cout << v << ' ';
  }
  cout << endl;
}

void solve(ll N, vll A){
  bool cont = true;
  while(cont){
    cont = false;
    sort(A.begin(), A.end());
    ll idx = 0;
    ll min = A.at(idx);
    while(min == 0){
      ++idx;
      min = A.at(idx);
    }
    //print(A);
    //cout << min << endl;
    for(ll i = idx + 1; i < N; ++i){
      if(A.at(i) != 0){
        cont = true;
        A.at(i) = A.at(i) % min;
      }
    }
  }
  sort(A.begin(), A.end());
  cout << A.at(N - 1) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  ll N;
  cin >> N;
  vll A(N);
  for(long long i = 0 ; i < N ; ++i){
    cin >> A.at(i);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int n,l,tun[102],pos[21],dir[21],sec,i,j,last,exi;
	char x[9];
	while(1){
		for(i=0;i<102;i++){
			tun[i]=0;
		}
		for(i=0;i<21;i++){
			pos[i]=dir[i]=0;
		}
		sec=0;
		exi=0;
		scanf("%d %d",&n,&l);
		if(n==0&&l==0){
			break;
		}
		for(i=1;i<=n;i++){
			scanf("%s %d",&x,&pos[i]);
			if(x[0]=='R'){
				dir[i]=1;
			}
			else{
				dir[i]=-1;
			}
		}
		while(1){
			sec++;
			for(i=1;i<=n;i++){
				if(pos[i]==1000){
					continue;
				}
				pos[i]+=dir[i];
				tun[pos[i]]++;
			}
			for(i=1;i<l;i++){
				if(tun[i]>1){
					for(j=1;j<=n;j++){
						if(pos[j]==i){
							dir[j]=dir[j]*(-1);
						}
					}
				}
			}
			if(tun[l]!=0||tun[0]!=0){
				for(i=1;i<=n;i++){
					if(pos[i]==l){
						pos[i]=1000;
						dir[i]=0;
						last=i;
						exi++;
						break;
					}
				}
				if(exi==n){
					break;
				}
				for(i=1;i<=n;i++){
					if(pos[i]==0){
						pos[i]=1000;
						dir[i]=0;
						last=i;
						exi++;
						break;
					}
				}
				if(exi==n){
					break;
				}
			}
			for(i=0;i<102;i++){
				tun[i]=0;
			}
		}
		printf("%d %d\n",sec,last);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
    int n;  cin >> n;
    vector<tuple<string,int,int>>p(n);

    for(int i=0;i<n;i++){
        string s;
        int a;
        cin >> s >> a;
        p[i] = make_tuple(s,-a,i+1);
    }
    sort(p.begin(),p.end(),greater<tuple<string,int,int>>());
    

    for(int i=n-1;i>=0;i--){
        cout << get<2>(p.at(i))  << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ld long double
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define sz(v) sizeof(v)
#define MOD 1000000007
#define MAX (ll)1e12+5


using namespace std;


int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
//////
// prime Seive
/*
bitset<1000005> bt;
//unordered_map<ll,bool> is_prime;
vector<ll> primes;
void pS(ll n){
    ll val = min(n+1,(ll)1000006);
    for(ll i=3;i<=val;i+=2){
        bt[i] =true;
    }
    bt[0] =false;
    bt[1] =false;
    bt[2] =false;
    //is_prime[2] =true;
    primes.pb((ll)2);
    for(ll i=3;i<=val;i+=2){
        if(bt[i])
            for(ll j=i*i;j<=val;j+=2*i)
                bt[j] =false;
    }
    for(ll i=3;i<=val;i+=2){
        if(bt[i]){primes.pb(i);
        //is_prime[i]=true;
        //cout<<i<<" :PRIME\n";
        }
    }
    return;
}
*/          
/////
// Fenwick Tree
/*
BIT[200005] ={0};
//BUILD BIT
// for(int i=1;i<1;i++){ cin>>a[i];update(i,a[i],n);};
 
void update(int i,int val,int n){
    while(i<=n){
    BIT[i]+= inc;
    i+= (i&(-i));
    }
}
ll query(int i){
    ll ans =0;
    while(i>0){
        ans+= BIT[i];
        i-=(i&(-i));
    }
    return ans;
}
 
*/
//__builtin_popcount(4)
ll logPow(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){
            ans*=a;
        }
        a*=a;
        b= b>>1;
    }
    return ans;
}

ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}



/*
// dsu
const int N = 500009;
int p[N],cmp[N];
int getP(int cn){
    return ((cn==p[cn])?cn:(p[cn]=getP(p[cn])));
}

void unite(int a,int b){
    a = getP(a);
    b = getP(b);
    if(a==b) return ;
    if(cmp[a]<cmp[b])
        swap(a,b);
    p[b] = a;
    cmp[a] += cmp[b];
}
*/

/*
//dfs
bool dfs(ll src ,ll dest,unordered_map<ll,bool> &vis,unordered_map<ll,vector<ll>> &g){
    vis[src] =true;
    if(src== dest) return true;
    bool  ans =false;
    for(auto nbr: g[src]){
        if(!vis[nbr])
            ans = ans|dfs(nbr,dest,vis,g);
    }
    return ans;
}

*/
// bfs
/*
ll bfs(ll i,unordered_map<ll,bool> &vis){
    queue<ll> q;q.push(i);vis[i] =true;ll ans =0;
    while(!q.empty()){
        ans++;ll cur = q.front();q.pop();
        for(auto nbr: g[cur]){
            if(!vis[nbr]){
                vis[nbr] =true;q.push(nbr);
    }}}
    return ans;
}
*/

unordered_map<ll,vector<ll>> g;

ll modPow(ll a,ll b){
    ll ans =1;
    while(b>0){
        if(b&1){
            ans*=a;
            ans= (ans+MOD)%MOD;
        }
        a*=a;
        a= (a+MOD)%MOD;
        b = b>>1;
    }
    return  ans;
}


int main(){
    ll t=1; 
    //cin>>t;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    while(t--){
        ll n,d; cin>>n>>d;
        ll x,y,cnt=0;
        for(int i=0;i<n;i++){
            cin>>x>>y;
            ll val = x*x+y*y;
            if(val<=d*d) cnt++;
        }
        cout<<cnt<<"\n";
        
    }
    return 0;
}

Measured memory_bytes: 3656
import bisect

n,k= map(int,input().split())
x = [int(i) for i in input().split()]

idx = bisect.bisect_left(x,0)
"""
if x[idx] == 0:
    x.insert(idx,0)
"""
ans = 10**100


for i in range(k+1):
    #print(idx-i,idx+k-1-i)
    if i == 0 and idx+k-1 < n:
        ans = min(ans, x[idx+k-1])
    elif idx - i < 0 or idx+k-1-i >= n:
        continue
    else:
        ans = min(ans, - 2*x[idx-i] + x[idx+k-1-i])
        ans = min(ans, - x[idx-i] + 2*x[idx+k-1-i])

if idx == n:
    ans = -x[-k]

print(ans)

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

int main() {
    long n, a, b, c;
    cin >> n >> a >> b >> c;
    string t, p;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int pa = a, pb = b, pc = c;
        char z;
        if(s == "AB" && b)
            a++, b--, z = 'A';
        else if(s == "AB" && !b)
            a--, b++, z = 'B';
        if(s == "AC" && c)
            a++, c--, z = 'A';
        else if(s == "AC" && !c)
            a--, c++, z = 'C';
        if(s == "BC" && c)
            b++, c--, z = 'B';
        else if(s == "BC" && !c)
            b--, c++, z = 'C';
        if(a < 0 || b < 0 || c < 0) {
            if(!i) {
                cout << "No" << endl;
                return 0;
            }
            a = pa, b = pb, c = pc;
            auto T = t.back();
            t.erase(t.end() - 1);
            if(p == "AB" && T == 'A')
                a -= 2, b += 2, t += 'B';
            if(p == "AB" && T == 'B')
                a += 2, b -= 2, t += 'A';
            if(p == "AC" && T == 'A')
                a -= 2, c += 2, t += 'C';
            if(p == "AC" && T == 'C')
                a += 2, c -= 2, t += 'A';
            if(p == "BC" && T == 'B')
                b -= 2, c += 2, t += 'C';
            if(p == "BC" && T == 'C')
                b += 2, c -= 2, t += 'B';
            if(s == "AB" && b)
                a++, b--, z = 'A';
            else if(s == "AB" && !b)
                a--, b++, z = 'B';
            if(s == "AC" && c)
                a++, c--, z = 'A';
            else if(s == "AC" && !c)
                a--, c++, z = 'C';
            if(s == "BC" && c)
                b++, c--, z = 'B';
            else if(s == "BC" && !c)
                b--, c++, z = 'C';
            if(a < 0 || b < 0 || c < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
        t += z;
        p = s;
    }
    cout << "Yes\n";
    for(auto y : t)
        cout << y << '\n';
    return 0;
}


Measured memory_bytes: 3768
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (input[0] + input[1] + input[2] >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	map<string, ll> mp;
	for(int i = 0; i < n; ++i) {
		string tmp;
		cin >> tmp;
		
		sort(tmp.begin(), tmp.end());
		mp[tmp]++;
	}
	
	ll ans = 0;
	for(auto x : mp) {
		ans += x.second * (x.second - 1) / 2;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
struct si{int a1,a2,a3,a4,a5,a6,a7;};
int n,m,a[10],b[10] = {0,2,5,5,4,5,6,3,7,6},d[10] = {};
vector<int> c[10],s,t;
vector<si> ans;
int ret(int x){
	if(x) return 10;
	return 1;
}
int main(){
	cin >> n >> m;
	int i,j,k,l,o,p,mn = 10;
	for(i=0;i<m;i++){
		int a; cin >> a;
		mn = min(mn,b[a]);
		c[b[a]].push_back(a);
	}
	for(i=0;i<10;i++){
		sort(c[i].begin(),c[i].end());
		if(c[i].size()) d[i] = i;
	}
	int x = n%mn,mx = -1;
	d[mn] = 0;
	for(i=0;i<ret(d[2]);i++){
		for(j=0;j<ret(d[3]);j++){
			for(k=0;k<ret(d[4]);k++){
				for(l=0;l<ret(d[5]);l++){
					for(o=0;o<ret(d[6]);o++){
						for(p=0;p<ret(d[7]);p++){
							int z = (d[2]*i+d[3]*j+d[4]*k+d[5]*l+d[6]*o+d[7]*p);
							if(n<z) continue;
							if(z%mn==x) mx = max(mx,(n - z)/mn + i + j + k + l + o + p);
						}
					}
				}
			}
		}
	}
	for(i=0;i<ret(d[2]);i++){
		for(j=0;j<ret(d[3]);j++){
			for(k=0;k<ret(d[4]);k++){
				for(l=0;l<ret(d[5]);l++){
					for(o=0;o<ret(d[6]);o++){
						for(p=0;p<ret(d[7]);p++){
							int z = (d[2]*i+d[3]*j+d[4]*k+d[5]*l+d[6]*o+d[7]*p);
							if(n<z) continue;
							if(z%mn==x && (n - z)/mn + i + j + k + l + o + p==mx){
								ans.push_back({i,j,k,l,o,p,z});
							}
						}
					}
				}
			}
		}
	}
	for(i=0;i<ans.size();i++){
		for(j=0;j<ans[i].a1;j++){
			s.push_back(2);
		}
		for(j=0;j<ans[i].a2;j++){
			s.push_back(7);
		}
		for(j=0;j<ans[i].a3;j++){
			s.push_back(4);
		}
		for(j=0;j<ans[i].a4;j++){
			s.push_back(c[5].back());
		}
		for(j=0;j<ans[i].a5;j++){
			s.push_back(c[6].back());
		}
		for(j=0;j<ans[i].a6;j++){
			s.push_back(8);
		}
		for(j=0;j<(n - ans[i].a7)/mn ;j++){
			s.push_back(c[mn].back());
		}
		sort(s.rbegin(),s.rend());
		if(t.size()<s.size()) t = s;
		for(j=0;j<t.size();j++){
			if(s[j]>t[j]){
				t = s;
				break;
			}
			if(s[j]<t[j]) break;
		}
		s.clear();
	}
	for(i=0;i<t.size();i++){
		cout << t[i] ;
	}
	cout << endl;
}

Measured memory_bytes: 256
def main():

    n = input()
    tmp = n[0]
    cnt = 0

    for i in n[1:]:
        if i==tmp:
            cnt += 1
            tmp = i
        elif cnt == 2:
            print('Yes')
            exit()
        else:
            cnt = 0
            tmp = i
    print('Yes' if cnt >= 2 else 'No')




if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// g++ -o a a.cpp -Wall -lm -std=c++17
int main(){
    ll n;cin>>n;
    set<ll>s;
    rep(i,n){
        ll t;cin>>t;
        s.insert(t);
    }
    ll k=n-(ll)s.size();
    if(k%2==0)cout<<s.size()<<endl;
    else cout<<s.size()-1<<endl;
    return 0;    
}

Measured memory_bytes: 8296
#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() {
	string s;
	cin >> s;
	ll k = s.length();
	ll sum = 0;
	rep(i,k) {
		sum += int(s[i]-'0');
		sum = sum % 9;
	}
	if (sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

const long long mod = 1000000007;

int main()
{
    int n;
    std::cin >> n;
    std::map<long long , long long> map;
    for(int itr = 2; itr <= n; itr++){
        int cur = itr;
        for(int i = 2; i * i <= cur; i++){
            if(cur % i == 0){
                while(cur % i == 0){
                    cur /= i;
                    map[i]++;
                }
            }
        }
        if(cur != 1)map[cur]++;
    }
    long long res = 1;
    for(auto i : map){
        res *= ( i.second + 1 );
        res %= mod; 
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	while(1){
		int n,k;
		int cdata[101];
		cin >> n;
		if(n==0) break;
		vector<int> data[101];
		REP(i,n){
			int m;
			cin >> m;
			REP(j,m){
				int tmp;
				cin >> tmp;
				data[i].pb(tmp);
			}
			sort(All(data[i]));
		}
		cin >> k;
		REP(i,k) cin >> cdata[i];
		sort(cdata,cdata+k);
		bool flag;
		int cnt = 0;
		int ans;
		REP(i,n){
			flag = true;
			REP(j,k){
				if(!binary_search(data[i].begin(),data[i].end(),cdata[j])) flag = false;
			}
			if(flag){
				cnt++;
				ans = i+1;
			}
		}
		if(cnt==1){
			cout << ans << endl;
		}else{
			cout << -1 << endl;
		}

	}
}

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

using namespace std;

typedef long long ll;

const int N = 100010;
const int MOD = 1e9 + 7;

ll f[N], inv[N];
int n, x, p[N], tot;

ll bigMod (ll a, int e) {
	if (e == -1) e = MOD - 2;
	ll r = 1; while (e) {
		if (e & 1) r = (r * a) % MOD;
		a = (a * a) % MOD;
		e >>= 1;
	}
	return r;
}

ll nCr (int n, int r) {
	if (n < r) return 0;
	ll res = (f[n] * inv[r]) % MOD;
	res = (res * inv[n - r]) % MOD;
	return res;
}

int main() {
	f[0] = inv[0] = 1LL;
	for (int i = 1; i < N; ++i) {
		f[i] = (i * 1LL * f[i - 1]) % MOD;
		inv[i] = bigMod(f[i], -1);
	}
	scanf("%d", &n);
	for (int i = 1; i <= n + 1; ++i) {
		scanf("%d", &x);
		if (p[x] == 0) {
			p[x] = i;
		} else {
			tot = p[x] + n - i;
		}
	}
	for (int k = 1; k <= n + 1; ++k) {
		ll ans = nCr(n + 1, k) - nCr(tot, k - 1);
		ans += MOD, ans %= MOD;
		printf("%lld\n", ans);
	}
  return 0;
}



Measured memory_bytes: 3200
n=int(input())
data=list(map(int,input().split()))
data=sorted(data)
ans=0
for i in range(len(data)):
    for j in range(i+1,len(data)):
        for k in range(j+1,len(data)):
            if data[i]!=data[j] and data[j]!=data[k]:
                if data[k]<data[i]+data[j]:
                    ans+=1
print(ans)

Measured memory_bytes: 9144
import itertools

N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

a = -1
b = -1
ind = 0
for i in itertools.permutations(list(range(1, N+1))):

    if p == i:
        a = ind
    if q == i:
        b = ind
    ind += 1

if a == -1 or b == -1:
    print(a, b)
else:
    print(abs(a-b))

Measured memory_bytes: 3064