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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  map <string, int> mp;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  for(int i = 0; i < m; i++) {
    string s;
    cin >> s;
    mp[s]--;
  }

  int mx = 0;
  for(auto tmp : mp) {
    mx = max(mx, tmp.second);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	int day;

	cin >> day;

	if (day == 25) {
		cout << "Christmas";
	}
	else if (day == 24) {
		cout << "Christmas Eve";
	}
	else if (day == 23) {
		cout << "Christmas Eve Eve";
	}
	else if (day == 22) {
		cout << "Christmas Eve Eve Eve";
	}

	return 0;
}

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

using namespace std;

const int N = 1234;

int col[N];
char s[N][N];

int main() {
  int h;
  scanf("%d", &h);
  int w = h;
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }
  bool any = false;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      any |= (s[i][j] == '#');
    }
  }
  if (!any) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        col[j]++;
      }
    }
  }
  int ans = (int) 1e9;
  for (int i = 0; i < h; i++) {
    int cur = 0;
    if (col[i] == 0) {
      cur++;
    }
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') {
        cur++;
      }
    }
    for (int j = 0; j < w; j++) {
      if (col[j] < h) {
        cur++;
      }
    }
    ans = min(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;
int dist[2][100005];
vector<int> G[100005];
int N;
int szA,szB;
queue<int> Q;
int main()
{
    cin>>N;
    for(int i=1;i<N;i++)
    {
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dist[0][1]=1;
    Q.push(1);
    while(!Q.empty())
    {
        int nod=Q.front();Q.pop();
        for(auto it:G[nod])
        {
            if(!dist[0][it])
            {
                Q.push(it);
                dist[0][it]=1+dist[0][nod];
            }
        }
    }
    dist[1][N]=1;
    Q.push(N);
    while(!Q.empty())
    {
        int nod=Q.front();Q.pop();
        for(auto it:G[nod])
        {
            if(!dist[1][it])
            {
                Q.push(it);
                dist[1][it]=1+dist[1][nod];
            }
        }
    }
    for(int i=1;i<=N;i++)
    {
        if(dist[0][i]<=dist[1][i])
            szA++;
        else
            szB++;
    }
    if(szA<=szB)cout<<"Snuke";
    else        cout<<"Fennec";
    return 0;
}


Measured memory_bytes: 6656
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define bql 2147483647
#define ll long long
#define ull unsigned long long
using namespace std::tr1;
using namespace std;
const int N=2e5+5;
const int mod=998244353;
const int fx[5]={0,-1,0,1,0};
const int fy[5]={0,0,-1,0,1};
inline 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<<3)+(x<<1);x+=(ch-'0');ch=getchar();}
    return x*f;
}

void write(int x)
{
    if (x<0) putchar('-'),x=-x;
    if (x>10) write(x/10);
    putchar(x%10+'0');
}

ll n,k;
ll a[N];

ll f(ll mid)
{
	ll ret = 0;
	for (int i = 0; i < n; i++)
  {
		if (a[i] == 0)
    {
			if (mid >= 0)	ret += n-1;
			continue;
		}
		if (a[i] < 0)
    {
			ll target = mid/a[i];
			if(target*a[i] > mid)	target++;
			int idx = lower_bound(a, a+n, target)-a;
			ret += n - idx;
			if(idx <= i)	ret -= 1;
		}
		else
    {
			ll target = mid/a[i];
			if(target*a[i] > mid)	target--;
			int idx = upper_bound(a, a+n, target)-a-1;
			if(idx < 0)	continue;
			ret += idx + 1;
			if(idx >= i)	ret -= 1;
		}
	}
	return ret/2;
}

