akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    unordered_map<int, int> M;
    M.reserve(2 * N);
    rep(i,N) {
        cin >> A[i];
    }
    ll sum = 0;
    for (int i = N - 1; i >= 0; i--) {
        sum += M[i + 1 + A[i]];
        M[(i + 1) - A[i]]++;
    }
    cout << sum << endl;
    
    return 0;
}


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

bool my_c(tuple<string,int,int>a,tuple<string,int,int>b){
  if(get<0>(a)!=get<0>(b)){
    return get<0>(a) < get<0>(b);
  }
  if(get<1>(a)!=get<1>(b)){
    return get<1>(a) > get<1>(b);
  }else{
    return true;
  }
}
int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> r(N);
  loop(i,N){
    cin >> get<0>(r.at(i)) >> get<1>(r.at(i));
    get<2>(r.at(i)) = i+1;
  }
  sort(r.begin(),r.end(),my_c);

  loop(i,N){
    cout << get<2>(r.at(i)) << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}

	vector<int> r[200010];
	ll add[200010] = {0};
	ll point[200010] = {0};
	int visited[200010] = {0};
int main()
{
	ll N,Q;
	string S;
	ll i,j,k;
	queue<int> pos;
	cin >> N >>Q;
	for(i=0;i<N-1;++i)
	{
		cin>>j>>k;
		--j;--k;
		r[j].push_back(k);
		r[k].push_back(j);
	}
	for(i=0;i<Q;++i)
	{
		cin>>j>>k;
		add[j-1] += k;
	}
	pos.push(0);
	while(!pos.empty())
	{
		int cur = pos.front();
		pos.pop();
		visited[cur] = 1;
		point[cur] = add[cur];
		for(j=0;j<r[cur].size();++j)
		{
			k = r[cur][j];
			if(!visited[k])
			{
				pos.push(k);
				add[k] += add[cur];
			}
		}
	}
	for(i=0;i<N;++i)
	{
		cout << point[i] << " ";
	}
	cout << endl;
	return 0;
}




















Measured memory_bytes: 18676
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll a, b, x; cin >> a >> b >> x;

    ll a_rem = a % x;
    ll b_rem = b % x;

    ll a_r;
    if (a_rem == 0) {
        a_r = a;
    } else {
        a_r = a + x - a_rem;
    }
    ll b_r = b - b_rem;
    ll n = b_r - a_r;
    cout << n / x + 1 << endl;
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
for i in range(N):
    a,b,c = map(int, input().split())
    if a**2 == b**2 + c**2 or b**2 == c**2 + a**2 or c**2 == a**2 + b**2 :
        print("YES")
    else :
        print("NO")


Measured memory_bytes: 5596
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, 5)
	m := 1001001001001001
	for i := 0; i < 5; i++ {
		a[i] = getInt()
		m = min(m, a[i])
	}

	out((N+m-1)/m + 4)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#define N 1005
using namespace std;

