akhauriyash/Code-Regression huggingface dataset:
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #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 rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    string s; cin >> s;
    bool flag = true;
    rep(i,s.length()){
        if(i%2 && s[i] == 'R') flag = false;
        if(i%2==0 && s[i] == 'L') flag = false;
    }
    if(flag) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    
}


Measured memory_bytes: 3524
#include <iostream>

int main(int argc, const char * argv[]) {
    int n, m;
    std::cin >> n >> m;
    int a[n][m], b[m], c;
    for (int j = 0; j < n; j++) {
        for (int i = 0; i < m; i++) {
            std::cin >> a[j][i];
        }
    }
    for (int j = 0; j < m; j++) {
        std::cin >> b[j];
    }
    for (int j = 0; j < n; j++) {
        c = 0;
        for (int i = 0; i < m; i++) {
            c += a[j][i] * b[i];
        }
        std::cout << c << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3124
n, m = gets.split().map(&:to_i)
ab = []

n.times do |i|
  ab[i] = gets.split().map(&:to_i)
end

ab.sort_by! {|a| a[0]}

money = 0
number = 0

ab.each do |a, b|
  if number + b < m
    number += b
    money += a*b
  else
    money +=  a*(m - number)
    break
  end
end

puts money

Measured memory_bytes: 12664
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000001
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int count=0,L[250002],R[250002];
int main(){
  int n,i,S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  
  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    if(i)
      printf(" ");
    printf("%d",S[i]);
  }

  printf("\n");
  printf("%d\n",count);

  return 0;
}
void merge(int* S,int l,int m,int r){
  int n1,n2,i,j,k;
  n1=m-l;
  n2=r-m;

  for(i=0;i<n1;i++)
    L[i]=S[l+i];
  for(i=0;i<n2;i++)
    R[i]=S[m+i];
  L[n1]=N;
  R[n2]=N;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    count++;
    if(L[i]<=R[j]){
      S[k]=L[i];
      i+=1;
    }
    else {
     S[k]=R[j];
      j+=1;
    }
  }
}
void mergeSort(int* S,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergeSort(S,l,m);
    mergeSort(S,m,r);
    merge(S,l,m,r);
  }
}



Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 210;
//const int md = 1e9 + 7;

ld t[maxn];
ld v[maxn];
//ld dp[maxn][maxn];
ld h[maxn];

int main() {
	IOS;;
	int n; cin>>n;
	for (int i = 1; i <= n; i++) cin>>t[i];
	for (int i = 1; i <= n; i++) cin>>v[i];
	
	v[n+1] = 0; h[n+1] = 0;
	for (int i = n; i >= 1; i--) {
		h[i] = min(h[i+1] + t[i], v[i]);
	}
				
	ld cur = 0; h[1] = 0; ld ans = 0;
	for (int i = 1; i <= n; i++) {
		ld mz = min(h[i+1], min(v[i], cur + t[i]));
		ld z = mz - cur + t[i];
		ld T = z / 2;
		if (z < 0) {
			ans += 0.5 * ((mz + cur) * t[i]); continue;
		}
		
		//cout<<i<<" : "<<T<<" : "<<cur<<" :: "<<mz<<endl;

		ld t1 = min(T, v[i] - cur);
		ld t2 = min(t[i] - T, v[i] - mz);
		
		ans += cur * t1 + 0.5 * t1 * t1;
		ans += mz * t2 + 0.5 * t2 * t2;

		ans += (t[i] - t1 - t2) * v[i];

		cur = mz;
	}

	cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){

int num = 0;
int *data;
int i;
int k;
int count = 0;
int finalans = 0;

while(1){
  scanf("%d",&num);
  if(1 <= num && num <=10000){
    break;
  }
}

data = (int *)malloc(sizeof(int)*num);

for(i = 0;i < num;i++){
  scanf("%d",&data[i]);
if(data[i] > 2 && data[i] % 2 == 0){
  continue;
}
  for(k = 1;k <= sqrt(data[i]);k++){
   if(data[i] % k == 0){
    count++;
   }
}
if(count == 1){
  finalans++;
}
count = 0;
}

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



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

using namespace std;

typedef long long ll;

ll s, w;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> s >> w;
    if (s > w) cout << "safe";
    else cout << "unsafe";
}

Measured memory_bytes: 3652
from collections import deque
INF = 10 ** 9

class Edge:
	def __init__(self, t, w):
		self.t = t
		self.w = w

