akhauriyash/Code-Regression huggingface dataset:
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

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

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

void func(void)
{
//DEBUG_OUT("----\n");
    int32 N;
    cin >> N;

    int32 h, n, w;
    double NN = 4.0/(double)N;
    vector<double> hh(3500), nn(3500), ww(3500);
    for(int32 i=1; i<3500; i++){
        double ii = 1.0/(double)i;
        hh[i] = nn[i] = ww[i] = ii;
    }
    for(h=1; h<3500; h++){
        DEBUG_OUT("\rh=%d", h);
        for(n=1; n<3500; n++){
            double hn = hh[h]+nn[n];
            if(NN > (hn+1.0)){ continue; }
            if(NN < hn){ continue; }
            double w_ = 1.0/(NN - hn);
            int32 intw = (int32)w_;
            double w__ = w_ - intw;
            if(w__ < 0.0000001 && intw > 0){
                DEBUG_OUT("\n----\n");
                cout << h << " " << n << " " << intw << endl;
                return;
            }
        }
    }
    DEBUG_OUT("no ans\n");
    return;
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String _n = sc.nextLine();
        char b = 1;
        int num = -1;
        for (char c : _n.toCharArray()){
            if (c != b) {
                b = c;
                num += 1;
            }
        }
        System.out.println(num);

    }
}


Measured memory_bytes: 14152
#include <bits/stdc++.h>
using namespace std;
struct dot {
	double x;
	double y;
};

int koch(int n, dot p1, dot p2) {
	double pi = 3.141592653;
	dot u, s, t;
	if (n==0) {
		return 0;
	}
	
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;
	u.x = ((t.x - s.x) * cos(pi / 3) - (t.y - s.y) * sin(pi / 3) + s.x);
	u.y = ((t.x - s.x) * sin(pi / 3) + (t.y - s.y) * cos(pi / 3) + s.y);


	koch(n-1, p1, s);
	cout << s.x << " "<< s.y<<endl;
	koch(n-1, s, u);
	cout << u.x << " " << u.y<<endl;
	koch(n-1, u, t);
	cout << t.x << " " << t.y<<endl;
	koch(n-1, t, p2);	
	return 0;

}


int main() {
	int n;
	dot begin = { 0,0 };
	dot end = { 100,0 };

	cin >> n;
	cout << begin.x <<" "<< begin.y << endl;
	koch(n, begin,end);
	cout << end.x << " " << end.y << endl;
	
	return 0;
}



Measured memory_bytes: 3244
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class union_find_t {
public:
  union_find_t(int T) : T_(T), parent_(new int[T]), rank_(new int[T]), count_(new int[T]) {
    for (int i = 0; i < T_; i++) {
      parent_[i] = i;
      rank_  [i] = 0;
      count_ [i] = 1;
    }
  };

  ~union_find_t() {
    delete[] parent_;
    delete[] rank_;
    delete[] count_;
  };

public:
  int find(int x) {
    if (parent_[x] == x) {
      return x;
    }
    else {
      return parent_[x] = find(parent_[x]);
    }
  };

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y)
      return;

    if (rank_[x] < rank_[y]) {
      parent_[x]  =        y;
      count_ [y] += count_[x];
    }
    else {
      parent_[y]  =        x;
      count_ [x] += count_[y];

      if (rank_[x] == rank_[y])
        rank_[x] ++;
    }
  };

  bool same(int x, int y) {
    return find(x) == find(y);
  };

public:
  int count(int x) {
    return count_[find(x)];
  };

public:
  int T_;

  int* parent_;
  int* rank_;
  int* count_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, A[111111], B[111111];

  long long c = 0;

  std::cin >> N >> M;

  for (int i = 0; i < M; i ++) {
    std::cin >> A[i] >> B[i];

    A[i] --;
    B[i] --;
  }

  union_find_t uf(N);

  std::vector<long long> a;

  a.reserve(M);

  for (int i = M - 1; i >= 0; i --) {
    a.push_back(c);

    if (! uf.same(A[i], B[i]))
      c += 1LL * uf.count(A[i]) * uf.count(B[i]);
    
    uf.unite(A[i], B[i]);
  }

  std::reverse(ALL(a));

  for (const auto& i : a)
    std::cout << 1LL * N * (N - 1) / 2 - i << std::endl;

  return 0;
}


Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a <= 5)
    {
        cout << 0;
    }
    else if(a >= 6 && a <= 12)
    {
        cout << b/2;
    }
    else
    {
        cout << b;
    }
    return 0;
}


