akhauriyash/Code-Regression huggingface dataset:
import math
import collections


def f(target):
    c = collections.Counter()
    for k in target.keys():
        l = sorted(target[k])
        for i in range(len(l) - 1):
            c.update([l[i + 1] - l[i]])
    v, cc = c.most_common(1)[0] if len(c) != 0 else (0, 0)
    return cc


def main():
    N = int(input())
    XY = [
        [int(a) for a in input().split()]
        for a in range(N)
    ]

    d = collections.defaultdict(lambda: [])
    for x, y in XY:
        d[x] = d[x] + [y]
    cc1 = f(d)
    d = collections.defaultdict(lambda: [])
    for x, y in XY:
        d[y] = d[y] + [x]
    cc2 = f(d)
    r = N - max(cc1, cc2)

    for i in range(N):
        x1, y1 = XY[i]
        for j in range(i + 1, N):
            x2, y2 = XY[j]
            dx = x1 - x2
            dy = y1 - y2
            if dx == 0 or dy == 0:
                continue

            if dx < 0:
                dx = -dx
                dy = -dy

            bs = collections.defaultdict(lambda: [])
            for x, y in XY:
                k = math.ceil(-x / dx)
                while True:
                    if x + k * dx < 0:
                        k += 1
                    elif x + (k - 1) * dx >= 0:
                        k -= 1
                    else:
                        break

                # while not x + k * dx>=0:

                t = x + k * dx, y + k * dy
                bs[t] = bs[t] + [k]
            # print(bs)
            r = min(N - f(bs), r)

    print(r)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>s;
      rep(i,Size(s)){
        if(s[i]=='9')s[i]='1';
        else s[i]='9';
      }
      Cout(s);
    
       
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 100050;

int N;
long long A[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

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

    std::vector<std::pair<long long, int>> vec;

    for (int i = 0; i < N; i++) {
        vec.push_back(std::pair<long long, int>({A[i], i}));
    }

    std::sort(vec.begin(), vec.end());

    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0 && vec[i].second % 2 == 1) {
            ret++;
        }
    }

    std::cout << ret << std::endl;

    
    return 0;
}


Measured memory_bytes: 3188
import math
import sys

n = int(sys.stdin.readline().rstrip())

if n == 1:
    print(1)
    sys.exit()
elif n == 2:
    print(2)
    sys.exit()

m = 1
s = 0
while (s <= n):
    s += m
    m += 1
# print(m)
for i in range(1, m):
    if i == s - n:
        continue
    else:
        print(i)