typedef long long ll;
ll n, m, mx[N];
vector<ll> gr[N], ga[N];
int main()
{
	ll i, j, k, t1, t2, t3;
	cin >> n >> m;
	while (m--) {
		scanf("%lld %lld %lld", &t1, &t2, &t3);
		gr[t1].push_back(t2); ga[t1].push_back(t3);
	}
	for (i = 2; i <= n; i++) mx[i] = -1e18;
	for (i = 0; i < n; i++) {
		for (j = 1; j <= n; j++) {
			if (mx[j] == -1e18) continue;
			for (k = 0; k < gr[j].size(); k++) {
				if (mx[j] + ga[j][k] > mx[gr[j][k]]) {
					if (i == n - 1 && gr[j][k] == n) {puts("inf"); return 0;}
					mx[gr[j][k]] = mx[j] + ga[j][k];
				}
			}
		}
	}
    cout << mx[n];
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char a[105][105];
    ll h,w;
    // ll ans=0;
    scanf("%lld%lld",&h,&w);
    // ll [n];
    rep(i,0,h){
        scanf("%s",a[i]);
    }
    rep(i,0,h+2){
        rep(j,0,w+2){
            if(i==0 || i==h+1 || j==0 || j==w+1){
                printf("#");
            }else{
                printf("%c",a[i-1][j-1]);
            }
        }
        PN;
    }

    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 128
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int M, K;
    cin >> M >> K;

    if ((M == 0 || M == 1) && K != 0) {
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;

    if (M == 0 || M == 1) {
        ans.resize((int)pow(2, M+1));
        for (int i = 0; i < (int)pow(2, M); i++) {
            ans[i] = i;
            ans[ans.size() - 1 - i] = i;
        }
    } else {
        if (K > (int)pow(2, M) - 1) {
            cout << -1 << endl;
            return 0;
        }

        ans.resize((int)pow(2, M+1));

        int idx = 0;
        for (int i = 0; i < (int)pow(2, M); i++) {
            if (i == K) continue;
            ans[idx] = i;
            ans[ans.size() - 2 - idx] = i;
            idx++;
        }

        ans[ans.size() - 1] = K;
        ans[idx] = K;
    }

    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if (i != ans.size() - 1) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3840
#include<stdio.h>

int main()
{
  int N, r;
  scanf("%d", &N);
  
  r = (N-N%111) / 111+1;
 
  if (N%111 == 0)
  {
    printf ("%d", N);
  }

  else
  {   
    printf("%d%d%d",r,r,r);
  }
    
  return 0;
}
  


Measured memory_bytes: 128
#// Problem link : 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<=n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
int sum = 0;
int fun(int n)
{
	if (n==0) return 0;
	//recursive case 

}
int main()
{
	int n;
	cin>>n;
	int a[n][3]={0};
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	ll dp[n][3]={0};
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j!=k)
				{
					dp[i][j]=max(dp[i-1][k]+a[i][j],dp[i][j]);
				}
			}
		}

	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
	return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    const int N = 5;
    vector<int> v;
    REP(0, i, N) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    vector<int> w;
    do {
        int tmp = 0;
        REP(0, i, N) {
            tmp += v[i];
            if (i != N - 1) {
                tmp += 9;
                tmp /= 10;
                tmp *= 10;
            }
        }
        w.push_back(tmp);
    } while(next_permutation(v.begin(), v.end()));

    sort(w.begin(), w.end());

    cout << w[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1000000+10;
inline void read(int &x)
{
	x=0;  int p=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') p=-1; ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		x=(x<<3)+(x<<1)+(ch^'0'); ch=getchar();
	}
	x=x*p;
}
char s[maxn],s2[maxn];
struct node
{
	int l_x;
	int r_x;
}e[maxn];
inline int judge(char a[],int len)
{
	int i,flag=0;
	for(i=1;i<=(len+1)/2;i++)
		if(a[i]!=a[len-i+1]){
			flag=1; break;
		}
	return flag;
}
int main()
{
	int i,j,x,y,z,len2=0;
	cin>>s+1;
	int len1=strlen(s+1);
	for(i=1;i<=len1;i++)
		if(s[i]!='x'){
			s2[++len2]=s[i];
			x=i-1; //printf("%d\n",x);
			while(x>=1 && s[x]=='x'){ //printf("1");
				e[len2].l_x++;
				x--;
			}
			x=i+1;
			while(x<=len1 && s[x]=='x'){ //printf("2");
				e[len2].r_x++;
				x++;
			}
		}
	//cout<<s2+1<<endl;
	if(judge(s2,len2)==1){
		printf("-1\n");
		return 0;
	}
	int ans=0;
	if(len2%2==0){ //printf("1");
		for(i=len2/2;i>=1;i--){
			x=e[i].l_x; y=e[len2-i+1].r_x;
			
			if(x==y) continue;
			else {
				ans+=abs(e[i].l_x-e[len2-i+1].r_x);
			}
		}
	}
	else { //printf("2");
		ans+=abs(e[(len2+1)/2].l_x-e[(len2+1)/2].r_x);
		for(i=len2/2;i>=1;i--){
			if(e[i].l_x==e[len2-i+1].r_x) continue;
			else {
				ans+=abs(e[i].l_x-e[len2-i+1].r_x);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

bool check(string s){
	int j = s.size()-1;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != s[j]) return false;
		j--;
	}
	return true;
}

bool checkr(string s){
	int j = (s.size()/2)-1;
	for(int i = 0; i <= (s.size()/2)-1; i++){
		if(s[i] != s[j]) return false;
		j--;
	}
	return true;
}
bool checkl(string s){
	int j = s.size()-1;
	for(int i = (s.size()/2)+1; i < s.size(); i++){
		if(s[i] != s[j]) return false;
		j--;
	}
	return true;
}

int main(){
	
	string s; cin>>s;
	if(check(s) && checkr(s) && checkl(s)) cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
	
	
	
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');
		int[] card = input.Select(int.Parse).ToArray();
		var sortedCard = card.OrderBy(a => -a);

		int alice = 0;
		int bob = 0;
		bool flag = true;

		foreach (int i in sortedCard)
		{
			if (flag)
			{
				alice += i;
				flag = !flag;
			}
			else
			{
				bob += i;
				flag = !flag;
			}
		}
		Console.WriteLine((alice - bob).ToString());
	}
}

Measured memory_bytes: 13396
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

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

#define		MXCLEN		1200
#define		FGAD		10

int		main(void)
{
	int		ii;
	int		lower;
	char	str[MXCLEN]={'\0'};
	int		a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r,
			s, t, u, v, w, x, y, z;

	//char	ret[MXCLEN]={'\0'};
	//int		ret0;

	a=b=c=d=e=f=g=h=i=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z=0;
	while( fgets( str, MXCLEN+FGAD, stdin) != NULL )
	{
		/*
		fgets( str, MXCLEN+FGAD, stdin);
		if( ret0 == NULL )
		{
			printf("NULL");
			break;
		}
		*/

		for(ii=0; ii<MXCLEN+FGAD; ii++)
		{
			lower = tolower(str[ii]);

			switch	(lower)
			{
			case 'a':
				a+=1;
				break;
			case 'b':
				b+=1;
				break;
			case 'c':
				c+=1;
				break;
			case 'd':
				d+=1;
				break;
			case 'e':
				e+=1;
				break;
			case 'f':
				f+=1;
				break;
			case 'g':
				g+=1;
				break;
			case 'h':
				h+=1;
				break;
			case 'i':
				i+=1;
				break;
			case 'j':
				j+=1;
				break;
			case 'k':
				k+=1;
				break;
			case 'l':
				l+=1;
				break;
			case 'm':
				m+=1;
				break;
			case 'n':
				n+=1;
				break;
			case 'o':
				o+=1;
				break;
			case 'p':
				p+=1;
				break;
			case 'q':
				q+=1;
				break;
			case 'r':
				r+=1;
				break;
			case 's':
				s+=1;
				break;
			case 't':
				t+=1;
				break;
			case 'u':
				u+=1;
				break;
			case 'v':
				v+=1;
				break;
			case 'w':
				w+=1;
				break;
			case 'x':
				x+=1;
				break;
			case 'y':
				y+=1;
				break;
			case 'z':
				z+=1;
				break;
			default:
				break;
			}
		}
		for(ii=0; ii<MXCLEN; ii++)
		{
			str[ii]='0';
		}
	}

	printf("a : %d\n",a);
	printf("b : %d\n",b);
	printf("c : %d\n",c);
	printf("d : %d\n",d);
	printf("e : %d\n",e);
	printf("f : %d\n",f);
	printf("g : %d\n",g);
	printf("h : %d\n",h);
	printf("i : %d\n",i);
	printf("j : %d\n",j);
	printf("k : %d\n",k);
	printf("l : %d\n",l);
	printf("m : %d\n",m);
	printf("n : %d\n",n);
	printf("o : %d\n",o);
	printf("p : %d\n",p);
	printf("q : %d\n",q);
	printf("r : %d\n",r);
	printf("s : %d\n",s);
	printf("t : %d\n",t);
	printf("u : %d\n",u);
	printf("v : %d\n",v);
	printf("w : %d\n",w);
	printf("x : %d\n",x);
	printf("y : %d\n",y);
	printf("z : %d\n",z);

	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N= sc.nextInt();
		long a[]= new long[5];
		char c[] = {'M','A','R','C','H'};
		long sum =0;
		for (int i =0;i<N;i++) {
			String str = sc.next();
			for (int j=0;j<c.length;j++) {
				if (str.charAt(0)==c[j]) {
					a[j] ++;
					break;
				}
			}
		}
		sum +=Main.count(a[0], a[1], a[2]);
		sum +=Main.count(a[0], a[1], a[3]);
		sum +=Main.count(a[0], a[1], a[4]);
		sum +=Main.count(a[0], a[2], a[3]);
		sum +=Main.count(a[0], a[2], a[4]);
		sum +=Main.count(a[0], a[3], a[4]);
		sum +=Main.count(a[1], a[2], a[3]);
		sum +=Main.count(a[1], a[2], a[4]);
		sum +=Main.count(a[1], a[3], a[4]);
		sum +=Main.count(a[2], a[3], a[4]);
		System.out.println(sum);
	}
	private static long count(long a,long b,long c) {
		return a*b*c;
	}
}

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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  void unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] > data[y]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

