akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

bool test1(int *set);
bool test2(int *set);

int main(){
        string s;
        while(cin >> s){
                int original[9] = {0};
                for(int i = 0; i < 13; i++){
                        original[s.at(i)-'1']++;
                }
                string out("");
                for(int i = 0; i < 9; i++){
                        if(original[i] < 4){
                                int set[9];
                                for(int j = 0; j < 9; j++){
                                        set[j] = original[j];
                                }
                                set[i]++;
                                if(test1(set)){
                                        if(!out.empty()){
                                                out += " ";
                                        }
                                        out += (char)(i+'1');
                                }
                        }
                }
                if(out.empty()){
                        out = "0";
                }
                cout << out << endl;
        }
}

bool test1(int *set){
        bool flag = false;
        for(int i = 0; i < 9; i++){
                if(set[i] >= 2){
                        int _set[9];
                        for(int j = 0; j < 9; j++){
                                _set[j] = set[j];
                        }
                        _set[i] -= 2;
                        flag |= test2(_set);
                }
        }
        return flag;
}

bool test2(int *set){
        bool flag1 = false;
        for(int i = 0; i < 9; i++){
                flag1 |= set[i];
        }
        if(!flag1){
                return true;
        }else{
                bool flag2 = false;
                for(int i = 0; i < 9; i++){
                        if(set[i] >= 3){
                                int _set[9];
                                for(int j = 0; j < 9; j++){
                                        _set[j] = set[j];
                                }
                                _set[i] -= 3;
                                flag2 |= test2(_set);
                        }
                }
                if(flag2){
                        return true;
                }else{
                        for(int i = 0; i < 7; i++){
                                if(set[i]*set[i+1]*set[i+2]){
                                        int _set[9];
                                        for(int j = 0; j < 9; j++){
                                                _set[j] = set[j];
                                        }
                                        _set[i]--;
                                        _set[i+1]--;
                                        _set[i+2]--;
                                        return test2(_set);
                                }
                        }
                }
        }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	string n;
 	cin >> n;
 	if(n=="abc"||n=="acb"||n=="bac"||n=="bca"||n=="cba"||n=="cab"){
 		cout << "Yes" << endl;
 	}else{
 		cout << "No" << endl;
 	}
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1e5;
int len1,len2,q,f[N+10],g[N+10];
char s[N+10],t[N+10];
int main() {
    scanf("%s%s",s+1,t+1);
    len1=strlen(s+1);
    len2=strlen(t+1);
    for (int i=1;i<=len1;i++)
	f[i]=f[i-1]+((s[i]=='A')?1:2);
    for (int i=1;i<=len2;i++)
	g[i]=g[i-1]+((t[i]=='A')?1:2);
    scanf("%d",&q);
    while (q--) {
	int l1,r1,l2,r2;
	scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
	int now1=f[r1]-f[l1-1],now2=g[r2]-g[l2-1];
	if (now1%3==now2%3) printf("YES\n");
	else printf("NO\n");
    }
    return 0;
}


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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

int main(){
	char S[200100]; scanf("%s",S);
	int s[200100],N=strlen(S);
	rep(i,0,N) s[i] = S[N-1-i]-'0';
	int sum[N],mod[2019];
	rep(i,0,2019) mod[i]=0;
	mod[0]++;
	sum[0]=s[0]; mod[sum[0]]++;
	int pow10=1;
	rep(i,1,N){
		pow10 = (pow10*10)%2019;
		sum[i] = (sum[i-1]+pow10*s[i])%2019;
		mod[sum[i]]++;
	}
	llong ans=0;
	rep(i,0,2019){
		ans += mod[i]*(mod[i]-1)/2;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3420
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>


using namespace std;

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

Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline

A, B = map(int, input().split())
X = A / 0.08
Y = B/0.1
for i in range(math.floor(min(X, Y)), math.ceil(max(X, Y)) + 1):
    if int(i * 0.08) == A and int(i * 0.10) == B:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 9120
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i,j;
	char a[11],b[11],c[11];

	scanf("%s %s %s",a,b,c);

	i=strlen(a)-1;
	j=strlen(b)-1;

	if((a[i]==b[0])&&(b[j]==c[0]))
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}


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

def main():
    #入力
    a, b = map(int , input().split())
    if a + b == 15:
        print('+')
    elif a * b == 15:
        print('*')
    else:
        print('x')

if __name__ == '__main__':
    main()
    

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i > b; i--)
#define repll(i, a, b) for (ll i = a; i < b; i++)

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

  float a, b, c, d;
  cin >> a >> b >> c >> d;

  if (ceil(c / b) <= ceil(a / d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
bool oppositeSigns(int x, int y) { return ((x ^ y) < 0); }
using namespace std;
typedef long long ll;
const int N = 100001;
const int MOD = 1000000007;
vector<int> adj[100001];
bool visited[100001];
vector<string> res;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int val[n],c[n],diff[n];
    
    for(int i=0;i<n;i++) cin >> val[i];
    for(int i=0;i<n;i++) cin >> c[i];
    for(int i=0;i<n;i++) diff[i]=val[i]-c[i];
    sort(diff,diff+n);
    int sum=0;
    for(int i=n-1;i>=0;i--){
        if(diff[i]>0) sum+=diff[i];
    }
    cout << sum;
}

Measured memory_bytes: 5992
#include <stdio.h>

int main(void)
{
	char c;
	int i;
	int tmp[26] = {0};
	while (scanf("%c", &c) != EOF) {
		if (c <= 'z' && 'a' <= c) {
			++tmp[c-'a'];
		} else if (c <= 'Z' && 'A' <= c) {
			++tmp[c-'A'];
		}
	}

	for (i = 0; i < 26; ++i) {
		printf("%c : %d\n", i+'a', tmp[i]);
	}
	return 0;
}

Measured memory_bytes: 540
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef vector<int> vint;
#define rep(i,n) for(lint i = 0;i < n;i++)
#define all(x) x.begin(),x.end()
#define clr(a) memset(a,0,sizeof(a))
#
int main(void){
    lint K;
    cin >> K;
    lint x = 0;
    for(lint i = 2;i <= K;i += 2){
        for(lint i = 1;i <= K;i += 2)
            x++;
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0;
  double w=0;
  std::cin >> w;
  w/=3;
  printf("%.10f\n",w*w*w);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll minV = 1 << 21;
	rep(i, 0, N) {
		ll a; cin >> a;
		ll t = a;
		ll cnt = 0;
		while (t % 2 == 0) {
			cnt++;
			t /= 2;
		}
		minV = min(minV, cnt);
	}
	cout << minV << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*

class Node(val Id:Int){
    private val mEdgesTo: LinkedList<Node> = LinkedList()
    var HasLoop:Boolean? = null
    fun AddEdge(to:Node):Unit = mEdgesTo.push(to)
    fun Edges():Iterable<Node> = mEdgesTo
}
fun findLoop(current:Node, count:Int = 0):Boolean{
    when(current.HasLoop){
        null -> when {
            count > 100 -> current.HasLoop = true
            else -> current.HasLoop = current.Edges().any{findLoop(it, count + 1)}
        }
    }
    return current.HasLoop!!
}
fun main(args:Array<String>):Unit{
    val (v, e) = readLine()!!.split(' ').map(String::toInt)
    val nodes = Array(v){Node(it)}
    for (i in 0 until e){
        val (s, t) = readLine()!!.split(' ').map(String::toInt)
        nodes[s].AddEdge(nodes[t])
    }
    println(if (nodes.any{findLoop(it)}) 1 else 0)
}


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

int A[200005], B[200005];
int main()
{
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i++)
		scanf("%d%d", &A[i], &B[i]);
		
	sort(A + 1, A + N + 1);
	sort(B + 1, B + N + 1);
	
	if(N % 2 == 1)
	{
		int medianA = A[(N + 1) / 2], medianB = B[(N + 1) / 2];
		printf("%d", abs(medianB - medianA) + 1);
	}
	
	else
	{
		int twiceMedianA = A[N / 2] + A[N / 2 + 1], twiceMedianB = B[N / 2] + B[N / 2 + 1];
		printf("%d", abs(twiceMedianA - twiceMedianB) + 1);
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

class Dice{
	public:
		int l,r,f,b,d,u;
		Dice(){}
		Dice(int _l,int _r,int _f,int _b,int _d,int _u){
			l=_l,r=_r,f=_f,b=_b,d=_d,u=_u;
		}
		#define rotation(a,b,c,d) swap(a,b),swap(b,c),swap(c,d);

		void rot_f(){ rotation(f,u,b,d);}
		void rot_b(){ rotation(b,u,f,d);}
		void rot_l(){ rotation(l,u,r,d);}
		void rot_r(){ rotation(r,u,l,d);}

		inline bool valid(){
			if(l<0||r<0||f<0||b<0||d<0||u<0) return false;
			int na=u+d,nb=l+r,nc=f+b;
			if(na>nb+nc) return false;
			if(nb>na+nc+1) return false;
			if(nc>na+nb+1) return false;
			return true;
		}
};



int main(void){
	int t[6];
	while(1){
		rep(i,6) cin >> t[i];
		
		int n=0;
		rep(i,6) n+=t[i];
		if(n==0) break;

		string ans="impossible";

		do{
			Dice d(t[0],t[1],t[2],t[3],t[4],t[5]),nd;
			if(d.valid()==false) continue;
			string cur="";

			rep(loop,n){
				nd=d; nd.rot_r(),nd.d--;
				if(nd.valid()){
					cur+="E",d=nd;
					continue;
				}
				nd=d; nd.rot_b(),nd.d--;
				if(nd.valid()){
					cur+="N",d=nd;
					continue;
				}
				nd=d; nd.rot_f(),nd.d--;
				if(nd.valid()){
					cur+="S",d=nd;
					continue;
				}
				nd=d; nd.rot_l(),nd.d--;
				if(nd.valid()){
					cur+="W",d=nd;
					continue;
				}
			}
			if(ans=="impossible") 
				ans=cur;
			else
				chmin(ans,cur);
		}while(next_permutation(t,t+6));

		int p,q;
		cin >> p >> q;
		if(ans=="impossible")
			cout << ans << endl;
		else
		 	cout << ans.substr(p-1,q-p+1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3264
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define OUT -1
#define IN 1
struct Data{int time,weight,io;};
bool operator<(Data a,Data b){return a.time!=b.time?a.time<b.time:a.io<b.io;}
int main()
{
  int n,i,capacity,max;
  vector<Data>person;
  while(cin>>n,n){
    person.resize(2*n);
    capacity=0;
    for(i=0;i<n;i++){
      Data d;
      cin>>d.weight>>d.time;
      d.io=IN;
      person[2*i]=d;
      cin>>d.time;
      d.io=OUT;
      person[2*i+1]=d;
    }
    sort(person.begin(),person.end());
    max=capacity=0;
    for(i=0;i<2*n;i++){
      capacity+=person[i].io*person[i].weight;
      if(max<capacity)max=capacity;
    }
    puts(150>=max?"OK":"NG");
  }
}

Measured memory_bytes: 0
"""
Writer : SPD_9X2
https://atcoder.jp/contests/agc010/tasks/agc010_f

Nが小さいので、各頂点に関して木を探索できる
つまり、この頂点に置いた時勝てるか？がわかれば解ける

まず2頂点で考えると、Aがもう片方以上の方に置けばかつ
→値の大小が重要そう

置いた点から小さい方に下っていくのが最適。

●→高橋
〇→青木とする

●-〇-●-〇
小さい方に下って行って、周囲に自分より小さいノードが無かったら
先っぽのノードの持ち主が負けになる

複数小さいノードがある場合、一つでも勝ちがある場合勝てるノードになる
一つもない場合負け
→結局dfsしてあげればいい

"""
import sys
sys.setrecursionlimit(5000)
N = int(input())

A = list(map(int,input().split()))

lis = [ [] for i in range(N) ]

for i in range(N-1):

    a,b = map(int,input().split())
    a -= 1
    b -= 1
    lis[a].append(b)
    lis[b].append(a)

def dfs(p,state): #0=tk 1=ao

    temp = [0,0]

    for nex in lis[p]:

        if A[nex] < A[p]:
            temp[ dfs(nex,state^1) ] += 1

    if temp[state] > 0:
        return state
    else:
        return state ^ 1

ans = []
for i in range(N):

    if dfs(i,0) == 0:
        ans.append(i+1)

print (*ans)

    
    


Measured memory_bytes: 53464
import sys
import heapq

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def end(flag):
    if flag:
        print('Yes')
    else:
        print('No')
    exit(0) #プログラムを終了

n = int(input())
plus = []
minus = []
zero = []
total = 0
for i in range(n):
    s = input()[:-1] #入力の右端の値を除去
    cnt = 0
    M = 0
    m = 0
    for t in s:
        if t == ')': #前から探索
            cnt += 1
            # print('+cnt:{}'.format(cnt))
            M = max(M,cnt) #'('が多い場合はcnt=0,')'が多い場合はcntは'('と')'の個数の差
            # print('M:{}'.format(M))
        else:
            cnt -= 1
            # print('-cnt:{}'.format(cnt))
    cnt = 0
    for t in s[::-1]: #後ろから探索
        if t == ')':
            cnt += 1
            # print('+cnt:{}'.format(cnt))
        else:
            cnt -= 1
            # print('-cnt:{}'.format(cnt))
            m = min(m,cnt) #')'が多い場合はcnt=0,'('が多い場合はcntは'('と')'の個数の差
            # print('m:{}'.format(m))
    if cnt > 0:
        minus.append((-m,cnt))
    elif cnt == 0:
        zero.append((-m,M))
    else:
        plus.append((M,-cnt))
    S = (M,-cnt)
    total += cnt
if total != 0:
    end(0)
plus.sort()
minus.sort()
cnt = 0
for need,increase in plus:
    if cnt < need:
        end(0)
    else:
        cnt += increase
cnt = 0
for need,increase in minus:
    if cnt < need:
        end(0)
    else:
        cnt += increase
for m,M in zero:
    if m > cnt or M > cnt:
        end(0)
end(1)

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

int main()
{
	ll n,rem,flag=0,sum;
	cin>>n;
	sum=n*(n+1)/2;
	for (int i = 0; i <= n; i=i+15)
	{
		sum=sum-i;
	}
	for (int i = 0; i <= n; i=i+3)
	{
		if(i%3==0 && i%5 !=0)
		{
			sum=sum-i;
		}
	}
	for (int i = 0; i <= n; i=i+5)
	{
		if(i%5==0 && i%3 !=0)
		{
			sum=sum-i;
		}
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n;
int frq[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        int nr;
        cin >> nr;
        frq[nr]++;
    }
    int ss = 0;
    int ans = 0;
    for(int i = 1; i <= 100000; ++i)
    {
        ss += frq[i];
        if(ss + ss == n)
            ++ans;
    }
    cout << ans;
    return 0;
}


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

int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    long double s = (double)w * (double)h  / (double)2.0;
    int ism = ((x+x == w) && (y+y == h)) ? 1 : 0;
    cout << fixed << setprecision(12) << s;
    cout <<  " " << ism << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    string L;

    cin >> L;
    reverse(L.begin(), L.end());

    ll dp[100100][2] = {0};
    dp[L.size()-1][0] = 1;
    dp[L.size()-1][1] = 2;
    for( int i = L.size()-2; i >= 0 ; i-- ){
        dp[i][0] = (dp[i+1][0]*3)%MOD;
        if( L[i] == '0' ){
            dp[i][1] = (dp[i+1][1])%MOD;
        }else{
            dp[i][0] += (dp[i+1][1])%MOD;
            dp[i][1] = (dp[i+1][1]*2)%MOD;
        }
    }

    cout << (dp[0][0]+dp[0][1])%MOD << endl;
}


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

template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);

struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c, d> e) {
	return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
	cerr << boolalpha << a;
	return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
	*this << "[";
	for (auto it = a.begin(); it != a.end(); ++it)
		*this << ","[1 - (it != a.begin())] << *it;
	return *this << "]";
}
#else
template<class c> debug& operator << (c) {
	return *this;
}
#endif
};

#define aty(x) " [" << #x ": " << x << "] "

using ll = long long;




int main() {
	
	int n, m, c;
    cin >> n >> m >> c;
    int ans = 0;

    vector<int> b(m);
    for (int& el : b) cin >> el;
    
    
    for (int i = 0; i < n; ++i)
    {
        int x = 0;
        for (int j = 0; j < m; ++j)
        {
            int f;
            cin >> f;
            x += f * b[j];
        }
        x += c;
        if (x > 0) ans++;
    }
    
    cout << ans;
	
}


Measured memory_bytes: 256
#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() {
	ll			x;
	cin >> x;
	bitset<32>	bs(x);

	cout << bs << endl;
	cout << ~bs << endl;
	cout << (bs << 1) << endl;
	cout << (bs >> 1) << endl;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define srep(i, from, to) for(int i=from;i<(int)(to);i++)

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

  vector<string> s(n);
  rep(i, n) cin >> s[i];

  map<string, ll> m;

  rep(i, n) {
    string x = s[i];
    sort(x.begin(), x.end());
    m[x] += 1;
  }

  ll ans = 0;
  for(auto it=m.begin(); it!=m.end(); it++) {
    ll count = it->second;
    ans += (count * (count -1))/2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 18176
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/llpow(10,d)>0){d++;}return d+1;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 int d[20];
 string t;
 cin>>t;
 ans=0;
 ll n=t.length();
 bool flag=false;
 ll tmp=0;
 rep(i,0,n){
  d[i]=t[i]-'0';
  tmp+=d[i];
  if(d[i]!=9)flag=true;
 }
 if(!flag){
  pr(9*n);
  return 0;
 }
 if(d[0]!=0)ans=d[0]-1;
 ans+=9*(n-1);
 ans=max(ans,tmp);
 pr(ans);
 return 0;}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

	int f=b/a;

	System.out.println(Math.min(f,c));
	}}

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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll ;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------




















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  ll ans = 0 ;
  
  for (int bitt = 0; bitt < (1 << n-1); bitt++) {
    bitset<10> bits(bitt); 
    bits.set(n-1) ;
    //cout << bits <<endl ;
    queue<string> que ;
    
    for (int i = 0; i < n; i++) {
      que.push(s.substr(i,1)) ;
      if (bits[i]==1) {
        str t = "" ;
          while(!que.empty()){
            t += que.front() ;
            que.pop() ;
          }
        ans += stol(t) ; 
      }
    }
  }
  
  cout << ans <<endl ;
  
  
  
  
  return 0 ;
}



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

const int S = 200000;
int N;
bitset<200000> sieve;
vector<int> P;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	sieve.set();
	sieve[0] = sieve[1] = 0;
	for (int i = 2; i <= S; i++) {
		if (sieve[i]) {
			P.push_back(i);
			for (int j = i + i; j <= S; j += i) sieve[j] = 0;
		}
	}
	cin >> N;
	cout << *lower_bound(P.begin(), P.end(), N) << '\n';
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({b * d, a * c, a * d, b * c});
}

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