Measured memory_bytes: 3408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll W;
    cin >> W;
    vector<ll> w(N,0);
    vector<ll> v(N,0);
    for(ll i=0;i<N;++i)cin>>w[i]>>v[i];

    //dp[i]は価値iの時の重さの和の最小値
    vector<ll> dp(100001,INF);
    dp[0]=0;
    for(ll i=0;i<N;++i){
        for(ll j=100001;j>=v[i];--j){
            chmin(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    ll ans=0;
    for(ll i=0;i<100001;++i)if(dp[i]<=W)chmax(ans,i);
    prt(ans)

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int N = (int)S.size();
  for (int i = N - 1; i >= 0; i --) {
    if (S[i] == '?') S[i] = 'D';
  }
  cout << S << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n - k) {
    if (a[i] < a[k + i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(all(a));
    int b=a[n/2];
    int ans=0;
    rep(i,n)ans+=abs(a[i]-b);
    cout<<ans<<endl;
    return 0;
}

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

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

  uint64_t sum = 0;
  for( uint64_t i = 1; i <= N; ++i ){
    if( i % 3 != 0 && i % 5 != 0 ){
      sum += i;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int x = x2 - x1;
		int y = y2 - y1;

	//	if(x<0)x*=-1;
	//	if(y<0)y*=-1;

		int x3 = x2-y;
		int y3 = y2+x;

		int x4 = x3 -x;
		int y4 = y3 -y;
		// 出力
		System.out.print(x3+" ");
		System.out.print(y3+" ");
		System.out.print(x4+" ");
		System.out.println(y4);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint A, B;
    cin >> A >> B;
    cout << A*B << endl;
}

Measured memory_bytes: 3648
N = gets.to_i
A = gets.split(" ").map(&:to_i)
B = gets.split(" ").map(&:to_i)
C = gets.split(" ").map(&:to_i)
ans = B.inject(:+)
 
(N - 1).times do |i|
    if A[i + 1] - A[i] == 1
        ans += C[A[i] - 1]
    end
end
 
puts ans

Measured memory_bytes: 1788
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    x1,y1,x2,y2 = map(float, input().split())
    print(((x1-x2)**2+(y1-y2)**2)**0.5)

main()



Measured memory_bytes: 5632
#include <math.h>
#include <stdio.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  long long total = -1;
  long long sum = 0;
  for (int xy = 0; xy <= 2 * max(X, Y); xy++) {
    sum = 0;
    int x;
    int y;
    if (xy % 2 == 0) {
      x = X - xy / 2;
      y = Y - xy / 2;
    } else {
      x = X - (xy - 1) / 2;
      y = Y - (xy - 1) / 2;
    }
    if (x < 0) {
      x = 0;
    }
    if (y < 0) {
      y = 0;
    }
    sum = A * x + B * y + C * xy;
    if (total < 0) {
      total = sum;
    } else {
      total = min(total, sum);
    }
  }
  cout << total << endl;
}

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

int main(){
  int64_t X;
  cin >> X;
  int64_t Y=100;
  int64_t Ans=0;
  for(int64_t i=1; i<10000000000; i++){
    Y=(int64_t)(Y*1.01);
    if(Y>=X){
      Ans=i;
      break;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 3624
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		Set<Integer> m = new HashSet<>();

		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if (m.contains(a)) {
				m.remove(a);
			} else {
				m.add(a);
			}
		}

		sc.close();

		out.println(m.size());

	}

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


Measured memory_bytes: 59876
#include <bits/stdc++.h>
using namespace std;
int main(){

    long long int X,Y,o = 1;
    cin >> X >> Y;
    for(int i = 1; i <= Y-X+1; i++) {
        long long int n = X;
        for(int j = 1; j <= i - 1; j++) {
            n *= 2;
        }
        if(n *2 > Y) {
           cout << o << endl;
            return 0;
        }
        o++;
    }

    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#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)
int c[5][5];
int a[5],b[5];
int main()
{
	rep(i,3) rep(j,3) cin>>c[i][j];
	rep(i,3) a[i]=c[i][0]-c[0][0];
	b[0]=c[0][0]-a[0];
	rep(i,3) b[i]=c[0][i]-c[0][0]+b[0];
	//rep(i,3) cout<<a[i]<<' '<<b[i]<<endl;
	rep(i,3) rep(j,3){
		if(c[i][j]!=a[i]+b[j]){
			cout<<"No"<<endl;return 0;
		}
	}
	cout<<"Yes"<<endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    int x;
    cin >> x;

    auto ans = x < 1200 ? "ABC" : "ARC";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
int main(void) {
	map < string, int > mp = {
		{"SUN", 7},
		{"MON", 6},
		{ "TUE", 5 },
		{ "WED", 4 },
		{ "THU", 3 },
		{ "FRI", 2 },
		{ "SAT", 1 },
	};
	string s;
	cin >> s;
	cout << mp[s] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
	int h, w;
	while (1) {
		scanf("%d %d", &h, &w);
		if (!h && !w) break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				putchar('#');
			}
			puts("");
		}
		puts("");
	}
}

Measured memory_bytes: 1016
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
int box[6] ,up[24] , front[24] ;
string Moji;
int q , ans;
for(int i = 0; i < 6; i++){
  cin >> box[i];
}
cin >> q;
for(int i = 0; i < q; i++){
  cin >> up[i] >> front[i];

if(up[i] == box[0]){
  if(front[i] == box[1])ans = box[2];
  else if(front[i] == box[2])ans = box[4];
  else if(front[i] == box[3])ans = box[1];
  else if(front[i] == box[4])ans = box[3];
}else if(up[i] == box[1]){
  if(front[i] == box[0])ans = box[3];
  else if(front[i] == box[2])ans = box[0];
  else if(front[i] == box[3])ans = box[5];
  else if(front[i] == box[5])ans = box[2];
}else if(up[i] == box[2]){
  if(front[i] == box[0])ans = box[1];
  else if(front[i] == box[1])ans = box[5];
  else if(front[i] == box[4])ans = box[0];
  else if(front[i] == box[5])ans = box[4];
}else if(up[i] == box[3]){
  if(front[i] == box[0])ans = box[4];
  else if(front[i] == box[1])ans = box[0];
  else if(front[i] == box[4])ans = box[5];
  else if(front[i] == box[5])ans = box[1];
}else if(up[i] == box[4]){
  if(front[i] == box[0])ans = box[2];
  else if(front[i] == box[2])ans = box[5];
  else if(front[i] == box[3])ans = box[0];
  else if(front[i] == box[5])ans = box[3];
}else if(up[i] == box[5]){
  if(front[i] == box[1])ans = box[3];
  else if(front[i] == box[2])ans = box[1];
  else if(front[i] == box[3])ans = box[4];
  else if(front[i] == box[4])ans = box[2];
}


printf("%d\n", ans );
}
return 0;
}


Measured memory_bytes: 3140
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (par[x] > par[y])
      swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { return -par[root(x)]; }
};


signed main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  UnionFind tree(m+1);
  vector<bool> seen(m+1, false);
  REP(i ,n) {
    int k, x;
    cin >> k >> x;
    seen[x] = true;
    REP(j, k-1) {
      int y;
      cin >> y;
      seen[y] = true;
      tree.unite(x, y);
    }
  }
  if(-*min_element(all(tree.par)) == accumulate(all(seen), 0l)) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;

signed main()
{
    int n;
    cin >> n;
    vector<int> v;
    v.push_back(0);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x + v[i]);
    }
    int sum = v[n];
    int minV = INF;
    for (int i = 0; i < n; i++)
    {
        int s1 = v[i];
        int s2 = sum - s1;
        int r = abs(s1 - s2);
        minV = min(minV, r);
    }
    cout << minV << "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N,Q;
  int i,j,k;
  cin>>N;
  int c[N];
  for(i=0;i<N;i++)
  {
    cin>>c[i];
  }
  cin>>Q;
  int t[Q];
  int x[Q];
  int d[Q];
  for(i=0;i<Q;i++)
  {
    cin>>t[i]>>x[i]>>d[i];
    x[i]--;
  }
  int ans[N];
  for(i=0;i<N;i++)
  {
    ans[i]=0;
  }
  for(k=0;k<Q;k++)
  {
    if(t[k]==1)
    {
      ans[x[k]]=ans[x[k]]+d[k];
    }else{
      ans[x[k]]=ans[x[k]]-d[k];
    }
    if(ans[x[k]]<0 || ans[x[k]]>c[x[k]])
    {
      cout<<x[k]+1<<endl;
      k=Q;
    }
  }
  if(k!=Q+1)
  {
    cout<<0<<endl;
  }
  return 0;


}



Measured memory_bytes: 4276
using System;

namespace Atcoder
{
    class Program
    {
        private static int[,] bingo = new int[3, 3];
        private static bool[,] bool_bingo = new bool[3, 3];
        static void checkVal(int value)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (bingo[i, j] == value) 
                    {
                        bool_bingo[i, j] = true;
                    }
                }
            }
        }
        
        static bool checkBingo()
        {
            //check row-wise
            for (int i = 0; i < 3; i++)
            {
                int j = 0;
                if (bool_bingo[i, j] && bool_bingo[i, j + 1] && bool_bingo[i, j + 2])
                {
                    return true;
                }
            }
            //check column-wise
            for (int j = 0; j < 3; j++)
            {
                int i = 0;
                if (bool_bingo[i, j] && bool_bingo[i + 1, j] && bool_bingo[i + 2, j])
                {
                    return true;
                }
            }
            if (bool_bingo[0, 0] && bool_bingo[1, 1] && bool_bingo[2, 2]) 
            {
                return true;
            }
            if (bool_bingo[2, 0] && bool_bingo[1, 1] && bool_bingo[0, 2])
            {
                return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int N = 0;
            for (int i = 0; i < 3; i++)
            {
                string[] s = Console.ReadLine().Split();
                for (int j = 0; j < 3; j++)
                {
                    bingo[i, j] = int.Parse(s[j]);
                    bool_bingo[i, j] = false;
                }
            }
            N = int.Parse(Console.ReadLine());
            while (N != 0)
            {
                checkVal(int.Parse(Console.ReadLine()));
                N--;
            }
            if (checkBingo()) 
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11220
package main

import (
	"fmt"
	"sort"
	"strings"
)

type ll int64

func main() {

	var N int
	fmt.Scan(&N)
	//string-int型の連想配列でソート済みの文字列の数を求める。
	sorted_strings := make(map[string]int)

	var scanS string


	ans := 0
	for i := 0 ; i < N ; i++ {

		fmt.Scan(&scanS)
		/* 文字列のソート */
		ss := strings.Split(scanS, "") //[]stringに一文字ずつ格納
		sort.Strings(ss)//[]stringの昇順ソート
		s := strings.Join(ss, "") //[]stringをstringにまとめる

		//intとエラーを返すのか。
		existed_num, exsit := sorted_strings[s]

		if exsit {
			//ansに足してからexisted_num++
			ans += existed_num
			sorted_strings[s]++
		} else {
			sorted_strings[s] = 1
		}

	}

	fmt.Println(ans)


}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    string s;
    cin>>s;
    ll cnt=0,pos1=0,pos2=0,slen=s.length();
    for(ll i=0;i<slen;i++){
        if(s[i]=='B') {
            pos1+=i;
            cnt++;
        }
    }
    for(ll i=slen-cnt;i<slen;i++){
        pos2+=i;
    }
    cout<<pos2-pos1<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] S = new char[H][W];
        for(int i=0; i<H; i++){
            S[i] = sc.next().toCharArray();
        }
        //String S = sc.next();

        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(S[i][j]=='#'){
                    System.out.print(S[i][j]);
                    continue;
                }
                int count=0;
                if(i>0){
                    if(S[i-1][j]=='#'){
                        count++;
                    } 
                    if(j>0 && S[i-1][j-1]=='#'){
                        count++;
                    }
                    if(j<W-1 && S[i-1][j+1]=='#'){
                        count++;
                    }
                }

                if(j>0 && S[i][j-1]=='#'){
                    count++;
                }
                if(j<W-1 && S[i][j+1]=='#'){
                    count++;
                }

                if(i<H-1){
                    if(S[i+1][j]=='#'){
                        count++;
                    } 
                    if(j>0 && S[i+1][j-1]=='#'){
                        count++;
                    }
                    if(j<W-1 && S[i+1][j+1]=='#'){
                        count++;
                    }
                }
                
                System.out.print(count);
            }
            System.out.println();
        }
        
        
        
        
        
                
            

        }
        
        

        
        
        }
    