int main()
{
  int N, W, H;
  vector< int > xs[100000], ys[100000];

  scanf("%d %d %d", &N, &W, &H);
  bool ei = false;
  for(int i = 0; i < N; i++) {
    int X, Y;
    scanf("%d %d", &X, &Y);
    xs[--X].push_back(i);
    ys[--Y].push_back(i);
    ei |= X == 0 || Y == 0 || X == W - 1 || Y == H - 1;
  }

  UnionFind tree(N);
  for(int i = 0; i < 100000; i++) {
    for(int j = 1; j < xs[i].size(); j++) tree.unite(xs[i][j - 1], xs[i][j]);
    for(int j = 1; j < ys[i].size(); j++) tree.unite(ys[i][j - 1], ys[i][j]);
  }

  int cnt = 0;
  for(int i = 0; i < N; i++) cnt += tree.find(i) == i;
  int ret = N - cnt;
  if(cnt > 1) ret += cnt * 2 - 1 - ei;
  printf("%d\n", ret);
}

Measured memory_bytes: 9952
#include<stdio.h>
int main(){
int K,N,i,j,x,y,z;
int a[51];
scanf("%d %d",&N,&K);
for(i=0;i<N;i++){
scanf("%d",&a[i]);
}
z=0;
for(i=0;i<K;i++){
x=0;
y=0;
for(j=0;j<N;j++){
if(x<a[j]){
x=a[j];
y=j;
}
}
z+=x;
a[y]=0;
}
printf("%d\n",z);
return 0;
}

