akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  vector<vector<mint>> dp(s.size()+1, vector<mint>(4,0));

  dp[0][0]=1;

  REP(i,s.size()){
    switch(s[i]){
      case 'A':
        // 選ばない
        dp[i+1][0] += dp[i][0];
        dp[i+1][1] += dp[i][1];
        dp[i+1][2] += dp[i][2];
        dp[i+1][3] += dp[i][3];
        // 選ぶ
        dp[i+1][1] += dp[i][0];
        break;
      case 'B':
        // 選ばない
        dp[i+1][0] += dp[i][0];
        dp[i+1][1] += dp[i][1];
        dp[i+1][2] += dp[i][2];
        dp[i+1][3] += dp[i][3];
        // 選ぶ
        dp[i+1][2] += dp[i][1];
        break;
      case 'C':
        // 選ばない
        dp[i+1][0] += dp[i][0];
        dp[i+1][1] += dp[i][1];
        dp[i+1][2] += dp[i][2];
        dp[i+1][3] += dp[i][3];
        // 選ぶ
        dp[i+1][3] += dp[i][2];
        break;
      case '?':
        // 選ばない(A,B,Cの3文字どれでも可なので3倍する)
        dp[i+1][0] += dp[i][0] * 3;
        dp[i+1][1] += dp[i][1] * 3;
        dp[i+1][2] += dp[i][2] * 3;
        dp[i+1][3] += dp[i][3] * 3;
        // 選ぶ(Aで1文字目を選ぶ、Bで2文字目を選ぶ、Cで3文字目を選ぶ)
        dp[i+1][1] += dp[i][0];
        dp[i+1][2] += dp[i][1];
        dp[i+1][3] += dp[i][2];
        break;
    }

  }

  cout << dp[s.size()][3].x << endl;
}



Measured memory_bytes: 7424
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int n;
    while( cin >> n ) {
        int const nn = n % 39;
        cout << "3C" << setw(2) << setfill('0') << ( nn == 0 ? 39 : nn ) << endl;
    }

}

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

int main() {
  int H,W;
  cin >> H>>W;
  vector<vector<string>> data(H, vector<string>(W));
  
  for (int i=0; i<H; i++){
        string k;
        cin>>k;
        for (int j=0; j<W; j++){
            data.at(i).at(j)=k.at(j);
        }
    }
  vector<vector<int>> d(H, vector<int>(W,0));
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (data.at(i).at(j) == "#"){
        for (int a=i-1; a<i+2; a++){
          for (int b=j-1; b<j+2; b++){
            if(a<0 || a>=H || b<0 || b>=W){
            continue;
          }
            d.at(a).at(b)++;
          }
        }
      }
      
    }
  }
for (int i =0; i<H; i++){
        for(int j =0; j<W; j++){
          if(data.at(i).at(j)=="#")
          cout<<'#';

          else 
          cout<<d.at(i).at(j);          

          if (j==W-1){
          cout<<endl;
          }


        }
      }

    
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
vector<string> s;
int N;
void solve()
{
    itn ans = 0;
    FOR(i, 0, N)
    {
        sort(all(s[i]));
    }
    sort(all(s));
    FOR(i, 0, N)
    {
        //cout << s[i] << endl;
    }
    int t = 0;
    FOR(i, 0, N - 1)
    {
        if (s[i] == s[i + 1]) {
            t++;
            ans += t;
        } else {
            t = 0;
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
    {
        string t;
        cin >> t;
        s.pb(t);
    }
    solve();
    return 0;
}


Measured memory_bytes: 5748
#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{
        cout << "Right" << endl;
    }
}

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

const int maxn=3e5+7;
int dp[maxn][66];//当前区间前缀1的个数

const ll mod=1000000007;
ll fac[66];



int main(){
	fac[0]=1ll;
	for(int i=1;i<=61;i++) fac[i]=fac[i-1]*2ll%mod;
        int n,m;cin>>n;
        for(int i=0;i<=n;i++) {
            for(int j=0;j<=61;j++)
                dp[i][j]=0;
        }
        for(int cas=1;cas<=n;cas++){
            ll x;cin>>x;
            for(ll i=0;i<=61;i++) dp[cas][i]=(dp[cas-1][i]+((x>>i)&1)%mod)%mod;
        }
            ll ans=0;
            int l,r;
            l=1,r=n;
            for(ll j=0;j<=61;j++){
                ll num1=dp[r][j]-dp[l-1][j];
                ll num0=(r-l+1)-num1;
                ans=ans+fac[j]*num0%mod*num1%mod,ans%=mod;
            }
            cout<<ans<<endl;    return 0;
}


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