Measured memory_bytes: 36280
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 123456
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

int n, d;
string s;
ll dp[10001][101][2];

ll memo(int idx, int rem, int eq) {
	if(idx == n) {
		if(rem == 0) return 1;
		return 0;
	}
	if(dp[idx][rem][eq] != -1) return dp[idx][rem][eq];
	ll res = 0;
	if(eq == 0) {
		for(int i=0; i<10; i++) {
			res = add(res, memo(idx+1, (rem + i)%d, 0));
		}
	}
	else {
		res = memo(idx+1, (rem + s[idx]-'0')%d, 1);
		for(int i=0; i<s[idx]-'0'; i++) {
			res = add(res, memo(idx+1, (rem + i)%d, 0));
		}
	}
	return dp[idx][rem][eq] = res;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> d;
	n = sz(s);
	memset(dp, -1, sizeof dp);
	cout << add(memo(0, 0, 1), mod-1) << endl;
	return 0;
}

Measured memory_bytes: 16896
#include<iostream>
#include<vector>

int main()
{
    int num;
    std::cin>> num;

    std::vector<int> monster_num( num + 1 );
    std::vector<int> monster_kill_num( num );

    for( int i = 0; i < num + 1; i++ )
    {
        std::cin>> monster_num[i];
    }

    for( int i = 0; i < num; i++ )
    {
        std::cin>> monster_kill_num[i];
    }

    int64_t kill_count = 0;

    for( int i = 0; i < num; i++ )
    {
        if( monster_num[i] != 0 )
        {
            if( monster_num[i] < monster_kill_num[i] )
            {
                monster_kill_num[i] -= monster_num[i];
                kill_count += monster_num[i];
            }
            else
            {
                kill_count += monster_kill_num[i];
                monster_kill_num[i] = 0;
            }
        }

        if( monster_kill_num[i] != 0 )
        {
            if( monster_num[i+1] < monster_kill_num[i] )
            {
                kill_count += monster_num[i+1];
                monster_num[i+1] = 0;
            }
            else
            {
                kill_count += monster_kill_num[i];
                monster_num[i+1] -= monster_kill_num[i];
            }
        }
    }

    std::cout<< kill_count;
}


Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
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;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    string S;
    cin >> S;
    int n = (int)S.size();
    int ans = 0;
    rep(i, n) reps(j, 1, n - i + 1) {
        bool ok = true;
        for (auto&& s : S.substr(i, j)) {
            if (s != 'A' and s != 'C' and s != 'G' and s != 'T') ok = false;
        }
        if (ok) chmax(ans, j);
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> a,b;
  bool f=1;
  int tmp=0;
  int suma=0,sumb=0;
  for(auto itr=s.begin();itr !=s.end();itr++)
  {
    if(*itr=='F'){tmp++;}
    else {
      if(f){a.push_back(tmp);suma+=tmp;}
      else{b.push_back(tmp);sumb+=tmp;}
      f=!f;
    tmp=0;
  }

  }
  if(f){a.push_back(tmp);suma+=tmp;}
  else{b.push_back(tmp);sumb+=tmp;}
  x-=a[0];
  suma-=a[0];
  x=abs(x);
  y=abs(y);
  a.erase(a.begin());
  int flag=0;
  if((suma-x)%2 or (sumb-y)%2 or suma<x or sumb<y){flag=0;}
  else
  {
    x=(suma-x)/2;
    y=(sumb-y)/2;
    vector<int> dpx(x+1);
    dpx[0]=1;
    for(auto itr1=a.begin();itr1 !=a.end();itr1++)
    {
      for(int i=x-*itr1;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr1]=1;}
      }
      if(dpx[x]!=0){flag+=1;break;}

    }
    if(a.size()==0 and x==0){flag+=1;}
    dpx.resize(y+1);
    dpx.clear();
    dpx[0]=1;
    for(auto itr2=b.begin();itr2 !=b.end();itr2++)
    {
      for(int i=y-*itr2;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr2]=1;}
      }
      if(dpx[y]!=0){flag+=1;break;}
    }
    if(b.size()==0 and y==0){flag+=1;}
  }
  cout<<yn(flag>=2)<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

