akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n; cin >> n;
  vector<string> s(n);
  vi t(n),sum(n+1);
  rep(i,n) {
    cin >> s[i] >> t[i];
    sum[i+1] = sum[i] + t[i];
  }

  string x; cin >> x;
  rep(i,n) {
    if(s[i] == x){
      cout << sum[n] - sum[i+1] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll in_cnt(vector<pll>& point, ll x1, ll y1, ll x2, ll y2)
{
  ll res = 0;
  ll N = point.size();
  for (ll i = 0; i < N; ++i) {
    if ((min(x1, x2) <= point.at(i).first) && (point.at(i).first <= max(x1, x2)) && (min(y1, y2) <= point.at(i).second) && (point.at(i).second <= max(y1, y2))) {
      res += 1;
    }
  }
  return res;
}

ll calc(ll x1, ll y1, ll x2, ll y2)
{
  ll res = abs(x1 - x2) * abs(y1 - y2);
  return res;
}

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<pll> point(N);
  vector<ll> x_list(N);
  vector<ll> y_list(N);
  for (ll i = 0; i < N; ++i) {
    ll x, y;
    cin >> x >> y;
    x_list.at(i) = x;
    y_list.at(i) = y;
    point.at(i) = {x, y};
  }
  ll ans = INF;
  for (ll x1 = 0; x1 < N - 1; ++x1) {
    for (ll x2 = 0; x2 < N; ++x2) {
      for (ll y1 = 0; y1 < N - 1; ++y1) {
        for (ll y2 = 0; y2 < N; ++y2) {
          ll cnt = in_cnt(point, x_list.at(x1), y_list.at(y1), x_list.at(x2), y_list.at(y2));
          if (cnt >= K) {
            ans = min(ans, calc(x_list.at(x1), y_list.at(y1), x_list.at(x2), y_list.at(y2)));
          }
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
	string s[3];
	string ans = "";
	for (int i  = 0; i < 3; i++) {
		cin >> s[i];
		ans += s[i].at(0) - 32;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a[3];
    int bak[2] = {0};

    for(int i = 0; i < 3; i++){
        cin >> a[i] ;
        if(a[i] == 5)bak[0]++;
        if(a[i] == 7)bak[1]++;
    }

    if(bak[0] == 2 && bak[1] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    

}

Measured memory_bytes: 256
x = 1

while x != 0:
    x,y,z = map(int, input().split(" "))
    ans = 0
    for i in range (1,z):
        for j in range(i,z):
            if int(i*(100+x)/100)+int(j*(100+x)/100) == z:
                ans = max(int(i*(100+y)/100)+int(j*(100+y)/100),ans)
    if x != 0:
        print(ans)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int a,b;
	cin>>a>>b;
	bool f1=true,f2=true,f3=true;
	if(a==1 || b==1) f1=false;
	if(a==2 || b==2) f2=false;
	if(a==3 || b==3) f3=false;

	if(f1) cout<<1<<endl;
	else if(f2) cout<<2<<endl;
	else cout<<3<<endl;
}

Measured memory_bytes: 256
loop do
  n = gets.to_i
  arr = []
  convert_list = {}

  break if n.zero?

  n.times do
    from, to = gets.split(' ')

    convert_list[from] = to
  end

  m = gets.to_i
  m.times do
    str = gets.chomp

    str = convert_list[str] unless convert_list[str].nil?

    arr << str
  end

  puts arr.join
end

Measured memory_bytes: 10460
from collections import Counter


def solve(string):
    s, k = string.split()
    k = int(k)
    count = Counter(s)
    chars = sorted(set(s))
    for t in range(min(3, len(chars))):
        tmp = []
        i = s.index(chars[t])
        tmp.append(s[i:i + k])
        if count[chars[t]] > 1:
            for _ in range(count[chars[t]] - 1):
                i = s.index(chars[t], i + 1)
                tmp.append(s[i:i + k])
        g = []
        for p in tmp:
            for j in range(1, len(p) + 1):
                g.append(p[:j])
        g = sorted(set(g))
        if len(g) < k:
            k -= len(g)
            continue
        return g[k - 1]


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 4596
import java.util.*;
class Main{
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		int[] top = new int[10];
		for(int i = 0; i < 10; i++){
			top[i] = scan.nextInt();
		}
		for(int i = 0; i < 10; i++){
			for(int j = 9; j > i; j--){
				if(top[j] > top[j-1]){
					int multi = top[j];
					top[j] = top[j-1];
					top[j-1] = multi;
				}
			}
		}
		System.out.println(top[0]);
		System.out.println(top[1]);
		System.out.println(top[2]);
	}
}

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

int main()
{
	int n,t,x[200001],i,ans=0;
	
	cin >> n >> t;
	for(i=0;i<n;i++){
		cin >> x[i];
	}

	for(i=0;i<n-1;i++){
		if(x[i+1]-x[i]>=t){
			ans += t;
		}
		else{
			ans += x[i+1]-x[i];
		}
	}
	ans += t;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
s = input()
start = 0
i = 0
ans = 0
for i in range(len(s)):
    if s[i] in ['A', 'C', 'G', 'T']:
        continue
    else:
        ans = max(ans, i - start)
        start = i + 1
ans = max(ans, len(s) - start)
print(ans)


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

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }

};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int main() {
    int n,k;cin>>n>>k;
    mint max = 0;
    mint min = 0;
    mint count = 0;
    //選ぶ数を増やしていく
    for(int i =1;i<=n+1;++i){
        min += i-1;
        max += n-i+1;
        if(i>=k){
            count+=(max-min+1);
        }

    }
    cout<<count<<endl;



}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <string>

int N;
long long ABC[3];
std::vector<std::vector<int>> c;
std::string s_buf;
std::string answer;
std::vector<char> choice;

char intToABC (int x) {
  if (x == 0) {
    return 'A';
  } else if (x == 1) {
    return 'B';
  } else {
    return 'C';
  }
}

void solve() {
    for (int i = 0; i < N; i++) {
    std::cin >> s_buf;
    if (s_buf == "AB") {
      c[i][0] = 0;
      c[i][1] = 1;
    } else if (s_buf == "BC") {
      c[i][0] = 1;
      c[i][1] = 2;
    } else {
      c[i][0] = 0;
      c[i][1] = 2;
    }
  }
  for (int i = 0; i < N; i++) {
    if (ABC[c[i][0]] == 0 && ABC[c[i][1]] == 0) {
      answer = "No";
      return;
    } 
    if (ABC[c[i][0]] == 0 && ABC[c[i][1]] > 0) {
      ++ABC[c[i][0]];
      choice[i] = intToABC(c[i][0]);
      --ABC[c[i][1]];
    } else if (ABC[c[i][0]] > 0 && ABC[c[i][1]] == 0) {
      --ABC[c[i][0]];
      ++ABC[c[i][1]];
      choice[i] = intToABC(c[i][1]);
    } else if (ABC[c[i][0]] == 1 && ABC[c[i][1]] == 1 && i != N-1 && ABC[0] + ABC[1] + ABC[2] == 2 && (c[i+1][0] != c[i][0] || c[i+1][1] != c[i][1])) {
      int next_p, next_m;
      next_p = (c[i][0] == c[i+1][0] || c[i][0] == c[i+1][1]) ? c[i][0] : c[i][1];
      next_m = (c[i][0] == c[i+1][0] || c[i][0] == c[i+1][1]) ? c[i][1] : c[i][0];
      ++ABC[next_p];
      choice[i] = intToABC(next_p);
      --ABC[next_m];
    } else {
      if (ABC[c[i][0]] >= ABC[c[i][1]]) {
        --ABC[c[i][0]];
        ++ABC[c[i][1]];
        choice[i] = intToABC(c[i][1]);
      } else {
        ++ABC[c[i][0]];
        choice[i] = intToABC(c[i][0]);
        --ABC[c[i][1]];
      }
    }
  }
  answer = "Yes";
  return;
}

int main() {
  std::cin >> N >> ABC[0] >> ABC[1] >> ABC[2];
  c.assign(N, std::vector<int>(2, 0));
  choice.assign(N, 'A');
  solve();
  std::cout << answer << std::endl;
  if (answer == "Yes") {
    for (int i = 0; i < N; i++) {
      std::cout << choice[i] << std::endl;
    }
  }
}

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

int main() {

    map<string,int> word_map;
    map<string,int>::iterator it;
    string s,freq_word,long_word;
    int freq_count=0;
    
    //cout << "???????????\?????????????????????" << endl;
    while (cin >> s) {
        it = word_map.find(s);
        if(it == word_map.end()){
            word_map.insert(map<string,int>::value_type(s,1));
            it = word_map.find(s);
        }
        else{
            (*it).second += 1;
        }
        //??????????????????
        if ((*it).second > freq_count) {
            freq_count = (*it).second;
            freq_word = s;
        }
        //?????°????¢????
        if (s.size() > long_word.size())
            long_word = s;
    
    }
    
    cout << freq_word << " " << long_word << endl;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int[] a = LineInt();
        long ans = 0;
        for (int i = 0; i < N; i++)
            while (a[i] % 2 == 0) { ans++; a[i] /= 2; }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 14176
#include<cstdio>
int n,d,ans,x[210],y[210],p[210];
int main(){
	scanf("%d",&n);
	int M=998244353;
	p[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		p[i]=1ll*p[i-1]*2%M;
	}
	ans=p[n]-n-1;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			d=0;
			for(int k=j+1;k<=n;k++)d+=(y[i]-y[j])*(x[i]-x[k])==(y[i]-y[k])*(x[i]-x[j]);
			ans=(ans+M-p[d])%M;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
# include<iostream>
# include<cstdio>
using namespace std;
int minM(int x,int y)
{
	if(x>y)
	return y;
	else return x;
}
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	cout<<minM(a,b)+minM(c,d)<<endl;

	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, A, B) = listOfLong()
    val m = N / (A + B)
    val r = N - (m * (A + B))
    val ans = A * m + Math.min(A, r)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 38024
#include <stdio.h>
int main(){
	int h1, m1, h2, m2, k;
	int minute, ans;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	minute = (h2- h1)*60 + (m2-m1);
	ans = minute - k;
	if (ans<=0)
	{
		printf("0");
	}else {
		printf("%d\n", ans);
	}
return 0;
}


Measured memory_bytes: 1696
N,M = map(int,input().split())
like = [1]
for i in range(2,M+1):
  like.append(i)
for j in range(N):
  A = list(map(int,input().split()[1:]))
  for l in range(M):
    if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1)
print(len(like))

Measured memory_bytes: 9200
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		//スキャナー型を宣言
		Scanner scan = new Scanner(System.in);

		while(true){
			//入力された文字列を変数に代入
			String strNum1 = scan.next();
			String strOpe = scan.next();
			String strNum2 = scan.next();

			//int型に変換
			int intNum1 = Integer.parseInt(strNum1);
			int intNum2 = Integer.parseInt(strNum2);

			if(strOpe.equals("+")){
				System.out.println(intNum1 + intNum2);
			}else if(strOpe.equals("-")){
				System.out.println(intNum1 - intNum2);
			}else if(strOpe.equals("*")){
				System.out.println(intNum1 * intNum2);
			}else if(strOpe.equals("/")){
				System.out.println(intNum1 / intNum2);
			}else if(strOpe.equals("?")){
				break;
			}
		}
		scan.close();
	}
}




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

int main () {
    string a[110],b,c;
    int n,i,x=0,j;
    cin >> n;
    cin >> b;
    a[0] = b;
    for (i = 1; i < n; i++) {
        cin >> c;
        if (c[0] != b[b.size()-1]) {
            x++;
        }
        a[i] = c;
        b = a[i];
        for (j = 0; j < i; j++) {
            if (a[i] == a[j]) {
                x++;
            }
        }
    }
    if (x == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

}

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

using namespace std;

int n,a[100100];
int use[100100],u1;

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==0) u1++,use[0]++,use[1]++;
		else use[a[i]-1]++,use[a[i]]++,use[a[i]+1]++;
	}
	
	int mx=0;
	for(int i=0;i<100100;i++)
		mx=max(mx,use[i]);
	mx=max(mx,u1);
	
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    int N, M;
    ll S;
    cin >> N >> M >> S;
    ll inf = 1e18;
    vector<vector<pair<int, pair<ll, ll>>>> edge(N+1);
    for (int i = 0; i < M; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        edge[u].push_back({v, {a, b}});
        edge[v].push_back({u, {a, b}});
    }
    
    vector<ll> C(N+1), D(N+1);
    for (int i = 1 ; i <= N; i++) cin >> C[i] >> D[i];
    
    ll L = 3000;
    S = min(S, L-1);
    vector<vector<ll>> dist(N+1, vector<ll>(L, inf));
    dist[1][S] = 0;
    
    priority_queue<pair<ll, pair<int, int>>, vector<pair<ll, pair<int, int>>>, greater<pair<ll, pair<int, int>>>> pq;
    pq.push({0, {1, S}});
    while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        ll d = p.first;
        int now = p.second.first;
        int coin = p.second.second;
        if (d > dist[now][coin]) continue;
        if (coin+C[now] < L && dist[now][coin+C[now]] > d + D[now]) {
            dist[now][coin+C[now]] = d + D[now];
            pq.push({dist[now][coin+C[now]], {now, coin+C[now]}});
        }
        for (auto p2 : edge[now]) {
            int nxt = p2.first;
            ll tocost = p2.second.first;
            ll todist = p2.second.second;
            if (coin < tocost) continue;
            if (d + todist >= dist[nxt][coin-tocost]) continue;
            
            dist[nxt][coin-tocost] = d + todist;
            pq.push({dist[nxt][coin-tocost], {nxt, coin-tocost}});
        }
    }
    
    for (int i = 2; i <= N; i++) {
        ll ans = inf;
        for (int j = 0; j < L; j++) {
            ans = min(ans, dist[i][j]);
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6604
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  if(s=="AAA"||s=="BBB") std::cout << "No" << '\n';
  else std::cout << "Yes" << '\n';
  return 0;
}


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

using namespace std;

int main()
{
  int n, pt = 0, ph = 0;
  cin >> n;
  string t, h;
  for (int i = 0; i < n; i++)
  {
    cin >> t >> h;
    int cmp = t.compare(h);
    if (cmp == 0)
    {
      pt++;
      ph++;
    }
    else if (cmp > 0)
      pt += 3;
    else
      ph += 3;
  }
  cout << pt << " " << ph << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-9
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int n, lis[100005];

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	REP (i, n) cin >> lis[i];
	sort(lis, lis + n);
	if (lis[0] < lis[n - 1] - 1) {
		cout << "No";
		return 0;
	}
	if (lis[0] == lis[n - 1] && lis[0] == n - 1) {
		cout << "Yes";
		return 0;
	}
	int nn = 0, mm = 0;
	REP (i, n) if (lis[i] == lis[n - 1]) mm++; else nn++;
	if (nn + 1 <= lis[n - 1] && lis[n - 1] <= nn + mm / 2) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,M = 0;
    cin >> N >> M;

    vector<int> aCity(M);
    vector<int> bCity(M);

    for (int i = 0; i < M; ++i) {
        cin >> aCity.at(i) >> bCity.at(i);
    }

    vector<int> count(N,0);

    for (int i = 0; i < M; ++i) {
        count.at(aCity.at(i)-1)++;
        count.at(bCity.at(i)-1)++;
    }

    for (int i = 0; i < N; ++i) {
       cout << count.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (i*500+j*100+k*50)==X:
                count += 1
print(count)

Measured memory_bytes: 3064
fun main(args:Array<String>?): Unit {
    val (n, _) = readLine()!!.trim().split(' ').map(String::toInt)
    var sum = 0L
    for (i in 0 until n) {
        println("lst $i")
        sum += readLine()!!.trim().split(' ').first().toLong().let{b -> b * (b - 1)}
    }
    println("ans $sum")
}


Measured memory_bytes: 34396
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
C = list(map(int,readline().split()))

ans = sum(B)
for i in range(N-1):
    for j in range(1,N):
        if A[i] == j and A[i+1] == j+1:
            ans += C[j-1]
print(ans)

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

int main(){
  ll n, k;
  cin >> n >> k;

  string s;
  cin >> s;

  ll score = 0;
  for(int i = 0; i < n-1; i++){
    if(s[i] == s[i+1])score++;
  }

  ll ans = min(score + 2 * k, n-1);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int N[4];
int C[10];

int main(void) {

	for (int i = 0; i < 4; i++) {
		cin >> N[i];
	}

	for (int i = 0; i < 4; i++) {
		C[N[i]]++;
	}

	if ((C[1] == 1) && (C[9] == 1) && (C[7] == 1) && (C[4] == 1)) {cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5+1;
int n, a[N];
ll k;
V<int> v[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n){
    cin >> a[i];
    v[a[i]].pb(i);
  }
  int idx = 0, c = 0;
  V<int> ans;
  while(c<k){
    auto itr = upper_bound(all(v[a[idx]]), idx);
    if(itr == v[a[idx]].end()){
      if(c==k-1){
        ans.pb(a[idx]);
      }else{
        c++;
        idx = v[a[idx]][0];
      }
    }else{
      idx = *itr;
    }
    idx++;
    if(idx == n){
      c++;
      k %= c;
      c = 0;
      idx = 0;
    }
  }
  for(int i:ans) cout << i << " "; cout << endl;
}

Measured memory_bytes: 14200
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}



int main()
{
    run;
    ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin>>k;
    k--;
    cout<<a[k];

    return 0;


}


Measured memory_bytes: 256
N,M,Q=map(int,input().split())

xmat,cmat=[],[]
for i in range(N+1):
  xmat.append([0]*(N+1))
  cmat.append([0]*(N+1))

for i in range(M):
  l,r=map(int,input().split())
  xmat[l][r]+=1
#print(xmat)

for i in range(1,N+1):
  for j in range(1,N+1):
    cmat[i][j]=xmat[i][j]+cmat[i][j-1]
#print(cmat)

for i in range(Q):
  p,q=map(int,input().split())
  ans=0
  for k in range(p,q+1):
    ans+=cmat[k][q]-cmat[k][p-1]
  print(ans)


Measured memory_bytes: 55256
package main

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

type Node struct {
	prev  *Node
	value string
	next  *Node
}

type DoublyLinkedList struct {
	first  *Node
	last   *Node
	length int
}

func insert(value string, list *DoublyLinkedList) {
	node := &Node{nil, value, nil}
	if list.first == nil {
		list.first = node
		list.last = node
	} else {
		node.next = list.first
		list.first.prev = node
		list.first = node
	}
	list.length += 1
}

func delete(value string, list *DoublyLinkedList) error {
	node := list.first
	for node != nil {
		if node.value == value {
			break
		} else {
			node = node.next
		}
	}
	if node == nil {
		return fmt.Errorf("not found value: %s\n", value)
	}
	if node.prev != nil {
		node.prev.next = node.next
	} else {
		list.first = node.next
	}
	if node.next != nil {
		node.next.prev = node.prev
	} else {
		list.last = node.prev
	}
	list.length -= 1
	return nil
}

func deleteFirst(list *DoublyLinkedList) error {
	if list.first == nil {
		return fmt.Errorf("there is no node\n")
	}
	if list.length == 1 {
		list.first = nil
		list.last = nil
		list.length = 0
		return nil
	}
	list.first.next.prev = nil
	list.first = list.first.next
	list.length -= 1
	return nil
}

func deleteLast(list *DoublyLinkedList) error {
	if list.last == nil {
		return fmt.Errorf("there is no node\n")
	}
	if list.length == 1 {
		list.first = nil
		list.last = nil
		list.length = 0
		return nil
	}
	list.last.prev.next = nil
	list.last = list.last.prev
	list.length -= 1
	return nil
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, _ := nextInt(sc)
	list := &DoublyLinkedList{}
	for i := 0; i < n; i++ {
		command := nextText(sc)
		switch command {
		case "insert":
			value := nextText(sc)
			insert(value, list)
		case "delete":
			value := nextText(sc)
			delete(value, list)
		case "deleteFirst":
			deleteFirst(list)
		case "deleteLast":
			deleteLast(list)
		default:
			panic(fmt.Errorf("unknown command: %s\n", command))
		}
	}

	results := make([]string, list.length)
	node := list.first
	for i := 0; i < len(results); i++ {
		results[i] = node.value
		node = node.next
	}
	if node != nil {
		panic("node should be last")
	}
	fmt.Println(strings.Join(results, " "))
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}


Measured memory_bytes: 67216
#include <bits/stdc++.h>
using namespace std;
const int N=100000+5;
pair <long long,long long > d[N];
long long n,c,a[N],b[N],x[N],y[N],ma,mb;
int main()
{
    cin >> n >> c;
    for(int i=0;i<n;i++) scanf("%lld %lld",&d[i].first,&d[i].second);
    sort(d,d+n);
    a[0]=d[0].second-d[0].first;
    x[1]=a[0]-d[0].first;
    b[0]=d[n-1].second-(c-d[n-1].first);
    y[1]=b[0]-(c-d[n-1].first);
    ma=a[0],mb=b[0];
    x[0]=y[0]=0;
    for(int i=1;i<n;i++)
    {
        a[i]=a[i-1]+d[i].second-(d[i].first-d[i-1].first);
        x[i+1]=max(x[i],a[i]-d[i].first);
        ma=max(ma,a[i]);
    }
    for(int i=1;i<n;i++)
    {
        b[i]=b[i-1]+d[n-i-1].second-(d[n-i].first-d[n-i-1].first);
        y[i+1]=max(b[i]-(c-d[n-i-1].first),y[i]);
        mb=max(mb,b[i]);
    }
    long long ans=0;
    ans=max(ans,max(ma,mb));
    for(int i=0;i<n;i++) ans=max(ans,a[i]+y[n-i-1]);
    for(int i=0;i<n;i++) ans=max(ans,b[i]+x[n-i-1]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

// practice for deque

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a.at(i);
  deque<int> b;
  rep(i,n) {
    if(i%2==0) b.push_back(a[i]);
    else b.push_front(a[i]);
  }
  if(n%2==1) reverse(b.begin(),b.end());
  rep(i,b.size()-1) cout << b[i] << " ";
  cout << b[b.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,-1,1,-1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
lol n,m,k,r,q;
int imos[400010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>k;
  vector<int> a(n);
  for(auto&& o:a) cin >>o;
  for(int r=0;r<k;r++){
    bool yes=true;
    for(int i=0;i<n;i++){
      if(i-a[i]>=0) imos[i-a[i]]++;
      else imos[0]++;
      if(i+a[i]+1<n) imos[i+a[i]+1]--;
    }
    int tmp=0;
    int j=0;
    for(auto&& o:a){
      o=imos[j]+tmp;
      if(o!=n) yes=false;
      tmp=o;
      imos[j]=0;
      j++;
    }
    if(yes) break;
  }
  cout <<a[0];
  for(int i=1;i<n;i++) cout <<' '<<a[i];
  cout <<'\n';
  return (0);
}


Measured memory_bytes: 4796
# coding: utf-8
n = int(input())
dic = {}
for i in range(n):
    t = ''.join(sorted(input()))
    dic.setdefault(t, 0)
    dic[t] += 1
ans = 0
for x in dic.values():
    ans += x * (x - 1) // 2
print(ans)

Measured memory_bytes: 17852
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,l,a[300000],b[300000];
int main(){
	cin >> n >> l;
	REP(i,n)
		cin >> a[i];

	REP(i,n - 1) {
		if(a[i] + a[i + 1] >= l) {
			b[n - 2] = i;

			RREP(j,i) {
				b[n - i - 2 + j] = j;
			}

			FOR(j,i + 1,n - 1) {
				b[n - 2 - j] = j;
			}
			cout << "Possible" << endl;
			REP(i,n - 1)
				cout << b[i] + 1 << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
  using namespace std;
  #define N 200005
  typedef long long int ll;
  ll beauty[N];
  ll bit[N];
    ll height[N];
  void update(int i,int n,ll w){
      int k=i;
      ll sum=0;
    while(k<=n){
      bit[k]=max(bit[k],w);
        k=k+(k&(-k));
    }

  }

  ll getsum(ll x){
  ll sum=0;
  while(x!=0){
     sum=max(sum,bit[x]);
     x=x-(x&(-x));
  }
  return sum;
  }

  int main(){

  map<ll,ll> unique;
  map<ll,ll> :: iterator it;

  int n;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>height[i];
  for(int i=1;i<=n;i++) cin>>beauty[i];
  ll ct=1;
  for(int i=1;i<=n;i++){
    unique[height[i]]=0;
  }
  for( it=unique.begin();it!=unique.end();it++){
    
      if(it->second==0){
        it->second=ct;
        ct++;
      }
  }
     
  for(int i=0;i<=ct;i++){
    bit[i]=0;
  }
  for(int i=1;i<=n;i++){
      ll max_sum=getsum(unique[height[i]]-1);
      update(unique[height[i]],ct,max_sum+beauty[i]);
  }

  ll ans=getsum(ct);

  cout<<ans<<endl;

  }


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

#define REP(i,n) for(int i=1; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	int res = 0;
	REP(i, n) {
		if (isupper(s[i])) {
			if (i == 1 || i == n - 1 || s[i] != 'C' || res != 0) {
				cout << "WA" << endl;
				return 0;
			}
			else res++;
		}
	}
	if (res == 0) cout << "WA" << endl;
	else cout << "AC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll x, k, d;
        cin >> x >> k >> d;
        x = abs(x);
        ll moves;
        moves = x / d;
        ll dist = x - d * moves;
        ll ans = dist;
        if(moves > k){
            ans = x - k * d;
            cout << ans;
            return 0;
        }
        moves = k - moves;
        if(moves % 2 == 1){
            ans = abs(dist - d);
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3628
def main():
    import sys

    sys.setrecursionlimit(10 ** 7)

    input = sys.stdin.readline

    def dfs(v, d):
        for u in g[v]:
            if d[u] != init:
                continue
            d[u] = d[v] + 1
            dfs(u, d)

    n = int(input())

    g = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        a, b = (int(x) - 1 for x in input().split())
        g[a].add(b)
        g[b].add(a)

    init = n

    dist_1 = [init] * n
    dist_1[0] = 0
    dfs(0, dist_1)

    dist_n = [init] * n
    dist_n[n - 1] = 0
    dfs(n - 1, dist_n)

    fennec = sum(dist_1[v] <= dist_n[v] for v in range(n))
    snuke = n - fennec

    if fennec > snuke:
        print('Fennec')
    else:
        print('Snuke')


if __name__ == '__main__':
    main()


Measured memory_bytes: 149112
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    scanf("%lld",&n);
    char s[10];
    scanf("%s",s);
    long long a,b;
    a=s[0]-'0';
    b=(s[2]-'0')*10+(s[3]-'0');
    long long count=0,h=0;
    count=n*a;
    h=b*n/100;
    printf("%lld",count+h);
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

// int main(){
//   int N;
//   cin >> N;
//   vector< vector<int> > vec(N);

//   string s[N];
//   REP(i, 0, N){
//     cin >> s[i];
//   }

//   REP(i, 0, N){
//     REP(j, 0, 10){
//       vec[i].push_back((int)s[i][j]);
//     }
//     sort(vec[i].begin(), vec[i].end()); // 1,2,3,4, ...
//   }

//   ll ans = 0;
//   ll equal_num;
//   REP(i, 0, N){
//     equal_num = 0;
//     REP(j, i+1, N){
//       if(vec[i] == vec[j]){
//         equal_num++;
//         vec.erase(vec.begin()+j);
//       }
//     }
//     ans += (equal_num + 1) * equal_num / 2; // equal_num+1 C 2
//   }

//   cout << ans << endl;

//   return 0;
// }


int main(){
  int N;
  cin >> N;
  vector<ll> vec(N); // store number generated from string.
  vector< vector<int> > str(N);

  string s[N];
  REP(i, 0, N){
    cin >> s[i];
    REP(j, 0, 10){
      str[i].push_back((int)s[i][j]-96); // string -> vector
    }
    sort(str[i].begin(), str[i].end());
  }

  REP(i, 0, N){
    vec[i] = 0;
    REP(j, 0, 10){
      vec[i] += pow(26, j) * str[i][j];
    }
  }

  // REP(i, 0, N){
  //   cout << vec[i] << endl;
  // }

  sort(vec.begin(), vec.end()); // 1,2,3,4, ...

  ll ans = 0;
  ll equal_num = 0;
  REP(i, 0, N-1){
    if(vec[i] == vec[i+1]){
      equal_num++;
    }
    else{
      ans += (equal_num + 1) * equal_num / 2; // equal_num+1 C 2
      equal_num = 0;
    }
  }
  ans += (equal_num + 1) * equal_num / 2; // equal_num+1 C 2

  cout << ans << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<int> b(n + 1);
  for (int i = n; i >= 1; i--) {
    int sum = 0;
    for (int j = i + i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = a[i] ^ sum;
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  rep(i, ans.size()) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
main(){int k;std::cin>>k;std::cout<<std::vector<int>({1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51})[k-1];}

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

constexpr long long mod = 998244353;

int main() {
  string s; int k; cin >> s >> k;
  k = min<int>(k, count(s.begin(), s.end(), '1'));
  vector<int> a = { 0 };
  for (auto c : s) if (c == '1') a.back()++; else a.push_back(0);
  reverse(a.begin(), a.end());
  int n = a.size();

  static long long dp[305][305][305]; // i, kx, carry

  dp[0][0][0] = 1;
  rep(i, n) rep(kx, k+1) rep(carry, k+1) {
    if ((dp[i][kx][carry] %= mod) == 0) continue;
    rep2(fw, 1, a[i]+1) dp[i+1][kx][carry+fw] += dp[i][kx][carry];
    rep(take, carry+1) dp[i+1][kx+take][carry-take] += dp[i][kx][carry];
  }

  long long res = 0;
  rep(kx, k+1) res += dp[n][kx][0];
  cout << res % mod << "\n";
}

Measured memory_bytes: 58132
N, M = map(int, input().split())

L_list = []
R_list = []

for i in range(M):
  L, R  = map(int, input().split())
  L_list.append(L)
  R_list.append(R)
 
Lmax = max(L_list)
Rmin = min(R_list)

if Rmin - Lmax < 0:
  print('0')
else:
  print(int(Rmin - Lmax +1))

 

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

typedef vector<vector<int> > Matrix;

const int INF = 100000000;
Matrix d; // グラフの距離を格納した2次元配列（隣接行列）
          // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
	
	while(1){
	
  int n=0, m;

  d = Matrix(10, vector<int>(10, INF));
  for (int i = 0; i < 10; i++) d[i][i] = 0;
  
  
  	
	cin >> m;
	if(m == 0) break;
  
	  for (int i = 0; i < m; i++) {
	    int from, to, cost;
	    cin >> from >> to >> cost;
		n = max(n,from);
		n = max(n,to);
	    d[from][to] = cost;
		d[to][from] = cost;
	  }
	  
	  n++;
	  
	  warshall_floyd(n);
	  
	
	  
	  int sum[100]  ; 
	  int a ;
	  
	  for (int i = 0; i < n ; i++) {
	  	sum[i] = 0;
	    for (int j = 0; j < n; j++) {
			
			
			sum[i] +=  d[i][j];
			
	    }
	  }
	  
	  int ans = sum[0];
	  int num = 0;
	  
	  for(int i = 0; i<n-1 ; i++){
	  	if(ans > sum[i+1]){
			ans = sum[i+1];
			num = i+1;
	  	}
	  }
	  
	  cout << num << " " << ans << endl;
  
  }
  
    
  
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = 1<<30;
const int mod = 1000000007;

double dp[3010][3010];

int main(){
	int n;
	cin >> n;
	vector<double> P(n);
	rep(i,n) cin >> P[i];
	dp[0][0] = 1.0;
	rep(i,n)rep(j,i+1){
		dp[i+1][j+1] += dp[i][j] * P[i];
		dp[i+1][j] += dp[i][j] * (1.0 - P[i]);
	}
	double ans = 0.0;
	for (int i = (n+1)/2; i <= n; i++) ans += dp[n][i];
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  char S;
  bool flag = false;
  
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == 'Y') {
      flag = true;
    }
  }
  
  if (flag) {
    cout << "Four";
  } else {
    cout << "Three";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(unsigned i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
template<class T> void chmin(T&x,T y){if(x>y)x=y;}
template<class T> void chmax(T&x,T y){if(x<y)x=y;}

unsigned c,dp[1u<<26u],d[200001],n{};
int main(){
    d[0]=0;
    while((c=getchar_unlocked()-'a')<26) d[n+1]=d[n]^(1u<<c),++n;
    fill(dp,dp+(1u<<26u),500000);
    dp[d[n]]=0;
    ifr(i,n) fr(j,26) chmin(dp[d[i]],dp[d[i]^(1u<<j)]+1);
    printf("%d\n",max(dp[0],1u));
}

Measured memory_bytes: 263296
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int inf=2147483647;
int n,m;
#define Maxn 100010
int c[Maxn][12];
int dp[Maxn],tmp[Maxn];
int main(){
	scanf("%d%d",&n,&m);
	int a,b;
	dp[0]=0;
	for(register int i=1;i<(1<<n);++i)dp[i]=inf;
	for(register int i=1;i<=m;++i){
		scanf("%d%d",&a,&b);
		int x,sta=0;
		for(register int j=1;j<=b;++j){
			scanf("%d",&x);
			sta|=(1<<(x-1));
		}
		for(register int j=(1<<n)-1;j>=0;--j)
		    if(dp[j]!=inf)dp[j|sta]=min(dp[j|sta],dp[j]+a);
	}
	if(dp[(1<<n)-1]==inf)puts("-1");
	else printf("%d\n",dp[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 256
import itertools
 
 
def find_eq(abcd):
    a, b, c, d = abcd
    ops = ("+", "-")
    for op1, op2, op3 in itertools.product(ops, repeat=3):
        eq = a + op1 + b + op2 + c + op3 + d
        if eval(eq) == 7:
            return eq + "=7"
 
 
def main():
    print(find_eq(input()))
 
 
if __name__ == '__main__':
    main()

 


Measured memory_bytes: 3060
#include <iostream>
#include<list>
#include<algorithm>
using namespace std;
int main(void){
    list<int> b;
    int n,tmp;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> tmp;
        if(i%2==0){
            b.push_front(tmp);
        }else{
            b.push_back(tmp);
        }
    }
    if(n%2==0){
        reverse(b.begin(),b.end());
    }
    for(auto i=b.begin();i!=b.end();i++){
        cout << *i<<endl;
    }
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define nl printf("\n");
#define N 200001
#define PR pair<int,int>
#define sf(n) scanf("%d", &n)
#define sff(n, m) scanf("%d %d",&n,&m)
#define sfl(n) scanf("%lld", &n)
#define sfu(n) scanf("%llu", &n)
#define sffl(n, m) scanf("%lld %lld",&n,&m)
#define pfn(n) printf("%d\n",n)
#define pf(n) printf("%d ",n)
#define pfl(n) printf("%lld ",n)
#define pfln(n) printf("%lld\n",n)
#define pfu(n) printf("%llu\n",n)
#define pfs(s) printf("%s",s)
#define YES printf("YES\n")
#define NO printf("NO\n")
#define PB push_back
#define PI 3.1415926536
#define VST(v) sort(v.begin(),v.end())
#define fori(i,n) for(;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define MP make_pair
int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
vector<ll>V,V2,V3;
vector<ll> :: iterator it1,it2;
void CLEAR(){
    V.clear();
    V2.clear();
    V3.clear();
}
int main()
{
    ///freopen("1input.txt","r",stdin);
    int tcase=1;
    //sf(tcase);
    for(int test=1;test<=tcase;test++)
    {
        int m,d,cnt=0;
        sff(m,d);
        for(int i=22;i<=d;i++){
            int a=i;
            int x=a%10;a/=10;
            int y=a;
            if(x>=2&&y>=2&&x*y<=m){
                cnt++;
            }
        }

        printf("%d\n",cnt);
    }
///*****************************  ALHAMDULILLAH  *****************************/
}



Measured memory_bytes: 256