akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string S; cin >> S;
    int size_of_s = S.size();
    for(int i=size_of_s-1;i>=0;i-=2){
        S.pop_back();
        S.pop_back() ;
        int x = S.size()/2;
        if (S.substr(0,x)==S.substr(x,x)){
            cout << 2*x << endl;
            return 0;
        }
    }
}


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

namespace A___Remaining_Balls
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            string s = input1[0];
            string t = input1[1];

            int[] input2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = input2[0];
            int b = input2[1];

            string u = Console.ReadLine();

            if(u == s)
            {
                a--;
            }
            else
            {
                b--;
            }

            Console.WriteLine(a + " " + b);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n,k;
	cin>>n>>k;
	int a[n+1],dp[k+1][n+1],any_one[k+1];
	init(dp,0);
	init(any_one,0);
	loop(i,1,n+1) cin>>a[i];
	loop(i,1,k+1)
		loop(j,1,n+1)
		{
			if(i - a[j] >= 0 && any_one[i-a[j]] == 0) dp[i][j] = 1;
			any_one[i] |= dp[i][j];
		}
	if(any_one[k]) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;		
}

Measured memory_bytes: 80000
import java.util.Scanner;

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

	//Scanner??????????????????????????????scan?????????
	Scanner scan = new Scanner(System.in);

	//??????A?????\???????´?????????°n???????????????
	int n = scan.nextInt();
	
	//??????A???????????????
	int[] A = new int[n];
	for(int i = 0; i < n; i++){
	    A[i] = scan.nextInt();
	}

	//??????M?????\???????´?????????°q???????????????
	int q = scan.nextInt();

	//??????M???????????????
	int[] M = new int[q];
	for(int i = 0; i < q; i++){
	    M[i] = scan.nextInt();
	}

	for(int i = 0; i < q; i++){
	    if(solve(0,M[i], n, A)) System.out.println("yes");
	    else System.out.println("no");
	}
			       

    }

    public static boolean solve(int i, int m, int n, int[] A){
	
	if(m == 0) return true;
	if(i >= n) return false;

	boolean ans = solve(i + 1, m, n, A) || solve(i + 1, m - A[i], n, A);
	return ans;
    }
}

Measured memory_bytes: 26804
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var b = readLine()!!.split(" ").map { it.toInt()}.toMutableList()

    var list = mutableListOf<Int>()
    for (i in 0 until n)list.add(-1)
    var p = -1
    for (i in 0 until n - 1){
        for (j in 0 until n-1){
            if (b[j] == b.min()) {
                p = j
                break
            }
        }

        if (list.get(p) == -1)list.set(p, b[p])
        if (list.get(p+1) == -1)list.set(p+1, b[p])
        b[p] = 1000000
    }
    println(list.sum())
}

Measured memory_bytes: 36036
fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let line = &input();
    let seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    triangle(seg);
}

fn triangle(seg: Vec<i32>) {
    let (W, H, x, y, r) = (seg[0], seg[1], seg[2], seg[3], seg[4]);
    let s = if x < r || x + r > W || y < r || y + r > H {
        "No"
    } else {
        "Yes"
    };
    println!("{}", s);
}


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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a, gray, brown, green, cyan, blue, yellow, orange, red, any;
  gray = brown = green = cyan = blue = yellow = orange = red = any = 0;
  cin >> n;
  while (n--) {
    cin >> a;
    if (a < 400) gray=1;
    else if (a < 800) brown=1;
    else if (a < 1200) green=1;
    else if (a < 1600) cyan=1;
    else if (a < 2000) blue=1;
    else if (a < 2400) yellow=1;
    else if (a < 2800) orange=1;
    else if (a < 3200) red=1;
    else any++;
  }
  int color_count = gray+brown+green+cyan+blue+yellow+orange+red;
  cout << max(1, color_count) << ' ' << color_count+any << ende;
  return 0;
}


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

long long factorial( long long n )
{
    if( n == 1 )
        return 1;
    else
        return n * factorial( n - 1 );
}