/**
 * Segment Tree (0-indexed)
 */
template<class Monoid> struct SegmentTree {
    using func = function<Monoid(Monoid, Monoid)>;
    int n;
    Monoid ie;
    func f;
    vector<Monoid> node;

    SegmentTree(){};
    SegmentTree(int n, Monoid ie, func f) : n(n), ie(ie), f(f) {
        const int cn = n;
        n = 1; while(n < cn)  n *= 2;
        node.assign(2*n, ie);
    }

    void update(int i, Monoid x) {
        i += n;
        node[i] = x;
        while(i /= 2)  node[i] = f(node[2*i], node[2*i+1]);
    }

    // [l, r)
    Monoid query(int l, int r) {
        l = max(l, 0);  r = min(n, r);
        if(l >= r)  return ie;

        Monoid res = ie;
        for(l += n, r += n; l != r; l /= 2, r /= 2) {
            if(l % 2)  res = f(res, node[l++]);
            if(r % 2)  res = f(res, node[--r]);
        }
        return res;
    }

    Monoid operator[](int i) {
        assert(0 <= i && i < n);
        return node[i+n];
    }
};

int main() {
    lint n, q;
    string s;
    cin >> n >> s >> q;

    SegmentTree<lint> seg[26];
    for(lint i=0; i<26; i++) {
        seg[i] = SegmentTree<lint>(n, 0LL, plus<lint>());
    }

    for(lint i=0; i<n; i++) {
        lint d = s[i] - 'a';
        seg[d].update(i, 1);
    }

    while(q--) {
        lint t;
        cin >> t;

        if(t == 1) {
            lint i;
            char c;
            cin >> i >> c;
            i--;
            lint before = s[i] - 'a';
            lint after = c - 'a';
            s[i] = c;
            seg[before].update(i, seg[before][i]-1);
            seg[after].update(i, seg[after][i]+1);
        }

        if(t == 2) {
            lint l, r;
            cin >> l >> r;
            l--;

            lint kind = 0;
            for(lint d=0; d<26; d++) {
                kind += (seg[d].query(l, r) != 0);
            }
            cout << kind << endl;
        }
    }
}