int main()
{
	int n, i, sum=0;
	scanf("%d", &n);
	int p[n+1];
	for(i=0; i<n; i++){
		scanf("%d", &p[i]);
	}

	int maks=0;

	for(i=0; i<n; i++){
		if(p[i]>maks) maks=p[i];
		sum+=p[i];
	}

	printf("%d", sum-maks/2);


    return 0;
}


Measured memory_bytes: 256
import  numpy as np
D = int(input())
c = np.array(list(map(int, input().split())))
s = [list(map(int, input().split())) for _ in range(D)]
last_d = np.array([0]*len(c))

ans = 0
for i in range(D):
  cc = c*(last_d+i+1)
  max_c = max(cc)
  index = np.argmax(cc)
  print(index + 1)
  last_d[index] = -(i+1)
  ans += s[i][index]
  cc[index] = 0
  for j in cc:
    ans -= j


Measured memory_bytes: 27520
#include <bits/stdc++.h>
#define MAX 1000000
#define INF 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

void solve() {
	int n, m, sum = 0;
	cin >> n >> m;
	int arr[m];
	for (int i = 0; i < m; i++) {
		cin >> arr[i];
		sum += arr[i];
	}

	int res = n - sum;
	if(res < 0) {
		cout << -1 << "\n";
	} else {
		cout << res << endl;
	}
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3644
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
vector<pair<ll, pii> > data;
int H,W,N;
int p1[2][214514]={0};
int p2[2][214514]={0};
int memor,memol;
bool calc(int dir,int memo,int st){
	bool flag =true;
	int lef=-1,rig=memo;
	for(int i=N-1;i>=0;i--){
		if(p2[dir][i]>0){
			lef = max(-1,lef-1);
		}else if(p2[dir][i]<0){
			rig = min(memo,rig+1);
		}
		if(p1[dir][i]>0){
			rig -=1;
		}else if(p1[dir][i]<0){
			lef +=1;
		}
		//cout<<lef<<" "<<rig<<endl;
		if(lef==N)flag=false;
		if(rig==-1)flag=false;
		if(rig-lef<=1)flag=false;
	}
	if(rig<=st)flag=false;
	if(lef>=st)flag=false;
	//cout<<lef<<" "<<rig<<endl;
	return flag;
}
int main(){
	cin>>H>>W>>N;
	int stx,sty;
	cin>>stx>>sty;
	stx--;sty--;
	string ta,ao;
	cin>>ta>>ao;
	for(int i=N-1;i>=0;i--){
		if(ta[i]=='U')p1[0][i]=-1;
		if(ta[i]=='D')p1[0][i]=1;
		if(ta[i]=='R')p1[1][i]=1;
		if(ta[i]=='L')p1[1][i]=-1;
		if(ao[i]=='U')p2[0][i]=-1;
		if(ao[i]=='D')p2[0][i]=1;
		if(ao[i]=='R')p2[1][i]=1;
		if(ao[i]=='L')p2[1][i]=-1;
	}
	//calc(0,H,stx);
	//calc(1,W,sty);
	if(calc(0,H,stx)&&calc(1,W,sty))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
}


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

int main()
{
	int n;
	cin >> n;
	int ans = 0, top = 0;
	for(auto i = 0; i < n; ++i){
		int h;
		cin >> h;
		if(h >= top){
			++ans;
			top = h;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define int int_fast64_t

vector<int> simulate(vector<int> v) {
  for (int i = 1; i < (int)v.size(); ++i)
    v[i-1] = abs(v[i-1] - v[i]);
  v.pop_back();
  return v;
}

int simulate_full(vector<int> v) {
  while (v.size() > 1)
    v = simulate(v);
  return v[0];
}



// Returns nCr % p.  In this Lucas Theorem based program, 
// this function is only called for n < p and r < p. 
int nCrModpDP(int n, int r, int p) 
{ 
    // The array C is going to store last row of 
    // pascal triangle at the end. And last entry 
    // of last row is nCr 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; // Top row of Pascal Triangle 
  
    // One by constructs remaining rows of Pascal 
    // Triangle from top to bottom 
    for (int i = 1; i <= n; i++) 
    { 
        // Fill entries of current row using previous 
        // row values 
        for (int j = min(i, r); j > 0; j--) 
  
            // nCj = (n-1)Cj + (n-1)C(j-1); 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
  
// Lucas Theorem based function that returns nCr % p 
// This function works like decimal to binary conversion 
// recursive function.  First we compute last digits of 
// n and r in base p, then recur for remaining digits 
int nCrModpLucas(int n, int r, int p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
   // Compute last digits of n and r in base p 
   int ni = n%p, ri = r%p; 
  
   // Compute result for last digits computed above, and 
   // for remaining digits.  Multiply the two results and 
   // compute the result of multiplication in modulo p. 
   return (nCrModpLucas(n/p, r/p, p) * // Last digits of n and r 
           nCrModpDP(ni, ri, p)) % p;  // Remaining digits 
}

int solve(vector<int> v) {
  int n = v.size();
  assert(n >= 1);
  v = simulate(v);
  if (v.size()%2 == 0)
    v = simulate(v);
  n = v.size();

  
  int mply = 1;
  if (count(v.begin(), v.end(), 1) == 0) {
    for (auto& x : v)
      x /= 2;
    mply = 2;
  } else {
    for (auto& x : v)
      x %= 2;
    mply = 1;
  }
  
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i]) {
      //cout << "nCr("<<n-1<<", "<<n-1 - i<<")\n";
      ans += nCrModpLucas(n-1, n-1 - i, 2);
    }
  }
  return mply*(ans%2);
}

static int seed=0;
void test_random() {
  mt19937 rng(seed++);
  int n = uniform_int_distribution<int>{2, 10}(rng);

  uniform_int_distribution<int> d(1, 3);
  vector<int> v(n);
  generate(v.begin(), v.end(), bind(d, rng));
  if (solve(v) != simulate_full(v)) {
    for (auto x : v) cout << x << ' ';
    cout << '\n';
    cout << solve(v) << " vs " << simulate_full(v) << '\n';
    cout << "--\n";
  }
}

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  
  //for (int i=0; i<10000; ++i)
  //  test_random();
  
  int n; cin >> n;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    char c; cin >> c;
    v.push_back(c - '0');
  }
  cout << solve(v) << '\n';
}



Measured memory_bytes: 24168
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define PI acos(-1)
int main ()
{
	double r, a, c;
	scanf("%lf", &r);
	a = r*r*PI;
	c = 2*PI*r;
	printf("%lf %lf\n", a, c);
	return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(a < b) {
    for(int i=0; i<b; i++) {
      cout << a;
    }
    cout << endl;
  } else {
    for(int i=0; i<a; i++) {
      cout << b;
    }
    cout << endl;
  }
}

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

s = input()

p1 = 0
p2 = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "1":
            p1 += 1
    else:
        if s[i] == "0":
            p1 += 1

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            p2 += 1
    else:
        if s[i] == "1":
            p2 += 1

print(min(p1,p2))


Measured memory_bytes: 3188
import numpy as np
N, M = map(int, input().split())
 
G = np.zeros((N, N)) 
total_path_num = 0
not_reach_node = list(range(1, N))
node = 0
 
for i in range(M):
  a, b = map(int, input().split())
  G[a-1, b-1] += 1
  G[b-1, a-1] += 1
  
def search_path(G, not_reach_node, node):
  global total_path_num
  if len(not_reach_node) == 0:
    total_path_num += 1
    return total_path_num
  
  for x in np.where((G[node] == 1))[0]:
    if (x in not_reach_node):
      not_reach_node_copy = not_reach_node.copy()
      not_reach_node_copy.remove(x)
      search_path(G, not_reach_node_copy, x)

search_path(G, not_reach_node, node)      	
 
print(total_path_num)

Measured memory_bytes: 12500
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define ALEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

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

  ll a, b;
  while(cin >> a >> b) cout << __gcd(a, b) << " " << (a * b) / __gcd(a, b) << endl;

  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll n, q;
  cin >> n;
  ll cnt[200000] = {0};

  ll tmp;
  REP(i, n) {
    cin >> tmp;
    cnt[tmp]++;
  }

  unsigned long sum = 0;
  REP(i, 150000) { sum += cnt[i + 1] * (i + 1); }

  cin >> q;
  ll b[q], c[q];

  REP(i, q) { cin >> b[i] >> c[i]; }

  REP(i, q) {
    ll b_cnt = cnt[b[i]];
    cnt[b[i]] = 0;
    cnt[c[i]] += b_cnt;
    sum -= b_cnt * b[i];
    sum += c[i] * b_cnt;
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 6756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (N*A<= B) {
			System.out.println(N*A);
		}else {
			System.out.println(B);
		}
	}
}


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