int main()
{
    long long n;

    cin >> n;

    cout << factorial(n) << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define MOD (long long)(1e9 + 7)
using namespace std;

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

long long n;
vector<long long> a;
vector<long long> cnt;

ModInt<MOD> solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

ModInt<MOD> solve() {
  ModInt<MOD> ans = 0;
  cnt.assign(70, 0);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 61; ++j)
      if((a[i] >> j) & 1) ++cnt[j];
  for(int i = 0; i < 61; ++i) {
    ModInt<MOD> now = (long long)(1LL << i);
    now *= cnt[i] * (n - cnt[i]);
    ans += now;
  }
  return ans;
}

Measured memory_bytes: 2560
uses math;
var
        f:text;
        x,y,h: ansistring;
        g: array [0..3000,0..3000] of longint;
        i,j,s,t,a: longint;

begin

        readln ( x);
        readln ( y);

        fillchar(g, sizeof (g),0);

        for i:=1 to length(x) do
        for j:=1 to length(y) do
        if x[i] = y[j] then g[i,j]:= g[i-1,j-1] + 1
        else g[i,j]:= max(g[i-1,j], g[i, j-1]);


        a:=0;
        i:= length (x); j:= length (y);
        while (i>0) and (j>0) do
        begin

                if  x[i] = y[j] then
                begin
                        h:= x[i] + h;
                        dec(i); dec(j);
                end
                else
                if g[i-1,j] > g[i, j-1] then dec (i) else dec (j);
        end;

        writeln (h);
        readln;

end.

Measured memory_bytes: 35456
#include<iostream>
using namespace std;
int main(void) {
    int n, number, cards[4][13] = {};
    char suit, suits[] = {'S', 'H', 'C', 'D'};
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> suit >> number;;
        int j;
        switch (suit) {
            case 'S':
                j = 0;
                break;
            case 'H':
                j = 1;
                break;
            case 'C':
                j = 2;
                break;
            case 'D':
                j = 3;
                break;
        }
        cards[j][number - 1] = 1;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (!cards[i][j]) {
                cout << suits[i] << " " << (j + 1) << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

class Main {
    public static void insertsort(int[] A, int n) {
	for (int i = 0; i < n; i++) {
	    int v = A[i];
	    int j = i-1;
	    while (j >= 0 && A[j] > v) {
		A[j+1] = A[j];
		j--;
	    }
	    A[j+1] = v;
	    for (int k = 0; k < n; k++) {
		System.out.print(A[k]);
		if (k < n-1)System.out.print(" ");
		else System.out.print('\n');
	    }
	}
    }

    public static void main(String[] av) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] A = new int[n];

	for (int i = 0; i < n; i++) {
	    A[i] = sc.nextInt();
	}

	insertsort(A,n);
    }
}


Measured memory_bytes: 34208
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

long long int norm(const std::vector<int>& a, const std::vector<int>& b) {
	auto res = 0LL;
	for (auto i = 0; i < a.size(); ++i) {
		res += (a[i] - b[i]) * (a[i] - b[i]);
	}
	return res;
}
bool is_good_distance(const std::vector<int>& a, const std::vector<int>& b) {
	auto len_square = norm(a, b);
	auto sqrt = static_cast<long long int>(std::sqrt(len_square));
	return sqrt * sqrt == len_square || (sqrt + 1) * (sqrt + 1) == len_square;
}
int main() {
	int n, d; std::cin >> n >> d;
	std::vector<std::vector<int>> points(n, std::vector<int>(d));
	for (auto& point : points) {
		for (auto& x : point) std::cin >> x;
	}
	int count = 0;
	for (auto i = 0; i < n; ++i) {
		for (auto j = i + 1; j < n; ++j) {
			if (is_good_distance(points[i], points[j])) {
				++count;
			}
		}
	}
	std::cout << count << std::endl;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
using P = pair<int, int>;
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  vector<P> v(n);
  REP(i,n) {
    int first = in(), second = in();
    v[i] = P(first, second);
  }
  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }
  map<P, int> vector_mp;
  REP(i,n) {
    REP(j,n) {
      if(i == j) continue;
      int first_diff = v[j].first - v[i].first;
      int second_diff = v[j].second - v[i].second;
      ++vector_mp[P(first_diff, second_diff)];
    }
  }
  int most_occur = 0;
  for(auto& itr : vector_mp) {
    most_occur = max(most_occur, itr.second);
  }
  cout << n - most_occur;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#define W 21