Measured memory_bytes: 504
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-12;

class Compare {
  int monster_x;
  int monster_y;
public:
  Compare(int monster_x,int monster_y)
    : monster_x(monster_x), monster_y(monster_y) {}
  bool operator()(const P& ci,const P& cj) const{
    int dist_i = (ci.first - monster_x) * (ci.first - monster_x)
      + (ci.second - monster_y) * (ci.second - monster_y);
    int dist_j = (cj.first - monster_x) * (cj.first - monster_x)
      + (cj.second - monster_y) * (cj.second - monster_y);
    return dist_i < dist_j;
  }
};

class State{
  int x;
  int y;
  double dist;
};

bool dfs(int hero_x,
         int hero_y,
         double current_time,
         int S,
         int monster_x,
         int monster_y,
         const vector<P>& cristals){
  bool res = false;

  if(S == (1<<cristals.size()) - 1) return true;
  for(int i=0;i<cristals.size();i++){
    if(S & (1<<i)) continue;
    double add_time = sqrt((hero_x - cristals[i].first) * (hero_x - cristals[i].first)
                           + (hero_y - cristals[i].second) * (hero_y - cristals[i].second));
    
    double impurity_arrive_time = sqrt((monster_x - cristals[i].first) * (monster_x - cristals[i].first)
                                       + (monster_y - cristals[i].second) * (monster_y - cristals[i].second));
    if(current_time + add_time >= impurity_arrive_time){
      return false;
    }
    
    res |= dfs(cristals[i].first,cristals[i].second,current_time + add_time,
               S | (1<<i),monster_x,monster_y,cristals);
  }
  return res;
}

int main(){
  int total_cristals;
  int hero_x;
  int hero_y;
  int monster_x;
  int monster_y;
  while(~scanf("%d %d %d %d %d",
               &total_cristals,
               &hero_x,
               &hero_y,
               &monster_x,
               &monster_y)){
    if(total_cristals == 0 && hero_x == 0 && hero_y == 0
       && monster_x == 0 && monster_y == 0) break;
    vector<P> cristals;
    for(int cristal_i = 0; cristal_i < total_cristals; cristal_i++){
      int x,y;
      scanf("%d %d",&x,&y);
      cristals.push_back(P(x,y));
    }
    Compare comp(monster_x,monster_y);
    sort(cristals.begin(),cristals.end(),comp);
    printf("%s\n", dfs(hero_x,hero_y,0,0,monster_x,monster_y,cristals)
           ? "YES" : "NO");
  }
}

Measured memory_bytes: 1172
package main

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

// n is not small thus we use bufio to scan inputs

var sc = bufio.NewScanner(os.Stdin)

// create a function to read integer one by one
func nextInt() int {
	sc.Scan()
	// read as string and covert to int
	i, err := strconv.Atoi(sc.Text())
	// error handling
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	// idea is to count the number of 2 as a factor for each inputs and get sum
	// prepare temporary storage for number
	var tmp int
	//count 2 as a factor
	var total int
	sc.Split(bufio.ScanWords)
	// read first inputs to know how many numbers are upcoming
	n := nextInt()
	// iterating n times
	for i := 0; i < n; i++ {
		// scan int one by one and set to temporary variable
		tmp = nextInt()
		j := tmp
		// how many factor 2 are in that variable
		for j > 1 {
			if j%2 != 0 {
				break
			} else {
				total++
				j /= 2
			}
		}
	}
	fmt.Printf("%d", total)
}


Measured memory_bytes: 768
#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 = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

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

    int D, N;
    cin >> D >> N;

    if (N == 100) N = 101;

    for (int i = 0; i < D; i++) {
        N *= 100;
    }

    cout << N << endl;

    return 0;
}

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

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  vector <int> v;
  int K;

  int tmp;
  REP(i,3){
    cin >> tmp;
    v.push_back(tmp);
  }
  cin >> K;

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

  int ans = 0;

  REP(i,K){
    v[2] = v[2] * 2;
    sort(v.begin(),v.end());
  }

  REP(i,v.size()){
    ans	+= v[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd ** 0.5) + 1):
        if gcd % i == 0:
            cnt += 1
            while True:
                if gcd % i == 0:
                    gcd //= i
                else:
                    break
    cnt += 0 if gcd == 1 else 1
    print(cnt)