Measured memory_bytes: 214020
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

int n;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	cout << (n&1?(n<<1):n) << endl;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
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; }
const ll inf = 1ll << 60;
int jmax = 100100;



int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> a(n);
    rp(i, 0, n) scanf("%d", &a.at(i));
    vector<vector<ll>> dp(110, vector<ll>(jmax));
    rp(i, 0, n+1) dp.at(i).at(0) = 1ll;
    rp(i, 1, n+1) {
        rp(j, 1, jmax) {
            ll res = 0;
            res += dp.at(i).at(j-1);
            res += dp.at(i-1).at(j);
            if(j-1-a.at(i-1) >= 0) {
                res += mod;
                res -= dp.at(i-1).at(j-1-a.at(i-1));
            }
            res %= mod;
            dp.at(i).at(j) = res;
        }
    }
    printf("%lld", dp.at(n).at(k));
    return 0;
} 

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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, ans;
   cin >> N;

   bool finished = false;
   for (int i = 1; i <= N; i++) {
     if ((int)(1.08 * i) == N) {
       cout << i << endl;
       finished = true;
       break;
     }
   }
   if (!finished) cout << ":(" << endl;
  }


Measured memory_bytes: 256
// Rotation.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string str1;
	string str2;

	cin >> str1;
	cin >> str2;

	if (str1[0] == str2[2] && str1[1] == str2[1] && str1[2] == str2[0])
	{
		cout << "YES";
	}
	else {
		cout << "NO";
	}

    return 0;
}



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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)){
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
    char ch;
    int count[26] = {};
    while (cin >> ch){
        ch = tolower(ch);
        if (isalpha(ch)){
            count[ch - 'a']++;
        }
    }
    for (int i = 0;i < 26;i++){
        printf("%c : %d\n", i+'a',count[i]);
    }
    return 0;
}