int main() 
{
	cin>>n>>k;
	for(int i = 0; i < n; i++)	cin>>a[i];
	sort(a, a+n);
	ll lo = -1e18, hi = 1e18;
	while(lo < hi){
		ll mid = lo + (hi - lo)/2;
		if (f(mid) >= k)	hi = mid;
		else	lo = mid + 1;
	}
	cout<<lo<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main()
{	
        ll n , m;
        cin >> n >> m;
        map< ll , ll > mp;
        vector < ll > ans (100005 , 0);
        for(int i = 0 ; i < m ; i++)
       	{
       		ll x;
       		cin >> x;
       		mp[x]++;
       	}
       	ans[0] = 1;
       	if(!mp[1])
       	ans[1] = 1;
       	for(int i = 2 ; i <= n ; i++){
       			if(!mp[i])
       				ans[i] = ans[i] + (ans[i - 1] % mod + ans[i - 2]% mod) % mod;

       	}
       	cout << ans[n] << endl;
  return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m; cin>>n>>m;
  int ar[n+1];
  memset(ar,0,sizeof(ar));

  int score=0,penalty=0;
  int p; string s;

  for(int i=1;i<=m;i++){

    cin>>p>>s;
    if(s[0]=='A')
    {
        if(ar[p]<=0){
            penalty=penalty-ar[p];
            score++;
            ar[p]=1;
        }
    }
    else{
        if(ar[p]<=0)
            ar[p]--;
    }
  }
        cout<<score<<" "<<penalty;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=10010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
string s;
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	cin>>n;
	double ans=0.0000000000;
	double x;
	repd(i,1,n)
	{
		cin>>x>>s;
		if(s[0]=='J')
		{
			ans+=x;
		}else
		{
			ans+=(x*380000.0000000000);
		}
	}
	cout<<fixed<<setprecision(7)<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int time, hour, minute, second;
  
  scanf("%d", &time);
  
  hour = time / 3600;
  minute = (time % 3600) / 60;
  second = time % 60;
  
  printf("%d:%d:%d\n", hour, minute, second);
  
  return 0;
}

Measured memory_bytes: 592
N=int(input())
 
X=[]
for i in range(N):
  a=input().split()
  X.append([int(a[0]),int(a[1])])
 
 
a=X[0][0]
b=X[0][1]
 
for i in range(1,N):
  c=X[i][0]
  d=X[i][1]
 

  x= (a + (c - 1)) // c
  y= (b + (d -1)) // d
  
  a1=1000000000000000000
  b1=1000000000000000000
  a2=1000000000000000000
  b2=1000000000000000000
  if d*x-b>=0:
    a1=c*x
    b1=d*x
 
  
  if c*y-a>=0:
    a2=c*y
    b2=d*y
  if (a1+b1)<(a2+b2):
    a=a1
    b=b1
  else:
    a=a2
    b=b2
 
  #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" a1 = "+str(a1)+" b1 = "+str(b1)+" a2 = "+str(a2)+" b2 = "+str(b2)+" c = "+str(c)+" d = "+str(d))
  
 
 
 
 
  
print(a+b)

Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))

money = 1000
stock = 0
for day in range(n-1):
    if a[day+1] > a[day]:
        buyStock = money // a[day]
        if buyStock > 0:
            stock += buyStock
            money -= buyStock * a[day]
    elif a[day+1] < a[day]:
        money += stock * a[day]
        stock = 0
money += stock * a[-1]
print(money)