int main()
{
	//ifstream fin("05.txt");
	int n;
	//fin>>n;
	cin>>n;
	long int a[n];
	/*for(int i=0;i<n;i++)
	{
		fin>>a[i];
	}*/
	for(int i=0;i<n;i++)
		cin>>a[i];
	//fin.close();
	//cout<<"\n The n "<<n;
	//cout<<"\n The k "<<k<<"\n";
	/*for(int i=0;i<n;i++)
	{
		cout<<a[i]<<" ";
	}*/
	sort(a,a+n);
	/*for(int i=0;i<n;i++)
	{
		cout<<a[i]<<" ";
	}*/
	long int sum[n];
	sum[0]=a[0];
	for(int i=1;i<n;i++)
	{
		sum[i]=a[i]+sum[i-1];
	}
	long int greaterInd=0;
	for(int i=0;i<n-1;i++)
	{
		if(sum[i]*2<a[i+1])
			greaterInd=i+1;
	}
	cout<<n-greaterInd<<"\n";

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n){
    rep(j,n-1){
      cin>>a[i][j];
      a[i][j]--;
    }
    reverse(begin(a[i]),end(a[i]));
  }
  vector<Pi> que;
  auto check=[&](int i){
    if(a[i].empty()) return ;
    int j=a[i].back();
    if(a[j].empty()) return ;
    if(a[j].back()==i){
      if(i>j) swap(i,j);
      que.push_back(Pi(i,j));
    }
  };
  rep(i,n) check(i);
  int ans=0;
  while(que.size()){
    ans++;
    sort(begin(que),end(que));
    que.erase(unique(begin(que),end(que)),end(que));
    vector<Pi> que2;
    swap(que,que2);
    for(auto q:que2){
      int i=q.fi,j=q.se;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(auto q:que2){
      int i=q.fi,j=q.se;
      check(i);
      check(j);
    }
  }
  rep(i,n){
    if(a[i].size()){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
}

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

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

    return gcd(b, a % b);
}

int main() {
  int k;
  ll ans = 0;
  cin >> k;
  rep(i, k) {
    rep(j, k) {
      rep(l, k) {
        ans += gcd(i, gcd(j, l));
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
int INF = 1001001001;
int dp[100100];
int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n)cin >> h [i];
    memset(dp,INF,sizeof(dp));
    dp[0]=0;
    for(int i = 0;i<n-1;++i){
         dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
         if(i+2<n){
             dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
         }
    }
    cout << dp[n-1] <<endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long m = sc.nextInt();
        Long[] a = new Long[n];
        int odd = 0, even = 0;
        for(int i=0;i<n;i++){
            a[i]=sc.nextLong()/2;
            if(a[i]%2==0) even++;
            else odd++;
        }
        if(even>0&&odd>0) return 0;
        Arrays.sort(a,Collections.reverseOrder());
        // gcd and stuff
        long g = gcd(a[0],a[0]);
        for(int i=1;i<n;i++){
            g = gcd(g,a[i]);
        }
        boolean flag = true;
        long[] b = new long[n];
        for(int i=0;i<n;i++){
            b[i] = a[i]/g;
            flag &= (b[i]%2==1);
            if(!flag) break;
        }
        if(!flag) return 0;
        long lcm = b[0];
        for(int i=1;i<n;i++){
            lcm = getLcm(lcm,b[i]);
            if(lcm>m) return 0;
        }
        long lower = lcm*g;
        if(m<lower) return 0;
        long diff = lcm*2*g;
        if((m-lower)%diff==0) {
            return (m-lower)/diff+1;
        }
        return (m-lower)/(diff)+1;
    }
    long gcd(long a, long b){
        if(a<b){
            long c = a;
            a = b; b = c;
        }
        while(a%b!=0){
            long c = a%b;
            a = b; b = c;
        }
        return b;
    }
    long getLcm(long a, long b){
        return a/gcd(a,b)*b;
    }
}



Measured memory_bytes: 62688
n = gets.to_i

$lucas = Array.new(100, -1)
def lucas(i)
	return 2 if i == 0
	return 1 if i == 1
	if $lucas[i] == -1
		$lucas[i] = lucas(i - 1) + lucas(i - 2)
	end
	$lucas[i]
end

puts lucas(n)


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);
ll modAdd(ll, ll, ll);
ll modSub(ll, ll, ll);
ll modTms(ll, ll, ll);
ll modInv(ll, ll);
ll modDiv(ll, ll, ll);
ll modPow(ll, ll, ll);

// ================ Main Loop ================
int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> ans(k + 1);
    for(int i = k; i >= 1; i--) {
        ans[i] = modPow(k / i, n, MOD);
        for(int t = 2; t * i <= k; t++) {
            ans[i] = modSub(ans[i], ans[t * i], MOD);
        }
        ans[0] = modAdd(ans[0], modTms(i, ans[i], MOD), MOD);
    }

    cout << ans[0] << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

ll modAdd(ll a, ll b, ll m) {
    return (a + b) % m;
}

//引き算:a - b O(1)
ll modSub(ll a, ll b, ll m) {
    return (a > b) ? (a - b) % m : (a - b) % m + m;
}

//掛け算:a * b O(1)
ll modTms(ll a, ll b, ll m) {
    return a * b % m;
}

//逆関数
//Extended Euclid Algorithm O(log a)
ll modInv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}