if __name__ == '__main__':
    slove()


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

int main(void){
    int n;
    cin >> n;
    double ary[n];
    for (int i = 0; i < n; i++) cin >> ary[i];
    sort(ary, ary + n);
    double ans = 0;
    for (int i = 0; i < n - 1; i++){
        if (i == 0){
            ans += (ary[i] + ary[i + 1]) / 2;
        }
        else {
            ans = (ans + ary[i + 1]) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int x,y;
  
  while(1){
    
    
  cin >> x >> y;
    if( x == 0 && y == 0 )
      break;
    
    if(x<y){
      cout << x << ' ' << y << endl;
    }
    
    else{
      cout << y << ' ' << x << endl;
    }
  }
  
}


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

void generatePS(char* ps, int n);

int main(void)
{
	int i;
	int n;
	int m;
	int result;
	char ps[1000001];
	char  s[1000001];
	while( 1 )
	{
		result = 0;
		scanf( "%d", &n );
		
		if( n == 0 )break;
		generatePS( ps, n );
		
		scanf( "%d%s", &m, s );
		
		for( i = 0; i < m; i++ )
		{
			if( strncmp( ps, s + i, 2 * n + 1 ) == 0 )
			{
				result++;
			}
		}
		printf( "%d\n", result );
	}
	
	return (0);
}

void generatePS(char* ps, int n)
{
	int i;
	for( i = 0; i < 2 * n + 1; i += 2 )
	{
		ps[i] = 'I';
	}
	for( i = 1; i < 2 * n + 1; i += 2 )
	{
		ps[i] = 'O';
	}
	ps[i] = '\0';
}

Measured memory_bytes: 1608
#include<iostream>
#include<string>
int main() {
	std::string str;
	std::getline(std::cin, str);
	int k = 0;
	int u = 0;
	int p = 0;
	int c = 0;
	int kanban = 0;
	for (int i = 0;i < str.size();++i) {
		if (str[i] == 'K') 
			k++;
		if (str[i] == 'U')
			++u;
			if (str[i] == 'P')
				p++;
			if (str[i] == 'C')
				++c;
	}
	while (1) {
		if ((k > 0)&&(u > 0)&&(p > 0)&&(c > 0)) {
			k--;u--;p--;c--;kanban++;
		}
		else {
			break;
		}
	}
	std::cout << kanban << std::endl;
	return 0;
}

Measured memory_bytes: 1180
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	_ = stoi(s.Text())

	s.Scan()
	vs := sstois(strings.Split(s.Text(), " "))

	s.Scan()
	cs := sstois(strings.Split(s.Text(), " "))

	sum := 0
	for i, v := range vs {
		if v-cs[i] > 0 {
			sum += v - cs[i]
		}
	}
	fmt.Println(sum)
}

func stoi(s string) int {
	res, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return res
}

func sstois(s []string) []int {
	res := make([]int, 0, len(s))
	for _, str := range s {
		res = append(res, stoi(str))
	}
	return res
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int a;
    int b;
    int c;
    cin>>a;
    cin>>b;
    cin>>c;
    
    if (a<b&&b<c){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)
#define FORR(I,A,B) for(int I=int(B-1);I>=int(A);--I)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m;
	cin >> n >> m;
	int a[n][m],b[m];
	FOR(i,0,n)FOR(j,0,m)cin>>a[i][j];
	FOR(i,0,m)cin>>b[i];
	FOR(i,0,n){
		int ans = 0;
		FOR(j,0,m){
			ans += a[i][j]*b[j];
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3176
let n = Int(readLine()!)!
let a = readLine()!.split(separator: " ").map{ String($0) }.map { Int($0)! }

var acc = 0
var min = 0

for num in a {
  if min > num {
    acc = acc &+ (min - num)
  } else {
    min = num
  }
}

print(acc)


Measured memory_bytes: 21440
#include "stdio.h"
#include "stdlib.h"

int main()
{
	long long int a, b;
	scanf("%lld%lld",&a,&b);
	if(a==1^b==1){printf("%lld",a*b-2);}
else{printf("%lld", ((a-2)*(b-2)));}
    return 0;
}



Measured memory_bytes: 128
n,t=map(int,input().split())
a=list(map(int,input().split()))
lmin=[a[0]]
rmax=[a[-1]]
for i in range(1,n):
  if a[i]<=lmin[-1]:
    lmin.append(a[i])
  else:
    lmin.append(lmin[-1])
  if a[-i-1]>=rmax[-1]:
    rmax.append(a[-i-1])
  else:
    rmax.append(rmax[-1])
mxls=[rmax[-i-2]-lmin[i] for i in range(n-1)]
mxls.append(-10**18)
ans=0
mx=max(mxls)
for i in range(n-1):
  if mxls[i]==mx and mxls[i]!=mxls[i+1]:
    ans+=1
print(ans)

Measured memory_bytes: 14940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int main()
{
    int n,i;
    while(cin>>n>>i)
    {
        cout<<n - i + 1<<endl;
    }

}
















Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
count = 0

for i in range(n-1):
    frag = 0
    minj = i
    for j in range(i+1,n):
        if A[minj] > A[j]:
            minj = j
            frag = 1

    if frag:
        v = A[minj]
        A[minj] = A[i]
        A[i] = v
        count += 1

print(' '.join(map(str, A)))
print(str(count))


Measured memory_bytes: 5592
#include <stdio.h>

int main(void)
{
	int a,b,i,ans=0;
	scanf("%d %d",&a,&b);
	for(i=0;i<2;i++){
		if(a>b){
			ans += a;
			a--;
		}else{
			ans += b;
			b--;
		}
	}
	printf("%d\n",ans);
	
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int x, y; cin>>x>>y;

    for (int a=0; a<=x; a++) {
	int b=x-a;
	int legs = 2*a + 4*b;
	if (legs==y) out("Yes");
    }

    out("No");
    
    return 0;
}


Measured memory_bytes: 3648
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

ll root(ll* a,ll A)
{
    while(a[A]!=A)
    {
        a[A]=a[a[A]];
        A=a[A];    
    }
    return A;    
}
 
int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
    ll a[n-1];
    Ff(i,0,n-1) cin>>a[i];

    ll fa[300001]={0};
    Ff(i,0,n-1)
    {
        fa[a[i]]++;
    }
    Ff(i,1,n+1)
    cout<<fa[i]<<endl;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 14616
import java.util.Scanner;

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

        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) break;

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i + j) % 2 == 0) System.out.print('#');
                    else System.out.print('.');
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 39616
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b>c)
    {
       cout<<0<<endl;
    }
    else
    {
        cout<<c-a+b<<endl;
    }
    return 0;
}


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