Measured memory_bytes: 3204
import numpy as np
    
strong_order = np.array([14,2,3,4,5,6,7,8,9,10,11,12,13])

A,B = [int(i)-1 for i in input().split()]

if strong_order[A] > strong_order[B]:
    print("Alice")
elif strong_order[A] < strong_order[B]:
    print("Bob")
else:
    print("Draw")
    
    


Measured memory_bytes: 12504
program main
 implicit none
   integer :: n,k
     read(*,*) n,k
     print*,count_higher(n,k)
contains
  function count_higher(n,k) result(res)
    integer,intent(in) :: n,k
      integer            :: h(n),res
        read(*,*) h
        res = COUNT(h(:)>=k)
  end function count_higher
end program main

Measured memory_bytes: 1024
package main

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

func main() {
	var t string
	var s = bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if s.Scan() {
		t = s.Text()
	}

	N, err := strconv.Atoi(t)
	if err != nil {
		return
	}

	if s.Scan() {
		t = s.Text()
	}

	K, err := strconv.Atoi(t)
	if err != nil {
		return
	}

	m := map[int]int{}
	for i := 1; i <= N; i++ {
		m[i] = 0
	}

	for i := 1; i <= K; i++ {
		if s.Scan() {
			t = s.Text()
		}

		d, err := strconv.Atoi(t)
		if err != nil {
			return
		}

		for j := 1; j <= d; j++ {
			if s.Scan() {
				t = s.Text()
			}

			a, err := strconv.Atoi(t)
			if err != nil {
				return
			}
			m[a]++
		}
	}

	count := 0
	for i := 1; i <= N; i++ {
		if m[i] == 0 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1796
// Aizu Vol0 0087: Strange Mathematical Expression
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);

#define MVS 0
#define MAX 100

int main()
{
	char buf[MAX+5];
	double stack[MAX + 5], d1, d2;
	int top;
	int k, minus;
	char *p;

	while (gets(buf) != NULL) {
		p = buf;
		top = 0;
		while (*p) {
			while (isspace(*p)) p++;
			if ((*p == '+' && !isdigit(*(p+1))) || (*p == '-' && !isdigit(*(p+1)))
				|| *p == '*' || *p == '/') {
				d1 = stack[--top];
				d2 = stack[--top];
				if (*p == '+') d2 += d1;
				else if (*p == '-') d2 -= d1;
				else if (*p == '*') d2 *= d1;
				else d2 /= d1;
				stack[top++] = d2;
#if MVS
				printf("d --> %lf\n", d2);
#endif
				p++;
			} else if (isdigit(*p) || *p == '+' || *p == '-') {
				minus = 0;
				if (*p == '+') p++;
				else if (*p == '-') p++, minus = 1;
				k = 0;
				while (isdigit(*p)) k = 10 * k + (*p++ - '0');
				if (minus) k = -k;
#if MVS
				printf("no --> %d\n", k);
#endif
				stack[top++] = k;
			}
		}
		printf("%lf\n", stack[--top]);
	}
	return 0;
}

Measured memory_bytes: 564
#include <bits/stdc++.h>
using namespace std;
char w[110];
int cnt[30];
bool ans;
int main() {
	scanf("%s",w);
	for (int i=0;i<strlen(w);i++)
		cnt[w[i]-'a']++;
	ans=1;
	for (int i=0;i<26;i++)
		if (cnt[i]%2==1) {
			ans=0; break;
		}
	if (ans) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    vector<int> a(2);
    int k;
    cin >> a[0] >> a[1] >> k;

    int times = 0;
    int side = 0;
    while(1){
        if(a[side] % 2 == 1) a[side] -= 1;
        a[side] /= 2;
        a[(side+1)%2] += a[side];
        side += 1;
        side %= 2;
        times += 1;
        if(times == k) break;
    }

    cout << a[0] << " " << a[1] << endl;
    return 0;
}

Measured memory_bytes: 3548
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#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.at(i);
    }
    
    int curr = 0;
    vector<int> visited(n);
    
    int cnt = 0;
    visited.at(curr) = 1;
    
    while(true){
        int next = a.at(curr) - 1;          //次のボタン
        if(visited.at(next) == 1){      //過去に押したかを確認
            cout << "-1" << endl;
            break;
        }
        curr = next;                   //押していなければ移動
        visited.at(curr) = 1;          //押したボタンの履歴を残す
        cnt++;
        if(curr == 1){
            cout << cnt;
            break;
        }
    }
}