def around(i, j, H, W):
	if H == 1:
		if j == 0:
			ans = [(i, j+1)]
		elif j == W - 1:
			ans = [(i, j-1)]
		else:
			ans = [(i, j-1), (i, j+1)]
	elif W == 1:
		if i == 0:
			ans = [(i+1, j)]
		elif i == H - 1:
			ans = [(i-1, j)]
		else:
			ans = [(i-1, j), (i+1, j)]
	else:
		if i == 0:
			if j == 0:
				ans = [(i, j+1), (i+1, j)]
			elif j == W-1:
				ans = [(i, j-1), (i+1, j)]
			else:
				ans = [(i, j-1), (i, j+1), (i+1, j)]
		elif i == H - 1:
			if j == 0:
				ans = [(i-1, j), (i, j+1)]
			elif j == W-1:
				ans = [(i-1, j), (i, j-1)]
			else:
				ans = [(i-1, j), (i, j-1), (i, j+1)]
		else:
			if j == 0:
				ans = [(i-1, j), (i, j+1), (i+1, j)]
			elif j == W-1:
				ans = [(i-1, j), (i, j-1), (i+1, j)]
			else:
				ans = [(i-1, j), (i, j-1), (i, j+1), (i+1, j)]
	return ans

def bfs(s):
	d = [INF for _ in range(H*W)]
	Q = deque()
	Q.append(s)
	d[s] = 0
	while len(Q) > 0:
		u = Q.popleft()
		for e in G[u]:
			if d[e.t] == INF:
				d[e.t] = d[u] + e.w
				Q.append(e.t)
	return d

def solve(s):
	d = bfs(s)
	maxv = 0
	tgt = 0
	for i in range(W*H):
		if d[i] == INF:
			continue
		if maxv < d[i]:
			maxv = d[i]
			tgt = i
	d = bfs(tgt)
	maxv = 0
	for i in range(W*H):
		if d[i] == INF:
			continue
		maxv = max(maxv, d[i])
	return maxv

if __name__ == "__main__":
	H, W = map(int, input().split())
	S = [[0 for j in range(W)] for i in range(H)]
	# print(S)
	for i in range(H):
		s = input()
		for j in range(W):
			if s[j] == "#":
				S[i][j] = 1
	# print(S)
	G = [[] for _ in range(H*W)]
	for i in range(H):
		for j in range(W):
			if S[i][j] != 1:
				for (k, l) in around(i, j, H, W):
					if S[k][l] != 1:
						G[i*W + j].append(Edge(k*W + l, 1))
						G[k*W + l].append(Edge(i*W + j, 1))

	ans = 0
	for i in range(H):
		for j in range(W):
			if S[i][j] != 1:
				v = solve(i*W + j)
				ans = max(ans, v)
	print(ans)

Measured memory_bytes: 3880
n=input()
a=[int(i) for i in input().split()]
m=input()
m=int(m)
for i in range(m):
  x=[i for i in a]
  t,p=input().split()
  t=int(t)
  p=int(p)
  x[t-1]=p
  print(sum(x))

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

