akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define fastAF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ull unsigned ll
#define ld long double
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mapll map<ll,ll>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define deb(x) cout<<x
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
void swap(auto*,auto*);
int main()
{
    
    fastAF
    ll n,x,t; cin>>n>>x>>t;
    ll d=ceil((ld)n/(ld)x);
    cout<<d*t;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

Measured memory_bytes: 3684
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                String s = sc.next();
                sc.close();
                if(s.length() == 3) ou.print("" + s.charAt(2) + s.charAt(1) + s.charAt(0) + "\n");
                else ou.print(s + "\n");
                ou.flush();
        }
}

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

string s;

int main(){

cin>>s;

int x,y;
for(int i=0; i<s.size(); i++){
    if(s[i]=='A'){
        x=i; break;
    }
}
for(int i=s.size()-1; i>=0; i--){
    if(s[i]=='Z'){
        y=i; break;
    }
}

cout<<y-x+1<<endl;

}

Measured memory_bytes: 640
def main():
    input = sys.stdin.readline
    try:
        a, b, c = map(int, input().split())
        for i in range(a, a * b, a):
            if i % b == c:
                print("YES")
                break
        else:
            print("NO")

    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()


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

using namespace std;
#define ll long long
#define ld long double

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;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i=0;i<n;i++) {
        cin >> a[i];
    }
    for(int i=0;i<n;i++) {
        int b;
        cin >> b;
        if(a[i] - b > 0) sum += a[i] - b;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
struct triple{ll   x=0;ll   y=0;ll   z=0;void mt(ll   a,ll   b, ll   c){x=a;y=b;z=c;} void holify(){x=69;y=420;z=911;}};
#define pb push_back
#define x first 
#define y second
#define vec vector
#define pf(vec,val) vec.insert(vec.begin(),val)
#define mp make_pair
#define pii pair<ll  ,ll  >
#define maxll  69696991169
#define minll  -69696942069
#define sz(vec) (ll )vec.size()
#define speedup ios_base::sync_with_stdio(0); cin.tie(NUll ); cout.tie(NUll );
#define loop(mep) for(auto it = mep.begin();it!=mep.end();++it)
//#define usaco_crap(str)ifstream cin((string)str + (string)".in"); ofstream cout ((string)str+(string)".out");
#define range(n) =0;i<(n);i++
#define prll  (vec) for(auto it=vec.begin();it!=vec.end();++it)cerr<<*it<<" ";cerr<<endl;
// mt make triple // triple.mt(a,b,c) //
int  main(){
	int n,m; cin>>n>>m;
	vector<pii>check(m);	
	for(int i = 0 ; i < m ; i++){
		cin>>check[i].x>>check[i].y;
	}
	for(int i = 0 ; i < 1000 ; i++){
		string s = to_string(i);
		if(s.size()!=n)continue;
		int flag = 0;
		for(int j = 0 ; j < m ; j++){
			if(s[check[j].x-1] != '0'+check[j].y)flag = 1;
		}
		if(!flag && s.size()==n){cout<<s<<endl;return 0;}
	}
	cout<<-1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vs grid(h);
    rep(i, h) cin >> grid[i];
    vi ansi(h, 0);
    vi ansj(w, 0);
    rep(i, h) {
        bool flag = false;
        rep(j, w) {
            if (grid[i][j] == '#') flag = true;
        }
        if (flag) ansi[i] = 1;
    }
    rep(j, w) {
        bool flag = false;
        rep(i, h) {
            if (grid[i][j] == '#') flag = true;
        }
        if (flag) ansj[j] = 1;
    }
    rep(i, h) {
        if (!ansi[i]) continue;
        rep(j, w) {
            if (!ansj[j]) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unsigned long long ans,n,a,b,s,ss;
int main(){
    cin>>n>>a>>b>>ss;
    for(int i=2;i<=n;i++){
    	scanf("%d",&s);
		unsigned long long cha=abs(s-ss)*a*1.0;
		if(cha<b)ans+=cha;
		else ans+=b;
		ss=s;
	}
	cout<<ans;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
//var input = 1463616;
var n = parseInt(input);
var on = n;

var primes = [];
while (n % 2 == 0) {
    primes.push(2);
    n = n / 2;
}
for (var i = 3; i <= Math.sqrt(n); i += 2) {
    while (n % i == 0) {
        primes.push(i);
        n /= i;
    }
}
if (n > 1) primes.push(n);

console.log(on + ': ' + primes.join(' '));


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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

vector<int> v1[MAX];
int dp[MAX];
bool visited[MAX];

void initialise() {
    for (int i = 0; i <= 100000; i++) dp[i] = -1;
}

void dfs(int node) {
    visited[node] = true;
    if (v1[node].size() == 0) dp[node] = 0;
    for (int i = 0; i < v1[node].size(); i++) {
        if (!visited[v1[node][i]]) dfs(v1[node][i]);
        dp[node] = max(dp[node], 1 + dp[v1[node][i]]);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        v1[x].push_back(y);
    }
    initialise();
    for (int i = 1; i <= n; i++)if (!visited[i]) dfs(i);
    int maxm = -1;
    for (int i = 1; i <= n; i++) maxm = max(maxm, dp[i]);
    cout << maxm << "\n";
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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


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

int n, dx, dy, hx, hy;
int cx[20], cy[20];

double dist(int x1, int y1, int x2, int y2){
  int dx = x1 - x2;
  int dy = y1 - y2;
  return sqrt((double)dx * dx + dy * dy);
}

bool dfs(int x, int y, double time, int k){
  if(time >= dist(x, y, dx, dy)) return false;
  if(k == n) return true;
  
  REP(i, n){
    if(time + dist(x, y, cx[i], cy[i]) >= dist(cx[i], cy[i], dx, dy)) return false;
  }
  REP(i, n){
    if(dfs(cx[i], cy[i], time + dist(cx[i], cy[i], x, y), k + 1)){ return true;
    }
  }
  return false;
}

int main(void){
  while(true){
    scanf(" %d %d %d %d %d", &n, &hx, &hy, &dx, &dy);
    if(n == 0) break;
    REP(i, n){
      scanf(" %d %d", &cx[i], &cy[i]);
    }
    if(dfs(hx, hy, 0.0, 0)) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 1168
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {v: [usize; 3]};
    let mut v = v;
    v.sort();
    println!("{}", v[1] + v[0]);
}


Measured memory_bytes: 4352
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);

  int res=0;
  for (int i=0; i<N; ++i) {
    int a;
    scanf("%d", &a);
    res += __builtin_ctz(a);
  }
  printf("%d\n", res);
}


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

int main() {
	int n;
  	cin>>n;
  
  int p[n];
  rep(i,n)cin>>p[i];
  
  int mitasu=0;
  
 for(int j=1;j<n-1;j++){
  	if(p[j]>p[j-1]&&p[j]<p[j+1]){
    	mitasu++;
    }
   
   else if(p[j]<p[j-1]&&p[j]>p[j+1]){
   		mitasu++;
   }
 }
  
  cout<<mitasu<<endl;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np


def solve(inp):
    def bitree_sum(bit, t, i):
        s = 0
        while i > 0:
            s += bit[t, i]
            i ^= i & -i
        return s

    def bitree_add(bit, n, t, i, x):
        while i <= n:
            bit[t, i] += x
            i += i & -i

    def bitree_lower_bound(bit, n, d, t, x):
        sum_ = 0
        pos = 0
        for i in range(d, -1, -1):
            k = pos + (1 << i)
            if k <= n and sum_ + bit[t, k] < x:
                sum_ += bit[t, k]
                pos += 1 << i
        return pos + 1

    def initial_score(d, ccc, sss, ttt):
        bit_n = d + 3
        bit = np.zeros((26, bit_n), dtype=np.int64)
        INF = 10 ** 18
        for t in range(26):
            bitree_add(bit, bit_n, t, bit_n - 1, INF)

        last = np.full(26, -1, dtype=np.int64)
        score = 0

        for i in range(d):
            t = ttt[i]
            score += sss[i, t]
            for u in range(26):
                if u == t:
                    continue
                score -= ccc[u] * (i - last[u])
            last[t] = i
            bitree_add(bit, bit_n, t, i + 2, 1)

        return bit, score

    def update_score(bit, bit_n, bit_d, ccc, sss, ttt, d, q):
        diff = 0
        t = ttt[d]
        bitree_add(bit, bit_n, t, d + 2, -1)
        k = bitree_sum(bit, t, d + 1)
        c = bitree_lower_bound(bit, bit_n, bit_d, t, k) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, t, k + 1) - 2
        b = ccc[t]
        diff -= b * (d - c) * (e - d)
        diff -= sss[d, t]

        k = bitree_sum(bit, q, d + 2)
        c = bitree_lower_bound(bit, bit_n, bit_d, q, k) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, q, k + 1) - 2
        bitree_add(bit, bit_n, q, d + 2, 1)
        b = ccc[q]
        diff += b * (d - c) * (e - d)
        diff += sss[d, q]

        return diff

    d = inp[0]
    ccc = inp[1:27]
    sss = np.zeros((d, 26), dtype=np.int64)
    for r in range(d):
        sss[r] = inp[27 + r * 26:27 + (r + 1) * 26]
    ttt = inp[27 + d * 26:27 + d * 27] - 1
    m = inp[27 + d * 27]
    ddd = inp[28 + d * 27::2] - 1
    qqq = inp[29 + d * 27::2] - 1

    bit, score = initial_score(d, ccc, sss, ttt)
    bit_n = d + 2
    bit_d = int(np.log2(bit_n))

    buf = np.zeros(m, dtype=np.int64)

    for i in range(m):
        diff = update_score(bit, bit_n, bit_d, ccc, sss, ttt, ddd[i], qqq[i])
        ttt[ddd[i]] = qqq[i]
        score += diff
        buf[i] = score

    return buf


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 37404
let () =
  let h, w = Scanf.scanf "%d %d" (fun h w -> h, w) in
  let a = Array.init h (fun _ -> Scanf.scanf " %s" (fun s -> s)) in
  a |> Array.mapi (fun i row -> row
      |> String.mapi (fun j c ->
          if c = '#' then '#' else
            [(1, 0); (1, 1); (0, 1); (-1, 1); (-1, 0); (-1, -1); (0, -1); (1, -1)]
            |> List.map (fun (di, dj) ->
                let i', j' = i+di, j+dj in
                if i' < 0 || h <= i' || j' < 0 || w <= j' then 0
                else if a.(i').[j'] = '#' then 1 else 0)
        |> List.fold_left (+) 0
        |> ((+) 48) |> char_of_int))
  |> Array.iter print_endline


Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::vector<uint32_t> A(N);
  for (auto &&a : A) std::cin >> a;

  uint32_t max = A[0], min = A[1];
  if (max < min) {
    max = A[1];
    min = A[0];
  }

  for (size_t i = 2; i < N; i++) {
    if (A[i] < min) {
      min = A[i];
    } else if (A[i] > max) {
      max = A[i];
    }
  }

  std::cout << max - min << std::endl;

  return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll imos[33][100100] = {0};
int main(void){
    ll n, c;
    cin >> n >> c;

    
    for(int i = 0; i < n; i++){
        ll s, t, c;
        cin >> s >> t >> c;
        imos[c][s]++;
        imos[c][t + 1]--;
    }

    for(int i = 0; i <= 30; i++){
        for(int j = 1; j < 100100; j++){
            imos[i][j] += imos[i][j - 1];
        }
    }

    ll ans = 0;
    for(int i = 0; i < 100100; i++){
        ll tmpans = 0;
        for(int j = 0; j <= 30; j++){
            if(imos[j][i] > 0){
                tmpans++;
            }
        }
        ans = max(ans, tmpans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 24832
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>

#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using PII=pair<int,int>;

vector<PII> l;
int r, c, n;
int x[2], y[2];

bool is_bor(int xs, int ys){
    return xs == 0 || ys == 0 || xs == r || ys == c;
}

int main(void){
    cin >> r >> c >> n;
    rep(i, n){
        cin >> x[0] >> y[0] >> x[1] >> y[1];
        if(is_bor(x[0], y[0]) && is_bor(x[1], y[1])){
            rep(j, 2){
                if(x[j] == 0){
                    l.push_back(PII(y[j], i));
                }else if(y[j] == c){
                    l.push_back(PII(c+x[j], i));
                }else if(x[j] == r){
                    l.push_back(PII(c+r+c-y[j], i));
                }else if(y[j] == 0){
                    l.push_back(PII(c+r+c+r-x[j], i));
                }
            }
        }
    }
    sort(l.begin(), l.end());

    bool ok = true;
    stack<int> s;
    rep(i, l.size()){
        int m = l[i].second;
        if(s.empty()){
            s.push(m);
        }else{
            if(s.top() == m){
                s.pop();
            }else{
                s.push(m);
            }
        }
    }
    cout << (s.empty()?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 2420
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String input = scanner.nextLine();
        // System.out.println(input);

        scanner.close();


        String[] tasks_str = input.split(" ");
        List<String> tasks_str_list = Arrays.asList(tasks_str);
        List<Integer> tasks = tasks_str_list.stream().map(s -> Integer.parseInt(s)).collect(Collectors.toList());

        int costs[] = new int[6];
        int index = 0;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i == j) continue;

                for (int k = 0; k < 3; ++k) {
                    if (i == k) continue;
                    if (j == k) continue;

                    costs[index] = Math.abs(tasks.get(j) - tasks.get(i));
                    costs[index] += Math.abs(tasks.get(k) - tasks.get(j));
                    ++index;
                }
            }
        }

        int min = costs[0];
        for (int i = 1; i < 6; ++i) {
            if (costs[i] < min) {
                min = costs[i];
            }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 26964
#include<iostream>
#include<iomanip>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

struct Dice{
    int f[6];
    void roll(char temp){
        switch (temp)
      {
        int temp_1;
        case 'S':
          temp_1 = f[4];
          f[4] = f[5];
          f[5] = f[1];
          f[1] = f[0];
          f[0] = temp_1;
          break;
        case 'N':
            temp_1 = f[1];
            f[1] = f[5];
            f[5] = f[4];
            f[4] = f[0];
            f[0] = temp_1;
            break;
        case 'W':
            temp_1 = f[2];
            f[2] = f[5];
            f[5] = f[3];
            f[3] = f[0];
            f[0] = temp_1;
            break;
        case 'E':
            temp_1 = f[2];
            f[2] = f[0];
            f[0] = f[3];
            f[3] = f[5];
            f[5] = temp_1;
            break;
        case 'R':
            temp_1=f[1];
            f[1]=f[2];
            f[2]=f[4];
            f[4]=f[3];
            f[3]=temp_1;
            break;
      
        default:
            break;
      }
    }
    int top(){
        return f[0];
    }
    int right(){
        return f[2];
    }
    int left(){
        return f[3];
    }
    int front(){
        return f[1];
    }
    int back(){
        return f[4];
    }
    int bottom(){
        return f[5];
    }
};
bool check_dice_same(Dice d1,Dice d2){
  bool res = false;
  string order = "RNNNNRNNNNRNNNNRNNNNWNNNNWNNNNENNNNENNNNWNNNN";
  for(int i = 0;i< order.size();i++){
      d1.roll(order[i]);
      if(d1.left() == d2.left() && d1.right() == d2.right() && d1.top() == d2.top()
    && d1.front() == d2.front() && d1.back() == d2.back() && d1.bottom() == d2.bottom()){
        res = true;
        return res;
      }
   }  
   return res;
}

int main(){
  int n;
  cin>>n;
  vector <Dice> dt(100);
  for(int i =0;i<n;i++){
      for(int j = 0;j<6;j++){
      cin>>dt[i].f[j];
      }
  }
  for(int i = 0;i<n;i++){
      for(int j =i+1;j<n;j++){
          if(check_dice_same(dt[i],dt[j])){
              cout<<"No"<<endl;
              return 0;
          }
      }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3204
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long N;
    cin >> N;

    switch (N % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    default:
        cout << "bon" << endl;
        break;
    }
}

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

int main() {
  int c = 0;
  string N;
  cin >> N;
  if(N[0] == '1') c++;
  if(N[1] == '1') c++;
  if(N[2] == '1') c++;
  cout << c << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
	
	int n;
	cin >> n;

	int s = 0;
	for(int i = 1;i <= n;i++){
		if(i%3 != 0 && i%5 != 0)s += i;
	}
	cout << s << endl;

	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc162/tasks/abc162_b


Measured memory_bytes: 3588
#include<queue>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
pair<int, int> P[100011];
vector<pair<int, int> > G[100011];
int M;
int F[100011];
bool use[100011], act[200011], dp[100011];

int par[100011], pari[100011];

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, N) scanf("%d%d", &P[i].first, &P[i].second);
    sort(P, P+N);

    REP (i, M) {
	int l, r;
	scanf("%d%d", &l, &r);
	r++;

	int posl = lower_bound(P, P+N, make_pair(l, -1)) - P;
	int posr = lower_bound(P, P+N, make_pair(r, -1)) - P;
	if (posl < posr) {
	    G[posl].emplace_back(posr, i);
	    G[posr].emplace_back(posl, i);
	}
    }

    REP (i, N) if (P[i].second == 1) {
	if (i == 0 || P[i-1].second == 0) {
	    F[i] = 1;
	}
	if (i == N-1 || P[i+1].second == 0) {
	    F[i+1] = 1;
	}
    }

    bool yes = true;
    REP (i, N+1) if (!use[i]) {
	VI ord;
	ord.push_back(i);
	use[i] = true;
	par[i] = i;
	for (int j=0; j<(int)ord.size(); j++) {
	    int v = ord[j];
	    EACH (e, G[v]) if (!use[e->first]) {
		par[e->first] = v;
		pari[e->first] = e->second;
		use[e->first] = true;
		ord.push_back(e->first);
	    }
	}

	int cnt = 0;
	EACH (e, ord) if (F[*e]) {
	    cnt++;
	    dp[*e] = 1;
	}
	if (cnt % 2) {
	    yes = false;
	}
	for (int j=ord.size(); j--;) {
	    int v = ord[j];
	    if (dp[v]) {
		act[pari[v]] ^= 1;
		dp[par[v]] ^= dp[v];
	    }
	}
    }

    if (yes) {
	VI ans;
	REP (i, M) if (act[i]) ans.push_back(i+1);
	printf("%d\n", (int)ans.size());
	rprintf("%d", ans.begin(), ans.end());
    } else {
	puts("-1");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 12144
#include <iostream>
#include <string>
using namespace std;
int main(){

int list[32] = {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};
int l; cin >> l;
  cout << list[l - 1] << endl;

return 0;}

Measured memory_bytes: 3632
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Tue Feb 11 19:59:55 JST 2020
 **/

signed main() {
    Int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<int> Solve(int N)
        {
            for (int i = 1; true; ++i)
            {
                if (i * (i + 1) / 2 >= N)
                {
                    var values = new List<int>();
                    while (N > 0)
                    {
                        if (N >= i)
                        {
                            values.Add(i);
                            N -= i;
                        }
                        --i;
                    }
                    values.Reverse();
                    return values;
                }
            }
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            foreach (int n in Solve(N))
            {
                Console.WriteLine(n);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
const int maxn = 40;
int ans[maxn];
void upd(long long x){
	if(x < 0){
		int b = 0;
		while((1ll<<b) != -x) b++;
		if(b%2){
			if(ans[b]){
				ans[b] = 0;
				upd(-(1ll<<(b+1)));
			} else {
				ans[b] = 1;
			}
		} else {
			if(ans[b]){
				ans[b] = 0;
			} else {
				upd(1ll<<b);
				upd(-(1ll<<(b+1)));
			}
		}
	} else {
		int b = 0;
		while((1ll<<b) != x) b++;
		if(b%2){
			if(ans[b]){
				ans[b] = 0;
			} else {
				upd(-(1ll<<b));
				upd(1ll<<(b+1));
			}
		} else {
			if(ans[b]){
				ans[b] = 0;
				upd(1ll<<(b+1));
			} else {
				ans[b] = 1;
			}
		}
	}
}
int main(){
	int x; cin >> x;
	int sign = x < 0 ? -1 : 1;
	x = abs(x);
	for(int i = 35; i >= 0; i--){
		if(x&(1ll<<i)) upd((1ll<<i)*sign);
	}
	int some = 0;
	for(int i = 35; i >= 0; i--){
		if(some || i == 0) cout << ans[i];
		else if(ans[i]){
			cout << ans[i];
			some = 1;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static int W;
    private static int H;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        int[][] s = new int[H + 2][W + 2];
        int count = 0;
        for (int row = 1; row <= H; row++) {
            String cur = sc.next();
            for (int col = 1; col <= W; col++) {
                char temp = cur.charAt(col - 1);
                if (temp == '.') {
                    s[row][col] = 1;
                    count++;
                }
            }
        }
        int res = bfs(s);
        if (res == -1) System.out.println(-1);
        else System.out.println(count - res);
    }
    static int bfs(int[][] s) {
        boolean[][] record = new boolean[H + 2][W + 2];

        int count = 1;
        LinkedList<int[]> cur = new LinkedList<>();
        LinkedList<int[]> next = new LinkedList<>();
        cur.add(new int[]{1, 1});
        while (cur.size() > 0) {
            int[] now = cur.remove();
            if (now[0] == H && now[1] == W) return count;
            if ((!record[now[0]][now[1]]) && s[now[0]][now[1]] != 0) {
                record[now[0]][now[1]] = true;
                next.add(new int[]{now[0] - 1, now[1]});
                next.add(new int[]{now[0] + 1, now[1]});
                next.add(new int[]{now[0], now[1] - 1});
                next.add(new int[]{now[0], now[1] + 1});
            }
            if (cur.size() == 0) {
                count++;
                cur = next;
                next = new LinkedList<>();
            }
        }
        return -1;
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

ll num[55][2],point[55][2];

int main(void)
{
    ll m,n,i,j,k=1,d,sum=0;
    string s;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>k>>d;
        num[i][0]=k;
        num[i][1]=d;
    }
    for(i=0;i<m;i++)
    {
        cin>>k>>d;
        point[i][0]=k;
        point[i][1]=d;
    }
    for(i=0;i<n;i++)
    {
        sum=d=k=0;
        for(j=0;j<m;j++)
        {
            k=abs(num[i][0]-point[j][0])+abs(num[i][1]-point[j][1]);
            if(!sum)
                sum=k;
            else if(k<sum)
            {
                d=j;
                if(!k) break;
                sum=k;
            }
        }
        cout<<d+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    cout << (N + 1) / 2  << endl;
    return 0;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n;
string s;
int a[312345], b[312345];

int main()
{
    cin >> n >> s;
    string rs = s;
    reverse(ALL(rs));
    int ans = INF;
    REP(i, n - 1)
    {
        a[i + 1] = a[i];
        b[i + 1] = b[i];
        if (s[i] == 'W')
        {
            a[i + 1]++;
        }
        if (rs[i] == 'E')
        {
            b[i + 1]++;
        }
    }
    REP(i, n)
    {
        ans = min(ans, a[i] + b[n - 1 - i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3332
N = int(input())

robots = []
for _ in range(N):
    robots.append(tuple(map(int, input().split())))
robots.sort(key=lambda x: x[0] + x[1])

ans = 0
tmp = -float('inf')
for x, l in robots:
    if tmp <= x - l:
        ans += 1
        tmp = x + l
print(ans)


Measured memory_bytes: 21348
<?php
        $n = trim(fgets(STDIN));
        $k = trim(fgets(STDIN));
        $x = trim(fgets(STDIN));
        $y = trim(fgets(STDIN));
        if($n>$k){
            echo $k*$x + ($n-$k)*$y;
        } else {
            echo $n*$x;
        }
?>  

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


#define int long long 

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n; bitset <10001> dp;
	dp.set(0);
	for(int i = 1; i <= n; i++) {
		int x; cin >> x;
		dp |= dp << x;
	}
	int ans = 0;
	for(int i = 1; i <= 10000; i++) if(i % 10 && dp[i]) {
		ans = i;
		//break;
	}

	cout << ans << endl;

}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int a, b, c;
	string s, t;

	cin >> s;
	if(s=="Sunny")
		cout << "Cloudy";
	if (s == "Cloudy")
		cout << "Rainy";
	if (s == "Rainy")
		cout << "Sunny";
	
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

const int NV=202020;
int N;
vector<int> E[NV];
int ret;

int dfs(int cur,int pre) {
	int cnt[32]={};
	int mi=-1;
	int mask=0,i;
	FORR(r,E[cur]) if(r!=pre) {
		int tr = dfs(r,cur);
		mask |= tr;
		FOR(i,30) if(tr&(1<<i)) {
			cnt[i]++;
			if(cnt[i]>=2) mi=max(mi,i);
		}
	}
	mi++;
	while(cnt[mi]) mi++;
	mask |= 1<<mi;
	
	ret=max(ret,mi);
	
	mask &= ~((1<<mi)-1);
	return mask;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	dfs(0,-1);
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 22912
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
int main() {
	int n, sum;
	cin >> n;
	sum = 0;
	while (1)
	{
		sum += (n % 10);
		n /= 10;
		if (n < 10) {
			sum += n;
			break;
		}
	}
	if (sum == 1) {
		cout << 10;
	}
	else {
		cout << sum;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        
	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        int Q = sc.nextInt();
	        long[][] m1 = new long[N][N];
	        long[][] m2 = new long[N][N];
	        
	        for(long i=0;i<M;i++) {
	        	int l = sc.nextInt()-1;
	        	int r = sc.nextInt()-1;
	        	m1[l][r]++;
	        }
	        
	        for(int i=0;i<N;i++) {
	        	for(int j=0;j<N;j++) {
	        		for(int k=i;k>=0;k--) {
	        			m2[k][j]=m2[k][j]+m1[i][j];
	        		}
	        	}
	        }
	        for(int i=0;i<N;i++) {
	        	for(int j=1;j<N;j++) {
	        		m2[i][j]=m2[i][j]+m2[i][j-1];
	        	}
	        }
	        
	        long[] ans = new long[Q];
	        for(int i=0;i<Q;i++) {
	        	ans[i]=m2[sc.nextInt()-1][sc.nextInt()-1];
	        }
	        		
	        for(int i=0;i<Q;i++) {
	        	System.out.println(ans[i]);
	        }
	        
		 }

	}

Measured memory_bytes: 65464
n, m, q = gets.chomp.split(' ').map(&:to_i)
a, b, c, d = [], [], [], []
q.times do
  tmp = gets.chomp.split(' ').map(&:to_i)
  a.append(tmp[0] - 1)
  b.append(tmp[1] - 1)
  c.append(tmp[2])
  d.append(tmp[3])
end

answer = 0
(1..m).to_a.repeated_combination(n).each_with_index do |array|
  s = (0...q).select { |i| array[b[i]] - array[a[i]] == c[i] }.map { |i| d[i] }.sum
  answer = s if s > answer
end

puts answer

Measured memory_bytes: 14548
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

const MODULO: i64 = 1_000_000_007;

fn main() {
  input! {
    n: usize,
    k: usize,
    aa: [usize; n]
  }
  let mut dp = vec![vec![0i64; k+1]; 2];
  dp[0][0] = 1;
  for (i, &a) in aa.iter().enumerate() {
    dp[(i+1)%2][0] = 1;
    for c in 0 .. k {
      dp[(i+1)%2][c+1] = (dp[(i+1)%2][c] + dp[i%2][c+1]) % MODULO;
      if let Some(d) = c.checked_sub(a) {
        dp[(i+1)%2][c+1] = (dp[(i+1)%2][c+1] - dp[i%2][d] + MODULO) % MODULO;
      }
    }
  }
  println!("{}", dp[n%2][k]);
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    vector<int> x{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};

    int k;  cin >> k;
    cout << x[k-1] << endl;


    return 0;

}


Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;

template<class T>
using vec2d = std::vector<std::vector<T>>;


template<class T>
vec2d<T> makeVec2d(const int n1, const int n2, const T initValue) {
  return vec2d<T>(n1, vec<T>(n2, initValue));
}


#define FOR(i, n) for (int i = 0; i < (n); ++i)
#define FORA(i, a, n) for (int i = (a); i < (n); ++i)


#define all(c) c.begin(), c.end()


typedef int64_t i64;


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto a = next<int>(in);
  auto x = next_vec<int>(in, n);
  int sum = accumulate(all(x), 0);

  vec2d<int64_t> dp = makeVec2d<int64_t>(sum + 1, n + 1, 0);
  vec2d<int64_t> nxt = makeVec2d<int64_t>(sum + 1, n + 1, 0);
  dp[0][0] = 1;

  FOR(i, n) {
    FOR(s, sum + 1) {
      FOR(j, n) {
        if (dp[s][j]) {
          nxt[s + x[i]][j + 1] += dp[s][j];
          nxt[s][j] += dp[s][j];
        }
      }
    }
    dp = nxt;
    nxt = makeVec2d<int64_t>(sum + 1, n + 1, 0);
  }

  i64 res = 0;
  FOR(s, sum + 1) {
    FORA(j, 1, n + 1) {
      if (s == a * j) {
        res += dp[s][j];
      }
    }
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 3536
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!
typedef struct{
    ll id; ll num;
}stud;

int cmp(const void *a, const void *b){
    ll A=((stud *)a)->num, B=((stud *)b)->num;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート1,2,....9
}

int main(void){
    ll N, x;
    stud A[100100];
    scanf("%lld", &N);
    rep(i, N) {
        scanf("%lld", &x);
        A[i].id = i+1;
        A[i].num = x;
    }
    qsort(A, N, sizeof(stud), cmp);
    rep(i, N) printf("%lld ", A[i].id);
    return 0;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};
 
// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ---------------------------------------------------------------------------

int main(){
  ll N,p;
  cin >> N >> p;
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  if(p == 2 || p == 5){
    ll ans = 0;
    for(int i=0; i<N; i++){
      if((S[i]-'0')%p== 0){
        ans += N-i;
      }
    }
    cout << ans << endl;
    return 0;
  }
  ll ten = 1;
  vector<ll> sum(N+1, 0);
  for(int i=0; i<N; i++){
    ll a = ((S[i] - '0') * ten)%p;
    sum[i+1] = (sum[i] + a)%p;
    ten *= 10;
    ten %= p;
  }
  ll ans = 0;
  vector<ll> cnt(p,0);
  for(int i=0; i<=N; i++){
    ans += cnt[sum[i]];
    cnt[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2180
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    //let n = input.trim().parse::<i32>();

    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let a = input.split_whitespace().map(|w| w.parse::<i32>().unwrap()).collect::<Vec<_>>();
    let min = a.iter().min().unwrap();
    let max = a.iter().max().unwrap();
    let sum = a.iter().map(|&a| a as i64).sum::<i64>();
    println!("{} {} {}", min, max, sum);
}



Measured memory_bytes: 5044
n,y=map(int,input().split())
def money(n,y):
    for i in range(n+1):
        if y-10000*i<0:
            continue
        for j in range(n-i+1):
            if y-10000*i-5000*j<0:
                continue
            k=n-i-j
            if 10000*i+5000*j+1000*k==y:
                print(i,j,k)
                return
    print("-1 -1 -1")
money(n,y)

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

int main() {
	
	int n;
	cin >> n;
	
	char ans[100];
	int digit;
	ll max_num, min_num;
	if(n == 0){
		puts("0");
		return 0;
	}else if(n > 0){
		// positive
		digit = 1;
		max_num = 1;
	}else{
		// negative
		n *= -1;
		digit = 2;
		max_num = 2;
	}
	while(max_num < n){
		min_num = max_num;
		digit += 2;
		max_num += 1LL << (digit - 1);
	}
	ans[0] = '1';
	for(int i = 1; i < digit; i++){
		int mid = (max_num + min_num) / 2;
		if(n <= mid){
			ans[i] = (i % 2 == 0) ? '0' : '1';
			max_num = mid;
		}
		else{
			ans[i] = (i % 2 == 0) ? '1' : '0';
			min_num = mid;
		}
	}
	rep(i, digit){
		printf("%c", ans[i]);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384