akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define max(a,b) a>b?a:b
int main()
{   int a,b,c,n,k,x;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        if(a>c){printf("%d",10*a+b+c);
    }else{
        printf("%d",10*c+a+b);
    }}else if(b>c){
        printf("%d",b*10+a+c);
    }else{
        printf("%d",10*c+a+b);
    }

    return 0;
}


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

using namespace std;
int P[330010];
int main()
{
	int N, i, cnt = 0, min;
	cin >> N;
	for(i = 1; i<=N; i++) {
		cin >> P[i];
		if(min > P[i]) {
			cnt ++;
//		} else {
			min = P[i];
		}
//		cout << i << " " << min << " " << cnt << endl;
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

vector<int> parent;
vector<ll> size;

int find_set(int v){
    if (v == parent[v]) return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b){
    a = find_set(a);
    b = find_set(b);
    if (a == b) return;
    if (size[a] < size[b])
        swap(a, b);
    size[a] += size[b];
    parent[b] = a;
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin>>n>>m;

    parent.resize(n+1);
    size.resize(n+1);

    lp(i, 1, n+1){
        size[i] = 1LL;
        parent[i] = i;
    }

    vector<pi> v(m);
    vector<ll> ans;

    int a, b;
    lp(i, 0, m){
        cin>>a>>b;
        v[i] = mp(a, b);
    }

    ll res = (ll)n*(n-1)/2;

    lpd(i, 0, m){
        ans.pb(res);
        int x = find_set(v[i].first);
        int y = find_set(v[i].second);

        if (x != y){
            res -= (size[x]*size[y]);
            union_sets(x, y);
        }
    }

    lpd(i, 0, m) cout<<ans[i]<<endl;

    return 0;
}

Measured memory_bytes: 4212
import numpy as np

N = int(input())
X_low = N // 1.08
X_high = int(X_low + 1)

if np.floor(X_low * 1.08) == N:
    print(X_low)
elif np.floor(X_high * 1.08) == N:
    print(X_high)
else:
    print(':(')




Measured memory_bytes: 26840
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  bool f = false;
  for(int i = 1;i < 3501;i++){
    for(int j = 1;j < 3501;j++){
      ll a = abs(n*i*j);
      ll b = 4*i*j-n*i-n*j;
      //cout << a << "  " << b  << endl;
      if(a != 0 && b != 0){
	if(a%b == 0 && a/b >= 0){
	  cout << a/b << " " << i << " " << j << endl;
	  f = true;
	  break;
	}
      }
    }
    if(f)
      break;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
A = sorted([X[i][0] for i in range(N)])
B = sorted([X[i][1] for i in range(N)])
if N%2==1:
    a = A[N//2]
    b = B[N//2]
    print(b-a+1)
else:
    a = (A[(N-1)//2]+A[N//2])/2
    b = (B[(N-1)//2]+B[N//2])/2
    print(int((b-a)/0.5)+1)


Measured memory_bytes: 136624
a , b, c , x = [int(input()) for i in range(4)]
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: 9116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll n;
  ll a[5];
  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int temp=0;
  rep(i,5){
    if(a[i]<a[temp]){
      temp=i;
    }
  }
  ll add=(n+a[temp]-1)/a[temp];
  cout << add+4 << endl;
return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;



struct st{
	string name;
	int be;
	int en;
	st(){}
	st(string str, int y, int n){
		name = str;
		be = y - n + 1;
		en = y;
	}
};


bool inRange(int a, int b, int c){
	return a<=b && b<=c;
}

bool solve(){
	int n, q;
	cin>> n>> q;
	if(n==0 && q==0) return false;
	
	vector<st> vst;
	for(int i=0;i<n;i++){
		int by, wy;
		string str;
		cin>> str>> by>> wy;
		st tmp(str, wy, by);
		vst.pb(tmp);
	}
	
	for(int i=0;i<q;i++){
		int in;
		cin>> in;
		bool flg = false;
		for(int j=0;j<vst.size();j++){
			if(inRange(vst[j].be, in, vst[j].en)){
				cout<< vst[j].name<< " "<< in - vst[j].be + 1<< endl;
				flg = true;
				break;
			}
		}
		if(!flg) cout<< "Unknown"<< endl;
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1284
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int res = 0;
	for (int i = 100; i < 1000; i++)
	{
		stringstream ss;
		ss << i;
		bool ok = true;
		for (int j = 0; j < sz(ss.str()); j++)
			if (ss.str()[j] - '0' > n || ss.str()[j] == '0')
				ok = false;
		if (ok)
			res++;

	}
	cout << res;
	return 0;
}

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

#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)

void solve(long long N, std::string S){
  long long mymax = 0;
  long long count = 0;

  REP(i, N){
    if(S[i] == 'I') count++;
    if(S[i] == 'D') count--;

    mymax = max(mymax, count);
  }

  cout << mymax << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
    solve(N, S);
    return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

const int m = 2019;

int main(void){
    std::ios_base::sync_with_stdio(false);

   int a,b,c,k;
   cin >> a >> b >> c >> k;

   int xa = min(a,k);
   k -= xa;
   int xb = min(b, k);
   k -= xb;
   int xc = min(c, k);
   cout << xa - xc;

    return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		char N = sc.next().charAt(0);
		
		if(Character.isLowerCase(N))
		{System.out.println("a");}
	else if (Character.isUpperCase(N))
		{System.out.println("A");}
		

		
	}
}

Measured memory_bytes: 35768
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll N;
    N=s.size();
    vector<int> S(0);
    
    FOR(i,0,N){
        if(s[i]=='A')S.pb(0);
        else if(i!=N-1 && s[i]=='B' && s[i+1]=='C'){
            S.pb(3);
            i++;
        }else if(s[i]=='B')S.pb(1);
        else S.pb(2);
    }

    /*FOR(i,0,S.size()){
        cout<<S[i];
    }*/
    
    ll cnt=0;
    ll ans=0;
    FOR(i,0,S.size()){
        if(S[i]==0)cnt++;
        else if(S[i]==3)ans+=cnt;
        else cnt=0;
    }
    
    //cout<<endl;
    cout<<ans<<endl;
    

    return 0;
}
//601

Measured memory_bytes: 1680
import sys
input=sys.stdin.readline

def runLength(s):
    a = []
    for c in s:
        if len(a)==0 or a[-1][0]!=c:
            a.append([c,1])
        else:
            a[-1][1] += 1
    return a

s = input().strip()
a = runLength(s)

#print(a)
ans = [0]*len(s)
j = 0
for i in range(len(s)-1):
    if s[i] == "R" and s[i+1] == "L":
        ans[i] += a[j][1]//2 + a[j+1][1]//2
        ans[i+1] += a[j][1]//2 + a[j+1][1]//2
        if a[j][1] % 2 != 0:
            ans[i] += 1
        if a[j+1][1] % 2 != 0:
            ans[i+1] += 1
#        print(j, ans)
        j += 2
print(*ans)


Measured memory_bytes: 16624
int(input().strip())
a_s = list(map(int,input().strip().split()))
a_mean = sum(a_s)/len(a_s)
min_div_a = 0
answer = 0
for i,a in enumerate(a_s):
    if i==0 or min_div_a > abs(a_mean-a):
        min_div_a = abs(a_mean-a)
        answer = i
print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include<climits>
#include<vector>
using namespace std;
#define ll long long
ll dp[100001]={0};
vector<ll> a[100001];
ll longestpath(ll src){
    if(dp[src]!=0)
    return dp[src];
    bool leaf=1;
    ll bestchild=0;
    for(auto p:a[src]){
        leaf=0;
        bestchild=max(bestchild,longestpath(p));
    }
    return dp[src]=leaf? 0:1+bestchild;
}
int main() {
    ll n,m;
    cin>>n>>m;
    ll k,l;
    for(ll i=1;i<=m;i++){
        //a[i].push_back(0);
        cin>>k>>l;
        a[k].push_back(l);
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans=max(ans,longestpath(i));
    }
    cout<<ans;
        return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

template<typename T>
class UndoableArray {
	int N;
	vector<int> pos, pre, data;
public:
	UndoableArray(int N) : N(N), data(N) {}
	UndoableArray(int N, T val) : N(N), data(N, val) {}
	UndoableArray(const vector<T>& v) : N(v.size()), data(v) {}
	UndoableArray(vector<T>&& v) : N(v.size()), data(move(v)) {}
	T change(int k, T val) {
		pos.push_back(k);
		pre.push_back(data[k]);
		return data[k] = val;
	}
	void undo() {
		data[pos.back()] = pre.back();
		pos.pop_back(), pre.pop_back();
	}
	T operator[](int k) const {
		return data[k];
	}
	int getversion() const {
		return pos.size();
	}
};

class UndoableUnionFind {
	UndoableArray<int> data;
	vector<int> pre;
	int find(int a) {
		return data[a] < 0 ? a : data.change(a, find(data[a]));
	}
public:
	UndoableUnionFind(int n) : data(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		pre.push_back(data.getversion());
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (data[a] < data[b]) swap(a, b);
		data.change(b, data[a] + data[b]);
		data.change(a, b);
	}
	void undo() {
		int cnt = data.getversion() - pre.back();
		while (cnt--) data.undo();
		pre.pop_back();
	}
	int size(int a) {
		return -data[find(a)];
	}
	int getversion() {
		return pre.size();
	}
};

class DynamicConnectivity {
	const int v, n;
	vector<vector<pii>> data;
	vector<pii> q;
	int size(int x) {
		int res = 1;
		while (res < x) res <<= 1;
		return res;
	}
	void sub(int node, vector<int>& res, UndoableUnionFind& uuf) {
		for (auto p : data[node]) uuf.unite(p.first, p.second);
		if (node < n) {
			sub(node * 2, res, uuf);
			sub(node * 2 + 1, res, uuf);
		}
		else if (q[node - n] != pii(-1, -1)) {
			res.push_back(uuf.same(q[node - n].first, q[node - n].second));
		}
		for (int i = 0; i < (int)data[node].size(); i++) uuf.undo();
	}
public:
	DynamicConnectivity(int v_, int n_) : v(v_), n(size(n_)), data(n * 2), q(n, pii(-1, -1)) {}
	void add_edge(int l, int r, int u, int v) {
		l += n, r += n;
		while (l < r) {
			if (l & 1) data[l++].emplace_back(u, v);
			if (r & 1) data[--r].emplace_back(u, v);
			l >>= 1, r >>= 1;
		}
	}
	void add_query(int p, int u, int v) {
		q[p].first = u;
		q[p].second = v;
	}
	vector<int> calc() {
		vector<int> res;
		UndoableUnionFind uuf(v);
		sub(1, res, uuf);
		return res;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> t(k), u(k), v(k);
	for (int i = 0; i < k; i++) {
		cin >> t[i] >> u[i] >> v[i];
	}
	map<pii, int> last;
	DynamicConnectivity dc(n, k);
	for (int i = 0; i < k; i++) {
		if (t[i] == 1) {
			last[pii(u[i], v[i])] = i;
		}
		else if (t[i] == 2) {
			dc.add_edge(last[pii(u[i], v[i])], i, u[i], v[i]);
			last.erase(pii(u[i], v[i]));
		}
		else {
			dc.add_query(i, u[i], v[i]);
		}
	}
	for (auto pp : last) {
		dc.add_edge(pp.second, k, pp.first.first, pp.first.second);
	}
	for (auto ans : dc.calc()) {
		puts(ans ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 14140
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a-lin bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    string S;cin >> S;
    long long K;cin >> K;
    bool ok = true;
    for(int i = 0;i<S.size()-1;i++){
        if(S.at(i) != S.at(i+1)) ok = false;
    }
    //全文字同じ時を例外処理
    if(ok){
        cout << (S.size()*K)/2 << endl;
        return 0;
    }
    
    long long times = 0;
    long long count = 1;
    if(S.size() == 1){
        cout << K-1 << endl;
        return 0;
    }
    for(int i = 0;i<S.size()-1;i++){
        if(S.at(i) == S.at(i+1)){
            count++;
            if(i == S.size()-2) times += count/2;
        }
        else {
            times += count/2;
            count = 1;
        }
    }
    long long ans = K*times;
    char C = '?';
    long long ren = 0;
    for(int i = 0;i<S.size();i++){
        if(C == '?'){
            C = S.at(i);
            ren = 1;
            continue;
        }
        if(C == S.at(i)){
            ren++;
        }
        else{
            break;
        }
    }
    ans -= (ren/2)*(K-1);
    long long kaihi = ren;
    for(int i = S.size()-1;i>=0;i--){
        if(C == S.at(i)){
            ren++;
        }
        else{
            break;
        }
    }
    ans -= ((ren-kaihi)/2)*(K-1);
    ans += (ren/2)*(K-1);
    cout << ans << endl;
}

Measured memory_bytes: 3568
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    N, M = map(int, input().split())
    si = []

    for i in range(M):
        tmp = [int(j) for j in input().split()]
        tmp.append(i)
        tmp.append(0)
        si.append(tmp)

    si.sort(key=lambda x: x[1])
    si.sort(key=lambda x: x[0])

    count = 1
    num = 1
    for i, s in enumerate(si):
        if num == s[0]:
            si[i][3] = count
            count += 1
        else:
            num = s[0]
            si[i][3] = 1
            count = 2

    si.sort(key=lambda x: x[2])

    for s in si:
        print(str(s[0]).zfill(6)+str(s[3]).zfill(6))


if __name__ == '__main__':
    main()


Measured memory_bytes: 72924
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> v.at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> c.at(i);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int diff = v.at(i) - c.at(i);
		ans += max(diff, 0);
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll h, w, ans = 0; cin >> h >> w;
    vector<string> s(h);
    queue<pair<pair<ll, ll>, ll>> que;
    vvi chk(h, vi(w, 0));

    // 黒の箇所をキューに積む
    rep(i, h){
        cin >> s[i];
        rep(j, w){
            if(s[i][j] == '#'){
                chk[i][j] = INFLL;
                que.push({{i, j}, 0});
            }
        }
    }
    
    // 幅優先探索
    vector<long long> dx = {-1, 1, 0, 0};
    vector<long long> dy = { 0, 0,-1, 1};
    while(que.size()){
        auto top = que.front();
        que.pop();
        rep(d, 4){
            ll x = top.first.second + dx[d];
            ll y = top.first.first + dy[d];
            if(x<0 || y<0 || x>w-1 || y>h-1) continue;
            if(chk[y][x] != 0) continue;
            chk[y][x] = top.second+1;
            chmax(ans, chk[y][x]);
            que.push({{y, x}, top.second+1});
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 36176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    //a[0]=A,a[1]=B,...とする
    string a;
    cin >> a;
  
    //式Aop1Bop2Cop3Dの値
    int total;
  
    //全探知
    for( int op = 0; op < (1<<3); op++){

      total = a[0]-'0';
      
      //式の値を求める
      for( int i = 0; i < 3; i++){

        //op(i) = 1なら足し算する
        if( op & (1<<i)) total += a[i+1]-'0';
        //op(i) = 0なら引き算する
        else total -= a[i+1]-'0';
        
      }

      //求めるものになったとき
      if( total == 7 ){
        for( int i = 0 ; i < 3; i++){
          cout << a[i];
          if( op & (1 << i) ) cout << "+";
          else cout << "-";
        }
        cout << a[3] << "=7";
        return 0;
      }
    
    } 

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    
    if (a == f && b == e && c == d){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

int main(){
    int n;
    double x;
    double ans = 0;
    string u;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> x >> u;
        if(u=="JPY") ans += x;
        else ans += x*380000.0;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo  998244353
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii\                               
  ios_base::sync_with_stdio(false);\                                      
  cin.tie(NULL);\
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll move = 1;
	while(true){
		if(c-move*b<=0) {cout<<"Yes";break;}
		if(a-move*d<=0) {cout<<"No";break;}
		move++;
	}


	
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  long long a,b;
  cin>>a>>b;
  long long temp;
  if(a<b)
  {
    temp=a;
    a=b;
    b=temp;
  }
  long long n=a;
  long long hcf=b;
  while(a%hcf!=0)
  {
    long long t=hcf;
    hcf=a%hcf;
    a=t;
  }
  
  
  cout<<(n/hcf)*(b/hcf)*hcf;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int x, int y) {
  int ay = y > 0 ? y : -y;
  int ax = x > 0 ? x : -x;
  if(ax == ay) return x != y;
  if(ay < ax) return (x > 0) + ax - ay + (y > 0);
  return (x < 0) + ay - ax + (y < 0);
}

int main(){
  int x, y;
  scanf("%d %d", &x, &y);
  printf("%d\n", solve(x, y));
  return 0;
}

Measured memory_bytes: 128
s = gets.chomp

a = s[0..1].to_i
b = s[2..3].to_i

flag_a = a >= 1 && a <= 12
flag_b = b >= 1 && b <= 12


if flag_a && flag_b then
  puts "AMBIGUOUS"
elsif flag_a then
  puts "MMYY"
elsif flag_b then
  puts "YYMM"
else
  puts "NA"
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> m1, m2;
  set<P, greater<P>> st1, st2;
  rep(i, n) {
    ll v;
    cin >> v;
    if(i % 2)
      m1[v]++;
    else
      m2[v]++;
  }
  m1[0] = m2[0] = 0;
  for(auto v : m1) st1.emplace(v.second, v.first);
  for(auto v : m2) st2.emplace(v.second, v.first);
  auto it = st1.begin();
  P a = *it;
  ++it;
  P b = *it;
  it = st2.begin();
  P c = *it;
  ++it;
  P d = *it;
  ll ans;
  if(a.second == c.second) {
    ll n1 = n - a.first - d.first;
    ll n2 = n - b.first - c.first;
    ans = min(n1, n2);
  } else
    ans = n - a.first - c.first;
  cout << ans << endl;
}

Measured memory_bytes: 15996
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	swap(a,b);swap(a,c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define lli long long int
using namespace std;
int main()
{
    lli n,k, count = 0;
    cin >> n >> k;
    string s;
    cin >> s;
    for(lli i = 0; i < n - 1; i++)
    {
        if(s[i + 1] == s[i])
            count++;
    }
    if(count + 2*k >= n - 1)
    cout << n - 1  << endl;
    else
    cout << count + 2*k  << endl;
    return 0;
}


Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[int(_) for _ in input().split()]
    sum_a=sum(A)
    if sum_a>n:
        print(-1)
    else:
        print(n-sum_a)

if __name__=='__main__':
    main()

Measured memory_bytes: 10004
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int mod = 1e9 + 7;

//const int inf = 1e9;
const int maxn = 1e5 + 66;

int a[maxn];

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 0; i < n; ++i)
    {
        int b;
        cin >> b;
        a[b]++;
        sum += b;
    }
    int q;
    cin >> q;
    for(int ii = 0; ii < q; ++ii)
    {
        int x, y;
        cin >> x >> y;
        sum += 1ll * a[x] * (y - x);
        a[y] += a[x];
        a[x] = 0;
        cout << sum << '\n';
    }
    return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

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

    ll n;
    cin >> n;
    string s = to_string(n);
    string t = s.substr(1);
    bool all_nine = true;
    for (auto c : t) if (c != '9') all_nine = false;
    ll ans = (ll) (s[0] - '0') + 9 * (t.length()) - !(all_nine);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC128A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            Console.WriteLine((a * 3 + b) / 2);
            Console.ReadKey();
        }
    }
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;


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

    auto s2 = s.substr(0, n / 2);

    cout << (s2 + s2 == s ? "Yes" : "No") << endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int a,N,check;
 int ans=1;
 vector<int> H;
 
 cin>>N;
 for(int i=0; i<N;i++){
  cin>>a; 
  H.push_back(a);
 }
 check=0;

 for(int i=1;i<N;i++){
  for(int j=i-1; j>=0; j--){
   if(H[j]<=H[i]);
   else check=1;
  }
  if(check==0)ans++;
  check=0;
 }
 
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

WAY = [0] * (N+1)
for a,b in AB:
  WAY[a] += 1
  WAY[b] += 1
  
print("\n".join(map(str,WAY[1:])))
  


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

int es(int *A,int len,int i,int m,int sum){
  if (len==i)return 0;
  if (sum+A[i] == m) return 1;
  if (es(A,len,i+1,m,sum))return 1;
  return es(A,len,i+1,m,sum + A[i]);
}

int main(){
  int n,A[30],q,m,i;

  cin >> n;

  for (i=0;i<n;i++)
    cin >> A[i];

  cin >> q;

  for (i=0;i<q;i++){
    cin >> m;
    if (es(A,n,0,m,0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
S = list(map(int, input()))
s = 0
ta = 0
for i in range(2 ** (len(S) - 1)):
    t = 0
    for j in range(len(S) - 1):
        ta = S[j]
        if (i >> j) & 1:
            s += ta + t * 10
            t = 0
        else:
            t = t * 10 + ta
    s += t * 10 + S[len(S) - 1]
print(s)


Measured memory_bytes: 3060
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
int L[210];
int ans = 0;

int main() {
	cin >> N;
	REP(i, 2 * N) {
		cin >> L[i];
	}
	sort(L, L + 2 * N);
	REP(i, N) {
		ans += L[2 * i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];

void adjacent() {
	int n;
	cin >> n;
	ll a[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] % 4 == 0) {
			t[2]++;
		}
		else if (a[i] % 2 == 0) {
			t[1]++;
		}
		else t[0]++;
	}
	int p = -1;
	for (int i = 0; i < n; i++)
	{
		if ((p == -1 && t[0] > 0)  || (p == 2 && t[0] > 0)){ p = 0; t[0]--; }
		else if ((p == -1 && t[2] > 0) || t[2] > 0) { p = 2; t[2]--; }
	}
	if (t[0] > 0 || (p == 0 && t[1] > 0) ) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
}

int main() {
	adjacent();
	return 0;
}



Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for C - Exception Handling
	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N)
	B := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		B[i] = A[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(B)))
	for i := 0; i < N; i++ {
		if A[i] == B[0] {
			fmt.Println(B[1])
		} else {
			fmt.Println(B[0])
		}

	}
}


Measured memory_bytes: 8736
#include<bits/stdc++.h>
using namespace std;
int N;string s;
int main(){
  cin>>N>>s;
  int sum=0;
  for(int i=0;i<N;i++)
    if(s.at(i)=='R')
      sum++;
  int ans=sum;int w=0;
  for(int i=0;i<N;i++){
  if(s.at(i)=='W')w++;
    else
      sum--;
    int a=max(w,sum);
    if(a<ans)ans=a;
  
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3732
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む]
		string S = Console.ReadLine();
		string T = Console.ReadLine();
		int len = S.Length;

		if(T.Substring(0,len) == S){
				Console.WriteLine("Yes");
		}else{
				Console.WriteLine("No");
		}
	}
}



Measured memory_bytes: 17364
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
      	long b=sc.nextLong();
    	long c=gcd(a,b);
      long d=1;
      
      for(long i=2; i*i<=c;i++){
        if(c%i!=0) continue;
      	while(c%i==0){
        	c/=i;
        }
        d++;
      }
      if(c>1) d++;
      System.out.println(d);
        
    }
  	
  	private static long gcd(long a, long b){
    	while(b%a!=0){
        	long c=b%a;
          	b=a;
          	a=c;
        }
      return a;
    }
  
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    string s;cin>>s;
    string t="keyence";
    int f=0,b=0;
    while(f<7&&s[f]==t[f]) f++;
    while(b<7&&s[(int)s.size()-1-b]==t[6-b]) b++;
    if(f==7||b==7||f+b>=7){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 

class Main
{
	public static void main(String args[])throws IOException
	{
		BufferedReader d=new BufferedReader(new InputStreamReader(System.in));

		String line="";
		while((line=d.readLine())!=null)
		{
			String[] str = line.split(" ");
			int a=Integer.parseInt(str[0]);
			int b=Integer.parseInt(str[1]);
			int sum=a+b;
			int count=1;

			while(sum>=10)
			{
				count++;
				sum/=10;
			}
			System.out.println(count);
		}
	}
}

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

int main()
{
	int N, K, x, sum = 0;
	cin >> N >> K;
	for (; N; --N)
	{
		cin >> x;
		if (x <= K - x)
			sum += x * 2;
		else
			sum += (K - x) * 2;
	}
	cout << sum;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 10001
#define P 104730 // No.10000 prime number is 104729

int main(void) {
	int is_prime[P];
	int prime[N];
	int i;
	int j;
	int len;
	int input;
	int output;
	
	for (i = 2;i < P;++i) {
		is_prime[i] = 1;
	}
	// sieve of Eratosthenes
	len = P/2;
	for (i = 2;i < len;++i) {
		if (is_prime[i]) {
			for (j = i*2;j < P;j += i) {
				is_prime[j] = 0;
			}
		}
	}
	for (i = 2,j = 0;i < P && j < N;++i) {
		if (is_prime[i]) {
			prime[++j] = i;
		}
	}
	while (1) {
		scanf("%d",&input);
		if (input == 0) {
			break;
		}
		output = 0;
		for (i = 1;i <= input;++i) {
			output += prime[i];
		}
		printf("%d\n",output);
	}
	return 0;
}

Measured memory_bytes: 1048
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5

int main(){
	int n,l;
	cin>>n>>l;
	vi a(n);
	int ans=0;
	rep(i,n) a[i]=l+i;
	if(a[0]>=0){
		for(int i=1;i<n;i++) ans+=a[i];
	}
	else if(a[n-1]<=0){
		for(int i=0;i<n-1;i++) ans+=a[i];
	}
	else{
		rep(i,n) ans+=a[i];	
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	ll n,h;
        	cout<<fixed<<setprecision(0);
        	cin>>n>>h;
        	cout<<n*h;

       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3804
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
string S[100001];
unordered_map<string, ll> M;

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

  cin >> N;
  string s;
  rep(i, N){
    cin >> s;
    sort(s.begin(), s.end());
    S[i] = s;
    if (M.count(s)>0){
      M[s] += 1ll;
    } else{
      M[s]= 1ll;
    }
  }

  ll cnt = 0ll;

  for (auto it=M.begin(); it !=M.end(); ++it){
    ll v = it->second;
    cnt += (v*(v-1))/2;
  }

  cout << cnt << endl;
  return 0;
}

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

int find(int x, vector<int>& par){
  if(par[x] == x) return x;
  else{
    /* path compression */
    par[x] = find(par[x], par);
    return par[x];
  }
}

void unite(int x, int y, vector<int>& par, vector<int>& rank){
  int px = find(x, par), py = find(y, par);
  if(px == py) return;
  /* union by rank */
  if(rank[px] > rank[py]) par[px] = py;
  else par[py] = px;
  if(rank[px] == rank[py]) rank[x]++;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> par(n), rank(n);
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
  int a,b;
  for(int i=0; i<m; i++){
    cin >> a >> b;
    a--;b--;
    unite(a, b, par, rank);
  }
  vector<int> cnt(n);
  int ans = 0;
  for(int i=0; i<n; i++) cnt[find(i, par)]++;
  for(int i=0; i<n; i++) ans = max(ans, cnt[i]);
  cout << ans << endl;
}

Measured memory_bytes: 8540
def gcd(n1, n2)
  return n2 if n1 % n2 == 0
  gcd(n2, n1 % n2)
end

h0, w0, h, w = gets.chomp.split(' ').map(&:to_i)

if h0 % h == 0 && w0 % w == 0
  puts 'No'
else
  puts 'Yes'

  if w0 % w == 0
    h0, w0, h, w = w0, h0, w, h
    tr = true
  else
    tr = false
  end

  w_p = w0 % w
  w_n = w - w_p

  g = gcd(w_p, w_n)

  po, ne = 0, 0
  1.upto(w_n) do |i|
    po = w0 / w * g / w_p + i

    if (g + w_p * po) % w_n == 0
      ne = -(g + w_p * po) / w_n
      break
    end
  end

  a = (0...h0).map { (([po] * w_p + [ne] * w_n) * (w0 / w) + [po] * w_p) } 
  a = a.transpose if tr

  a.each { |a2| puts a2.join(' ') }
end


Measured memory_bytes: 24012
// ABC072_C
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    ll N, t;
    cin >> N >> t;
    
    // calculation
    if (N <= t) {
        cout << 0 << "\n";
    } else {
        cout << N - t << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

ll dist(ll x,ll y){
	return x*x + y*y;
}

int main(){
	int n;
	ll D;
	cin>>n>>D;
	int ans = 0;
	for(int i = 0 ; i < n; i++){
		ll x,y;
		cin>>x>>y;
		if( dist(x,y) <= D*D) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3188
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	long double a, b, c; cin >> a >> b >> c;
	long double eps = 1.0e-14;
	if (sqrt(a) + sqrt(b) + eps < sqrt(c))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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


long long com[51][51];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }

    int N, A, B; cin >> N >> A >> B;
    vector<long long> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long>());

    // 最大値
    long long sum = 0;
    for (int i = 0; i < A; ++i) sum += v[i];
    double ave = (double)(sum) / A;

    // 小さいやつの個数
    long long res = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[A-1]) ++num;
    if (v[0] == v[A-1]) {
        for (int j = A; j <= B; ++j) {
            res += com[num][j];
        }
    }
    else {
        int a = 0;
        for (int i = 0; i < A; ++i) if (v[i] == v[A-1]) ++a;
        res = com[num][a];
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <unordered_set>
#include <string>
#if _WIN32
#include <locale>
#endif

using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;

int main() {
  using namespace std;
  #if _WIN32
  locale::global(locale(""));
  #endif
  unordered_set<string> achieved;
  i32 n;
  string n_str;
  getline(cin, n_str);
  n = stoi(n_str);
  for(i32 i = 0; i < n; ++i) {
    string id;
    getline(cin, id);
    achieved.insert(id);
  }
  cout << achieved.size() << '\n';
  return 0;
}


Measured memory_bytes: 17792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CAverageLength {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> x(n), y(n);
      rep(i, n) {
        cin >> x[i] >> y[i];
      }

      double len = 0;
      rep(i, n) {
        for(int j=i+1; j<n; j++) {
          double dx = x[i] - x[j];
          double dy = y[i] - y[j];
          len += sqrt(dx*dx + dy*dy);
        }
      }
      len /= n*(n-1);
      cout << setprecision(10) << fixed << len*(n-1)*2 << endl;
    }
};

signed main() {
  CAverageLength solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256