int main(){
    ll X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    vector<pair<ll,ll>> Apple(A+B+C);
    for(ll i=0;i<A+B+C;i++){
        cin>>Apple.at(i).first;
        Apple.at(i).second=i;
    }
    sort(Apple.begin(),Apple.end());
    reverse(Apple.begin(),Apple.end());
    ll ans= 0;
    ll tmp=0;
    ll cnt=0;
    while(X+Y>tmp){
        //cout<<Apple.at(cnt).first<<" "<<Apple.at(cnt).second<<" "<<X<<Y<<tmp<<endl;
        if(X>0 && Y>0){
            ans+=Apple.at(cnt).first;
            if(Apple.at(cnt).second<A){
                X-=1;
            }
            else if(Apple.at(cnt).second<A+B){
                Y-=1;
            }
            else{
                tmp++;
            }
            cnt++;
        }
        else if(Y>0){
            if(Apple.at(cnt).second<A){
                cnt++;
            }
            else{
                ans+=Apple.at(cnt).first;
                if(Apple.at(cnt).second<B){
                    Y-=1;
                }
                else{
                    tmp++;
                }
                cnt++;
            }
        }
        else{
            if(Apple.at(cnt).second>=A && Apple.at(cnt).second<A+B){
                cnt++;
            }
            else{
                ans+=Apple.at(cnt).first;
                if(Apple.at(cnt).second<A){
                    X-=1;
                }
                else{
                    tmp++;
                }
                cnt++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

ll N, K;

int main() {
    cin >> N >> K;
    vector<pair<ll, ll>> vp;
    rep(i, N) {
        ll a, b; cin >> a >> b;
        vp.emplace_back(make_pair(a, b));
    }

    sort(vp.begin(), vp.end());
    ll accum = 0;
    rep(i, N) {
        accum += vp[i].second;
        if (accum >= K) {
            cout << vp[i].first << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A){
  vector<ll> AA=A;
  sort(AA.begin(),AA.end());
  REP(N){
    if(A[i]==AA.back()){
      cout<<AA[N-2]<<endl;
    }else{
      cout<<AA[N-1]<<endl;
    }
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4736
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out, false);
        int n= scanner.nextInt();
        vals = new double[n][2];
        for(int i = 0; i < n; i++) {
            vals[i][0] = scanner.nextInt();
            vals[i][1] = scanner.nextInt();
        }
        order= new int[n];
        used = new boolean[n];
        for(int i = 2; i <= n; i++) {
            fact *= i;
        }
        bt(0);
        out.println(average);
        out.flush();
    }
    static int[] order;
    static boolean[] used;
    static double[][] vals;
    static double average = 0;
    static int fact = 1;
    static void bt(int ind) {
        if (ind == order.length) {
            double val = 0;
            for(int i = 0; i < ind -1; i++) {
                val += dist(order[i], order[i+1]);
            }
            average += val/fact;
        }
        for(int i = 0; i < order.length; i++) {
            if (used[i]) continue;
            used[i] = true;
            order[ind] = i;
            bt(ind + 1);
            used[i] = false;
        }
    }
    static double dist(int a,int b) {
        double dx = vals[a][0] - vals[b][0];
        double dy = vals[a][1] - vals[b][1];
        return Math.sqrt(dx * dx + dy * dy);
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

void solve(long long N, std::vector<long long> a)
{
    map<int, int> freq;
    map<int, int>::iterator it;
    for (int i = 0; i < N; i++)
    {
        int temp = a.at(i);
        it = freq.find(temp);
        if (it != freq.end())
        {
            it->second += 1;
        }
        else
        {
            freq.insert(pair<int,int>(temp,1));
        }

        it = freq.find(temp - 1);
        if (it != freq.end())
        {
            it->second += 1;
        }
        else
        {
            freq.insert(pair<int,int>(temp-1,1));
        }

        it = freq.find(temp + 1);
        if (it != freq.end())
        {
            it->second += 1;
        }
        else
        {
            freq.insert(pair<int,int>(temp+1,1));
        }
    }
    int ans = 0;
    for(auto x: freq){
        ans = max(ans,x.second);
    }

    cout << ans << endl;


}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 5504
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, r;
  cin >> n >> r;
  int ret = r;
  if (n < 10) ret += 100 * (10 - n);
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;


int main(int argc, char const *argv[]) {
    int dist[100010];
    REP(i,100010) dist[i] = INF;
    int n;
    cin >> n;
    queue<int> q;
    vector<ll> a;
    a.push_back(1);
    for (int i = 6; i <= n; i*=6) a.push_back(i);
    for (int i = 9; i <= n; i*=9) a.push_back(i);
    sort(a.begin(), a.end(), greater<int>());
    q.push(0);
    dist[0] = 0;

    while(!q.empty()){
        int v = q.front();
        q.pop();
        for (auto x : a) {
            if (v+x > n) continue;
            if(dist[v+x] == INF) {
                dist[v+x] = dist[v]+1;
                q.push(v+x);
            }
        }
    }
    cout << dist[n] << std::endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;
typedef long long ll;

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

    int l=s.length();

    if(s[l-1]=='s'){
        cout<<s+"es"<<endl;
    }
    else{
        cout<<s+"s"<<endl;
    }



return 0;
}


Measured memory_bytes: 3628
import java.util.*;
import java.io.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();   
        int x = sc.nextInt();   
        
        if (k * 500 >= x) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc103/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v(M);// <終点, 始点>のpair
    rep(i, M){
        pair<int, int> p;
        cin >> p.second;
        cin >> p.first;
        v[i] = p;
    }
    sort(v.begin(), v.end());

    int ans = 0;
    int island = -1;//島islandまではいけてる
    rep(i, M){
        if(island > v[i].second) continue;
        island = v[i] .first;
        ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main(){
    ll N;
    cin >> N;
    VL A(N);
    FOR(i, 0, N) cin >> A[i];

    ll S = A.size();
    sort(ALL(A));
    A.erase(unique(ALL(A)), A.end());

    cout << (S == A.size() ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
bool flag[50000];

int main() {
    int N; cin >> N;
    uint A[N];
    for (int i = 0; i < N; i++) cin >> A[i]; 
    for (int bit = 0; bit < (1 << N); bit++) {
        int sum = 0;
        for (int i = 0; i < N; i++) {
            if ((bit >> i) & 1) {
                sum += A[i];
            }
        }
        flag[sum] = true;
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int m; cin >> m;
        if (flag[m]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3112
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
 */

var re = /\s+|$/;
var kinds=['S','H','C','D'];
var seq=[...Array(14).keys()];
    seq.shift()

reader.on('close', () => {
    var n = Number(lines.shift());
    var cards={};
    for (var i of kinds) {
	cards[i]=[];
    }

    var k, r;
    for (var l of lines) {
	[k, r] = l.trim().split(re);
	cards[k].push(Number(r));
    }

//    for (var i of kinds) {
//	console.log('kind: ',i,'cards: ', cards[i]);
//    }
    
    var result = aux(cards);
/*
    for (var i of kinds) {
	console.log('kind: ',i,'result: ', result[i].map(String).join(' '));
    }
*/

    for (var i of kinds) {
	var sa = result[i].sort((a,b)=>a-b).map(String);
	for (var j  of sa) {
	    console.log(i, j);
	}
    }

});

function aux(cards)
{
    var result={};
    for (var i of kinds) {
	result[i] = [];
    }

    for (var i of kinds) {
	for (var j of seq) {
	    if (cards[i].indexOf(j) == -1){
		result[i].push(j);
	    }
	}}

    return(result);
}


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

n=int(input())
s=[input().strip("\n") for _ in range(n)]
p=[];m=[]
for si in s:
    cnt=0;a=0;b=0
    for i in range(len(si)):
        if si[i]==")":
            cnt+=1
        else:
            cnt-=1
        a=max(a,cnt)
    cnt=0
    for i in range(len(si)-1,-1,-1):
        if si[i]=="(":
            cnt+=1
        else:
            cnt-=1
        b=max(b,cnt)
    if b-a>=0:
        p.append((a,si))
    else:
        m.append((-b,si))
p.sort();m.sort()
ss=""

for _,si in p:
    ss+=si
for _,si in m:
    ss+=si
cnt=0
for i in range(len(ss)):
    if ss[i]=="(":
        cnt+=1
    else:
        cnt-=1
    if cnt<0:
        print("No")
        exit()
if cnt:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 89044
a, b, c, d = gets.chomp.split(" ").map(&:to_i)
result = 0
c_result = ((b / c) - ((a - 1) / c))
d_result = ((b / d) - ((a - 1) / d))
c_d = c.lcm(d)
c_d_result = ((b / c_d) - ((a - 1) / c_d))
result = c_result + d_result - c_d_result

puts ((b - a + 1) - result)

Measured memory_bytes: 3836
#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 main(){
    vector<int> v(4),v2(4);
    for(int i=0;i<4;i++){
        cin>>v[i];
    }
    for(int i=0;i<4;i++){
        if(v[i]==1){
            v2[0]++;
        }else if(v[i]==9){
            v2[1]++;
        }else if(v[i]==7){
            v2[2]++;
        }else if(v[i]==4){
            v2[3]++;
        }
    }
    int cnt=0;
    for(int i=0;i<4;i++){
        if(v2[i]==1){
            cnt++;
        }
    }
    if(cnt==4){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%10==3 || i%3==0 || (i/10)%10==3 || (i/100)%10==3 || (i/1000)%10 ==3){
            cout << " " <<i;
        }
    }
    cout << endl;
    return 0;
}




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

int getColor(int rate){
    if(rate >= 1 && rate <= 399){
        return 0;
    }else if(rate >= 400 && rate <= 799){
        return 1;
    }else if(rate >= 800 && rate <= 1199){
        return 2;
    }else if(rate >= 1200 && rate <= 1599){
        return 3;
    }else if(rate >= 1600 && rate <= 1999){
        return 4;
    }else if (rate >= 2000 && rate <= 2399){
        return 5;
    }else if(rate >= 2400 && rate <= 2799){
        return 6;
    }else if(rate >= 2800 && rate <= 3199){
        return 7;
    }else{
        return 8;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> people(9,0);

    for (auto i = 0; i < n; i++)
    {
        int a_i;
        cin >> a_i;
        a[i] = a_i;
    }

    for (auto i = 0; i < n; i++)
    {
        people[getColor(a[i])] += 1;
    }

    int num = 0;
    for (auto i = 0; i < 8; i++)
    {
        if(people[i] > 0){
            num += 1;
        }
    }

    int min, max;
    if(num == 0){
        min = 1;
        max = people[8];
    }else{
        min = num;
        max = num + people[8];
    }

    cout << min << " " << max << endl;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	map<int,int> mp;
	vi wa;

	rep(i,1001){
		rep(j,1001){
			if(mp[i+j]==0)wa.pb(i+j);
			mp[i+j]++;
		}
	}



	int n;
	while(cin>>n){
		int len=wa.size();
		int sum=0;
		rep(i,len){
			if(wa[i]>n)break;
			sum+=mp[wa[i]]*mp[n-wa[i]];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if((a*b)%2) cout << "Odd" << endl;
  else cout << "Even" << endl;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
L = LI()

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        c = bisect.bisect_left(L, L[i]+L[j])

        ans += max(0, c - (j+1))

print(ans)


Measured memory_bytes: 45212
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll K,A,B;
        cin>>K>>A>>B;
        if(B<A) swap(A,B);
        if(K*(ceil((double)A/(double)K))>B) cout<<"NG";
        else cout<<"OK";










    }



    return 0;
}

Measured memory_bytes: 3652
#![allow(unused)]

use std::io::{Read, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

pub fn read_bytes<T: FromIterator<char>>(s: &mut StdinLock) -> T {
    s.bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<T>()
}

pub fn reads(s: &mut StdinLock) -> String {
    read_bytes::<String>(s)
}

pub fn read<T: FromStr>(s: &mut StdinLock) -> T {
    reads(s).parse().ok().unwrap()
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut sin = sin.lock();

    let n: usize = read(&mut sin);
    let s: Vec<char> = read_bytes(&mut sin);

    let s: Vec<usize> = s.into_iter()
        .map(|c| {
            match c {
                'R' => 0,
                'G' => 1,
                'B' => 2,
                _ => panic!("Unreachable"),
            }
        })
        .collect();

    let mut counts: Vec<Vec<i64>> = vec![vec![0; 3]; n];
    for i in (0..n).rev() {
        if i < n - 1 {
            counts[i] = counts[i + 1].clone();
        }
        counts[i][s[i]] += 1;
    }
  
    // dp[i][c]: s[i..n] の範囲で色 c 抜きで作れる組合せ
    let mut dp: Vec<Vec<i64>> = vec![vec![0; 3]; n];

    for i in (0..(n - 1)).rev() {
        for c in 0..=2 {
            dp[i][c] = if s[i] == c {
                dp[i + 1][c]
            } else {
                let cunused = 3 - s[i] - c;
                dp[i + 1][c] + counts[i + 1][cunused]
            };
        }
    }

    let mut ans: i64 = 0;

    for i in 0..(n - 2) {
        let mut cnt = dp[i + 1][s[i]];
        for j in (i + 1)..(n - 1) {
            if j * 2 - i >= n {
                break;
            }
            if s[j] != s[i] {
                let kc = s[j + (j - i)];
                if kc != s[i] && kc != s[j] {
                    cnt -= 1;
                }
            }
        }
        ans += cnt;
    }

    println!("{}", ans);
}

Measured memory_bytes: 2592
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
    int N;
    cin >> N;
    int p[10000];
    for (int i = 0; i < N; i++){
        cin >> p[i]; 
    }
    sort(p, p + N, greater<int>());
    p[0] = p[0]/2;

    int num = 0;
    for (int i = 0; i < N; i++){
        num += p[i];
    }

    cout << num << endl;

}

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

using namespace std;

int main(){
    int K;
    cin >> K;
    vector <int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a.at(K-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long lli;
void constructXOR(lli A[], lli n)
{
	lli XOR = 0;
	for (lli i = 0; i < n; i++)
		XOR ^= A[i];

	for (lli i = 0; i < n; i++)
		A[i] = XOR ^ A[i];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	lli n;
	lli ara[200007];
	cin >> n;
	for(lli i=0; i<n; i++) cin >> ara[i];
	constructXOR(ara, n);

	for (lli i = 0; i < n; i++){
		if(i!=(n-1)) cout << ara[i] << " ";
		else cout << ara[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5152
import bisect

q = int(input())
S = []

for i in range(q):
    query, *n = input().split()
    x = int(n[0])
    index_left = bisect.bisect_left(S, x)
    index_right = bisect.bisect_right(S, x)

    # insert
    if query[0] == "0":
        x = int(n[0])
        S.insert(index_left, x)
        print(len(S))

    # find
    elif query[0] == "1":
        x = int(n[0])
        print(index_right - index_left)

    # delete
    elif query[0] == "2":
        x = int(n[0])
        S[index_left:index_right] = []

    # dump
    else:
        L = int(n[0])
        R = int(n[1])
        
        index_left = bisect.bisect_left(S, L)
        index_right = bisect.bisect_right(S, R)

        [print(i) for i in S[index_left:index_right]]



Measured memory_bytes: 15652
from collections import defaultdict as dd

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
# a1 x a2 x .. x aN = M となる数列{ai}が何通りあるか
# まずは素因数分解
def make_prime_dict(x):
    primes = dd(int)
    check = 2
    while True:
        if x % check == 0:
            primes[check] += 1
            x = x // check
        else:
            check += 1
            if check > x:
                break
    return dict(primes)

primes = make_prime_dict(M)
if len(primes) == 0:
    print(1)
    exit()
Q = max(primes.values())
fact = [1]
fact_inv = [1]
for i in range(Q+N):
    new_fact = fact[-1] * (i+1) % MOD
    fact.append(new_fact)
    fact_inv.append(pow(new_fact, MOD - 2, MOD))

def mod_comb(n, r, mod):
    return fact[n] * fact_inv[n - r] % mod * fact_inv[r] % mod

res = 1
for q in primes.values():
    res *= mod_comb(q + N - 1, q, MOD)
    res %= MOD

print(res)

Measured memory_bytes: 51440
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

long long A, B, C, D, E, F;
long long ans_water = 0, ans_sugar = 0;
double max_percentage = -1;
int memo[3001][3001];

void DFS(long long water, long long sugar) {
    //F以下でないとダメ
    if (water + sugar > F)
        return;

    //溶け残ったらダメ
    if (water / 100 * E < sugar)
        return;

    //訪問フラグ
    if (memo[water][sugar] != 0) {
        return;
    }

    //printf("water = %lld, sugar = %lld\n", water, sugar);
    //作った砂糖水の濃度
    if (water != 0) {
        double tmp = 100.0 * sugar / (100.0 * water + sugar);

        if (tmp > max_percentage) {
            max_percentage = tmp;
            ans_water = water;
            ans_sugar = sugar;
        }
    }
    memo[water][sugar] = 1;

    //操作1
    DFS(water + 100 * A, sugar);
    //操作2
    DFS(water + 100 * B, sugar);
    //操作3
    DFS(water, sugar + C);
    //操作4
    DFS(water, sugar + D);
}

int main()
{
    cin >> A >> B >> C >> D >> E >> F;

    DFS(0, 0);

    if (ans_water != 0)
        cout << ans_water + ans_sugar << " " << ans_sugar << endl;
    else 
        cout << 0 << " " << 0 << endl;
}


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

int main(){
   
    while(true){
        int H,W;
        cin>>H>>W;
      if(H==0 && H==W){
            break;
        }
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    
}


Measured memory_bytes: 3128
#include<stdio.h>
#define N 100

typedef struct{
  int  data[N+1];
}Node;

Node a[N+1];

int main()
{
  int i,j,n,k=0,min = 0,keiro=0,kakuno[N+1] = {0},num=1,hantei[N+1] = {0};

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      scanf("%d",&a[i].data[j]);
  
  
  kakuno[0] = 1;
  hantei[1] = 1;
    while(num < n)
    {
      min = 2001;
      for(i = 0;i < num;i++)
	{
	  for(j = 1;j <= n;j++)
	    {
	      if(hantei[j] == 1 )
		  continue;
	      else if(a[kakuno[i]].data[j] != -1 && min > a[kakuno[i]].data[j])
		{
		  min = a[kakuno[i]].data[j];
		  kakuno[num] = j;
		}
	    }
	}
      keiro += min;
      hantei[kakuno[num]] = 1;
      num++;
    }
  
  printf("%d\n",keiro);
  return 0;
}



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

int main() {
    string s, t;
    cin >> s >> t;

    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) {
            ++cnt;
        }
    } 

    cout << cnt << '\n';
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int V, E; cin>>V>>E;
    ll dist[V][V];

    for(int i=0; i<V; i++){
        for(int j=0; j<V; j++){
            dist[i][j]=INF;
        }
    }

    for(int i=0; i<E; i++){
        int s, t, d; cin>>s>>t>>d;
        dist[s][t]=d;
    }

    ll dp[(1<<V)][V];
    for(int i=0; i<(1<<V); i++){
        for(int j=0; j<V; j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;

    for(int S=1; S<(1<<V); S++){
        for(int v=0; v<V; v++){
            for(int j=0; j<V; j++){
                if((1<<v) & S){
                    dp[S][v]=min(dp[S][v], dp[S-(1<<v)][j]+dist[j][v]);
                }
            }
        }
    }
    if(dp[(1<<V)-1][0] == INF) cout << -1 << endl;
    else cout << dp[(1<<V)-1][0] << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 092 B / Link: http://abc092.contest.atcoder.jp/tasks/abc092_b  ----- */


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

	LL N, D, X; cin >> N >> D >> X;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	LL ans = X;
	FOR(i, 0, N) {
		LL multi = (D-1)/( a[i]);

		ans += multi+1;
	}

	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
import sys
import bisect
readline = sys.stdin.readline
n = int(readline())
A = list(map(int,readline().split()))
memo1 = {}
memo2 = {}
A.sort()
memo1[A[0]+A[1]] =1
memo2[A[0]] =1
if A[1] in memo2:
    memo2[A[1]] +=1
else:
    memo2[A[1]] =1
ans = 0
for c in A[2:]:
    for l,amount in memo1.items():
        if c<l:
            ans +=amount
    for a,amount in memo2.items():
        ac = a+c
        if ac in memo1:
            memo1[ac] += memo2[a]
        else:
            memo1[ac] = memo2[a]
    if c in memo2:
        memo2[c] +=1
    else:
        memo2[c] =1

print(ans)

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

int main() {
  int n;cin>>n;
  vector<int> v(n);
  vector<int> p(n);
  REP(i,n){
    int val;cin>>val;
    v[i]=val;
  }
  int sum=0;
  REP(i,n){
    int cost;cin>>cost;
    int pro=v[i]-cost;
    if(pro>0)sum+=pro;
  }
  cout << sum << endl;
}

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

int bel[N],a[N],b[N],n;
bool G[N][N],vis[N];
map<int,int> M;

bool isprime(int n) {
	if(n==1) return 0;
	for(int i=2;i*i<=n;i++)
		if(n%i==0) return 0;
	return 1;
}

bool find(int i) {
	for(int j=1;j<=n;j++)
		if(!vis[j]&&G[i][j]) {
			vis[j]=1;
			if(!bel[j]||find(bel[j])) { bel[j]=i;return 1; }
		}
	return 0;
}

int main() {
	cin>>n;
	for(int i=1,x;i<=n;i++) cin>>x,M[x]^=1,M[x+1]^=1;
	for(auto x:M)
		if(x.second) (x.first&1?a[++*a]:b[++*b])=x.first;
	int ans=0;
	for(int i=1;i<=*a;i++)
		for(int j=1;j<=*b;j++)
			if(isprime(abs(a[i]-b[j]))) G[i][j]=1;
	for(int i=1;i<=*a;i++) {
		memset(vis,0,sizeof(vis));
		ans+=find(i);
	}
	cout<<ans+(*a-ans)/2*2+(*b-ans)/2*2+(*a-ans)%2*3;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n;
int main()
{
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j<=9; j++) {
            if (i*j == n) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;
vector<string> v;

int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      string s;
      cin >> s;
      sort(s.begin(), s.end());
      v.pb(s);
   }

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

   int cnt = 0;

   for (int i = 0; i < n; )
   {
      int j = i;
      while(j < n and v[i] == v[j]){
         ++j;
      }
      int tot = j-i;
      cnt += ((tot) * (tot-1)) / 2; 
      i = j;
      tr(i, j);
   }

   cout<<cnt;

   

   return 0;
}

Measured memory_bytes: 5748
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int dd[]={1,0,-1,0,1};

VV(char) vv;
vvint vis;
vvint tmp;
int h,w;
bool foo2(int a,int b){
	// cout<<a<<" "<<b<<endl;
	if(vv[a][b]==' ') return true;
	if(vis[a][b]) return false;
	if(tmp[a][b]==-1) return false;
	if(vv[a][b]=='#'&&tmp[a][b]==0){
		// vis[a][b]=1;
		tmp[a][b]=-1;
		return false;
	}
	// if(vv[a][b]=='#') return false;
	vis[a][b]=1;
	bool ret=false;
	rep(i,4){
		ret|=foo2(a+dd[i],b+dd[i+1]);
	}
	return ret;
}
void foo3(int a,int b){
	if(vv[a][b]!='#') return;
	tmp[a][b]=-1;
	rep(i,4){
		if(tmp[a+dd[i]][b+dd[i+1]]==-1) continue;
		foo3(a+dd[i],b+dd[i+1]);
	}
}
int foo(int c){
	// cout<<a<<" "<<b<<" "<<c<<endl;
	// rep(i,h+2){
		// rep(j,w+2){
			// cout<<tmp[i][j];
		// }
		// cout<<endl;
	// }
	// cout<<endl;
	// int a;
	// cin>>a;
	rep(i,h+2){
		rep(j,w+2){
			if(tmp[i][j]==1){
				// cout<<"aaa "<<endl;
				if(foo2(i,j)) return c;
			}
		}
	}
	rep(i,h+2){
		rep(j,w+2){
			if(tmp[i][j]==1){
				tmp[i][j]=2;
			}
		}
	}
	rep(i,h+2){
		rep(j,w+2){
			if(tmp[i][j]==-1){
				foo3(i,j);
			}
		}
	}
	rep(i,h+2){
		rep(j,w+2){
			if(tmp[i][j]==-1){
				tmp[i][j]=1;
			}
		}
	}
	return foo(c+1);
}

void mainmain(){
	// int w,h;
	while(cin>>w>>h,w||h){
		initvv(vv,h+2,w+2,' ');
		initvv(vis,h+2,w+2,0);
		initvv(tmp,h+2,w+2,0);
		reep(i,1,h+1){
			string s;
			cin>>s;
			reep(j,1,w+1){
				vv[i][j]=s[j-1];
				if(vv[i][j]=='&'){
					tmp[i][j]=1;
				}
			}
		}
		// rep(i,h+2){
			// rep(j,w+2){
				// cout<<vv[i][j];
			// }
			// cout<<endl;
		// }
		cout<<foo(0)<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1572
/*?????????????????¨??????????????????????????§?????????????????????????¨?????????????*/
/*
????§£??????
????????????????????????????¨??????????????????????????????????
?????????????????????????????????????????????????????????????????§??????????????¨??£????????????????????£??????????¨?????¶?????????????
*/
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int n;
    int product,sum1,sum2=0,ans; //?????????????????????????????????????????????(??\???)
    char c;

    cin>>product;
    sum1=product;
    while(1){
        c=getchar();

        //?????????????????§?????????????????????????¶????
        if(c=='\n'){
            sum2+=product;
            break;
        }

        cin>>n;

        switch(c){
        case '+':
            sum1+=n;
            sum2+=product;
            product=n;
            break;
        case '*':
            sum1*=n;
            product*=n;
            break;
        }
    }
    cin>>ans;

    /*??\????????°????????????????????¨???????????????U?????????????????????????????????L????????????????????????????????????M???????????????????????????I?????????*/
    if(sum1==ans) c=(sum1==sum2 ? 'U' : 'L');
    else if(sum2==ans) c='M';
    else c='I';
    cout<<c<<endl;

    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int x;
    cin>>x;

    if(x>=30)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;

}

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

int main() {
    long long a,b,x;
    cin >> a >> b >>x;
    int st=a/x;
    if(a%x!=0){
        st++;
    }
    long long ans=0;

    for(long long i=st;i<b/x+1;i++){
        ans++;

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,C=map(int,input().split())
D=[[int(x) for x in input().split()] for _ in range(N)]

X,V,M=[0]*(N+1),[0]*(N+1),[0]*(N+1)
for i in range(1,N+1):
  X[i],V[i]=D[i-1][0],V[i-1]+D[i-1][1]
  M[i]=M[i-1] if M[i-1]>V[i]-D[i-1][0] else V[i]-D[i-1][0]

m=0
for i in range(1,N+1):
  e=M[i-1]-(C-X[i]) if M[i-1]>C-X[i] else 0
  e+=V[N]-V[i-1]-(C-X[i])
  m=m if m>e else e

M=[0]*(N+2)
for i in range(N,0,-1):
  p=V[N]-V[i-1]-(C-X[i])
  M[i]=M[i+1] if M[i+1]>p else p

for i in range(1,N+1):
  e=M[i+1]-X[i] if M[i+1]>X[i] else 0
  e+=V[i]-X[i]
  m=m if m>e else e

print(m)


Measured memory_bytes: 31456
N = int(input())
a = list(map(int,input().split()))
count=0
while True:
    flag = False
    for i in range(N):
        if a[i] % 2==1:
            flag = True
    if flag:
        break
    for i in range(N):
        a[i]/=2

    count += 1

print(count)

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

int main() {
	long long unsigned a[1000] = { 0 }, ans = 1;

	int n; cin >> n;
	for (int i = 2, k = i; i <= n; k = ++i) {
		for (int j = 2; j <= k; j++) {
			while (k % j == 0) {
				a[j]++;
				k /= j;
			}
		}
	}
	for (int i = 2; i <= n; i++)ans = ans * (a[i] + 1) % ((int)1e9 + 7);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256