using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int a = 0;
	for (auto c : s) {
		if (c == 'R') {
			++a;
		}
	}
	if (a > n/2) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
const double PI=3.14159265358979323846;
int main(){
    int x, y, a, b ,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> red(a), green(b), trans(c);
    for(int i = 0; i < a; i++){
        cin >> red[i];
    }
    for(int i = 0; i < b; i++){
        cin >> green[i];
    }
    for(int i = 0; i < c; i++){
        cin >> trans[i];
    }
    sort(red.begin(), red.end(), greater<ll>());
    sort(green.begin(), green.end(), greater<ll>());
    for(int i = 0; i < x; i++){
        trans.push_back(red[i]);
    }
    for(int j = 0; j < y; j++){
        trans.push_back(green[j]);
    }
    sort(trans.begin(), trans.end(), greater<ll>());
    ll sum = 0;
    for(int i = 0; i < x + y; i++){
        sum += trans[i];
    }
    cout << sum;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string N;
  cin >> N;
  int n = N.length();
  int K;
  cin >> K;
  long long dp[n + 1][K + 1];
  int cnt = 0;
  fill(dp[0], dp[0] + K + 1, 0);
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
    for (int k = 1; k <= K; k++) {
      dp[i][k] = dp[i - 1][k];
      if (cnt == k - 1) {
        dp[i][k] += 9 * (dp[i - 1][k - 1] - 1) + (N[i - 1] - '0');
      } else {
        dp[i][k] += 9 * dp[i - 1][k - 1];
      }
    }
    cnt += N[i - 1] > '0';
  }
  cout << dp[n][K] << endl;
  return 0;
}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define elif else if