#define H 21
int w,h;
char map[W][H];
int search(int s,int t){
	if(s<0||t<0||s>=h||t>=w ||map[s][t]=='#')return 0;
	int sum=1;
	map[s][t]='#';
	sum+=search(s-1,t);
	sum+=search(s,t+1);
	sum+=search(s+1,t);
	sum+=search(s,t-1);
	return sum;
}
int main(){
	int i,j;
	while(1){
		int st_w,st_h;
		scanf("%d %d\n",&w,&h);
		if(!w && !h)break;
		memset(map,' ',sizeof(map));
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf("%c",&map[i][j]);
				if(map[i][j]=='@'){
					st_w=j;st_h=i;
				}
			}
			scanf("\n");
		}
		printf("%d\n",search(st_h,st_w));
	}
	return 0;
}

Measured memory_bytes: 0
use std::io;

fn unbalanced_index(string: &String) -> Option<(usize, usize)> {
    let s = string.as_bytes();
    // println!("'{}': len = {}", string, s.len());
    for i in 0..(s.len() - 1) {
        // println!("'{}': i = {}", string, i);
        if s[i] == s[i + 1] {
            // println!("'{}': aa", string);
            return Some((i, i + 1));
        }
        if s.len() - 3 < i {
            // println!("'{}': eos", string);
            return None;
        }
        if s[i] == s[i + 2] {
            // println!("'{}': aXa", string);
            return Some((i, i + 2));
        }
    }
    return None;
}

fn is_unbalanced(s: &String) -> bool {
    match unbalanced_index(s) {
        Some((_, _)) => true,
        None => false,
    }
}

#[test]
fn test_is_unbalanced() {
    assert!(is_unbalanced(&"needed".to_string()));
    assert!(!is_unbalanced(&"atcoder".to_string()));
}

fn main() {
    let mut input = String::with_capacity(10002);
    io::stdin().read_line(&mut input).unwrap();
    match unbalanced_index(&input) {
        Some((a, b)) => println!("{} {}", a + 1, b + 1),
        None => println!("-1 -1"),
    }
}


Measured memory_bytes: 4352
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 04 04 2020

#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