//割り算:a/b O(log b)
ll modDiv(ll a, ll b, ll m) {
    return modTms(a, modInv(b, m), m);
}

//冪乗:a^n O(log n)
ll modPow(ll a, ll n, ll m) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}


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

int main(){
    int N;
    cin >> N;
    double ans = 0;

    for(int i = 0; i < N; i++){
        double value;
        string type;
        cin >> value >> type;

        if(type == "JPY"){
            ans += value;
        }
        else{
            ans += value*380000.0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

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

	@SuppressWarnings("unchecked")
	void run() {
		Scanner sc = new Scanner();

		int N = sc.nextInt();
		int M = sc.nextInt();//合計M個以下選ぶ
		int C = sc.nextInt();
		int[] l = new int[C];//l[i]=色iの選べる数
		int[] c = new int[N];//色
		int[] w = new int[N];//価値
		for (int i = 0; i < C; ++i) {
			l[i] = sc.nextInt();
		}
		PriorityQueue<Long> pq = new PriorityQueue();
		for (int i = 0; i < N; ++i) {
			c[i] = sc.nextInt();
			w[i] = sc.nextInt();
			--c[i];
			pq.add(-((long) w[i] << 32 | c[i]));
		}
		long ans = 0;
		while (M > 0 && !pq.isEmpty()) {
			long ball = pq.poll();
			int color = (int) -ball;
			int value = (int) ((-ball) >> 32);
			if (l[color] > 0) {
				--l[color];
				ans += value;
				--M;
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		pw.println(ans);
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

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



Measured memory_bytes: 34284
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String S = scan.next();
		
		if(S.equals("SUN")){
			System.out.println("7");
		}else if(S.equals("MON")){
			System.out.println("6");
		}else if(S.equals("TUE")){
			System.out.println("5");
		}else if(S.equals("WED")){
			System.out.println("4");
		}else if(S.equals("THU")){
			System.out.println("3");
		}else if(S.equals("FRI")){
			System.out.println("2");
		}else if(S.equals("SAT")){
			System.out.println("1");
		}
		

	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	ll n, a, i, j, k, dp[51][51][2501],ans=0,x;
	cin >> n >> a;
	for (i = 0; i <= n; i++)
		for (j = 0; j <= i; j++)
			for (k = 0; k <= 50 * j; k++)
				dp[i][j][k] = 0;
	dp[0][0][0] =1;
	for (i = 0; i < n; i++) {
		cin >> x; 
		for (j = 0; j <= i; j++)
			for (k = j; k <= 50 * j; k++)
				dp[i + 1][j][k] = dp[i][j][k];
		for (j = 0; j <= i; j++)
			for (k = j; k <= 50 * j; k++)
				dp[i + 1][j + 1][k + x] += dp[i][j][k];
	}
	for (j = 1; j <= n; j++)
		for (k = j; k <= 50 * j; k++)
			if (a*j == k&&dp[n][j][k]>0)
				ans += dp[n][j][k];
	cout << ans << endl;
}

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

dp = [0] * (k + 1)  #-1=lose,1=win

for i in range(k + 1):
    if any(dp[i - j] == -1 if i >= j else False for j in a):
        dp[i] = 1
    else:
        dp[i] = -1
print('First' if dp[k] == 1 else 'Second')


Measured memory_bytes: 43740
#include <string>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
    string s;
    cin >> s;
    for (char c : s) {
        if (c == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3040
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if (a/100==a%10)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x1, x2;
  rep(i, N) {
    int x;
    cin >> x;
    if (x >= 0) {
      x2.push_back(x);
    } else if (x < 0) {
      x1.push_back(-x);
    } else {
      cout << "error" << endl;
    }
  }
  sort(x1.begin(), x1.end());

  int N1 = x1.size();
  int N2 = x2.size();
  int result = INF;
  rep(i, K + 1) {
    // cout << i << " " << result << endl;
    int K1 = i;
    int K2 = K - i;
    if (K1 > N1 || K2 > N2) {
      // cout << "n1" << endl;
      continue;
    }
    if (K2 == 0) {
      // cout << "n2" << endl;
      result = min(result, x1[K1 - 1]);
      continue;
    }
    if (K1 == 0) {
      // cout << "n3" << endl;
      result = min(result, x2[K2 - 1]);
      continue;
    }
    // cout << "n4" << endl;
    int alpha = min(x1[K1 - 1], x2[K2 - 1]);
    result = min(result, x1[K1 - 1] + x2[K2 - 1] + alpha);
    continue;
  }

  cout << result << endl;

  return 0;
}


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


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

    string s;
    cin >> s;
    int sum = 0;
    for (char c : s) {
        sum += (c - '0');
        sum %= 9;
    }

    cout << (sum == 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int second = scanner.nextInt();
		int h;
		int m;
		int s;
		
		h = second / 3600;
		second = second - h * 3600;
		m = second / 60;
		second = second - m * 60;
		s = second;
		
		System.out.println(h + ":" + m + ":" + s);

	}
}

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

int map[14][14];

void inkM( int x, int y ){
	for( int i=-1; i<=1; i++ ){
		for( int j=-1; j<=1; j++ ){
			map[x+i][y+j]++;
		}
	}
}

void inkL( int x, int y ){
	inkM( x, y );
	map[x-2][y]++;
	map[x+2][y]++;
	map[x][y-2]++;
	map[x][y+2]++;
}

void inkS( int x, int y ){
	map[x][y]++;
	map[x-1][y]++;
	map[x+1][y]++;
	map[x][y+1]++;
	map[x][y-1]++;
}

int main(){
	int x,y,s;
	string str;
	while(1){
		getline( cin, str );
		if( str.length()==0 ) 	break;
		sscanf( str.c_str(), "%d,%d,%d", &x, &y, &s );
		x+=2; y+=2;
		if( s==1 )		inkS( x, y );
		else if( s==2 )	inkM( x, y );
		else if( s==3 )	inkL( x, y );
	}
	int max=0, cnt=0;
	for( int y=2; y<12; y++ ){
		for( int x=2; x<12; x++ ){
			if( map[x][y] == 0 )	cnt++;
			if( max < map[x][y] )	max = map[x][y];
		}
	}
	cout << cnt << endl;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 0
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b += a // 2
        a //= 2
    else:
        if b % 2 == 1:
            b -= 1
        a += b // 2
        b //= 2
print(a, b)

Measured memory_bytes: 2940
#include <stdio.h>

int main(){
	
	int x1,y1,x2,y2;

	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

	printf("%d %d %d %d\n",y1-y2+x2,x2-x1+y2,y1-y2+x1,x2-x1+y1);


return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }else{
    if(a+b>c+d){
      cout<<"Left"<<endl;
    }else{
      cout<<"Right"<<endl;
    }
  }
 return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int>::iterator maxIt = max_element(A.begin(), A.end());
  int maxIndex = distance(A.begin(),maxIt);
  int max = A[maxIndex];
  for(int i = 0; i < N; i++){
    if(i != maxIndex) cout << max << endl;
    else{
      int max2 = 0;
      for(int j = 0; j < N; j++){
        if(j == i) continue;
        else if(A[j] > max2)max2 = A[j];
      }
      cout << max2 << endl;
    }
  }
  return 0;
}


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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    long long A, B, C;
    cin >> A >> B >> C;
    if (C % GCD(A, B) == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	string s; cin >> s;
	n=s.size();
	
	int ans=0;
	
	for(int i=0;i<n;i++){
		if(i&1){
			if(s[i]=='g'){
				ans++;
			}
		}
		else{
			if(s[i]=='p'){
				ans--;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#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>;

// rep(i, 3){cout << i << endl;}


int main(){
    long double A, B;
    cin >> A >> B;
    ll ans =  A*B;

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

Measured memory_bytes: 3736
#include<cstdio>
#include<ctime>
#include<cctype>
#include<cassert>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<sstream>
//STL
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
//C++11 needed
#include<unordered_map>
#include<unordered_set>
#include<random>
using namespace std;

int N , C , K , T[100003];

int main(){
	scanf("%d %d %d" , &N , &C , &K);
	for(int i = 1 ; i <= N ; ++i) scanf("%d" , &T[i]);
	sort(T + 1 , T + N + 1);
	int pos = 1 , num = 0;
	while(pos <= N){
		int p = pos; ++num;
		while(p <= N && p - pos < C && T[p] - T[pos] <= K) ++p;
		pos = p;
	}
	printf("%d" , num);
	return 0;
}


Measured memory_bytes: 512