int n,m;
int p[100010],y[100010];
vector<signed> v[100010];

signed main(){
  cin>>n>>m;
  rep(i,m){cin>>p[i]>>y[i];v[p[i]].push_back(y[i]);}
  rep(i,n+1)sort(v[i].begin(),v[i].end());
  rep(i,m){
    printf("%06d",p[i]);
    int ans=lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin()+1;
    printf("%06d\n",ans);
  }

  return 0;
}


Measured memory_bytes: 7808
#include <cmath>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> v(n, vector<int>());
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<int> d0(n, -1);
	vector<int> d1(n, -1);
	queue<int> q;
	d0[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int i = q.front();
		q.pop();
		for (auto it = begin(v[i]); it != end(v[i]); it++) {
			if (d0[*it] == -1) {
				d0[*it] = d0[i] + 1;
				q.push(*it);
			}
		}
	}
	d1[n - 1] = 0;
	q.push(n - 1);
	while (!q.empty()) {
		int i = q.front();
		q.pop();
		for (auto it = begin(v[i]); it != end(v[i]); it++) {
			if (d1[*it] == -1) {
				d1[*it] = d1[i] + 1;
				q.push(*it);
			}
		}
	}
	int c = 0;
	for (int i = 0; i < n; i++) {
		if (d0[i] <= d1[i]) {
			c++;
		}
	}
	cout << (c > n - c ? "Fennec" : "Snuke") << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    priority_queue<ll> q;
    vector<ll> f(n);




    vector<ll> fa(n);
    rep(i,n){cin>>a[i];}
    rep(i,n){cin>>f[i];}

    sort(a.rbegin(),a.rend());
    sort(f.begin(),f.end());
    rep(i,n){fa[i]=a[i]*f[i];}

    ll up = 1000000000001;
    ll down = 0;
    int nibu = 0;


    while(nibu<100){
        ll kk = k ;
       // cout<<up<<" "<<down<<endl;
        nibu++;
        ll med = (up+down)/2;
        bool flag= true;


       for(int j=0;j<n;j++){
            ll kai = f[j]*a[j];
            if(med<kai){
                ll hiku = a[j]-(med/f[j]);
                //ll hiku = (a[j]*f[j]-med-1)/f[j]+1;
               kk-=hiku;
               if(kk<0){
                   flag = false;
                   break;
               }
            }

        }


        if(flag){
            up = med;
        }else{

            down = med;
        }
    }