def main():
    n, m = map(int, input().split())

    if n == 1:
        a = int(input())
        for i in range(m):
            a //= 2
        print(a)
        exit()

    a = (list(map(int, input().split())))
    a = [-1 * i for i in a]
    heapq.heapify(a)

    for i in range(m):
        tmp = math.ceil(heapq.heappop(a) / 2)
        heapq.heappush(a, tmp)
    print(sum(a)*-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 3616
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main()
    {
        string[] inputs = Console.ReadLine().Split(' ');
        int n = int.Parse(inputs[0]);
        int a = int.Parse(inputs[1]);
        int b = int.Parse(inputs[2]);

        long pattern = Math.Max(((long)(b - a) * (n - 2) + 1), 0);
        Console.WriteLine(pattern);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>

int main()
{
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    int a = x2-x1;
    int b = y2-y1;

    x3 = x2 - b;
    y3 = y2 + a;
    x4 = x3 - a;
    y4 = y3 - b;

    std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    vector<ll> x(3);
    for (auto &&i : x) {
        cin >> i;
    }

    SORT(x);
    ll ans = x[0] * x[1] * (x[2] - 2 * (x[2] / 2));
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (auto &&i : v) {
        int a;
        scanf("%d %d", &i, &a);
    }
    ll ans = 0;
    sort(v.begin(), v.end(), greater<>());
    for (int i = 0; i < m-1; ++i) {
        if(v[i] < n) ans += n-v[i];
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3232
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]

dic = {}
ans = 0

for i in range(N):
    if not s[i] in dic:
        dic[s[i]] = 0
    dic[s[i]] += 1

for v in dic.values():
    ans += v*(v-1)//2

print(ans)


Measured memory_bytes: 68312
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

#pragma endregion 

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

	LL n, x;
	cin >> n >> x;
	vi a(n);
	f_vI(a, n);
	LL ans = 0;

	if (a[0] > x) {
		ans += a[0] - x;
		a[0] = x;
	}
	f(i, 0, n - 1) {
		if (a[i] + a[i + 1] > x) {
			ans += a[i + 1] - (x - a[i]);
			a[i + 1] = x - a[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	string S;
	cin>>S;
	vector<int> n(2, 0);
	for(int i = 0; i < S.size(); i++){
		n[S[i] - 48]++;
	}
	int ans = min(n[0], n[1]) * 2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    import sys
    import numpy as np
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    a = list(map(int, input().split()))
    inf = 1e18
    k = n%2 + 1
    dp = np.full((n+1, k+2), -inf, dtype=int)
    dp[0,0] = 0
    for i in range(n):
        for j in range(k+1):
            dp[i+1, j+1] = max(dp[i+1,j+1],dp[i,j])
            now = dp[i,j]
            if (i+j)%2 == 0: now += a[i]
            dp[i+1,j] = max(dp[i+1,j],now)
    print(dp[n,k])

if __name__ == '__main__':
    main()

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

int a[110];

int main(){
	int n; scanf("%d", &n);
	n *= 2;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i += 2){
		ans += a[i];
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int A,B,C;
  char a,b;
  cin>>A>>a>>B>>b>>C;
  if(A<2019)
    cout<<"Heisei"<<endl;
  else if(A==2019&&B<4)
    cout<<"Heisei"<<endl;
  else if(A==2019&&B==4&&C<=30)
    cout<<"Heisei"<<endl;
  else
    cout<<"TBD"<<endl;



  return 0;
}


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

using namespace std;

int main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > v;
  for(int i=0; i<n; i++) {
    long long a, b; cin >> a >> b; v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());

  long long ans = 0;
  for(long long i=0, count =0; count < m && i < n; i++) {
    long long a = min(v[i].second, m-count);
    ans += a*v[i].first;
    count += a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		long max1 = b * d;
		long max2 = a * c;
		long max3 = a * d;
		long max4 = b * c;
		
		System.out.println(Math.max(Math.max(max1, max2), Math.max(max3, max4)));
	}
}


Measured memory_bytes: 35764
#include<iostream>
#include<algorithm>
using namespace std;
long n,a;
main()
{
	cin>>n;
	long ans=0;
	for(int i=0;i<5;i++)
	{
		cin>>a;
		ans=max(ans,(n-1)/a+1+4);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())

ca = [list(map(int, input().split())) for _ in range(n)]

c = [ca[i][0] for i in range(n)]

a = [0]*m
costs = []

for i in range(2**n):
    cost = 0
    
    for j in range(n):
        if (i>>j) & 1:
            cost += c[j]
            for k in range(m):
                a[k] += ca[j][k+1]
    
    flag = True
    for l in range(m):
        if a[l] < x:
            flag = False
    if flag:
        costs.append(cost)
    a = [0]*m
if costs == []:
    print(-1)
else:
    print(min(costs))

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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 main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi a(n-1);
  rep(i,n-1) cin >> a[i];
  sort(all(a));
  a.push_back(0);
  int tmp = 0;
  REP(i,n+1) {
    int ans = 0;
    while(a[tmp] == i) {
      ans++;
      tmp++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 4784
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <climits>

const int N = 200000;

int n, dp[N + 2], next[N + 1][26];
char s[N + 1];

int main()
{
    scanf("%s", s);
    n = strlen(s);
    dp[n] = 1;
    dp[n + 1] = 0;
    for (int i = 0; i < 26; ++ i) {
        next[n][i] = n;
    }
    for (int i = n - 1; i >= 0; -- i) {
        for (int j = 0; j < 26; ++ j) {
            next[i][j] = next[i + 1][j];
        }
        next[i][s[i] - 'a'] = i;
        dp[i] = INT_MAX;
        for (int j = 0; j < 26; ++ j) {
            dp[i] = std::min(dp[i], dp[next[i][j] + 1] + 1);
        }
    }
    int now = 0;
    while (now != n + 1) {
        int j = 0;
        while (dp[next[now][j] + 1] + 1 != dp[now]) {
            j ++;
        }
        putchar('a' + j);
        now = next[now][j] + 1;
    }
    puts("");
}


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

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

    int a_idx, z_idx;

    for(int i = 0; i < s.length(); ++i){

        if(s[i] == 'A'){
            a_idx = i;
            break;
        }
    }

    for(int i = s.length() - 1; i >= 0; --i){

        if(s[i] == 'Z'){
            z_idx = i;
            break;
        }
    }

    cout << z_idx - a_idx + 1 << endl;
}

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

using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;

    vector<vector<int>> arr(n, vector<int>(n, 0));
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        arr[l - 1][r - 1]++;
    }

    for (int i = n - 1; i > 0; i--) {
        for (int j = 0; j < n; j++) {
            arr[i - 1][j] += arr[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 1; j < n; j++) {
            arr[i][j] += arr[i][j - 1];
        }
    }

    for (int i = 0; i < q; i++) {
        int pi, qi;
        cin >> pi >> qi;
        cout << arr[pi - 1][qi - 1] << endl;
    }
}


Measured memory_bytes: 1920
#include <cstdio>
#include <queue>
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 1;
typedef unsigned long long ull;
const ll INF = 1ll<<60;
int m,n,t;
int main()
{
    int n;
    scanf("%d", &n);
    int a;
    map<int,int>s;
    bool f = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a);
        if (s[a])
        {
            f = 1;
        }
        else
            s[a] = 1;
    }
    if (f)
        printf("NO\n");
    else
        printf("YES\n");

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int a[200000];
int dp[200000];
 
int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		scanf("%d",&a[i]);
		dp[a[i]]=-1;
	}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		if(dp[i]==-1)continue;
		if(i>=2&&dp[i-2]!=-1)(dp[i]+=dp[i-2])%=MOD;
		if(dp[i-1]!=-1)(dp[i]+=dp[i-1])%=MOD;
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	char bef='?';

	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=bef)
		{
			cnt++;
			bef=s[i];
		}
	}


	cout << cnt << endl;




}


Measured memory_bytes: 512
import numpy as np
import fractions

A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(A[k-1])

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, q;
    cin >> n >> q;
    dsu ds(n);
    for (int i=0; i<q; i++) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            ds.merge(u, v);
        else
            cout << ds.same(u, v) << "\n";
    }

    return 0;
}