Measured memory_bytes: 128
inpl = lambda: list(map(int,input().split()))
R,G,B,N = inpl()
# (R,G,B) = sorted([R,G,B])
ans = 0
for b in range(N//B+1):
    N1 = N - b*B
    for g in range(N1//G+1):
        N2 = N1 - g*G
        if N2 % R == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3060
using System;

class Program
{
    static void Main(string[] args)
    {
        var a = long.Parse(Console.ReadLine());
        var b = Console.ReadLine().Split(" ");
        var times = 1000 / a + 1;
        for (var i = 1;  times >= i; i++)
        {
            if (int.Parse(b[0]) <= a * i && a * i <= int.Parse(b[1]))
            {
                Console.WriteLine("OK");
                break;
            }
            if (i == times)
            {
                Console.WriteLine("NG");
                break;
            }
        }
    }
}

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

template <typename T>
void print(const T &v);

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    for (int i = 0; i < m; i++)
    {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    // dp
    vector<vector<int>> dp(m, vector<int>(n + 1, 0));
    for (int i = 0; i <= n; i++)
    {
        dp[0][i] = i;
    }
    for (int i = 1; i < m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            // cout << i << ':' << j << endl;
            if (j - c[i] < 0)
            {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            dp[i][j] = min(dp[i][j - c[i]] + 1, dp[i - 1][j]);
        }
    }
    // for (auto l : dp)
    // {
    //     print(l);
    // }
    cout << dp[m - 1][n] << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 7036
#include<bits/stdc++.h>
using namespace std;
int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}


int main() {
    int q, M, i;
    scanf("%d", &n);
    for (i = 0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i<q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXN 200000
#define MAXLG 63

int N, nxt[MAXN + 3][MAXLG + 3];
LL K;

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
        cin >> nxt[i][0];

    for (int lg = 1; lg <= MAXLG; lg++) {
        for (int i = 1; i <= N; i++) {
            nxt[i][lg] = nxt[nxt[i][lg - 1]][lg - 1];
        }
    }

    int current = 1;
    for (int lg = 0; lg <= MAXLG; lg++) {
        if (K & (1LL << lg))
            current = nxt[current][lg];
    }

    cout << current << endl;
}


Measured memory_bytes: 55196
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fscanf(szpFpI, "%d", &si1Array[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 最大 - 取得
	int liMax = 0;
	int liLen = 0;
	for (i = 0; i < siACnt - 1; i++) {
		if (si1Array[i + 1] <= si1Array[i]) {
			liLen++;
			if (liMax < liLen) {
				liMax = liLen;
			}
		}
		else {
			liLen = 0;
		}
	}

	return liMax;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

namespace TYC
{
	typedef long long ll;
	typedef pair<int, int> pii;

	const int N = 2e5 + 5, INF = 0x3f3f3f3f;

	int n;
	struct node { int x, y; } A[N];
	bool operator < (const node &a, const node &b) { return a.x < b.x; }

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	void work()
	{
		n = read();
		int mnx = INF, mny = INF;
		int mxx = -INF, mxy = -INF;
		for (int i = 1; i <= n; i++)
		{
			scanf("%d%d", &A[i].x, &A[i].y);
			if (A[i].x > A[i].y)
				swap(A[i].x, A[i].y);
			mnx = min(mnx, A[i].x);
			mxx = max(mxx, A[i].x);
			mny = min(mny, A[i].y);
			mxy = max(mxy, A[i].y);
		}
		ll ans = (ll)(mxx - mnx) * (mxy - mny);
		sort(A + 1, A + 1 + n);
		int t = mxy - mnx;
		mny = INF, mxy = -INF;
		for (int i = 1; i <= n; i++)
		{
			mny = min(mny, A[i].y);
			mxy = max(mxy, A[i].y);	
			ans = min(ans, (ll)t * (max(mxy, mxx) - min(mny, A[i + 1].x))); 
		}
		printf("%lld\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(5);
    cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
}


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

using namespace std;

int main(void){
	long long int ans = 0;
	char S[500010];
	cin >> S;
	int len = strlen(S);
	long int kucount = 0;
	long int hecount = 0;
	long int w = 0;
	long long int k = 0;
	int i;
	i = 0;
	while(i <len){
		k = 0;
		kucount = 0;
		hecount = 0;
		while(S[i] == '<'){
			kucount++;
			i++;
		}
		while(S[i] == '>'){
			hecount++;
			i++;
		}
		w = kucount;
		if(hecount == 0){
			k = 0;
		}
		else if(w >= hecount && hecount != 0){
			k = hecount*(hecount-1)/2;
		}
		else{
			k = hecount*(hecount+1)/2;
			k -= w;
		}
		ans += k;
		k = kucount*(kucount+1)/2;
		ans+=k;
	}
	cout << ans << endl;
	
	return 0;
}



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

int main(){
    int A, B;
    cin >> A >> B;
    if (A == B) cout << "Draw" << endl;
    else if (A == 1 && B != 1) cout << "Alice" << endl;
    else if (A != 1 && B == 1)cout << "Bob" << endl;
    else if (A > B) cout << "Alice" << endl;
    else if (A < B)cout << "Bob" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- ar.cpp --------------------------------- */
const int maxn = 1e5+5;
void solve(int tc)
{
    //  cout<<"Case #"<<tc<<": ";
    int n,i,j,w,k,m,q,l,r;
    cin>>n>>w;
    pii ar[n+1];
    repv(i,1,n)
        cin>>ar[i].F>>ar[i].S;
    int dp[n+1][w+1];
    memset(dp , 0 ,sizeof(dp));
    repv(i,0,n)
        dp[i][0] = 0 , dp[0][i] = 0;
    repv(i,1,n)
    {
        repv(j,0,w)
        {
            dp[i][j] = dp[i-1][j];
            if(j - ar[i].F>=0)
            {
                dp[i][j] = max(dp[i][j] , dp[i-1][j-ar[i].F] + ar[i].S);
            } 
        }
    }
    cout<<dp[n][w];
}       
signed main()
{
    // ar.cpp
    RAGE;
 //   db();    
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
//    timeit();
    return 0;
}


Measured memory_bytes: 82552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

ll n, k;
vector<ll> a, dp;

void dfs(ll v) {
    if (dp[v] != -1) return;
    bool f = false;
    rep(i, n) {
        ll nv = v - a[i];
        if (nv < 0) continue;
        dfs(nv);
        if (dp[nv] == 0) {
            f = true;
        }
    }
    dp[v] = f ? 1 : 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];
    dp.resize(k + 1, -1);
    dp[0] = 0;
    dfs(k);
    cout << ((dp[k] == 1) ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 10256
#include <iostream>
#include <complex>
#include <utility>

using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;

#define X real()
#define Y imag()

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

// 射影
Point project(Segment s, Point p){
    Vector base = s.second - s.first;
    double r = dot(p - s.first, base) / norm(base);
    return s.first + base * r;
}

Point reflect(Segment s, Point p){
    return p + (project(s, p) - p) * 2.0;
}

int main(){
    double x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2;
    Line li = {Point(x1, y1), Point(x2, y2)};

    int q; cin>>q;
    while(q--){
        double x, y; cin>>x>>y;
        Point ansp = reflect(li, Point(x, y));
        printf("%.10f %.10f\n", ansp.X, ansp.Y);
    }
}


Measured memory_bytes: 3280
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();
        int min = 300001;
        int w[] = new int[n];
        int e[] = new int[n];
        if(c[0]=='W'){
            w[0] = 1;
        }
        if(c[n-1]=='E'){
            e[n-1]=1;
        }

            for(int i =1; i<n; i++){
                if(c[i]=='W') {
                    w[i] += 1;
                }
                w[i] += w[i-1];
            }
            for(int i=n-2; i>=0; i--){
                if(c[i]=='E') {
                    e[i] += 1;
                }
                e[i] += e[i+1];
            }
            if(c[0]=='E'){
                e[0]++;
            }
            if(c[n-1]=='w'){
                w[n-1]++;
            }
            min = Math.min(w[n-1],e[0]);
            for(int i=1; i<n-1; i++){
                min = Math.min(w[i-1]+e[i+1],min);
            }
            System.out.println(min);
    }
}


Measured memory_bytes: 31292
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    ll n=in();
    ll ans=0;
    rep2(i,1,n){
       // cout<<i<<" "<<(1+n/i)*(n/i)/2<<" "<< i*i*(1+n/i)*(n/i)/2<<endl;
        ans += i*(1+n/i)*(n/i)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3684
#include <stdio.h>
int main()
{
int W, H, x, y, r;
scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

if ((r <= x)&& (x <= W - r)&&(r <= y) &&(y <= H - r))
printf("Yes\n");
else
printf("No\n");

return 0;
}

Measured memory_bytes: 2660
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
if(s=="ABC"):
    print("ARC")
else:
    print("ABC")



Measured memory_bytes: 9888
function Main(input) {
 input = input.split(" ");
 var A = parseInt(input[0], 10);
 var B = parseInt(input[1], 10);
 var result = (A,B) => {
  if ( A+B > A-B) {
		if (A+B > A*B) {
 			console.log(A+B);
    } else {
    	console.log(A*B);
    }
  } else {
  	  if (A-B > A*B) {
				console.log(A-B);
   	 } else {
				console.log(A*B);
     }
	}
 };
  result(A,B);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  ll n, d;
  cin >> n >> d;
  int a = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    a += x * x + y * y <= d * d;
  }
  cout << a << endl;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
long long gcd(long long a, long long b){
    if(b==0)
        return a;
    if(a==0)
        return b;
    return gcd(b, a%b);
}
int main() {
    long long a,b;
	cin>>a>>b;
    long long g = gcd(a,b);
    long long ans = (a*b)/g;
    cout<<ans <<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

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

	final long MOD = (long) (1e9 + 7);

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
		}
		long[] one = new long[62];
		for (int i = 0; i < N; ++i) {
			for (int shift = 0; shift < 62; ++shift) {
				if ((A[i] >> shift) % 2 == 1) {
					++one[shift];
				}
			}
		}
		long MOD = (long) (1e9 + 7);
		long ans = 0;
		for (int shift = 0; shift < one.length; shift++) {
			ans += (1L << shift) % MOD * one[shift] % MOD * (N - one[shift]) % MOD;
			ans %= MOD;
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 96896
let solve a_lst =
    let rec solve' lst min_a max_profit num_max =
        match lst with
        | [] -> num_max
        | x::xs ->
            let next_profit = x - min_a
            let next_mp, next_nm =
                if next_profit > max_profit then
                    (next_profit, 1)
                elif next_profit = max_profit then
                    (next_profit, num_max + 1)
                else (max_profit, num_max)
            let next_ma = min min_a x
            solve' xs next_ma next_mp next_nm
    
    let min_a = List.head a_lst
    let rest = List.tail a_lst
    solve' rest min_a 0 0

let () =
    let _ = stdin.ReadLine ()
    let a_lst = stdin.ReadLine () |>
                (fun str -> str.Split()) |>
                Array.map int |> List.ofArray
    solve a_lst |> printfn "%d"


Measured memory_bytes: 20428
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N;
    int sum = 0, ma = 0;
    REP(i, N) {
        cin >> L;
        sum += L;
        amax(ma, L);
    }
    if (ma < sum - ma) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    int a,b,h,m;
    double l,anga,angb,angc;
    scanf("%d %d %d %d",&a,&b,&h,&m);
    anga=2*M_PI*((60*h)+m)/(60*12);
    angb=2*M_PI*m/60;
    angc=abs(anga-angb);
    if(angc>M_PI) angc=2*M_PI-angc;
    l=a*a+b*b-(2*a*b*cos(angc));
    printf("%.9lf\n",sqrt(l));
    return 0;
}


Measured memory_bytes: 2592
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#include<numeric>
#include<cfenv>
#include<cmath>
#define MAX_N pow(10,6)
#define MAX_M pow(10,6)
#define INF pow(10,6)
#define REP(i,n) for(long long i=0;i<n;i++)
typedef long long ll;
using namespace std;
vector<ll>h(MAX_N);
vector<bool>seen(MAX_N);
vector<vector<ll>>miti(MAX_N,vector<ll>(2));
using Graph = vector<vector<int>>;
Graph G(MAX_N);
ll ans=0;

int main(){
    string a;
    cin>>a;
    if(a=="ABC"){
        cout<<"ARC";
    }else{
        cout<<"ABC";
    }
}


Measured memory_bytes: 89028
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main() {
  int N;
  cin >> N;
  while (N != 0) {
    string S;
    cin >> S;
    vector<int> mem(N);
    int field = 0;
    for (int i = 0, j = 0; i < 100; i++, j++) {
      if (j == N) j = 0;
      if (S[i] == 'M') {
        mem[j]++;
      } else if (S[i] == 'S') {
        field += mem[j] + 1;
        mem[j] = 0;
      } else if (S[i] == 'L') {
        mem[j] += field + 1;
        field = 0;    
      }
    }
    sort(mem.begin(), mem.end());
    for (int i = 0; i < N; i++) cout << mem[i] << " ";
    cout << field << endl;
    cin >> N;
  }
}



Measured memory_bytes: 3164
import sys

def get_gcd(x, y):
    if (x % y == 0) or (y % x == 0):
        return min(x, y)
    return get_gcd((max(x, y) % min(x, y)), min(x, y))

if __name__ == "__main__":
    array = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))
    print get_gcd(array[0], array[1])
    

Measured memory_bytes: 6428
let g n m = 2. *. (n -. m);;
let h a b c d = a *. a -. b *. b +. c *. c -. d *. d;;
let () =
  let n = read_int () in (* nを読み込む *)
  let rec loop = function
    | 0 -> () (* 正常終了 *)
    | i -> let (x1, y1, x2, y2, x3, y3) = Scanf.scanf "%f %f %f %f %f %f\n" (fun a b c d e f -> (a, b, c, d, e, f)) in
      let (a, b, c, d, e, f) =
        (g x1 x2, g y1 y2, g x1 x3, g y1 y3, h x1 x2 y1 y2, h x1 x3 y1 y3) in
      let j = a *. d -. b *. c in
      let (x, y) = ((e *. d -. b *. f) /. j, (a *. f -. e *. c) /. j) in
      let r = sqrt ((x -. x1) ** 2. +. (y -. y1) ** 2.) in
      Printf.printf "%.3f %.3f %.3f\n" x y r; loop (i-1)
  in loop n


Measured memory_bytes: 2364
def f(x, y):
    i = 1
    while i * x < y: i *= 2
    return 1 / i

n, k = map(int, input().split())
p = sum(f(i, k) for i in range(1, min(k, n + 1)))
print((max(0, n - k + 1) + p) / n)


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}


vector<vector<ui> > nCr_table(int N){
    vector<vector<ui>> dp(N+1);
    dp[0].push_back(1);
    for (int n=1;n<=N;++n){
        dp[n].resize(n+1,1);
        for (int r=1;r<n;++r) {
            dp[n][r] = (dp[n - 1][r] + dp[n - 1][r - 1]);
            if (dp[n][r]>=MOD) dp[n][r] -= MOD;
        }

    }
    return dp;
}

int main() {
    READ(0);
    int n,k;cin>>n>>k;
    int nn=n-k+1;
    auto ncr = nCr_table(max(k-1,nn));
    int i=1;
    for(;i<=min(k,n-k+1);++i) {
        cout << ((ll)ncr[k-1][k-i]*ncr[nn][nn-i])%MOD << '\n';
    }
    for(;i<=k;++i) cout << "0\n";
    return 0;
}



Measured memory_bytes: 8192
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
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 gcd_list(nums): return reduce(gcd, nums, nums[0])
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

L=[0]*N
L[0]=A[0]
for i in range(1, N):
    L[i]=gcd(L[i-1], A[i])
R=[0]*N
R[-1]=A[-1]
for i in range(N-2, -1, -1):
    R[i]=gcd(R[i+1], A[i])

ans=0
for i in range(N):
    if i==0:
        ans=max(ans, R[1])
    elif i==N-1:
        ans=max(ans, L[-2])
    else:
        ans=max(ans, gcd(L[i-1], R[i+1]))
print(ans)


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

int main(){
  int n;
  while(cin >> n,n){
    string str[n];
    for(int i=0; i<n; ++i){
      cin >> str[i];
    }
    bool state = false;
    int ans = 0;
    for(int i=0; i<n-1; ++i){
      if(!state){
        if(str[i] == "lu" && str[i+1] == "ru"){
          ++ans;
          state = true;
        }else if(str[i] == "ru" && str[i+1] == "lu"){
          ++ans;
          state = true;
        }
      }else if(state){
        if(str[i] == "ld" && str[i+1] == "rd"){
          ++ans;
          state = false;
        }else if(str[i] == "rd" && str[i+1] == "ld"){
          ++ans;
          state = false;
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3124
#include "iostream"
#include "math.h"
using namespace std;

int main()
{
	int h, w;
	char s[50][50];
	bool ans=true;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)cin >> s[i][j];
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				if (i==0&&j==0){
					if (s[i + 1][j] == '.'&&s[i][j + 1] == '.')ans = false;
				}
				else if(i==0&&j==w-1){
					if (s[i + 1][j] == '.'&&s[i][j - 1] == '.')ans = false;
				}
				else if(i==h-1&&j==0){
					if (s[i - 1][j] == '.'&&s[i][j + 1] == '.')ans = false;
				}
				else if(i==h-1&&j==w-1){
					if (s[i - 1][j] == '.'&&s[i][j - 1] == '.')ans = false;
				}
				else if(i==0){
					if (s[i][j - 1] == '.'&&s[i + 1][j] == '.'&&s[i][j + 1] == '.')ans = false;
				}
				else if(i==h-1){
					if (s[i - 1][j] == '.'&&s[i][j - 1] == '.'&&s[i][j + 1] == '.')ans = false;
				}
				else if(j==0){
					if (s[i - 1][j] == '.'&&s[i + 1][j] == '.'&&s[i][j + 1] == '.')ans = false;
				}
				else if(j==w-1){
					if (s[i - 1][j] == '.'&&s[i][j - 1] == '.'&&s[i + 1][j] == '.')ans = false;
				}
				else if (s[i - 1][j] == '.'&&s[i][j - 1] == '.'&&s[i + 1][j] == '.'&&s[i][j + 1] == '.')ans = false;
			}
		}
	}
	if (ans == true)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256