cout<<up<<endl;








    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<vector<int>> card(4,vector<int>(13,0));
    int n;
    cin >> n;
    char s;
    int a;
    for(int i=0;i<n;i++){
        cin >> s >> a ;
        if(s=='S') card.at(0).at(a-1) =1;
        else if(s=='H') card.at(1).at(a-1) =1;
        else if(s=='C') card.at(2).at(a-1) =1;
        else card.at(3).at(a-1) =1;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(card.at(i).at(j) ==0){
                if(i==0) cout << "S " << j+1 <<endl;
                else if(i==1)  cout << "H " << j+1 << endl;
                else if(i==2) cout << "C " << j+1 << endl;
                else cout << "D " << j+1 << endl;
            }
        }
    }
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N, K;
    cin >> N >> K;

    int maxK = (N - 1) * (N - 2) / 2;

    if(K > maxK){
        cout << -1 << endl;
        return 0;
    }
    
    int M = (N - 1) + (maxK - K);
    cout << M << endl;
    int cnt = 0;
    for(int i = 0; i < N - 1; i++){
        cout << 1 << " " << i + 2 << endl;
        cnt++;
    }

    if(cnt != M){
        for(int i = 2; i <= N; i++){
            for(int j = i + 1; j <= N; j++){
                cout << i << " " << j << endl;
                cnt++;
                if(cnt == M){
                    break;
                }
            }
            if(cnt == M){
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>b(2*m+1);
    vector<ll>c(2*m+1);
    ll sum=0;
    REP(i,1,n){
        ll x=a[i-1];
        ll y=a[i];
        if(y<x)y+=m;
        b[x+2]++;
        b[y+1]--;
        c[y+1]-=y-x-1;
        sum+=y-x;
    }
    REP(i,1,2*m+1)b[i]+=b[i-1];
    ll ma=0;
    REP(i,1,2*m+1){
        b[i]+=b[i-1]+c[i];
        //cout<<b[i]<<endl;
    }
    REP(i,1,m+1){
        b[i]+=b[i+m];
        ma=max(b[i],ma);
        //cout<<b[i]<<endl;
    }
    cout<<sum-ma<<endl;
}

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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < p.size(); i++) {
        cin >> p.at(i);
    }
    int count = 0;
    int M, m;
    
    for (int i = 0; i < p.size() - 2; i++) {
        M = 0, m = n + 1;
        for (int j = 0; j < 3; j++) {
            if (p.at(i + j) > M) {
                M = p.at(i + j);
            }
            if (p.at(i + j) < m) {
                m = p.at(i + j);
            }
        }
        if (p.at(i + 1) != M && p.at(i + 1) != m) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 10000000000000000LL
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n;
	cin>>n;
	ll h[5001], p[5001];
	vector<P> v;
	for(int i=0; i<n; i++){
		cin>>h[i]>>p[i];
		v.push_back(P(h[i]+p[i], i));
	}
	sort(v.begin(), v.end());
	ll dp[5001][5001];
	for(int i=0; i<=n; i++){
		for(int j=0; j<=i; j++){
			if(j==0) dp[i][j]=0;
			else dp[i][j]=INF;
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=i; j++){
			if(dp[i-1][j-1]<=h[v[i-1].second]){
				dp[i][j]=min(dp[i][j], dp[i-1][j-1]+p[v[i-1].second]);
			}
			if(i-1>=j){
				dp[i][j]=min(dp[i][j], dp[i-1][j]);
			}
		}
	}
	for(int i=n; i>=0; i--){
		if(dp[n][i]<INF){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
  int n;cin>>n;
  int X[n],Y[n];
  vector<int> zipx,zipy;
  rep(i,n){
    int p,q;cin>>p>>q;
    X[i]=p;Y[i]=q;
    zipx.push_back(p);
    zipy.push_back(q);
  }
  sort(all(zipx));sort(all(zipy));
  zipx.erase(unique(all(zipx)),zipx.end());
  zipy.erase(unique(all(zipy)),zipy.end());
  UnionFind uf(2*n);
  rep(i,n){
    int p,q;
    p=lower_bound(all(zipx),X[i])-zipx.begin();
    q=lower_bound(all(zipy),Y[i])-zipy.begin();
    q+=n;
    uf.unite(p,q);
    //cout<<p<<" "<<q<<endl;
  }
  int x[2*n]={};
  int y[2*n]={};
  rep(i,2*n)uf.find(i);
  rep(i,2*n){
    int f=uf.find(i);
    //cout<<f<<endl;
    if(i<n)x[f]++;
    else y[f]++;
  }
  ll ans=0;
  rep(i,2*n){
    ans+=1ll*x[i]*y[i];
    //cout<<x[i]<<" "<<y[i]<<endl;
  }
  cout<<ans-n<<endl;
}


Measured memory_bytes: 4340
suit_set = {}
key_num = 0
while True:
    key_num += 1
    s_set = {}
    suit = input()
    if suit == '-':
        break

    shuffle_list = []
    m = int(input())
    for i in range(m):
        shuffle_list.append(int(input()))

    s_set[suit] = shuffle_list

    suit_set[key_num] = s_set

for k,v_p in suit_set.items():
    for k,v in v_p.items():
        suit = str(k)
        for i in v:
            tmp = suit[i:] + suit[0:i]
            suit = tmp
        print(suit)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int i,i0,n,m,a[10005];
int main()
{
    scanf("%d %d",&n,&m);
    int now=0,ans=1;
    for(i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        now+=x;
        ans+=(now<=m);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    int x[n];
    for(int i=0;i<n-1;i++)cin>>x[i];
    int sum=x[0]+x[n-2];
    for (int i=1;i<n-1;i++)sum+=min(x[i],x[i-1]);
    cout<<sum<<endl;
}


Measured memory_bytes: 256
/*    *** Bismillahir Rahmanir Rahim***
          *A S M Masud Parvez*
             *18ICTCSE035*
           *SHIICT(BSMRSTU)*
*/
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define End return 0
#define ll long long int
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
int Max = INT_MIN;
int Min = INT_MAX;
int i,j,f=0,x,y,z,n,m,S=0,len;
#define pi acos(-1)
int main()
{     
  MP;
  
  cin>>n;
  ll p=0;
  for(i=1;i<=n;i++)
  {
    if(i%3==0)
    continue;
    else if(i%5==0)
    continue;
    else 
    p+=i;
  }
  cout<<p;
    
  End;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <queue>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 1e5+10;
char s[maxd],p[maxd];
int fail[maxd],ans,n;
void getfail()
{
    fail[0] = -1;
    int match = -1;
    //printf("%s\n",p);
    for(int i=1;p[i];i++)
    {

        while(match>=0&&p[match+1] != p[i])
            match = fail[match];
        if(p[match+1] == p[i]) match++;
        fail[i] = match;
        //printf("%d ",fail[i]);
    }

}
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d%s",&n,s); 
    int len =strlen(s),ans = 0;
    for(int i=0;s[i];i++)
    {
        for(int j=0;j+i<len;j++)
            p[j] = s[i+j];
        p[len-i] = '\0';
        
        getfail();
        for(int j=0;p[j];j++)
        ans = max(ans,min(fail[j]+1,(j+1)/2));
    }
    printf("%d",ans);
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int hit = 0;
  for( int x=A; x<=B; x++ ){
    int y = x / 10000;
    y += ((x%10000)/1000) * 10;
    y += ((x%1000)/100) * 100;
    y += ((x%100)/10) * 1000;
    y += (x%10) * 10000;
    if( x == y ){
      hit++;
    }
  }
  cout << hit << endl;
}



Measured memory_bytes: 3588
#include<iostream>

using namespace std;

int main()
{
    int n;
    int m;
    int l;
    int a[100][100];
    int b[100][100];

    cin >> n >> m >> l;

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

    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> b[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            long long sum = 0;
            for (int k = 0; k < m; k++)
            {
                sum += a[i][k] * b[k][j];
            }
            if (j) cout << " ";
            cout << sum;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3164
# String Palindrome
def is_palindrome(s):
    res = s == s[::-1]
    return res

S = input()
N = len(S)
ans = ['No', 'Yes'][is_palindrome(S) & is_palindrome(S[:((N-1)//2)]) & is_palindrome(S[((N+1)//2):])]
print(ans)

Measured memory_bytes: 8980
N = gets.to_i
h = {}
gets.split.map(&:to_i).each{ |a| h[a] = (h[a] || 0) + 1 }
s = h.keys.select{ |k| h[k] >= 2 }.map{ |k| h[k] >= 4 ? [k,k] : [k] }.flatten.sort
p s.size >= 2 ? s[-2..-1].inject(:*) : 0


Measured memory_bytes: 15748
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	if x == "H":
		a.append(y + 13)
	if x == "C":
		a.append(y + 26)
	if x == "D":
		a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))
            



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 300005
#define mod 998244353
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

int n,m;
LL pw[maxn];
LL sum[maxn];
int tree[4*maxn];
int lazy[4*maxn];

int proc(int x , int y , int val) {
	int l = n-y;
	int r = n-x;
	LL res = sum[r];
	if(l)
		res = (res - sum[l-1] + mod) % mod;
	res = (res * val) % mod;
	return res;
}

void init(int x , int y , int id) {
	tree[id] = proc(x,y,1);
	if(x == y)
		return;
	int mid = (x+y) >> 1;
	init(x,mid,id*2);
	init(mid+1,y,id*2+1);
}

int update(int cx , int cy , int qx , int qy , int val , int id) {
	if(lazy[id]) {
		tree[id] = proc(cx,cy,lazy[id]);
		if(cx != cy)
			lazy[id*2] = lazy[id*2+1] = lazy[id];
		lazy[id] = 0;
	}
	if(qy < cx || cy < qx)
		return tree[id];
	if(qx <= cx && cy <= qy) {
		tree[id] = proc(cx,cy,val);
		if(cx != cy)
			lazy[id*2] = lazy[id*2+1] = val;
		return tree[id];
	}
	int mid = (cx + cy) >> 1;
	int l = update(cx,mid,qx,qy,val,id*2);
	int r = update(mid+1,cy,qx,qy,val,id*2+1);
	return tree[id] = (l+r) % mod;
}

int main() {
	pw[0] = 1;
	for( int i = 1 ; i < maxn ; i++ )
		pw[i] = (pw[i-1] * 10LL) % mod;
	sum[0] = 1;
	for( int i = 1 ; i < maxn ; i++ )
		sum[i] = (sum[i-1] + pw[i]) % mod;
	scanf("%d%d",&n,&m);
	init(1,n,1);
	for( int i = 0 , x,y,v ; i < m ; i++ ) {
		scanf("%d%d%d",&x,&y,&v);
		printf("%d\n",update(1,n,x,y,v,1));
	}
	return 0;
}

Measured memory_bytes: 12624
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    cin >> n;
    vector<int> ones;
    ones.push_back(1);
    int i = 6;
    while (i < 1e5 + 1) {
        ones.push_back(i);
        i *= 6;
    }
    i = 9;
    while (i < 1e5 + 1) {
        ones.push_back(i);
        i *= 9;
    }
    
    vector<int> dp(1e5 + 1, 1e8);
    for (auto e: ones) dp[e] = 1;
    
    repeat (i, 1e5 + 1) {
        for (auto e: ones) {
            if (i < e) continue;
            dp[i] = min(dp[i-e] + 1, dp[i]);
        }
    }
    cout << dp[n] << endl;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

int N, A;
vec<int> x;
int dp[55][55][2555];

int rec(int idx, int mai, int sum) {
  if (idx >= N) {
    if (mai == 0) return 0;
    if (sum % mai == 0 && sum / mai == A) {
      return 1;
    }
    return 0;
  }

  if (dp[idx][mai][sum] != -1) {
    return dp[idx][mai][sum];
  }

  int ret = 0;

  int yes = rec(idx + 1, mai + 1, sum + x[idx]);
  int no = rec(idx + 1, mai, sum);

  ret += yes + no;

  return dp[idx][mai][sum] = ret;
}

signed main() {
  cin >> N >> A;
  x.resize(N);
  rep (i, N) {
    cin >> x[i];
  }

  memset(dp, -1, sizeof(dp));
  int ans = rec(0, 0, 0);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 60672
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int x,y;
    cin>>x>>y;
    int y2 = y-2*x;
    if(y2%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    int k=y2/2;
    int t = x-k;

    if(t>=0&&k>=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}



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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A;
    string B;
    cin >> A >> B;
    ll p = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0')*1;
    ll ans = (A*p)/100L;
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N; cin >> N;
	cout << (double)((N + 1) / 2) / N << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int y1,y2,m1,m2,d1,d2,c,i;
  int M[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  while(1){
    c=0;
    scanf("%d %d %d %d %d %d",&y1,&m1,&d1,&y2,&m2,&d2);
    if(y1<0||y2<0||m1<0||m2<0||d1<0||d2<0)break;
    if(d1<d2)c+=d2-d1;
    else     c-=d1-d2;
    while(m1!=m2){
      c+=M[m1];
      if(m1==2){
	if(y1%4==0&&(y1%100!=0||y1%400==0))c++;
      }
      m1++;
      if(m1==13){
	m1=1;
	y1++;
      }
    }
    c+=(y2-y1)*365;
    if(m1<3&&y1%4==0&&(y1%100!=0||y1%400==0))c++;
    y1+=4-(y1%4);//printf("%d ",c);
    for(;y1<=y2;y1+=4){
      if(y1%100!=0||y1%400==0)c++;
    }
    printf("%d\n",c); 
  }
  return 0;
}
      

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int c[4][4];

signed main()
{   
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            cin>>c[i][j];
        }
    }

    if(c[1][1]+c[2][2]+c[3][3]==c[1][2]+c[2][3]+c[3][1] and 
       c[1][1]+c[2][2]+c[3][3]==c[1][3]+c[2][1]+c[3][2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.Math.*


fun main() {
    val K = rd.readInt()
    val S = rd.readString()

    val ans = if (S.length <= K) S else S.slice(0 until K) + "..."

    println(ans)
}


//val rd = debug.Reader("abc", "168", "b", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 36284
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

class Rolliha{
public:
    using ull=unsigned long long int;
    using uint=unsigned int;
    const ull MASK30=(1ULL<<30)-1;
    const ull MASK31=(1ULL<<31)-1;
    const ull MOD_rh=(1ULL<<61)-1;
    const ull POSITIVIZER=MOD_rh*((1ULL<<3)-1);

    int sz;
    vector<ull> hash_table,power; //1-indexed

    Rolliha(const string& s,uint base=0):sz{(int)s.size()}{
        hash_table.assign(sz+1,0);
        power.assign(sz+1,1);

        random_device rd;
        uniform_int_distribution<uint> dist(129,numeric_limits<int>::max()-1);
        if(base==0) base=dist(rd);

        rep(i,sz){
            power[i+1]=mul(power[i],base);
            hash_table[i+1]=mul(hash_table[i],base)+s[i];
            if(hash_table[i+1]>=MOD_rh) hash_table[i+1]-=MOD_rh;
        }
    }

    //(l,r] 1-indexedの場合
    ull sechash(int l,int r){
        return calc_mod(hash_table[r]+POSITIVIZER-mul(hash_table[l],power[r-l]));
    }

    //mod 2^61-1
    ull mul(ull a,ull b){
        ull aq=a>>31, bq=b>>31;
        ull ar=a&MASK31, br=b&MASK31;
        ull mid=aq*br+ar*bq;
        ull midu=mid>>30;
        ull midl=mid&MASK30;
        return ((aq*bq)<<1)+midu+(midl<<31)+ar*br;
    }

    ull mul(ull a,uint b){
        ull aq=a>>31;
        ull ar=a&MASK31, br=b&MASK31;
        ull mid=aq*br;
        ull midu=mid>>30;
        ull midl=mid&MASK30;
        return midu+(midl<<31)+ar*br;
    }

    ull calc_mod(ull x){
        ull xq=x>>61;
        ull xr=x&MOD_rh;
        ull res=xq+xr;
        if(res>=MOD_rh) res-=MOD_rh;
        return res;
    }
};

int main(){
    int n; cin>>n;
    ll ans=0;
    vector<pair<int,string>> s(n);
    rep(i,n){
        string S; cin>>S;
        s[i]=mk(S.size(),S);
    }
    sort(al(s));
    vector<set<unsigned long long>> st(26);
    vector<int> cnt(26,0);
    rep(i,n){
        Rolliha rh{s[i].second,1000000007U};
        int N=s[i].first;
        for(auto ch:s[i].second) cnt[ch-'a']++;
        for(int j=N-1;j>=0;j--){
            rep(k,26)if(cnt[k]) ans+=st[k].count(rh.sechash(j+1,N));
            cnt[(s[i].second)[j]-'a']--;
        }
        st[(s[i].second)[0]-'a'].insert(rh.sechash(1,N));
    }
    cout<<ans<<endl;
}

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

using namespace std;


#define mod        1000000007
#define ft         first
#define sd         second
#define pb         push_back
#define all(x)     x.begin(),x.end()
#define ll         long long int
#define bl         bool
#define db         long double
#define vbi        vector<bool> 
#define vlli       vector<ll>
#define mp         make_pair
#define ms(x,v)    memset(x, v, sizeof x)
#define cnl        printf("\n");
#define fr(i,b)    for(ll i=0; i<=b; i++)
#define frr(i,b)   for(ll i=0;i<b;i++)
#define fb(i,b)    for(ll i=b-1; i>=0; i--)
#define PI         3.14159265
ll i,j,k;

int main(){
ll n; cin>>n; 
vlli v(n);
frr(i,n) cin>>v[i];
ll cnt=0;
for(i=0;i<n;i++){
  if(v[i]!=(i+1)) cnt++;
}
if(cnt<=2) cout<<"YES"<<endl;
else cout<<"NO"<<endl;





return 0;
}


Measured memory_bytes: 256
n = int(input())

ans = 0
for i in range(1, n+1):
    count = 0
    if i % 2 != 0:
        for j in range(1, int(i**(0.5))+1):
            if i % j == 0:
                count += 2
        if (int(n**0.5))**2 == n:
            count -= 1
        if count == 8:
            ans += 1

print(ans)



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

typedef long long ll;

const ll mod = 10007;
const int inf = 101234567;

int main() {
    ll N, M;
    cin >> N >> M;
    ll ans = 1;
    vector<int>yakusu;

    for (int i = 1; i < sqrt(M); i++) {
        if (M % i == 0) {
            yakusu.push_back(i);
            yakusu.push_back(M/i);
        } 
    }
    if ((int)sqrt(M) == sqrt(M)) {
        yakusu.push_back(sqrt(M));
    }
    sort(yakusu.begin(), yakusu.end());

    auto itr = lower_bound(yakusu.begin(), yakusu.end(), N);
    ans = M / *itr;

    cout << ans << endl;
}


Measured memory_bytes: 256