Measured memory_bytes: 9220
#include<iostream>
using namespace std;
long n,m,ans;
main()
{
	cin>>n>>m;
	for(long i=1;i*i<=m;i++)
	{
		if(m%i)continue;
		if(m/i>=n)ans=ans<i?i:ans;
		if(i>=n)ans=ans<m/i?m/i:ans;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{int n=0;
 cin>>n;
 int d[n][2];
 int temp=0,dle=0;
 for(int i=0;i<n;i++)
 {cin>>d[i][0]>>d[i][1];
  if(d[i][0]==d[i][1])
    temp++;
  else
    temp=0;
  if(temp>=3)
  {dle=1;break;}
 }
 if(dle==1)
   cout<<"Yes";
 else 
   cout<<"No";
 return 0;
}

Measured memory_bytes: 3620
import itertools


def main():
    N, M = map(int, input().split())
    patterns = list(itertools.product((1, -1), repeat=3))
    l = {p: [0] * N for p in patterns}
    for i in range(N):
        x, y, z = map(int, input().split())
        for p in patterns:
            l[p][i] = p[0] * x + p[1] * y + p[2] * z
    ans = 0
    for p in patterns:
        l[p].sort(reverse=True)
        total = sum(l[p][:M])
        ans = max(ans, total)
    print(ans)


if __name__ == "__main__":
    main()


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

long long a[300];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    long long x = 0;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        x ^= a[i];
    }

    if (x == 0) {
        cout << "0\n";
        return 0;
    }
    if (n == 2) {
        if (a[0] % 2 != a[1] % 2 || a[0] < a[1])
            cout << "-1\n";
        else
            cout << (a[0] - a[1]) / 2 << "\n";
        return 0;
    }

    long long y = x ^ a[0] ^ a[1];
    if ((a[0] + a[1] - y) % 2) {
        cout << "-1\n";
        return 0;
    }

    long long z = (a[0] + a[1] - y) / 2, ret = 0;
    vector<int> pos;
    for (int i=39; i>=0; i--) {
        if (y & (1LL << i)) {
            if (z & (1LL << i)) {
                cout << "-1\n";
                return 0;
            }
            pos.push_back(i);
        } else {
            if (z & (1LL << i))
                ret |= 1LL << i;
        }
    }
    for (int i : pos)
        if ((ret | (1LL << i)) <= a[0])
            ret |= 1LL << i;

    if (ret == 0 || a[0] < ret)
        cout << "-1\n";
    else
        cout << a[0] - ret << "\n";

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int binary(int n) {
	//10進数→2進数
	int ans = 0;
	for (int i = 0; n > 0; i++) {
		ans += n % 2 * intpow(10, i);
		n /= 2;
	}
	return ans;
}
int intabs(int n) {
	if (n < 0)
		return -1 * n;
	else
		return n;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion

signed main() {
	string N,ans="No";
	cin >> N;
	rep(i, 3) {
		if (N[i] == '7')
			ans = "Yes";
	}
	cout << ans;		
}

Measured memory_bytes: 3720
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

typedef long long  Weight;
struct Edge {
	int src, dest;
	int cap, rev;
	Weight weight;
	bool operator < (const Edge &rhs) const { return weight > rhs.weight; }
};

const int V = 4000;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
Weight h[V];                //ポテンシャル
Weight dist[V];             //最短距離
int prevv[V], preve[V];  //直前の辺と頂点

void add_edge(Graph &g, int src, int dest, int cap, Weight weight) {
	g[src].push_back(Edge{ src, dest, cap, (int)g[dest].size(), weight });
	g[dest].push_back(Edge{ dest, src, 0, (int)g[src].size() - 1, -weight });
}
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const Weight INF = 2147483647;
const Weight ZERO=0;
//コストがdoubleの時はeps使おう
Weight min_cost_flow(Graph &g, int s, int t, int f) {
	Weight res = ZERO;
	memset(h, ZERO, sizeof(h));
	typedef pair<Weight, int> P;
//ポテンシャルを先に計算して速度向上
//REP(i, g.size() / 2 - 1) {
//	int v = i + 2;
//	REP(j, g[v].size()) {
//		Edge &e = g[v][j];
//		if (e.cap == 0) continue;
//		int u = e.dest;
//		h[u] = min(h[u], h[v] + e.weight);
//	}
//	v = i + g.size() / 2 + 1;
//	REP(j, g[v].size()) {
//		Edge &e = g[v][j];
//		if (e.cap == 0) continue;
//		int u = e.dest;
//		h[u] = min(h[u], h[v] + e.weight);
//	}
//}
	while (f > 0) {
		priority_queue<P, vector<P>, greater<P> > que;
		fill(dist, dist + V, INF);
		dist[s] = 0;
		que.push(P(ZERO, s));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			const int v = p.second;
			if (dist[v] < p.first) continue;
			REP(i, g[v].size()) {
				Edge &e = g[v][i];
				if (e.cap > 0 && dist[e.dest] > dist[v] + e.weight + h[v] - h[e.dest] + eps) {
					dist[e.dest] = dist[v] + e.weight + h[v] - h[e.dest];
					prevv[e.dest] = v;
					preve[e.dest] = i;
					que.push(P(dist[e.dest], e.dest));
				}
			}
		}
		if (dist[t] == INF) return -1;
		REP(v, V) h[v] = h[v] + dist[v];

		int d = f;
		for (int v = t; v != s; v = prevv[v]) d = min(d, g[prevv[v]][preve[v]].cap);
		f -= d;
		res = res + d * h[t];
		for (int v = t; v != s; v = prevv[v]) {
			Edge &e = g[prevv[v]][preve[v]];
			e.cap -= d;
			g[v][e.rev].cap += d;
		}
	}
	return res;
}

int main() {
	int N;cin>>N;
	string S,T;cin>>S>>T;
	vector<int>s_nums(26),t_nums(26);
	for (auto ch : S) {
		s_nums[ch-'a']++;

	}
	for (auto ch : T) {
		t_nums[ch-'a']++;
	}

	const int start=0;
	const int s_x=start+1;
	const int g_x=s_x+26;
	const int goal=g_x+26;

	Graph g(goal+1);

	for (int i = 0; i < 26; ++i) {
		add_edge(g,start,s_x+i,1,0);
	}
	for (int i = 0; i < 26; ++i) {
		for (int j = 0; j<26; ++j) {
			add_edge(g,s_x+i,g_x+j,1,abs(s_nums[i]-t_nums[j]));
		}
	}
	for (int j = 0; j < 26; ++j) {
		add_edge(g,g_x+j,goal,1,0);
	}

	int fl=min_cost_flow(g,start,goal,26);

	cout<<fl/2<<endl;
	return 0;
}


Measured memory_bytes: 3428
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  int neg = 0;
  rep(i, n) if (A[i] < 0) {neg++; A[i] *= -1;}
  ll ans = 0;
  if (neg%2 == 0) {
    rep(i, n) ans += A[i];
  } else {
    sort(A.begin(), A.end());
    ans -= A[0];
    REP(i, 1, n) ans += A[i];
  }
  cout << ans << endl;
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using vll=vector<ll>;
int gcd(int x,int y){
  int u,v,r;
  u=min(x,y);
  v=max(x,y);
  r=v%u;
  while(r>0){
    v=u;
    u=r;
    r=v%u;
  }
  return u;
}

int main() {
  int n,k,i,ans=0;
  cin>>n>>k;
  vi p(n);
  for(i=0;i<n;i++) cin>>p.at(i);
  sort(p.begin(),p.end());
  for(i=0;i<k;i++) ans+=p.at(i);
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;

#define MAXN 100
int N;
int P[MAXN+5];

int main(){
    int N,A,B;
    scanf("%d",&N);
    scanf("%d%d",&A,&B);
    for(int i=1;i<=N;i++)
        scanf("%d",P+i);
    int cnt1=0,cnt2=0,cnt3=0;
    for(int i=1;i<=N;i++){
        if(P[i]<=A)
            cnt1++;
        else if(P[i]<=B)
            cnt2++;
        else
            cnt3++;
    }
    printf("%d",min(cnt1,min(cnt2,cnt3)));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin,(x).end()

int main(){
  char a,b;
  cin >> a >> b;
  if(a=='H'){
    if(b=='H'){
      cout << "H" << endl;
    }
    if(b=='D'){
      cout << "D" << endl;
    }
  }
  
  if(a=='D'){
     if(b=='H'){
       cout << "D" << endl;
     }
     if(b=='D'){
       cout << "H" << endl;
     }
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {

	int A, B, M;
	cin >> A >> B >> M;

	int* a = new int[A];
	int* b = new int[B];
	for (int i = 0; i < A; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < B; ++i)
	{
		cin >> b[i];
	}

	int* as = new int[A];
	int* bs = new int[B];
	for (int i = 0; i < A; ++i)
	{
		as[i] = a[i];
	}
	for (int i = 0; i < B; ++i)
	{
		bs[i] = b[i];
	}

	vector<vector<int>> c(M, vector<int>(3));
	for (int i = 0; i < M; ++i)
	{
		cin >> c[i][0] >> c[i][1] >> c[i][2];
	}
	
	int* X = new int[M + 1];
	for (int i = 0; i < M + 1; ++i)
	{
		X[i] = 0;
	}

	sort(as, as + A);
	sort(bs, bs + B);

	X[0] = as[0] + bs[0];

	for (int i = 0; i < M; ++i)
	{
		X[i + 1] = a[c[i][0] - 1] + b[c[i][1] - 1] - c[i][2];
	}

	sort(X, X + M + 1);

	cout << X[0];

	return 0;
}

Measured memory_bytes: 9344
import math
N=int(input())
C=[tuple(map(int,input().split())) for _ in range(N)]
e=10**-10

def dist2(p1,p2):
    return ((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)

def max_dist_xy(x,y):
    max_dist=0
    p=(x,y)
    for c in C:
        max_dist=max(max_dist,dist2(p,c))
    return max_dist

def max_dist_x(x):
    l=0
    r=1000
    for _ in range(80):
        m1=(2*l+r)/3
        m2=(l+2*r)/3
        d1=max_dist_xy(x,m1)
        d2=max_dist_xy(x,m2)
        if d1>d2:
            l=m1
        else:
            r=m2
    return max_dist_xy(x,l)

def solve():
    l=0
    r=1000
    for _ in range(80):
        m1=(2*l+r)/3
        m2=(l+2*r)/3
        d1=max_dist_x(m1)
        d2=max_dist_x(m2)
        if d1>d2:
            l=m1
        else:
            r=m2
    return math.sqrt(max_dist_x(l))

print(solve())


Measured memory_bytes: 3188
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
S = str(input())
K = int(input())

for i in range(len(S)):
    if(S[i] == "1" and i+1 == K):
        print("1")
        sys.exit()
    elif(S[i]!="1"):
        print(S[i])
        sys.exit()


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, r;
	cin >> n >> r;
	if(n >= 10) {
		cout << r << endl;
	} else {
		cout << r + 100*(10 - n) << endl;
	}
}


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

int dx[2] = {0,1};
int dy[2] = {1,0};
int area[17][17]={0};
int x,y;
int xg,yg;
int ans=0;

int saiki(int a,int b){
  if(a > x || b > y) return 0;
  if(area[a][b] == 2) return 1;
  if(area[a][b] == -1)return 0;
  return saiki(a+1,b) + saiki(a,b+1);
}


int main(){
  while(1){
    int no;
    memset(area,0,sizeof(area));
    ans=0;
    cin >> x >> y;
    if(x == 0 && y == 0)break;
    area[x][y] = 2;
    cin >> no;
    for(int i=0;i<no;i++){
      cin >> xg >> yg;
      area[xg][yg] = -1;
    }
    ans = saiki(1,1);
    cout << ans << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

int N;
string s[1001];
int dp[1001][1001][2];

int dfs(int com,int ecom,int pari){
  if(dp[com][ecom][pari]!=-1)return dp[com][ecom][pari];
  if(com==1)return 1;
  int res=0;
  if(pari&&dfs(com,ecom,0)==0)res=1;
  rep(e1,2)rep(e2,2){
    if(ecom<e1+e2)continue;
    if(e1==0&&e2==0&&(com-ecom)>=2){
      if(dfs(com-1,ecom+1,pari)==0)res=1;
    }else if((e1==0||e2==0)&&(com-ecom)>=1){
      if(dfs(com-1,ecom-1,1-pari)==0)res=1;
    }else{
      if(dfs(com-1,ecom-1,1-pari)==0)res=1;
    }
  }
  return dp[com][ecom][pari]=res;
}

int main(){
  cin>>N;
  rep(i,N)cin>>s[i];
  UnionFind uf(N);
  rep(i,N)rep(j,i){
    if(s[i][j]=='Y')uf.unite(i,j);
  }
  int com=0,ecom=0,pari=0;
  vector<bool> used(N,false);
  rep(i,N){
    if(used[uf.find(i)])continue;
    used[uf.find(i)]=true;
    com++;
    int sz=uf.size(i);
    int ecnt=0;
    vector<int> vs;
    rep(j,N){
      if(!uf.same(i,j))continue;
      vs.push_back(j);
    }
    for(int v1 : vs){
      for(int v2 : vs){
        if(s[v1][v2]=='Y')ecnt++;
      }
    }
    ecnt/=2;
    if(sz%2==0)ecom++;
    if(((sz*(sz-1)/2)-ecnt)%2==1)pari=1-pari;
  }
  memset(dp,-1,sizeof(dp));
  if(dfs(com,ecom,pari))cout<<"Taro"<<endl;
  else cout<<"Hanako"<<endl;
  return 0;
}



Measured memory_bytes: 12036
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<pair<int,ll>> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int n; cin >> n;
	vector<int> a(n);
	int x = 0;
	rep(i, n) {
		cin >> a[i];
	}
	vector<int> b = a;
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	if (b.size() > 3) {
		cout << "No" << endl; return;
	}
	else if (b.size() == 3) {
		if (n % 3 > 0) {
			cout << "No" << endl; return;
		}
		if ((b[0] ^ b[1]) != b[2]) {
			cout << "No" << endl; return;
		}
		int c[3] = {};
		rep(i, n) {
			rep(j, 3) {
				if (a[i] == b[j])c[j]++;
			}
		}
		if (c[0] != n / 3 || c[1] != n / 3) {
			cout << "No" << endl; return;
		}
		cout << "Yes" << endl; return;
	}
	else if (b.size() == 2) {
		if (b[0] != 0) {
			cout << "No" << endl; return;
		}
		if (n % 3 > 0) {
			cout << "No" << endl; return;
		}
		int c[2] = {};
		rep(i, n)rep(j, 2) {
			if (a[i] == b[j])c[j]++;
		}
		if (c[0] != n / 3) {
			cout << "No" << endl; return;
		}
		cout << "Yes" << endl; return;
	}
	else {
		if (b[0] > 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 1024
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace AtCoder {
    public class Program {
        static int[] getKeys() {
            var Keys = Console.ReadLine().Split(' ');
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(delimiter);
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }

        public static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        public static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }

        static void Main() {
            var keys = getKeys();
            int answer = Math.Min(keys[3], keys[1]) - Math.Max(keys[2], keys[0]);
            Console.WriteLine(Math.Max(0, answer));
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;

int		main(void)
{
	string S;

	cin >> S;
	int i = 0;
	ll sum = 0, s1, s2;

	while (S[i])
	{
		s1 = 0;
		while (S[i] == '<')
		{
			s1++;
			i++;
		}
		s2 = 0;
		while (S[i] == '>')
		{
			s2++;
			i++;
		}
		s1 < s2 ? s1-- : s2--;
		sum += ((1 + s1) * s1 / 2) + ((1 + s2) * s2 / 2);
	}
	cout << sum << endl;
}


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

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int i, n, k, t, c = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> t;
    if (t >= k)
      c++;
  }
  cout << c << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define inf (int)1e8
using namespace std;
int n;
bool flag=0;
int main(){
	cin>>n;
	int tim=n/4;
	for(int i=0;i<=tim;i++){
		if((n-i*4)%7==0){
			flag=1;
			break;
		}
	}
	if(flag)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <string>
int idx[6005], a[3005], b[3005], n, cnta, cntb;
char str[6005];
std::string work(int l, int r)
{
	int lp = -1, rp;
	for (int i = 0; i < n; i++)
	{
		if (l <= a[i] && a[i] <= r)
		{
			if (lp == -1)
				lp = i;
			rp = i;
		}
	}
	std::string ans = "";
	if (a[lp] < b[lp])
	{
		int lst = -1;
		for (int i = lp; i <= rp; i++)
		{
			if (lst < a[i])
			{
				ans += "ab";
				lst = b[i];
			}
		}
		return ans;
	}
	for (int i = lp; i <= rp; i++)
	{
		std::string res = "";
		for (int j = l; j <= r; j++)
		{
			if (idx[j] >= i)
				res += str[j];
		}
		ans = std::max(ans, res);
	}
	return ans;
}
std::string dp[6005], val[6005];
int main()
{
	// freopen("AGC026-E.in", "r", stdin);
	scanf("%d%s", &n, str);
	for (int i = 0; i < n << 1; i++)
	{
		if (str[i] == 'a')
		{
			idx[i] = cnta++;
			a[idx[i]] = i;
		}
		else
		{
			idx[i] = cntb++;
			b[idx[i]] = i;
		}
	}
	int len = 0, lst = 0, cur = 0;
	for (int i = 0; i < n << 1; i++)
	{
		cur += str[i] == 'a' ? 1 : -1;
		if (!cur)
		{
			val[len++] = work(lst, i);
			lst = i + 1;
		}
	}
	for (int i = len - 1; i >= 0; i--)
		dp[i] = std::max(dp[i + 1], val[i] + dp[i + 1]);
	puts(dp[0].c_str());
	return 0;
}


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

void setMetrix (vector<vector <int> >& v){
	for (size_t i = 0; i < v.size(); i++){
		for (size_t j = 0; j < v[0].size(); j++){
			cin >> v[i][j];
		}
	}
}

int main() {
	int n, m, l;

	cin >> n >> m >> l;

	vector<vector <int> > a(n, vector<int>(m));
	vector<vector <int> > b(m, vector<int>(l));
	vector<vector <long long> > c(n, vector<long long>(l));

	setMetrix(a);
	setMetrix(b);

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			for (int k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	for (size_t i = 0; i < n; i++){
		for (size_t j = 0; j < l; j++){
			cout << c[i][j];
			if (j < l - 1) cout << " ";
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3216
#pragma region GNUC
//以下を参考にした
//https://yukicoder.me/wiki/auto_vectorization
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif
#pragma endregion

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
#include <random>
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
//inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}

// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
//inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

void solve(){
	int H,W;
	cin >> H >> W;
	string temp;
	for(int h=0;h<H;++h){
		cin >> temp;
		cout << temp << "\n";
		cout << temp << "\n";
	}
	cout << flush;
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数点以下の桁数を指定
	
	solve();
}


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

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if pl < N - 1 and s[pl + 1] == lt[q]:
            pl += 1
        if pr <= N - 1 and s[pr] == lt[q]:
            pr += 1
    else:
        if pr > 0 and s[pr - 1] == lt[q]:
            pr -= 1
        if pl >= 0 and s[pl] == lt[q]:
            pl -= 1

print(max(pr - pl -1, 0))


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

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int a = 0, b = 0;
		for(int i = 0; i < n; i++){
			int x, y;
			cin >> x >> y;
			if(x > y){
				a += x + y;
			} else if(y > x){
				b += x + y;
			} else {
				a += x;
				b += y;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N, M = gets.chomp.split(" ").map(&:to_i)

ans = 0
if [N, M].min == 1 then
  if [N, M].max > 1 then
    ans += [N, M].max - 2
  else
    ans += 1
  end
else
  ans += (N-2) * (M-2)
end

puts ans


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int ctoi(char c){
    switch (c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}

int main(){
    string S;
    cin >> S;
    int len = S.size();
    vector<vector<ll> > dp(len,vector<ll>(13));
    rep(i,len){
        rep(j,13){
            dp[i][j] = 0;
        }
    }
    if (S[0] == '?'){
        rep(i,10){
            dp[0][i]++;
        }
    }
    else{
        dp[0][ctoi(S[0])]++;
    }
    for (int i = 0; i < len - 1; i++){
        if (S[i + 1] == '?'){
            rep(j,13){
                rep(k,10){
                    dp[i + 1][(10 * j + k) % 13] = (dp[i + 1][(10 * j + k) % 13] + dp[i][j]) % 1000000007;
                }
            }
        }
        else{
            rep(j,13){
                dp[i + 1][(10 * j + ctoi(S[i + 1])) % 13] = (dp[i + 1][(10 * j + ctoi(S[i + 1])) % 13] + dp[i][j]) % 1000000007;
            }
        }
    }
    cout << dp[len - 1][5] << endl;
}


Measured memory_bytes: 13696
#include<stdio.h>
#include<stdlib.h>
int minimum(int ,int);
int main()
{
    int n;
    scanf("%d",&n);
    int *tot;
    tot=(int *)malloc((n+1)*sizeof(int));
    tot[0]=0;
    int min=200000;
    for (int i = 1; i <=n; i++)
    {
        min=tot[i-1]+1;
        int draw=6;
        while(draw<=i)
        {
            min=minimum(min,tot[i-draw]+1);
            draw*=6;
        }
        draw=9;
        while(draw<=i)
        {
            min=minimum(min,tot[i-draw]+1);
            draw*=9;
        }
        tot[i]=min;
    }
    printf("%d",min);
    free(tot);
    return 0;
}

int minimum(int a,int b)
{
    if(a<b)return a;
    else return b;
}

Measured memory_bytes: 512
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad

solve :: Int -> Int -> VU.Vector Int -> Int
solve n k xs = 
    sum [(xs VU.! a) * (xs VU.! b) * (xs VU.! c) |
            a <- [0..k-1]
            , let b = (k-a) `rem` k
            , let c = (k-a) `rem` k
            , ((b + c) `rem` k) == 0]

main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    xs <- VUM.replicate (k+1) 0
    forM_ [1..n] $ \i -> do
        VUM.modify xs (+1) (i `rem` k)
    xs' <- VU.unsafeFreeze xs
    print $ solve n k xs'

Measured memory_bytes: 2556
i = list(map(int,input().split()))
c = 0
if i[0] != i[1]:
    if i[0] > i[1]:
        c = 2 * i[0] - 1
    else:
        c = 2 * i[1] - 1
else:
    c = 2 * i[0]
print(c)

Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn freq(s: Vec<char>) -> [usize; 26] {
    let mut ans = [0; 26];
    for s in s {
        ans[s as usize - 97] += 1;
    }
    ans
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        s: [chars; n],
    }
    let mut hm = HashMap::new();
    for s in s {
        let f = freq(s);
        *hm.entry(f).or_insert(0i64) += 1;
    }
    let mut ans = 0;
    for (_, v) in hm {
        ans += v * (v - 1) / 2;
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

#define x first
#define y second
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<pair<int,int>> in;
	int ans  = INF;
	cin>>N;
	
	in.resize(N);
	

	for(int i = 0; i < N; i++){
		cin>>in[i].x>>in[i].y;
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i == j) continue;
			int p = in[i].x - in[j].x;
			int q = in[i].y - in[j].y;
			int con = 0;
			for(int k = 0; k < N; k++){
				// for(int k = i; k < i+1; k++){
				for(int l = 0; l < N; l++){
					if(k == l) continue;
					int p2 = in[k].x - in[l].x;
					int q2 = in[k].y - in[l].y;
					if(p2 == p && q == q2) con++;
				}
			}
			// cout
			ans = min(ans, N-con);
		}
	}
	
	if(N != 1)cout<<ans<<endl;
	else cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string,int>mp;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	int mx=0;
	for(auto p:mp)mx=max(mx,p.second);
	for(auto p:mp){
		if(p.second!=mx)continue;
		cout<<p.first<<endl;
	}
	return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> A(N);for(int i=0;i<N;i++) cin>>A[i];
  int ans=0;
  for(int i=0;i<N;i++){
    while(A[i]%2==0){A[i]/=2;ans++;}
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  int count=1;
  cin >> N;
  vector<int> di(N);
  for(int i=0; i<N; i++){
    cin >> di.at(i);
  }
  sort(di.begin(),di.end());
  M = di.at(0);
  for(int i=0; i<N; i++){
    if(M<di.at(i)){
      count++;
      M=di.at(i);
    }
  }
    cout << count << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
flag = 1

for i in range(N+1):
    for j in range(N+1-i):
        if Y == i * 10000 + j * 5000 + (N-i-j) * 1000 and flag == 1:
            print("{} {} {}".format(i, j, N-i-j))
            flag = 0

if flag == 1:
    print("-1 -1 -1")


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
    int N,M;
    cin>>N>>M;
    
    int sum=0;
    int ai;
    for(int i=0;i<M;i++){
        cin>>ai;
        sum+=ai;
    }
    
    if(N-sum>=0){
        cout<<N-sum<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3636
# Python program to print prime factors 

import math 

def primeFactors(n):
    A=[] 
    while n % 2 == 0:
        A.append(2)
        n = n // 2
        
 
    for i in range(3,int(math.sqrt(n))+1,2): 
        
        
        while n % i== 0: 
            A.append(i)
            n = n // i 
            
   
    if n > 2: 
        A.append(n)
    
    return A
        


N = int(input())
primes = set(primeFactors(N))
answer = 0
for p in primes:
    d = p
    while N%d == 0:
        answer += 1
        N //= d
        d *= p
 
print(answer)


Measured memory_bytes: 9088
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int n = a.length();
    int x=0,y=0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == '1')
            x++;
        else
            y++;
    }
    cout<<2*min(x,y);

}

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

int len1,len2;
string seq1,seq2;
int dp[1000+10][1000+10];

int main() {
	for (int i=0; i<=1000; i++){
		dp[i][0] = i;
		dp[0][i] = i;
	}
	
	cin >> seq1 >> seq2;
	len1 = seq1.length();
	len2 = seq2.length();
	
	for (int i=1; i<=len1; i++){
		for (int j=1; j<=len2; j++){
			if (seq1[i-1] == seq2[j-1]){
				dp[i][j] = dp[i-1][j-1];
			}else{
				dp[i][j] = min((dp[i-1][j-1]+1), min((dp[i][j-1]+1), (dp[i-1][j]+1)));
			}
		}
	}
	cout << dp[len1][len2] << endl;
	return 0;
}

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

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

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
    cin >> N;
    Sieve s(N);

    map<ll, ll> mp;
    for (int i = 1; i <= N; i++) {
        vector<P> v = s.factor(i);
        rep(i, v.size()) {
            // printf("%d %d\n", v[i].first, v[i].second);
            mp[v[i].first] += v[i].second;
        }
    }

    // ll dp[mp.size() + 1][100];
    // rep(i, mp.size() + 1) {
    //     rep(j, 100) {
    //         dp[i][j] = 0;
    //     }
    // }
    // ll cnt = 0;
    vector<ll> dp(77);
    dp[1] = 1;

    for (auto p : mp) {
    //     cnt++;
    //     for (int j = 0; j <= p.second; j++) {
    //         ll target = pow(p.first, p.second);
    //         target = min(target, 76LL);
    //         dp[cnt][target] += max(dp[cnt - 1][target], 1LL);
    //         printf("cnt: %d target: %d value: %d\n", cnt, target, dp[cnt][target]);
    //     }
        for (ll k = 76; k >= 0; k--) {
            for (ll j = p.second; j > 0; j--) {
                dp[min(76LL, k * (j + 1))] += dp[k];
            }
        }
        // printf("%d %d\n", p.first, p.second);
    }

    cout << dp[75] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	int ** candy = new int*[2];
	for(int i = 0; i < 2; i++) {
		candy[i] = new int[n];
	}
	for(int i = 0; i < 2*n; i++) {
		int temp;
		cin >> temp;
		candy[i/n][i%n] = temp;
	}
	int ** dp = new int*[2];
	for(int i = 0; i < 2; i++) {
		dp[i] = new int[n];
	}
	dp[1][n-1] = candy[1][n-1];
	for(int i = n-2; i >= 0; i--) {
		dp[1][i] = dp[1][i+1] + candy[1][i];
	}
	for(int i = n-1; i >= 0; i--) {
		dp[0][i] = max(dp[0][i+1], dp[1][i]) + candy[0][i];
	}
	cout << dp[0][0] << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
  int a, b;
  std::cin >> a >> b;
  if (a + b == 15) {
    std::cout << "+" << std::endl;
  } else if (a * b == 15) {
    std::cout << "*" << std::endl;
  } else {
    std::cout << "x" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256