Measured memory_bytes: 1152
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int in[3][100050];
int main() {
	int N, i, j;
	scanf("%d", &N);
	for (i = 0; i < 3; i++) {
		for (j = 1; j <= N; j++) scanf("%d", &in[i][j]);
		sort(in[i] + 1, in[i] + N + 1);
	}

	ll ans = 0;
	for (i = 1; i <= N; i++) {
		int t = in[1][i];

		int t1 = lower_bound(in[0] + 1, in[0] + N + 1, t) - (in[0] + 1);
		int t2 = lower_bound(in[2] + 1, in[2] + N + 1, t + 1) - (in[2] + 1);
		t2 = N - t2;
		ans += (ll)t1 * t2;
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 1408
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

ret = []

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n) + ',' +str(X%n)
    return str(X%n)

def main():
    N = I()
    N -= 1

    for i in range(1, 15):
        if N >= 26 ** i:
            N -= 26 ** i
            continue

        ans = ''
        for j in range(i):
            r = N % 26
            N //= 26
            ans += l_alp[r]

        print(ans[::-1])
        break


if __name__ == '__main__':
    main()


Measured memory_bytes: 74628
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    ll N = s.size();
    map<char, ll> mp;

    rep(0, i, N)
    {
        mp[s.at(i)]++;
    }
    mp['a'];
    mp['b'];
    mp['c'];

    ll c = 0;
    for (auto m : mp)
    {
        if (m.second == N / 3)
        {
            continue;
        }
        else if (m.second == N / 3 + 1)
        {
            c++;
            continue;
        }

        cout << "NO" << endl;
        return 0;
    }

    if (c == N % 3)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3736
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

string S = "";

void add(string c, int t) {
  for (auto i = 0; i < t; i++) {
    S += c;
  }
}

int main () {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx;
  int y = ty - sy;
  add("U", y);
  add("R", x);
  add("R", 1);
  add("D", y+1);
  add("L", x+1);
  add("U", 1);
  add("L", 1);
  add("U", y+1);
  add("R", x+1);
  add("D", 1);
  add("D", y);
  add("L", x);
  cout << S << endl;
}


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

int INF = 1e9;
vector<vector<int> > d(205, vector<int>(205));
int main(void){
    int n, m, r;
    cin>>n>>m>>r;
    vector<int> vr(r);
    rep(i, r) cin>>vr[i];
    sort(vr.begin(), vr.end());
    rep(i, n)rep(j, n) d[i][j] = INF;
    rep(i, n) d[i][i] = 0;

    rep(i, m){
        int a, b, c;
        cin>>a>>b>>c;
        --a;--b;
        d[a][b] = min(d[a][b], c);
        d[b][a] = min(d[b][a], c);
    }

    rep(k, n)rep(i, n)rep(j, n){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    }
    int ans = INF;
    do{
        int tmp = 0;
        rep(i, vr.size()-1){
            tmp += d[vr[i]-1][vr[i+1]-1];
        }
        ans = min(ans, tmp);
    }while(next_permutation(vr.begin(), vr.end()));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
maps = gets
maps.gsub!(/BC/,"X")
maps.gsub!(/C/,"Y")
maps.gsub!(/B/,"Y")
maps.gsub!(/Y+/,"Y")
maps.chomp!

maps = maps.split("Y")
ans = 0
a_num = 0
maps.each do|unit|
  unit.split("").each_with_index do|item,idx|
    if item == "X"
      ans += a_num
    else
      a_num += 1
    end
  end
  a_num = 0
end

puts ans.to_s

Measured memory_bytes: 18556
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  cout << (N % K == 0 ? 0 : 1) << endl;
}

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

signed main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> av(a), bv(b), cv(c);
    for(int i = 0; i < a; ++i) cin >> av[i];
    for(int i = 0; i < b; ++i) cin >> bv[i];
    for(int i = 0; i < c; ++i) cin >> cv[i];
    
    sort(av.begin(), av.end());
    sort(bv.begin(), bv.end());
    sort(cv.begin(), cv.end());
    reverse(av.begin(), av.end());
    reverse(bv.begin(), bv.end());
    reverse(cv.begin(), cv.end());
    
    priority_queue<int, vector<int>, greater<int>> q;
    for(int i = 0; i < x; ++i) q.push(av[i]);
    for(int i = 0; i < y; ++i) q.push(bv[i]);
    
    for(int i = 0; i < c; ++i) {
        if(q.top() < cv[i]) {
            q.pop();
            q.push(cv[i]);
        }
    }
    
    int ans = 0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 4724
#include<stdio.h>
#include<string.h>
int mod=1e9+7;
int main()
{
	int n,i,x,j;
	int a[10005];
	scanf("%d",&n);
	memset(a,0,sizeof(a));
	for(i=2;i<=n;i++)
	{
		x=i;
		for(j=2;j<=x;j++)
		{
			while(x%j==0)
			{
				a[j]++;
				x/=j;
			}
		}
		if(x!=1) a[x]++;
	}
	long long sum;
	sum=1;
	for(i=1;i<=n;i++)
	{
		if(a[i]!=0)
		  sum=(sum*(a[i]+1))%mod;
	}
	printf("%lld\n",sum);
	return 0;
 } 
 
 

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	ln := make([]int, a)
	for i := 0; i < a; i++ {
		var l int
		fmt.Scan(&l)
		ln[i] = l
	}
	fmt.Println(maximumLength(ln, b))
}

func maximumLength(ln []int, b int) int {
	sort.Ints(ln)
	var sum int
	var counter int
	for i := len(ln) - 1; i >= 0; i-- {
		if counter == b {
			break
		}
		sum += ln[i]
		counter++
	}
	return sum
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

void BFS(vector<int> *v, int x, int y)
{
	int color[y+1]= {0};
	color[x] = 1;
	color[y] = 2;
	queue<int> q;
	q.push(x);
	q.push(y);
	while(!q.empty())
	{
		int y = q.front();
		q.pop();
		for(int i:v[y])
			if(!color[i])
			{
				color[i] = color[y];
				q.push(i);
			}
	}

	int white= 0, black=0;
	for(int i :color)
		if(i==1) black++;
		else white++;
		white--;
	if(black>white) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> v[n+1], stack;
	for(int i = 0 ,j,k; i<n-1; i++)
	{
		cin>>j>>k;
		v[k].push_back(j);
		v[j].push_back(k);
	}
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	// DFS(v,vis,1,n,stack);
	BFS(v,1,n);
	return 0;
}

Measured memory_bytes: 6272