void task()
{
    int n, m;
    long int sum=0;
    int value;

    cin>>n>>m;
    vector<int> ara(n);

    for(int K=0; K<n; K++){
        cin>>ara[K];
        sum += ara[K];
    }

    value= sum / (4*m);

    int count=0;
    for(int K=0; K<n; K++){
        if(sum%4==0 || sum%m==0){
            if(ara[K]>=value){
                count++;
            }
        }
        else{
            if(ara[K]>value){
                count++;
            }
        }
    }

    if(count>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    task();

    return 0;
}


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

int main()
{
    int n, q, num = 0;
    cin >> n >> q;
    vector<int> ac(n);
    char c = ' ', prev = ' ';
    for (int i = 0; i < n; i++)
    {
        cin >> c;
        if (prev == 'A' && c == 'C')
            num++;
        ac.at(i) = num;
        prev = c;
    }
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++)
        cin >> l.at(i) >> r.at(i);
    for (int i = 0; i < q; i++)
    {
        int out = ac.at(r.at(i) - 1) - ac.at(l.at(i) - 1);
        if (l.at(i) - 2 >= 0)
            if (ac.at(l.at(i) - 1) != ac.at(l.at(i) - 2))
                num--;
        cout << out << endl;
    }
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

#define MAX 12810

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

    int h, w, a[100][100], b[100][100];

    cin >> h >> w;

    REP(i, h)
    REP(j, w)
    cin >> a[i][j];

    REP(i, h)
    REP(j, w)
    cin >> b[i][j];

    static bool dp[82][82][MAX];

    memset(dp, 0, sizeof(dp));

    dp[0][0][0] = true;

    REP(i, h)
    REP(j, w)
    REP(k, MAX)
    {
        if (!dp[i][j][k])
            continue;

        dp[i][j + 1][k + abs(a[i][j] - b[i][j])] = true;
        dp[i][j + 1][abs(k - abs(a[i][j] - b[i][j]))] = true;

        dp[i + 1][j][k + abs(a[i][j] - b[i][j])] = true;
        dp[i + 1][j][abs(k - abs(a[i][j] - b[i][j]))] = true;
    }

    REP(k, MAX)
    if (dp[h - 1][w][k])
    {
        cout << k << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 84480
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	ifstream fin("Text.txt");
	ios_base::sync_with_stdio(false); cin.tie(0);

	ll i, j, q;
	ll n, m, p, k, t;
	ll a, b, c, d;
	ll x, y, z, l, r;
	ll one = 1, zero = 0, ans = 0;
	ll mod = 1000000007;
	string st1, st2, st3;
	char ch1, ch2, ch3;

	cin >> m;
	cout << 2 * 24 - m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define resort(v) sort((v).rbegin(), (v).rend())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*signed*/int main(void) {
    int N;
    cin >> N;
    for (int i = 1; i < 2 * N; i++) {
        if (0 <= i * 1.08 - N && i * 1.08 - N < 1) {
            cout << i << endl;
            break;
        }
        if (i == 2 * N - 1) {
            cout << ":(" << endl;
        }
    }
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
  cin >> n;
  vector<int> a(n+1, 0);
  rep(i, n) cin >> a[i+1];

  vector<int> ans(n+1, 0);
  int ball = 0;
  for(int i = n; i >= 1; --i){
    if(i * 2 > n){
      ans[i] = a[i];
      ball += a[i];
    }
    else{
      int index = i;
      while(index <= n){
        ans[i] += ans[index];
        index += i;
      }
      if(a[i] != (ans[i] & 1)){
        ans[i] = 1;
        ball++;
      }
      else{
        ans[i] = 0;
      }
    }
  }

  cout << ball << endl;
  for(int i = 1; i <= n; ++i){
    if(ans[i]){
      cout << i << " ";
    }
  }
  cout << endl;
	return 0;
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int a, b;
    cin >> a >> b;

    cout << (a ^ b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
    int cnt[26] = {0};

    char ch;

    while ((ch = getchar()) != EOF) {
        ch = tolower(ch);
        int i = 0;
        for (i = 0; i < 26; i++) {
            if (ch == alphabet[i]) {
                cnt[i]++;
                break;
            }
        }
    }

    int j;
    
    for (j = 0; j < 26; j++) {
        printf("%c : %d\n", alphabet[j], cnt[j]);
    }

    return 0;
}

Measured memory_bytes: 524
while(h=gets.split[1].to_i)>t=0
a=[]
m=(0...h).map{|i|(0...gets.size).map{|j|(d="WSEN".index$_[j])&&a<<[j,i,d]};$_}
while a[0]&&181>t+=1
n=a.map{|i,j,d|[[i,j-1,3],[i-1,j,0],[i,j+1,1],[i+1,j,2]].rotate(d).find{|e,f|m[f][e]!=?#&&a.all?{|k,l|k!=e||l!=f}}}
a=n.zip(a).map{|l,k|i,j,d=l;l ?n.all?{|e,f,g|i!=e||j!=f||d<=g}?l:k[0,2]+[d]:k}.reject{|i,j|m[j][i]==?X}
end
puts t>180?:NA:t
end

Measured memory_bytes: 6124
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> v;

  rep(i,n) {
    ll a;
    cin >> a;
    v.push_back(make_pair(a, 1));
  }
  rep(i,m) {
    ll b, c;
    cin >> b >> c;
    v.push_back(make_pair(c, b));
  }

  sort(v.begin(), v.end(), greater<>());
  ll ans = 0;
  ll count = 0;
  ll i = 0;

  while (count < n) {
    if (v[i].second <= n - count) {
      ans += v[i].second * v[i].first;
      count += v[i].second;
    } else {
      ans += (n - count) * v[i].first;
      count = n;
    }
    i++;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin>>s;
if(s.at(0)=='M'){
cout<<6<<endl;}
else if(s.at(0)=='F'){
cout<<2<<endl;}
else if(s.at(0)=='W'){
cout<<4<<endl;}
else if(s.at(1)=='A'&&s.at(2)=='T'){
cout<<1<<endl;}
else if(s.at(1)=='U'&&s.at(0)=='S'){
cout<<7<<endl;}
else if(s.at(1)=='U'&&s.at(0)=='T'){
cout<<5<<endl;}
else
cout<<3<<endl;}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; cin>>a>>b;
    if((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N=2e5+20;
int n,a[N],f[N],mx1,mx2;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]),f[a[i]]++;

	mx1=*max_element(a,a+n);
	if(f[mx1]>1)
	{
		for(int i=0;i<n;i++) printf("%d\n",mx1);
	}
	else
	{
		for(int i=mx1-1;mx2==0;i--)
			if(f[i]>0) mx2=i;
		for(int i=0;i<n;i++)
			if(a[i]==mx1) printf("%d\n",mx2);
			else printf("%d\n",mx1);
	}
}

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

using namespace std;
const int N = 2e5 + 100;

int n, Maxn, a[N];
long long ans = 0;

int main(){ 
	scanf("%d", &n); Maxn = 0; ans = 0;
	for(int i = 1;i <= n; ++i) {
		scanf("%d", &a[i]);
		if(a[i] < Maxn) 
			ans += Maxn - a[i];
		else
			Maxn = a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	priority_queue<long long> que;
	rep(i, N) {
		long long A;
		cin >> A;
		que.push(A);
	}
	
	rep(i, M) {
		long long t = que.top();
		que.pop();
		que.push(t / 2);
	}

	long long ans = 0;
	while (!que.empty()) ans += que.top(), que.pop();
	
	cout << ans;
}



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

int main()
{
	int n,j = 0,l = 0;
	cin >> n;
	int* a = new int[n];
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		if(a[i] % 2 == 1)
		j++;
		if(a[i] % 4 == 0)
		l++;
	}
	if(l >= j || l >= n / 2)
	cout << "Yes" << endl;
    else
    cout << "No" <<endl;
    delete []a;
    return 0;
}

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

int main(){
    int H, W, ch, cw, dh, dw;
    int dH[] = {1,-1,0,0}, dW[] = {0,0,1,-1};
    cin >> H >> W >> ch >> cw >> dh >> dw;
    vector<vector<char>> S(H+1, vector<char>(W+1));
    vector<vector<int>> ans(H+1, vector<int>(W+1, -1));
    queue<int> Qh, Qw;
    for(int i = 1; i <= H; ++i){
        for(int j = 1; j <= W; ++j){
            cin >> S[i][j];
        }
    }
    Qh.push(ch); Qw.push(cw);
    int n = 0;
    ans[ch][cw] = 0;
    while(!Qh.empty()){
        queue<int> buf_h, buf_w;
        while(!Qh.empty()){
            int h = Qh.front(), w = Qw.front();
            buf_h.push(h), buf_w.push(w);
            Qh.pop(); Qw.pop();
            for(int i = 0; i < 4; ++i){
                int y = dH[i], x = dW[i];
                if(1<=h+y && h+y<=H && 1<=w+x && w+x<=W && S[h+y][w+x]=='.' && ans[h+y][w+x]==-1){
                    ans[h+y][w+x] = n;
                    Qh.push(h+y); Qw.push(w+x);
                }
            }
        }
        ++n;
        while(!buf_h.empty()){
            int h = buf_h.front(), w = buf_w.front();
            buf_h.pop(); buf_w.pop();
            for(int i = -2; i <= 2; ++i){
                for(int j = -2; j <= 2; ++j){
                    if(1<=h+i && h+i<=H && 1<=w+j && w+j<=W && S[h+i][w+j]=='.' && ans[h+i][w+j]==-1){
                        ans[h+i][w+j] = n;
                        Qh.push(h+i); Qw.push(w+j);
                    }
                }
            }
        }
    }
    cout << ans[dh][dw] << endl;
    return 0;
}

Measured memory_bytes: 8564
#include <iostream>
#include <vector>
using namespace std;
#define SIZE 100000
int N;
void solve()
{
    vector < int > tmp;
    long i,res=0;
    for (i=0;i<=SIZE;i++)
        tmp.push_back(0);
    while(N--)
    {
        long l,r;
        cin>>l>>r;
        for (i=l;i<=r;i++)
            tmp[i]=1;
    }
    for (i=1;i<=SIZE;i++)
        if (tmp[i]) res++;
    cout<<res<<endl;
}
int main()
{
    while(cin>>N)
        solve();
}

Measured memory_bytes: 892
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoderABC086
{
    class Program
    {
        public static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            bool flag = true;
            Dictionary<char, char> dict =  new Dictionary<char, char>();
            Dictionary<char, char> dict2 =  new Dictionary<char, char>();
            for (int i = 0; i < S.Length; i++)
            {
                if (dict.ContainsKey(S[i]) && dict[S[i]] != T[i])
                {
                    flag = false;
                    break;
                }
                if (dict2.ContainsKey(T[i]) && dict2[T[i]] != S[i])
                {
                    flag = false;
                    break;
                }
                if (!dict.ContainsKey(S[i])) dict[S[i]] = T[i];
                if (!dict2.ContainsKey(T[i])) dict2[T[i]] = S[i];
            }
            Console.WriteLine((flag)? "Yes": "No");
        }
    }
}


Measured memory_bytes: 14688
x,y=map(int,input().split())
if(y==0):
    print(x)
else:
    s=list(map(int,input().split()))
    i=0
    while(1):
        if(abs(x-i) not in s):
            print(abs(x-i))
            break
        if(abs(x+i) not in s):
            print(abs(x+i))
            break
        
        i+=1
            
            
        

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
//cin.tie(NULL);
   long long int n,sum=0,curr_sum=0,ans=0,t;
   cin>>n;
   for(long long int i=2;i<=n;i++)
    for(long long int j=1;j<=n;j++)
    for(long long int k=1;k<=n;k++)
   {
       t=__gcd(i,j);t=__gcd(t,k);
       ans+=t;
   }
   ans+=(n*n);
   cout<<ans<<endl;
}


Measured memory_bytes: 3648
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int i;
        int sum;
        while (true) {
            str = br.readLine();
            if (str.equals("0")) break;
            sum = 0;
            for (i = 0; i < str.length(); i++) {
                sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 24636
import sys
import math
if sys.platform =='ios':
  sys.stdin=open('Untitled.txt')
input = sys.stdin.readline


N = int(input())
dp = [float("INF") for _ in range(N+1)]
dp[0] = 0

MAX_JOU = int(math.ceil(math.log(N, 6)))

a_six = [6**x for x in range(MAX_JOU+1)]
a_nine = [9**x for x in range(MAX_JOU+1)]

for i in range(N+1):
    if (i-1 >= 0):
            dp[i] = min(dp[i], dp[i-1]+1)
    for six in a_six:
        if (i-six >= 0):
            dp[i] = min(dp[i], dp[i-six]+1)
    for nine in a_nine:
        if (i-nine >= 0):
            dp[i] = min(dp[i], dp[i-nine]+1)

print(dp[-1])

Measured memory_bytes: 47136
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 998244353;

string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 3;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n;
    cin >> n;
    vvi a(2, vi(n));
    cin >> a;
    
    vvi dp(1<<n, vi(51, INF));
    dp[0].assign(51, 0);
    REP(mask, 0, 1<<n) REP(u, 1, 51) {
        REP(card, 0, n) if (mask>>card&1LL) {
            int oldmask = mask ^ 1LL<<card;
            int cardval = a[(__builtin_popcountll(oldmask)+card)%2][card];
            if (cardval <= u) {
                int cost = 0;
                REP(i, 0, card) if (!(mask>>i&1LL)) ++cost;
                dp[mask][u] = min(dp[mask][u], cost + dp[oldmask][cardval]);
            }
        }
    }
    int res = dp[(1<<n)-1][50];
    if (res==INF) cout << -1;
    else cout << res;
}

Measured memory_bytes: 114944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    string s; cin>>s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '7') {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#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)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

int h, w;
vector<string> s;

const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};

vector<vector<int>> bfs(int i, int j) {
    auto dist = make_vec<int>(h, w);
    fill_v<int>(dist, -1);
    dist[i][j] = 0;
    using P = pair<int, int>;
    queue<P> que;
    que.push(P(i, j));
    while (!que.empty()) {
        P v = que.front();
        que.pop();
        rep(k, 4) {
            int ni = v.first + di[k], nj = v.second + dj[k];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (s[ni][nj] == '#') continue;
            if (dist[ni][nj] >= 0) continue;
            dist[ni][nj] = dist[v.first][v.second] + 1;
            que.push(P(ni, nj));
        }
    }
    return dist;
}

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

    cin >> h >> w;
    s.resize(h);
    rep(i, h) cin >> s[i];

    int ans = 0;
    rep(i, h) rep(j, w) {
        if (s[i][j] == '.') {
            auto res = bfs(i, j);
            rep(k, h) rep(l, w) chmax(ans, res[k][l]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3676
s = gets().to_s.chomp!.split("").map(&:to_s).reverse!

beki = Array.new(10){}
10.times do |i|
	beki[i] = 2 ** i
end

sum = 0
0.upto(s.length - 1) do |i|
	tmp = s[i].to_i
	0.upto(i) do |j|
		k = (j == i) ? j : j + 1
		sum += tmp * beki[s.length - k - 1]
		tmp *= 10
	end
end

puts sum

Measured memory_bytes: 1788
// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

void solve() {
  int n;cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  loop(i,0,n) A[i]--;
  int cur = 0;
  int count = 0;
  loop(i,0,n) {
    cur = A[cur];
    count++;
    if (cur == 1) {
      cout << count << endl;
      return;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3792
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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 powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int primeNumber(const int n) {
	//上から確認する
	for (int N = n; N >= 1; N--) {

		bool isPrime = true;
		//素数判定 i < sqrt(N)+1
		for (int i = 2; i * i <= N; i++) {
			if (N % i == 0) {
				isPrime = false;
				break;
			}
		}
		//もし素数なら
		if (isPrime) {
			return N;
		}
	}
}

int main() {
	int i, j, k;
	
	int N;
	cin >> N;
	vector<int> A(N);
	ll sum = 0;
	rep(i, 0, N) {
		cin >> A[i];
		sum ^= A[i];
	}
	rep(i, 0, N) {
		cout << (sum ^ A[i]) << " ";

	}

	return 0;
}

Measured memory_bytes: 3972
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump_line(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

ll dp[51][51][2501];

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

	int n,a; cin >> n >> a;
	int x[n];
	rep(i,n) cin >> x[i];

	rep(i,n){
		dp[i][1][x[i]]++;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=i+1;j++){
			for(int k=0;k<=2500;k++){
				dp[i][j][k] += dp[i-1][j][k];
				if(k-x[i] >= 1) dp[i][j][k] += dp[i-1][j-1][k-x[i]];
			}
		}
	}

	ll ans=0;

	for(int j=1;j<=n;j++){
//		cout << j << " " << dp[n-1][j][j*a] << "\n";
		ans += dp[n-1][j][j*a];
	}
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 48128
N = int(input())
H = list(map(int, input().split()))
ans = True
b = 999999
if ans == True:
  for i, x in enumerate(H[::-1]):
    if i != 0:
      if x <= b:
        b = x
      elif (x-1) <= b:
        b = x-1
      else:
        ans = False
        break
    else:
      b = x
if ans:
  print("Yes")
else:
  print("No")

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    map<int, int> even;
    map<int, int> odd;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(i%2==0){
            if(even.find(v[i])==even.end())even[v[i]]=1;
            else even[v[i]]++;
        }
        else{
            if(odd.find(v[i])==odd.end())odd[v[i]]=1;
            else odd[v[i]]++;
        }
    }
    int e1=0,e2=0,o1=0,o2=0,ko=0,ke=0;
    for(auto itr=even.begin();itr!=even.end();itr++){
        if(itr->second>=e1){
            e2=e1;
            e1=itr->second;
            ke=itr->first;
        }
        else if(itr->second>e2){
            e2=itr->second;
        }
    }
    for(auto itr=odd.begin();itr!=odd.end();itr++){
        if(itr->second>=o1){
            o2=o1;
            o1=itr->second;
            ko=itr->first;
        }
        else if(itr->second>o2){
            o2=itr->second;
        }
    }
    int half=n/2;
    //cout<<e1<<" "<<e2<<" "<<o1<<" "<<o2<<endl;
    if(ke!=ko)cout<<half-e1+half-o1<<endl;
    else{
        cout<<min(half-e1+half-o2,half-e2+half-o1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	quick
	// Bahut gussa aya mujhe YE QUESTION BANAKE @!@
	ll t;t=1;
    // cin >> t;
	while(t--)
	{
		ll a; cin >>a;
		cout<<a+a*a+a*a*a<<endl;
	}
}

Measured memory_bytes: 3648
sum = 0
a, b = (int(i) for i in input().split())  
t = [int(input()) for j in range(a)] 
for k in range (a):
    b = b - t[k]
    sum = sum + 1
t.sort()
if b < t[0]:
    print(sum)
else:
    z = b // t[0]
    sum = sum + z
    print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace  std ;
#define       sf scanf
#define      pf printf
#define   pb push_back
#define   mp make_pair
typedef long long  ll;
const int MOD = 1e9+7;
const int   N = 1e6+7;
const ll  INF =  1e18;

#define nr()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll ar[5000005],br[500005];

int32_t main()
{
    nr();
    ll T, n, nb=0, r;
    cin >> n >> r;
    if(n>=10)
        cout<<r<<endl;
    else
        cout<<(100*(10-n))+r<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll a,b;
    cin>>a>>b;
    putout(a*b);
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(){
	int a,b;
	cin>> a>> b;
	if(a<b){
		cout<< "a < b"<<endl;
	}
	else if(a>b){
		cout<< "a > b"<<endl;
	}
	else if(a==b){
		cout<< "a == b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int N;
long long K;

int main() {
    cin >> N >> K;
    vector<bool> flag(40);
    map<int, int> mp;
    K++;
    for (int i = 0; i < 40; i++) {
        if ((1ll << i) & K) {
            flag[i] = true;
        }
    }
  
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        long long a;
        cin >> a;
        int j = 0;
        while (a > 0) {
            if (a & 1) {
                mp[j]++;
            }
            j++;
            a >>= 1;
        }
    }
    long long ans = 0;
    for (int j = 0; j < 40 ; j++) {
        if (!flag[j]) continue;
        long long tmp = 0;
        long long p = 1;
        for (int i = 0; i < 40; i++) {
            bool f = (i < j)? true: flag[i];
            if (i == j) f = false;
            if (mp[i] * 2 < N && f) {
                tmp += p * (N - mp[i]);
            } else {
                tmp += p * mp[i];
            }
            p *= 2;
        }
        ans = max(tmp, ans);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1024