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

int main()
{
    ios::sync_with_stdio(false);  cin.tie(0); 
    int n , ac=0 ,tle=0, wa=0, re=0;
    string s;
    cin >> n;
    while(n--)
    {
        cin >> s;
        if (s == "AC")
            ac++;
        else if (s == "TLE")
            tle++;
        else if (s == "WA")
            wa++;
        else
            re++;
    }
    cout << "AC x " <<ac <<"\nWA x "<<wa;
    cout << "\nTLE x "<<tle<<"\nRE x "<<re;
    return 0;
}


Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;
 
 
#define FILENAME ""
 
const ll MAXN = 100002;

                          
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    //freopen("sum2.in", "r", stdin);
    //freopen("sum2.out", "w", stdout);
	ll a, b;
	cin >> a >> b;
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
	 	cout << a*b;
   	}
   	else {
   	 	cout << -1;
   	}
    re 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, long long> cnt;
    for (auto i = 0; i < n; i++)
    {
        string str;
        cin >> str;
        s[i] = str;
    }
    for (auto i = 0; i < n; i++)
    {
        sort(s[i].begin(), s[i].end());
    }

    for (auto i = 0; i < n; i++)
    {
        auto iter = cnt.find(s[i]);
        if (iter != cnt.end())
        {
            iter->second += 1;
        }
        else
        {
            cnt[s[i]] = 1;
        }
    }

    long long ans = 0;

    for (auto i = cnt.begin(); i != cnt.end(); ++i)
    {
        if (i->second > 1)
        {
            ans += i->second * (i->second - 1) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 18176
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n = Integer.parseInt(sc.next()); //N
		int number[]= new int [n];
		int ans[] =new int [n];
		for(int i=0;i<n;i++) {
			number[i]= Integer.parseInt(sc.next()); 
		}
		int []sub =number.clone();
		sc.close();
		Arrays.sort(number);
		for(int k=0;k<n;k++) {
			if(sub[k]>=number[n/2]) {
				System.out.println(number[(n/2)-1]);
			}else
				System.out.println(number[(n/2)]);
		}
	}
}

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

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


    void Solve()
    {
        WriteLine((cin.Nextint - 1) * (cin.Nextint - 1));
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

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

using namespace std;

#define ll long long

struct Zoo {
private:
	int n;
public:
	int* k; // k[i] := 羊なら1,狼なら2,未定なら0
	// コンストラクタ
	Zoo(int n) {
		this->n = n;
		this->k = new int[n];
		for (int i = 0; i < n; ++i)
			k[i] = 0;
	}
	// kを出力する
	void show() {
		for (int i = 0; i < n; ++i)
			cout << (k[i] == 1 ? 'S' : 'W');
		cout << endl;
	}
};

// 動物0,1がそれぞれk0,k1であるとき、
// 残りの動物を順に割り当て、OKかどうか
// 判定する.
bool judge(int n, string s, int k0, int k1) {
	Zoo z(n);
	z.k[0] = k0;
	z.k[1] = k1;
	for (int i = 2; i < n; ++i) {
		// 動物i-1の発言に基づいて動物iを決定する.
		if (z.k[i - 1] == 1 && s[i - 1] == 'o') {
			z.k[i] = z.k[i - 2];
		}
		else if (z.k[i - 1] == 1 && s[i - 1] == 'x') {
			z.k[i] = z.k[i - 2] == 1 ? 2 : 1;
		}
		else if (s[i - 1] == 'o') {
			z.k[i] = z.k[i - 2] == 1 ? 2 : 1;
		}
		else
			z.k[i] = z.k[i - 2];
	}
	bool f = true; // 割り当てが正しいかのフラグ
	// 動物n-1の発言を検証する
	if (z.k[n - 1] == 1) { // 羊の場合
		if (s[n - 1] == 'o')
			f = f && z.k[n - 2] == z.k[0];
		else
			f = f && z.k[n - 2] != z.k[0];
	}
	else { // 狼の場合
		if (s[n - 1] == 'o')
			f = f && z.k[n - 2] != z.k[0];
		else
			f = f && z.k[n - 2] == z.k[0];
	}
	// 動物0の発言を検証する
	if (z.k[0] == 1) { // 羊の場合
		if (s[0] == 'o')
			f = f && z.k[n - 1] == z.k[1];
		else
			f = f && z.k[n - 1] != z.k[1];
	}
	else { // 狼の場合
		if (s[0] == 'o')
			f = f && z.k[n - 1] != z.k[1];
		else
			f = f && z.k[n - 1] == z.k[1];
	}
	// 割り当てが正しくないならfalse
	if (!f) return false;
	// 正しいなら出力してtrue
	z.show();
	return true;
}

signed main() {
	int n; cin >> n;
	string s; cin >> s;

	for (int i = 0; i < 4; ++i) {
		if (judge(n, s, i / 2 + 1, (i & 1) + 1)) return 0;
	}

	cout << "-1\n";

	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    string s; cin >> s;
    cout << s.substr(0,3) << endl;
return 0;
}



Measured memory_bytes: 3628
## coding: UTF-8
import math
MOD = 10**9+7
N = int(input())
#A = []
#for i in range(N):
    #A.append(list(map(int,input().split()))) 
d = dict()
'''
def bisection(a, n, p):
    #二分累乗法によるO(log p)計算
    bin_str = format(n, 'b')
    res = 1
    tmp = a
    for i in range(1, len(bin_str)+1):
        if(bin_str[(-1)*i] == '1'):
            res = res * tmp % p
        tmp = tmp * tmp % p
    return res
'''
d['a'] = 0
d['b'] = 0
d['c'] = 0

for i in range(N):
    #l = list(map(int,input().split()))
    #l = A[i]
    a,b=map(int,input().split())
    #if(l[0] == 0):
    if(a == 0):
        #if(l[1] == 0):
        if(b == 0):
            d['c'] += 1
        else:
            d['b'] += 1
    #elif(l[1] == 0):
    elif(b == 0):
        d['a'] += 1
    else:
        #g = math.gcd(l[0], l[1])
        g = math.gcd(a, b)
        #a = int(l[0]/g)
        #b = int(l[1]/g)
        a = a//g
        b = b//g
        if(a<0):
            p = (-1*a, -1*b)
        else:
            p = (a, b)
        if p in d:
            d[p] += 1
        else:
            d[p] = 1
    #print('i:{}, l[0]:{}, l[1]:{}, d:{}'.format(i, l[0], l[1], d))

#res = 1
a = d.pop('a')
b = d.pop('b')
#あとで二分累乗法に変換する4 
#if(a > 0 and b > 0):
    #a, b>=0 より、a+b>=0, よってa==0 and b == 0でなければ、a >0 or b> 0
    #ma = bisection(2, a, MOD)
    #mb = bisection(2, b, MOD)
    #res *= ma + mb -1
res = pow(2, a, MOD) + pow(2, b, MOD) - 1
res %= MOD

#elif(a == 0 and b > 0):
    #mb = bisection(2, b, MOD)
    #res *= mb
    #res %= MOD
#elif(a > 0 and b == 0):
    #ma = bisection(2, a, MOD)
    #res *= ma
    #res %= MOD
c = d.pop('c')

#print('a:{}, b:{}, c:{}'.format(a,b,c))
#print('d:{}, len(d):{}'.format(d, len(d)))
#print('res', res)

while len(d) > 0:
    s, v = d.popitem()
    if(s[1] < 0):
        opposite = (-1*s[1], s[0])
    else:
        opposite = (s[1], -1*s[0])
    if opposite in d:
        t = d.pop(opposite)
        #print('s:{}, v:{}, opposite:{}, t:{}, d:{}, len(d):{}'.format(s, v, opposite, t, d, len(d)))
        #mv = bisection(2, v, MOD)
        #mt = bisection(2, t, MOD)        
        #res *= mv + mt - 1
        res *= pow(2, v, MOD) + pow(2, t, MOD) - 1
        res %= MOD
    else:
        #print('s:{}, v:{}, opposite:{},       d:{}, len(d):{}'.format(s, v, opposite, d, len(d)))
        #mv = bisection(2, v, MOD)        
        #res *= mv
        res *= pow(2, v, MOD)
        res %= MOD
    #print('res', res)


res += c
res = (res + MOD - 1) % MOD

print(res)

Measured memory_bytes: 119192
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 一行読み込み、空白で分解してusize２つパースする

    let (A, B, T) = get!(usize, usize, usize);
    let ans = T / A * B;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
struct Data
{
	ll num;
	Data() :num(INF) {};
	Data(ll n) :num(n) {};
};

struct SegmentTree
{
	ll n; vector<Data> data;
	SegmentTree(ll N)
	{
		n = 1;
		while (n < N) n *= 2;
		data.resize(2 * n);
	}
private:
	Data sub(ll left, ll right, ll node, ll nleft, ll nright)
	{
		if (nright <= left || right <= nleft) return Data();
		if (left <= nleft && nright <= right) return data[node];
		Data vl = sub(left, right, node * 2 + 1, nleft, (nleft + nright) / 2);
		Data vr = sub(left, right, node * 2 + 2, (nleft + nright) / 2, nright);
		return min(vl.num, vr.num);
	}

public:
	void update(ll pos, Data value)
	{
		pos += n - 1;
		data[pos] = value;
		while (pos > 0)
		{
			pos = (pos - 1) / 2;
			data[pos] = min(data[pos * 2 + 1].num, data[pos * 2 + 2].num);
		}
	}
	Data min_query(ll left, ll right)
	{
		return sub(left, right, 0, 0, n);
	}
};



int main()
{
	ll n;
	cin >> n;
	SegmentTree seg(n);
	REP(i, n) seg.update(i, 0);
	REP(i, n)
	{
		ll a;
		cin >> a;
		ll val = seg.min_query(0, a).num - a;
		seg.update(a-1, val);
	}
	cout << n*(n + 1) / 2 + seg.min_query(0, n).num << endl;
	return 0;
}

Measured memory_bytes: 4920
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using ll = long long;

vector<ll> bucket(100002, 0);

int main() {
    ll N;
    cin >> N;

    for (ll n = 0; n < N; n++) {
        ll a;
        cin >> a;

        if (a != 0) { bucket[a - 1] += 1; }
        bucket[a] += 1;
        bucket[a + 1] += 1;
    }

    cout << *max_element(bucket.begin(), bucket.end()) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	string s;
	cin>>n>>s;
	int a=0,b=0;
	FOR(i,0,n){
		if(s[i]=='R')a++;
		else b++;
	}
	if(a>b)cout<<"Yes";
	else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;cin>>n;
    ll b,a2;
    for(ll a=sqrt(n); a>=1; a--){
        if(n%a==0){
            b=n/a;
            a2=a;
            break;
        }
    }

    cout<<b+a2-2<<endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, D, Q, A[500009], d[500009];
ll B[500009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>D;
    
    rep(i,N) cin>>d[i];
    
    A[0]=D;
    rep(i,N){
        A[i+1] = min(A[i],abs(A[i]-d[i]));
    }
    
    B[N]=1;
    rrep(i,N-1){
        if(B[i+1]<=1LL*d[i]/2){
            B[i]=B[i+1];
        }else{
            B[i]=B[i+1]+d[i];
        }
    }
    
    cin>>Q;
    rep(i,Q){
        int q; cin>>q;
        q--;
        cout1((A[q]>=B[q+1]?"YES":"NO"));
    }
}

Measured memory_bytes: 9728
#include <stdio.h>
int main()
{
    int a = 0, b = 0, con = 0;
    scanf("%d %d", &a, &b);
    con = a - 2 * b;
    if (con < 0)
    {
        con = 0;
    }
    printf("%d", con);
    return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp


public class Test
{
	public static void Main()
	{

		  string[] str1 = Console.ReadLine().Split(' ');
		  int n = int.Parse(str1[0]); 
		  int m = int.Parse(str1[1]); 

		
		  //Console.WriteLine("改行あり N = {0} P = {1} Ai = {2}", n, p, a);
		  Console.WriteLine(calc(n,m));


	}

  public static ulong calc(int n,int m) {
	ulong t = 0;
	ulong mm= (ulong)m-1;
	  for(int i=1;i<n;i++) t = t+(t/mm)+1;



	  return t;
  }
  

  
  

}



Measured memory_bytes: 9240
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main() 
{
	int n;

	cin >> n;

	if (n == 1)
	{
		cout << 0 << endl;
	}
	else
	{
		int64_t n2 = n - 1;
		cout << n2 * (n2 + 1) / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool find(long long N, vector<long long>&A) {
    for (long long i = 0; i < A.size(); i++) {
        if (A.at(i) == N) return true;
    }
    return false;
}
int main() {
    string S; cin >> S;
    if (S.at(S.size() - 1) == 's') {
        cout << S + "es" << endl;
    }
    else cout << S + 's' << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
using namespace std;

typedef long long int64;

typedef double float64;
typedef long double float128;

const int kMaxN = 1e5+5, kInf = 0x3f3f3f3f;

string txt[100];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w; cin >> h >> w;
    for (int i = 0; i < h; i += 1) {
        cin >> txt[i];
    }

    vector<vector<int>> best(h, vector<int>(w, (int)1e9));
    best[0][0] = 0;
    queue<pair<int, int>> bfs;

    bfs.push({0, 0});

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

    while (bfs.size()) {
        int x, y; tie(x, y) = bfs.front();
        bfs.pop();

        for (int d = 0; d < 4; d += 1) {
            int nx = dx[d] + x;
            int ny = dy[d] + y;
            if (!(0 <= nx and nx < h and 0 <= ny and ny < w)) {
                continue;
            }

            if (txt[nx][ny] == '#') {
                continue;
            }

            int new_c = 1 + best[x][y];
            if (best[nx][ny] > new_c) {
                best[nx][ny] = new_c;
                bfs.push({nx, ny});
            }
        }
    }

    int num = 0;
    for (int i = 0; i < h; i += 1) {
        for (int j = 0; j < w; j += 1) {
            num += txt[i][j] == '.';
        }
    }

    if (best[h - 1][w - 1] == (int)1e9) {
    	cout << -1 << '\n';
    	return 0;
    }

    cout << num - best[h - 1][w - 1] - 1 << '\n';

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    ll x;
    cin>>x;
    ll a=100;
    ll ans=0;
    while(a<x)
    {
        a*=1.01;
        ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mp make_pair
#define sqr(x) (x)*(x)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=200007;
const ll inf=0x3f3f3f3f;
const int mod=998244353;
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int a[maxn];
map<int,int> b;
int main(){
    int n=read();
    rep(i,1,n) a[i]=read();
    ll ans=0;
    rep(i,1,n){
        ans+=b[i-a[i]];
        b[a[i]+i]++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 21288
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    ll h,w;cin>>h>>w;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    vector<pll>ans(0);
    vector<vector<ll> >visited(h,vector<ll>(w));
    rep(i,h){
        rep(j,w){
            if(visited[i][j])continue;
            visited[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            ll cnt1=0,cnt2=0;
            while(!q.empty()){
                pll k=q.front();
                ll x=k.first,y=k.second;
                q.pop();
                if(s[x][y]=='#')cnt1++;
                else cnt2++;
                rep(k,4){
                    if(x+dx[k]<0||x+dx[k]>=h||y+dy[k]<0||y+dy[k]>=w)continue;
                    ll nx=dx[k]+x,ny=dy[k]+y;
                    if(visited[nx][ny])continue;
                    if(s[nx][ny]!=s[x][y]){
                        q.push(mp(nx,ny));
                        visited[nx][ny]=1;
                    }
                }
            }
            ans.pb(mp(cnt1,cnt2));
        }
    }
    ll a=0;
    for(auto e:ans){
        a+=e.first*e.second;
    }
    cout<<a<<endl;
}

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

int main() {
  int h,a;
  cin >> h >> a;
  int ans;
  if (h%a==0) ans=h/a;
  else ans=h/a +1;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef uint64_t u64;
typedef int64_t i64;
typedef double db;

int main() {
  u64 X, n_500, n_5;
  cin >> X;
  n_500 = X / 500;
  X %= 500;
  n_5 = X / 5;
  cout << n_500 * 1000 + n_5 * 5 << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> 
#include <cmath>
#include <iomanip> 

using namespace std;

#define PI 3.1415926535897

int main() {
	cout << setprecision(10);
	double A, B, H, M;
	cin >> A >> B >> H >> M;

	double ang1 = (H / 12) * 2 * PI + (M / 60) * (PI / 6);
	double ang2 = (M / 60) * 2 * PI;
	double d = abs(ang1 - ang2);
	cout << sqrt(A * A + B * B - 2 * A * B * cos(d));
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int k;
    cin >> k;
    cout << (k / 2) * (k - k / 2) << endl;
    return 0;
}

Measured memory_bytes: 3632
import heapq
import math


def solve(n, v):
    heapq.heapify(v)

    while len(v) != 1:
        x = heapq.heappop(v)
        y = heapq.heappop(v)
        z = (x + y) / 2
        heapq.heappush(v, z)

    return v[0]


n = int(input())
v = list(map(int, input().split()))

print(solve(n, v))


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

int main() {
  int n;
  cin >> n;
  std::vector<double> vec(n);
  rep(i,n) cin >> vec.at(i);
  double total = 0.0;
  int i = 0;
  while (vec.size() != 1) {
    sort(vec.begin(), vec.end());
    total = (vec.at(i) + vec.at(i+1)) / 2.0;
    reverse(vec.begin(), vec.end());
    vec.pop_back();
    vec.pop_back();
    vec.push_back(total);
  }
  cout << vec.at(0) << endl;
}


Measured memory_bytes: 3760
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int N = scanner.nextInt();

        Map<String, Integer> answer = new HashMap<>();
        answer.put("AC", 0);
        answer.put("WA", 0);
        answer.put("TLE", 0);
        answer.put("RE", 0);

        for (int i = 0 ; i < N ; i++) {
            String result = scanner.next();
            answer.put(result, answer.getOrDefault(result, 0) + 1);
        }

        System.out.println("AC x " + answer.get("AC"));
        System.out.println("WA x " + answer.get("WA"));
        System.out.println("TLE x " + answer.get("TLE"));
        System.out.println("RE x " + answer.get("RE"));
    }
}


Measured memory_bytes: 58876
#include <iostream>

using namespace std;

int H, A[1000000];

// ノードiを適切な場所に移動させる
void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;
  // left, self, rightの中で値が最大のノードをlargestに代入
  if (l <= H && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if (r <= H && A[r] > A[largest]) {
    largest = r;
  }
  if (largest != i) {
    swap(A[largest], A[i]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for (int i = 1; i <= H; i++) {
    cin >> A[i];
  }
  for (int i = H; i >= 1; i--) {
    maxHeapify(i);
  }
  for (int i = 1; i <= H; i++) {
    cout << " " << A[i];
  }
  cout << endl;
}



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

int main(void){
	int check[101]={0};
	int n,MAX=0;
	while(cin >> n, !cin.eof()){
		check[n]++;
	}
	for(int i=1;i<=100;i++)
		MAX=max(MAX,check[i]);
	for(int i=1;i<=100;i++)
		if(check[i]==MAX)
			cout << i << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int b[105];
    long long sum=0;
    for (int i=1;i<n;i++)
    {
        cin >> b[i];
    }
    sum+=b[1]+b[n-1];
    for (int i=1;i<n-1;i++)
    {
        sum+=min(b[i],b[i+1]);
    }
    cout << sum;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try( BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      br.lines()
        .filter(s -> !s.equals("0") && !s.isEmpty())
        .mapToInt(s -> IntStream.range(0,s.length())
          .map(i -> Character.getNumericValue(s.charAt(i)))
          .sum() )
        .forEach(System.out::println);
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))

#define dbg(x) cerr << #x << " = " << x << endl;
#define dbgall(x) cerr << #x << " = "; for(auto i_ : x) cerr << i_ << " "; cerr << endl;
#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int n; cin >> n;
    vvi ans(n+1);
    repa(i, 2, n+1) {
        int a; cin >> a;
        ans[a].pb(i);
    }
    repa(i, 1, n+1) cout << sz(ans[i]) << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 14232
//Littleboy123 Template 1.7
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

//pragmas

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")t
// #pragma GCC optimization ("unroll-loops")


typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(int (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(int (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(int (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(int (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void infile(){
    freopen("walk.in", "r", stdin);
}

void outfile(){
    freopen("output.txt", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2LL, mod);
    tmp = (tmp * tmp) % mod;
    if(b & 1LL)
        tmp = (tmp * a) % mod;
    return tmp;
}

ll ex(ll a, ll b){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = ex(a, b/2LL);
    tmp = (tmp * tmp);
    if(b & 1LL)
        tmp = (tmp * a);
    return tmp;
}

//End of template

int arr[105];

int main(){
    init();

    int n;
    cin >> n;
    int u, v;
    FOR(i, 0, n){
        cin >> u >> v;
        if(u == v)
            arr[i] = 1;
        else
            arr[i] = 0;
    }
    int flag = 0;
    FOR(i, 2, n){
        if(arr[i] && arr[i-1] && arr[i-2]){
            flag = 1;
        }
    }
    if(flag)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3648
l = input().split()
N,Q = int(l[0]),int(l[1])
S = input()
blue = [0] * N
for k in range(1,N):
  if S[k-1] == 'A' and S[k] == 'C':
    blue[k] = blue[k-1] + 1
  else:
    blue[k] = blue[k-1]
for i in range(1,Q+1):
  rl = input().split()
  r = int(rl[0])
  l = int(rl[1])
  print(
    blue[l-1] - blue[r-1])

Measured memory_bytes: 6060
import Control.Monad
import Data.List
main = do
  [n,m] <- map read . words <$> getLine
  as <- sort . map read . words <$> getLine
  bcs <- fmap (reverse . sortOn snd) . replicateM m $ do
    [b,c] <- map read . words <$> getLine
    return (b,c)
  print $ f as bcs

f [] _  = 0
f as [] = sum as
f as ((0,_):bcs) = f as bcs
f (a:as) ((b,c):bcs) 
  | a > c     = sum (a:as)
  | otherwise = c + f as ((b-1,c):bcs)

Measured memory_bytes: 162684
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    
    double r;
    double a;
    double b;
    
    cin>>r;
    
    a=r*r*3.141592653589;
    b=2*r*3.141592653589;
    
    printf("%f %f\n",a,b);
}



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

int main(void) {
	int h, w; cin >> h >> w;
	string c[h];
	int i;
	for (i = 0; i < h; i++) {
		cin >> c[i];
		cout << c[i] << endl;
		cout << c[i] << endl;
	}
	return 0;
}


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

int main(){
  int N,A;
  cin >> N >> A;
  ll x[N];
  rep(i,N) cin >> x[i];
  sort(x,x+N);
  ll DP[N+3][2507]={};
  DP[0][0]=1;
  rep(i,N){
    for(int j=i;j>=0;j--) for(int k=A*j;k>=0;k--){
      DP[j+1][k+x[i]]+=DP[j][k];
    }
  }
  ll ans=0;
  for(int i=1;i<=N;i++){
    ans+=DP[i][A*i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long signed int ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int N;
int main() {
	int f, s, t,count=0;
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	cin >> f;
	cin >> s;
	REP(i, N - 2) {
		cin >> t;
		if ((f < s&&s < t) || (f > s&&s > t)) {
			count++;
		}
		f = s; s = t;
	}
	cout << count << endl;
	return 0;
}

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

int main() {
  vector<int64_t> p(31);
  p.at(0) = 1;
  for (int i = 1; i <= 30; i++) {
    p.at(i) = 3 * p.at(i - 1);
  }
  int q;
  cin >> q;
  vector<int64_t> a(q), b(q), c(q), d(q);
  for (int i = 0; i < q; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }
  for (int i = 0; i < q; i++) {
    int64_t dh = abs(a.at(i) - c.at(i)), dw = abs(b.at(i) - d.at(i));
    int64_t direct = dh + dw;
    vector<int> a3(30), b3(30), c3(30), d3(30);
    a.at(i)--; b.at(i)--; c.at(i)--; d.at(i)--;
    vector<int64_t> ac = a, bc = b, cc = c, dc = d;
    for (int j = 0; j < 30; j++) {
      a3.at(j) = ac.at(i) % 3;
      ac.at(i) /= 3;
    }
    for (int j = 0; j < 30; j++) {
      b3.at(j) = bc.at(i) % 3;
      bc.at(i) /= 3;
    }
    for (int j = 0; j < 30; j++) {
      c3.at(j) = cc.at(i) % 3;
      cc.at(i) /= 3;
    }
    for (int j = 0; j < 30; j++) {
      d3.at(j) = dc.at(i) % 3;
      dc.at(i) /= 3;
    }
    int64_t add_h = 0, add_w = 0;
    bool same_h = true, same_w = true;
    for (int j = 29; j >= 0; j--) {
      if (add_h == 0 && same_h && a3.at(j) == 1 && c3.at(j) == 1
          && ((same_w && dw >= p.at(j)) || dw >= 2 * p.at(j))) {
        int64_t ar = a.at(i) % p.at(j), cr = c.at(i) % p.at(j);
        add_h = 2 * min({ar + 1, p.at(j) - ar,
                         cr + 1, p.at(j) - cr});
      }
      if (add_w == 0 && same_w && b3.at(j) == 1 && d3.at(j) == 1
          && ((same_h && dh >= p.at(j)) || dh >= 2 * p.at(j))) {
        int64_t br = b.at(i) % p.at(j), dr = d.at(i) % p.at(j);
        add_w = 2 * min({br + 1, p.at(j) - br,
                         dr + 1, p.at(j) - dr});
      }
      if (a3.at(j) != c3.at(j)) same_h = false;
      if (b3.at(j) != d3.at(j)) same_w = false;
    }
    cout << direct + add_h + add_w << endl;
  }
}


Measured memory_bytes: 1088
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s, s2;

	cin>>s;

	bool flag2=true;
	rep(i, s.size()-1){
		if(s[i]!=s[i+1]) flag2=false;
	}

	if(flag2||(int)s.size()==1){
		cout<<0<<endl;
	}else{
		int ans=1e9;
		rep(i, 26){
			int count=0; s2=s;
			while(1){
				int count2=0;
				rep(j, s2.size()-count){
					if(s2[j]=='a'+i){
						count2++;
						if(j!=0) s2[j-1]='a'+i;
					}
				}
				if(count==0&&count2==0){
					count=1e9;
					break;
				}
				bool flag=true;
				rep(j, s2.size()-count-2){
					if(s2[j]!=s2[j+1]) flag=false;
				}
				count++;
				//cout<<s2<<endl;
				if(flag) break;
			}
			if(ans>count) ans=count;
			//cout<<endl;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int N;
vll st;
ll pw4[26];
ll pw3[26];
ll pw2[26];
void input(){
    pw4[0]=1;
    pw3[0]=1;
  	pw2[0]=1;
    rep1(i,25){
        pw4[i]=pw4[i-1]*4;
      pw3[i]=pw3[i-1]*3;
      pw2[i]=pw2[i-1]*2;
    }
    cin>>N;
    rep(_,N){
        int tmp[26];
        rep(i,26)tmp[i]=0;
        string S;
        cin>>S;
        rep(i,10){
            int z=S[i]-'a';
            tmp[z]++;
        }
        ll oo=0;
        rep(i,26)oo+=tmp[i]*(pw4[i]+pw3[i]+pw2[i]+1);
        st.pb(oo);
    }
    sort(all(st));
    st.pb(-1);
}

ll ans;
void solve(){
    ll tmp=st[0];
    ll same=(ll)1;
    rep1(i,sz(st)-1){
        if(st[i]==tmp){
            same++;
        }
        else{
            tmp=st[i];
          	ans+=same*(same-1)/2;
            same=1;
        }
    }
    cout<<ans<<endl;
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 1400
n,m = map(int,input().split())
stu = [list(map(int,input().split())) for i in range(n)]
chk = [list(map(int,input().split())) for i in range(m)]
for ab in stu:
  manh = [abs(ab[0]-cd[0])+abs(ab[1]-cd[1]) for cd in chk]
  print(manh.index(min(manh))+1)

Measured memory_bytes: 3064
N, K = map(int, input().split())
coin = [0.5**k for k in range(10**5)]
ans = 0
for i in range(1,N+1):
    x = 0
    while(True):
        if i*(2**x) >= K:
            ans += 1/N * coin[x]
            break
        else: x += 1

print(ans)

Measured memory_bytes: 45424
#include <iostream>
#include <string>
#define LEN 100005
using namespace std;
struct P{
    char name[100];
    int t;
};

P Q[LEN];
int head,tail,n,q;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}
//???????????????????????????????????????????°????????????????????????????????´??°±??????
bool isFull(){
    return head==(tail+1)%LEN;
}

bool isEmpty(){
    return head==tail;
}

int main(){
    cin>>n>>q;
    int i,j;
    for(i=0;i<n;i++){
        cin>>Q[i].name;
        cin>>Q[i].t;
    }
    head=0;tail=n;
    int time=0;
    while(!isEmpty()){
        P x=dequeue();
        x.t=x.t-q;
        if(x.t>0){
            enqueue(x);
            time=time+q;
        }
        else{
            time=time+q+x.t;
            cout<<x.name<<" "<<time<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 13212
n = int(input())
a_list = list(map(int, input().split()))
results = [0] * n
a_sum = 0
sign = 1
for a in a_list:
    a_sum += sign * a
    sign *= -1
results[0] = a_sum
print(results[0], end='')
for i in range(1, n):
    results[i] = a_list[i-1] * 2 - results[i-1]
    print(' ' + str(results[i]), end='')
print()


Measured memory_bytes: 14616
import java.util.Scanner;

public class Main {


	void main() {
		try(Scanner sc = new Scanner(System.in)) {
			for(;;) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				if(x == 0 && y == 0) break;
				
				System.out.println(Math.min(x, y) + " " + Math.max(x, y));
			}
		}
	}

	public static void main(String[] args) {
		new Main().main();
	}

}



Measured memory_bytes: 35840
#include<bits/stdc++.h>
#define int long long
#define fo(i,n)   for(i=0;i<n;i++)
#define mod       1000000007
using namespace std;

int chk(int n)
{
	int max = 0, cnt = 0;
	if (n % 2 == 0)
	{
		while (n / 2 != 0)
		{
			cnt++;
			n = n / 2;
		}
	}
	return cnt;
}
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codefi.txt", "r", stdin);
	freopen("codefo.txt", "w", stdout);
#endif


	int n;
	cin >> n;
	int max = 0;
	int fin = 1;
	for (int i = 1; i <= n; i++)
	{
		int res = chk(i);
		if (res > max) {
			fin = i;
			max = res;
		}
	}

	cout << fin << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int tab[N], res[N], i, n, k, last, bat[3];
set<int> s;
set<int>::iterator it;
map<int, int> mapa;

bool ok() {
	for (int i=1;i<n;i++) if (res[i + 1] == tab[res[i]]) return false;
	return true;
}

int badMap() {
	if (mapa.size() != 2) return -1;
	bool r = 0;
	for (auto& w : mapa) if (w.second == 1) r = 1;
	if (!r) return -1;
	for (auto& w : mapa) if (w.second != 1) return w.first;
}

void go(int ind, int l) {
	//printf("%d %d\n", ind, l);
	res[ind] = l;
	s.erase(l);
	mapa[tab[res[ind]]]--;
	if (mapa[tab[res[ind]]] == 0) mapa.erase(tab[res[ind]]);
}

int main() {
scanf("%d", &n);
if (n == 2) {
	printf("-1\n");
	return 0;
}
for (i=1;i<=n;i++) {
	scanf("%d", &tab[i]);
	mapa[tab[i]]++;
}
for (i=1;i<=n;i++) s.insert(i);
for (i=1;i<=n-3;i++) {
	k = badMap();
	if (k == -1) {
		it = s.begin();
		if (tab[res[i - 1]] == *it) it++;
		go(i, *it);
	} else go(i, k);
}
it = s.begin();
bat[0] = *it; it++; bat[1] = *it; it++; bat[2] = *it;
do {
	res[n - 2] = bat[0];
	res[n - 1] = bat[1];
	res[n] = bat[2];
	if (ok()) {
		for (i=1;i<=n;i++) printf("%d ", res[i]);
		printf("\n");
		return 0;
	}
} while (next_permutation(bat, bat + 3));
printf("AA\n");
return 0;
}

Measured memory_bytes: 11008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if((int)(S.length())<=K){
        cout << S << endl;
    }else{
        string S1 = S.substr(0,K);
        cout << S1 << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a, b := nextInt(), nextInt()

	var o, r int
	if a < b {
		o, r = a, b
	} else {
		o, r = b, a
	}

	result := strings.Repeat(strconv.Itoa(o), r)

	fmt.Println(result)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

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

const int MAX=1<<18;
const int INF=0x3f3f3f3f;
int n,m,ans;
pii arr[MAX],seg[MAX*2];;
int find_max(int a,int b,int x,int y,int node){
    if(a<=x&&y<=b) return seg[node].first+seg[node].second;
    if(b<=x||y<=a) return -INF;
    if(seg[node].second!=0){
        seg[node].first+=seg[node].second;
        seg[node*2].second+=seg[node].second;
        seg[node*2+1].second+=seg[node].second;
        seg[node].second=0;
    }
    return max(find_max(a,b,x,(x+y)/2,node*2),find_max(a,b,(x+y)/2,y,node*2+1));
}
int update(int a,int b,int x,int y,int node){
    if(a<=x&&y<=b) {
        seg[node].second++;
        return seg[node].first+seg[node].second;
    }
    if(b<=x||y<=a) return seg[node].first+seg[node].second;
    if(seg[node].second!=0){
        seg[node*2].second+=seg[node].second;
        seg[node*2+1].second+=seg[node].second;
        seg[node].second=0;
    }
    return seg[node].first=max(update(a,b,x,(x+y)/2,node*2),update(a,b,(x+y)/2,y,node*2+1));
}
int build(int x){
    if(x>=MAX) return seg[x].first;
    return seg[x].first=max(build(x*2),build(x*2+1));
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        arr[i].x=t1,arr[i].y=t2;
    }
    sort(arr,arr+n);
    for(int i=MAX;i<2*MAX;i++) seg[i].first=-INF;
    for(int i=1;i<=m+1;i++) seg[i+MAX].first=i;
    build(1);
    for(int i=0;i<n;i++){
        update(0,arr[i].y+1,0,MAX,1);
        ans=max(ans,find_max(arr[i].x+1,m+2,0,MAX,1)-(arr[i].x+m+1));
        //printf("%d : %d %d %d\n",i,arr[i].x,arr[i].y,find_max(arr[i].x+1,m+2,0,MAX,1));
    }
    printf("%d\n",max(ans,n-m));
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

//#define DEBUG
using namespace std;

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    int ans = 0;
    for(int i = 0; i <= T; i++){
        if(i >= A && i % A == 0){
            ans += B;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256