Measured memory_bytes: 3956
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        a: usize, b: usize, c: usize,
        k: u32,
    }
    let mut ans = "No";
    for i in 0..=k {
        for j in 0..=k - i {
            for k in 0..=k - i - j {
                let x = a * 2usize.pow(i);
                let y = b * 2usize.pow(j);
                let z = c * 2usize.pow(k);
                if x < y && y < z {
                    ans = "Yes";
                    break;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2200
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
int M, D;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> M >> D;
    int ans = 0;
    for (int m = 1; m <= M; ++m) {
        for (int d = 1; d <= D; ++d) {
            int d1 = d % 10;
            int d2 = d / 10;
            if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

int main()
{
	int n;
	int p[1000], x[1000];
	scanf("%d", &n);
  if(n==1){
    printf("%s\n", "POSSIBLE");
    return 0;
  }
	vector<int> v[1000];
	for(int i=1; i<n; i++){
		scanf("%d", &p[i]);
        p[i]--;
		v[p[i]].push_back(i);
	}
	for(int i=0; i<n; i++){
		scanf("%d", &x[i]);
	}
	int d[1000];
	queue<int> que;
	que.push(0);
	d[0]=0;
	while(!que.empty()){
		int k=que.front();
		que.pop();
		for(int i=0; i<v[k].size(); i++){
			d[v[k][i]]=d[k]+1;
			que.push(v[k][i]);
		}
	}
	vector<P> dpr;
	for(int i=0; i<n; i++){
		dpr.push_back(P(-d[i], i));
	}
	sort(dpr.begin(), dpr.end());
	int w[1000]={};
	for(int j=0; j<n; j++){
		int k=dpr[j].second;
		if(v[k].empty()) continue;
		int sum=0;
		bitset<5001> bs;
		bs[0]=1;
		for(int i=0; i<v[k].size(); i++){
			sum=sum+x[v[k][i]]+w[v[k][i]];
		}
		for(int i=0; i<v[k].size(); i++){
			bs=(bs<<x[v[k][i]])|(bs<<w[v[k][i]]);
		}
		int m;
		for(m=x[k]; m>=0; m--){
			if(bs[m]==1) break;
		}
		if(m==-1){
			printf("%s\n", "IMPOSSIBLE");
			return 0;
		}
		w[k]=sum-m;
	}
	printf("%s\n", "POSSIBLE");
	return 0;
}

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


int main(){
    int N;
    cin>>N;
    long a[N];
    for(int i=0;i<N;i++)cin>>a[i];

    int ans=0;
    for(int i=0;i<N;i++){
        while(a[i]%2==0){
            ans++;
            a[i]/=2;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, A;
    cin >> N >> A;
    vec x(N);
    rep(i, N) cin >> x[i];

    vec3 f(N + 1, vec2(N + 1, vec(3000, 0)));

    rep(i, N + 1) f[i][0][0] = 1;

    rep1(i, N) rep1(j, N) rep(k, 2501){
        if(k >= x[i - 1]) f[i][j][k] += f[i - 1][j - 1][k - x[i - 1]];
        f[i][j][k] += f[i - 1][j][k];

    }

    ll ans = 0;
    rep1(j, N) ans += f[N][j][A * j];

    print(ans);

    return 0;
}

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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        long[]x=new long[n],s=new long[n];
        for(int i=0;i<n;++i){
            x[i]=sc.nextLong();
            s[i]=sc.nextLong();
            if(i>0)s[i]+=s[i-1];
        }
        long[]pre=new long[n+1],pos=new long[n+1];
        for(int i=0;i<n;++i){
            pre[i]=(i==0?0:s[i-1])-x[i];
            pos[i+1]=s[i]-x[i];
        }
        long ans=0;
        long min=Long.MAX_VALUE;
        for(int i=0;i<=n;++i){
            if(i>0)ans=Math.max(ans,pos[i]-min);
            min=Math.min(min,pre[i]);
        }
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] nextIntArray(int n){
            int[]r=new int[n];
            for(int i=0;i<n;++i)r[i]=nextInt();
            return r;
        }
    }
}


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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.size(); i++) {
        if ((i % 2 == 0 && s.at(i) == 'L') || (i % 2 == 1 && s.at(i) == 'R')) {
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    REP(i, 1, 10) {
        if (N % i != 0) continue;
        if (N / i < 10) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題161

            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int m = int.Parse(line[1]);

            string[] line2 = Console.ReadLine().Split(' ');

            int[] a = new int[n];

            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(line2[i]);
                sum += a[i];
                //Console.WriteLine(a[i]);

            }

            int count = 0;

            //Console.WriteLine("sum" + sum);

            foreach(int b in a)
            {
                //Console.WriteLine(b);
                if (b*4*m >= sum)
                {
                    //Console.WriteLine(b);
                    count++;
                    if (count == m)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }

            //Console.WriteLine(count);

            Console.WriteLine("No");
        }

    }





    
}


Measured memory_bytes: 27444
# 35
import string

S = str(input())

set1 = set()
for s in S:
    set1.add(s)

set2 = set()
for alf in string.ascii_lowercase:
    set2.add(alf)

list = sorted(set2 - set1)
if not list: print('None')
else: print(sorted(list)[0])

Measured memory_bytes: 9980
from scipy.special import comb
N = int(input())
a = [input() for _ in range(N)]

d = dict()
for x in a:
  s = ''.join(sorted(x))
  if s not in d.keys():
    d[s] = 1
  else:
    d[s] += 1

print(sum([comb(i, 2, exact=True) for i in d.values()]))

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

int main(){
  int a,b,h,m; cin>>a>>b>>h>>m;
  
  long double k1=30*h+30*(m/60.0);
  long double k2=6*m;
  long double k=abs(k1-k2);
  
  if (k==0){
    cout<<abs(a-b)<<endl;
    return 0;
  }
  
  k=k*(3.14159265359/180);
  
  long double x=pow(a,2)+pow(b,2)-2*a*b*cos(k);
  cout << fixed << setprecision(12);
  cout<<pow(x,0.5)<<endl;
  
}

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

using namespace std;

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

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

char sub(char ch,int x){
    x=x%52;
    if(x>=26){
        x-=26;
        if('a'<=ch && ch<='z')ch+=('A'-'a');
        else if('A'<=ch && ch<='Z')ch+=('a'-'A');
    }

    if('a'<=ch && ch<='z'){
        if(ch-x<'a')return ('Z'+1-('a'-(ch-x)));
    }else{
        if(ch-x<'A')return ('z'+1-('A'-(ch-x)));
    }
    return ch-x;
}

int main(){
    int n;
    while(cin>>n){
        vi key;
        if(n==0)return 0;
        rep(i,n){
            int tmp;
            cin>>tmp;
            key.pb(tmp);
        }
        string s;
        cin>>s;
        int len=s.size();
        rep(i,len){
            cout<<sub(s[i],key[i%key.size()]);
        }
        cout<<endl;
        
        
    }
    
    return 0;
}

Measured memory_bytes: 1224