akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================


const int MAX_SIZE = 1e5;
int A[MAX_SIZE], B[MAX_SIZE];

int main(){
  int n, B, minus_number = 0; cin >> n;
  ll sum = 0, minus_sum = 0;
  // input
  REP(i, n) cin >> A[i];
  REP(i, n){
    cin >> B;
    A[i] -= B;
    sum += A[i];
    if(A[i] < 0){
      minus_sum += A[i];
      minus_number++;
    }
  }
  // if it is impossible
  if(sum < 0){
    cout << "-1\n";
    return 0;
  }
  sort(A, A + n);
  int plus_need_number = 0, p = n - 1;
  while(minus_sum < 0){
    minus_sum += A[p];
    plus_need_number++;
    p--;
  }
  cout << minus_number + plus_need_number << "\n";
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

long long pow3[31];

int main() {
	long long a = 1;
	for (int i = 0; i < 31; i++) {
		pow3[i] = a;
		a = a * 3;
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		long long x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1--; y1--; x2--; y2--;
		
		long long x1_copy, x2_copy, y1_copy, y2_copy;
		int x1_tri[30], y1_tri[30], x2_tri[30], y2_tri[30];

		x1_copy = x1;
		y1_copy = y1;
		x2_copy = x2;
		y2_copy = y2;

		for (int i = 0; i < 30; i++) {
			x1_tri[29 - i] = x1 % 3; x1 = x1 / 3;
			y1_tri[29 - i] = y1 % 3; y1 = y1 / 3;
			x2_tri[29 - i] = x2 % 3; x2 = x2 / 3;
			y2_tri[29 - i] = y2 % 3; y2 = y2 / 3;
		}
		x1 = x1_copy;
		y1 = y1_copy;
		x2 = x2_copy;
		y2 = y2_copy;

		/*縦に■を横切るか確認*/
		int N = 30;
		for (int i = 0; i < 30; i++) {
			if (x1_tri[i] != x2_tri[i]) { break; }
			if (x1_tri[i] == 1 && x2_tri[i] == 1) {
				long long y1_r = 0;
				long long y2_r = 0;

				for (int j = 0; j <= i; j++) {
					y1_r *= 3; y1_r += y1_tri[j];
					y2_r *= 3; y2_r += y2_tri[j];
				}
				if (y1_r - y2_r >= 2 || y1_r - y2_r <= -2) {
					N = i;
					break;
				}
			}
		}
		if (N < 30) {
			long long x1_er = 0;
			long long x2_er = 0;
			for (int i = N + 1; i < 30; i++) {
				x1_er *= 3; x1_er += x1_tri[i];
				x2_er *= 3; x2_er += x2_tri[i];
			}

			long long ans = 0;
			ans = x1_er + x2_er + 2;
			if (ans > (pow3[30 - N - 1] - x1_er) + (pow3[30 - N - 1] - x2_er)) {
				ans = (pow3[30 - N - 1] - x1_er) + (pow3[30 - N - 1] - x2_er);
			}
			if (y1 > y2) {
				ans += y1 - y2;
			}
			else {
				ans += y2 - y1;
			}
			cout << ans << "\n";
			continue;
		}

		/*横に■を横切るか確認*/
		N = 30;
		for (int i = 0; i < 30; i++) {
			if (y1_tri[i] != y2_tri[i]) { break; }
			if (y1_tri[i] == 1 && y2_tri[i] == 1) {
				long long x1_r = 0;
				long long x2_r = 0;

				for (int j = 0; j <= i; j++) {
					x1_r *= 3; x1_r += x1_tri[j];
					x2_r *= 3; x2_r += x2_tri[j];
				}
				if (x1_r - x2_r >= 2 || x1_r - x2_r <= -2) {
					N = i;
					break;
				}
			}
		}
		if (N < 30) {
			long long y1_er = 0;
			long long y2_er = 0;
			for (int i = N + 1; i < 30; i++) {
				y1_er *= 3; y1_er += y1_tri[i];
				y2_er *= 3; y2_er += y2_tri[i];
			}

			long long ans = 0;
			ans = y1_er + y2_er + 2;
			if (ans > (pow3[30 - N - 1] - y1_er) + (pow3[30 - N - 1] - y2_er)) {
				ans = (pow3[30 - N - 1] - y1_er) + (pow3[30 - N - 1] - y2_er);
			}
			if (x1 > x2) {
				ans += x1 - x2;
			}
			else {
				ans += x2 - x1;
			}
			cout << ans << "\n";
			continue;
		}
		
		/*邪魔がないとき*/
		long long x_diff, y_diff;
		if (x1 - x2 > 0) { x_diff = x1 - x2; }
		else { x_diff = x2 - x1; }

		if (y1 - y2 > 0) { y_diff = y1 - y2; }
		else { y_diff = y2 - y1; }

		cout << x_diff + y_diff << "\n";

	}
}

Measured memory_bytes: 384
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
n, k = [int(x) for x in input().split()]
a = [[0, *(int(x) for x in input().split())] if p == 0 else [0 for i in range(n + 1)] for p in range(60)]
for p in range(1, 60):
    for i in range(1, n + 1):
        a[p][i] = a[p - 1][a[p - 1][i]]
ans = 1
for p in range(60):
    if k & (1 << p):
        ans = a[p][ans]
print(ans)


Measured memory_bytes: 217680
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 998244353;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  ll arr[n + 5];

  memset(arr, 0, sizeof(arr));
  ll max1 = 0;
  for (ll i = 1; i <= n; i++) {
    ll x;
    cin >> x;
    max1 = max(max1, x);
    if (i == 1 && x) {
      cout << 0 << en;
      return 0;
    }
    arr[x]++;
  }

  if (arr[0] > 1) {
    cout << 0 << en;
    return 0;
  }
  ll res = 1;

  for (ll i = 1; i <= max1; i++) {
    if (arr[i] == 0) {
      cout << 0 << en;
      return 0;
    }
    res *= power(arr[i - 1], arr[i], mod);
    res %= mod;
  }

  cout << res << en;

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int month(int m){
	switch(m){
		case 2: return 29;
		case 4: return 30;
		case 6: return 30;
		case 9: return 30;
		case 11:return 30;
		default:return 31;
	}
}
void day(int y){
	switch(y%7){
		case 0:puts("Monday");break;
		case 1:puts("Tuesday");break;
		case 2:puts("Wednesday");break;
		case 3:puts("Thursday");break;
		case 4:puts("Friday");break;
		case 5:puts("Saturday");break;
		case 6:puts("Sunday");break;
	}
}
int main(){
	int m,d;
	int y=3;
	int nm=1,nd=1;
	while(scanf("%d %d",&m,&d)){
		if(m==0&&d==0){
			break;
		}
		y=3;
		
		for(nm=1;nm<=m;nm++){
			for(nd=1;nd<=month(nm);nd++){
				if(nm==m&&nd==d){
					break;
				}
				y++;
			}
		}
		day(y);
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef long double db;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;

ll a,b,c;

int main(){
	cin>>a>>b>>c;
	if(c-a-b>=0){
		if(4*a*b<(c-a-b)*(c-a-b)){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=110,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int power(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=mul(x,x))
		if (y&1) ans=mul(ans,x);
	return ans;
}
int n,m,k,dfn[N],low[N],fac[N],ifac[N];
vector<int> e[N];
typedef pair<int,int> pii;
pii sta[N];int top,ans=1;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int dp[N][N][N];
//dp[i][j][k]表示把i拆成j项之和，最大的是k的方案数
int calc_partition(int n){//拆分数列
	int ans=0;
	for (int i=1;i<=n&&i<=k;i++)
		ans=inc(ans,mul(dp[n][i][n+1],ifac[k-i]));
	return mul(ans,fac[k]);
}
int calc_cir(int n){
	int ans=0;
	for (int i=1;i<=n;i++) ans=inc(ans,power(k,gcd(i,n)));
	return mul(ans,power(n,p-2));
}
int calc(int l,int r){
	//for (int i=l;i<=r;i++) printf("%d %d\n",sta[i].first,sta[i].second);puts("");
	if (l==r) return k;
	static int vis[N],C;C++;
	int v=0,e=r-l+1;
	for (int i=l;i<=r;i++){
		int x=sta[i].first,y=sta[i].second;
		if (vis[x]!=C) vis[x]=C,v++;
		if (vis[y]!=C) vis[y]=C,v++;
	}
	if (v==e) return calc_cir(e);
	else return calc_partition(e);
}
void tarjan(int x,int fa){
	static int cnt=0;
	dfn[x]=low[x]=++cnt;
	for (int i=0;i<e[x].size();i++){
		int v=e[x][i];
		if (v==fa) continue;
		if (dfn[v]){
			low[x]=min(low[x],dfn[v]);
			if (dfn[x]>dfn[v]) sta[++top]=pii(x,v);
		}
		else{
			sta[++top]=pii(x,v);
			int last=top;
			tarjan(v,x);
			low[x]=min(low[x],low[v]);
			//x是割点,栈内的边就是个bcc
			if (low[v]>=dfn[x]) ans=mul(ans,calc(last,top)),top=last-1;
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	fac[0]=1;
	for (int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
	ifac[N-1]=power(fac[N-1],p-2);
	for (int i=N-1;i;i--) ifac[i-1]=mul(ifac[i],i);
	dp[0][0][1]=1;
	for (int i=0;i<=100;i++)
	for (int j=0;j<=i;j++)
	for (int k=1;k<=100;k++)
	for (int a=0;i+k*a<=100;a++){
		int &to=dp[i+k*a][j+a][k+1];
		to=inc(to,mul(dp[i][j][k],ifac[a]));
	}
	for (int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for (int i=1;i<=n;i++)
		if (!dfn[i]) tarjan(i,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string S; cin >> S;
	vector<string> Key = { "dream","dreamer","erase","eraser" };
	int len[4] = { 5,7,5,6 };
	while (true) {
		bool f = false;
		for (int i = 0;i < 4;i++) {
			int l = S.length();
			if (l - len[i] >= 0) {
				if (S.substr(S.length() - len[i]) == Key[i]) {
					f = true;
					S.erase(S.end() - len[i], S.end());
					if (S.length() == 0) { cout << "YES" << endl; return 0; }
					break;
				}
			}
		}
		if (!f) {
			cout << "NO" << endl; return 0;
		}
	}
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, K; cin >> N >> K;
    ll ans = 0;
    ans += pow(N / K, 3);
    if(K % 2 == 0)
    {
        int count = 0;
        for(int i = 1; i <= N; i++)
        {
            if(i % K == K / 2) count++;
        }
        ans += pow(count, 3);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
// 参考にさせていただきました https://qiita.com/drken/items/cce6fc5c579051e64fab

#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
template<class T> 
class UnionFind {
  using _Tp = T;
  using size_type = std::size_t;
public:
  vector<int> par;
  vector<int> rank;
  vector<_Tp> diff_weight;
 
  UnionFind(int n = 1, _Tp SUM_UNITY = 0) {
    init(n, SUM_UNITY);
  }

  const _Tp & operator[] (size_type i) {
    root(i);
    return diff_weight[i];
  }
 
  void init(int n = 1, _Tp SUM_UNITY = 0) {
    par.resize(n); rank.resize(n); diff_weight.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
  }
 
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }
 
  _Tp weight(int x) {
    root(x);
    return diff_weight[x];
  }
 
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
 
  bool merge(int x, int y, _Tp w) {
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }
 
  _Tp diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

// verify ABC87D Poeple on the line
 
int main() {
    int N, M;
    cin >> N >> M;
    UnionFind<int> uf(N);
    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (uf.issame(l, r)) {
            int diff = uf[r] - uf[l];
            if (diff != d) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            uf.merge(l, r, d);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

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

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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 gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
   int n;
   cin >> n;
   if(n <= 7 && n >2 && n%2 == 1)yb();
   else nb();

}

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

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

int main() {
	int n;
	string str;

	cin >> n;
	cin >> str;

	if (n % 2 == 0) {
		for (int i = 0; i < n / 2; i++) {
			if (str[i] != str[i + n / 2]) {
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const int INF = 1001001001;
vi v[100005];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    queue<int> q;
    q.push(0);

    vi seen(n, INF);
    vi sign(n, -1);
    seen[0] = 0;
    while(!q.empty()) {
        int prev = q.front(); q.pop();
        for(int u : v[prev]) {
            if(seen[u] != INF) continue;
            seen[u] = seen[prev] + 1;
            sign[u] = prev;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if(i == 0) continue;
        cout << sign[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10616
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int ans=0;
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> mp;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
  }

  vector<int> vec;
  int x=2;
  while(x<1e9*3+1){
    vec.push_back(x);
    x*=2;
  }
  sort(a.begin(),a.end(),greater<int>());
  sort(vec.begin(),vec.end(),greater<int>());

  for(int i=0;i<n-1;i++){
    for(int j=0;j<vec.size();j++){
      if(mp.count(a[i])&&mp.count(vec[j]-a[i])&&mp[a[i]]>0&&mp[vec[j]-a[i]]>0){
        if(a[i]!=(vec[j]-a[i])){
          ans++;
          mp[a[i]]--;
          mp[vec[j]-a[i]]--;
        }else{
          if(mp[a[i]]>1){
            mp[a[i]]-=2;
            ans++;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}


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


int main() {
  // 科目の数Nを受け取る
  int N, K;
  cin >> N >> K;
  int num = 1;
  for (int i = 0; i < N; i++)  {
    if (num >= K)  {
      num += K;
    }
    else if (num < K) {
      num *= 2;
    }
  }
  cout << num << endl;

  vector<int> d(10);
  for (int i = 0; i < 10; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  
}



Measured memory_bytes: 256
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



n,d=MI()
x=2*d+1
if n%x==0:
    print(n//x)
else:
    print(n//x+1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int n, i;
	long at, bt;
	long *a;
	long *b;
	long sum = 0;
	scanf("%d", &n);
	a = (long*)malloc(sizeof(long) * n);
	b = (long*)malloc(sizeof(long) * n);
	for(i = 0; i < n; i++){
	scanf("%ld %ld", &at, &bt);
		a[i] = at % bt;
		b[i] = bt;
	}
	for(i = n-1; i >= 0; i--){
		if((sum+a[i]) % b[i] != 0){
			sum = sum + b[i] - ((sum + a[i]) % b[i]);
		}
	}
	printf("%ld\n", sum);
	free(a);
	free(b);
	return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
const int N=3001;
struct node{int v,nxt;}g[N];
int n,f[N],a[N],head[N],k;
inline void Insert(int u,int v){g[++k]=(node){v,head[u]};head[u]=k;}
inline void Dfs(int u){
	if(~f[u])return;
	f[u]=1;
	for(int i=head[u];i;i=g[i].nxt)
	  Dfs(g[i].v),f[u]&=f[g[i].v];
	f[u]^=1;
}
int main()
{
	int u,v;
	scanf("%d",&n);
	for(u=1;u<=n;u++)scanf("%d",a+u);
	for(int i=1;i<n;i++){
	  scanf("%d%d",&u,&v);
	  if(a[u]>a[v])Insert(u,v);
	  if(a[u]<a[v])Insert(v,u);
	}
	memset(f,-1,sizeof f);
	for(u=1;u<=n;u++){
	  Dfs(u);
	  if(f[u])printf("%d ",u);
	}return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	ll n;
	cin >> n;
	if (n == 1)
	{
		cout << 0 << endl;
		return (0);
	}
	ll tmpn = n;
	//ll lim = sqrt(n)+1;
	ll div = 2;
	ll c = 0;
	while (div * div <= tmpn)
	{
		ll num = 0;
		while (n % div == 0)
		{
			num++;
			n /= div;
		}
		for (int i = 1; ; i++) {
			if (num >= i)
			{
				c++;
				num -= i;
			}
			else
				break;
		}
		div++;
	}
	if (n != 1)
		c++;
	cout << c << endl;
}



Measured memory_bytes: 3608
#include <stdio.h>

int main()
{
	long long int n;
	char s[11];
	long long int mozi[5] = {0};
	long long int ans = 1;
	long long int zenbu = 0;
	int i, j, k;

	scanf("%lld", &n);
	for (i= 0; i < n; i++) {
		scanf("%s", s);

		switch (s[0]) {
			case 'M' :
				mozi[0]++;
				break;
			case 'A' :
				mozi[1]++;
				break;
			case 'R' :
				mozi[2]++;
				break;
			case 'C' :
				mozi[3]++;
				break;
			case 'H' :
				mozi[4]++;
				break;
		}

	}

	for (i = 0; i < 3; i++) {
		for (j = i+1; j < 4; j++) {
			for (k = j+1; k < 5; k++) {
				ans = mozi[i] * mozi[j] * mozi[k];
				zenbu += ans;
			}
		}
	}

	printf("%lld", zenbu);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
char c;
cin >> c;
if(c == 'a' || c == 'i' || c == 'u' || c== 'e' || c == 'o'){
cout << "vowel" << endl;}
else{
cout << "consonant" << endl;}
}

Measured memory_bytes: 380
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a * b, max(a + b, a - b)) << endl;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        out.println(n*n-in.ni());
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22868
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<(n-a+1)*(n-b+1);
}

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

using namespace std;
typedef long long int ll;

int main()
{
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N),B(M);
    for(ll i = 0; i < N; i++) 
    {
        if(i == 0) cin >> A[i];
        else
        {
            ll a;
            cin >> a;
            A[i] = A[i-1] + a;
        }
    }
    for(ll i = 0; i < M; i++) 
    {
        if(i == 0) cin >> B[i];
        else
        {
            ll b;
            cin >> b;
            B[i] = B[i-1] + b;
        }
    }
    // A[i] = 上からi番目の本を読み終えるのにかかる時間
    // B[i] = 上からi番目の本を読み終えるのにかかる時間
    ll ans;
    vector<ll>::iterator itr = upper_bound(B.begin(),B.end(),K);
    if(itr == B.begin()) 
    {
        ans = 0;
    }
    else
    {
        itr--;
        ans = distance(B.begin(),itr) + 1;
    }
    ll x = 1;
    while(1)
    {
        if((A[x-1] > K)||(x > N)) break;
        ll tmp = 0;
        vector<ll>::iterator itr = upper_bound(B.begin(),B.end(), K - A[x-1]);
        if(itr == B.begin()) tmp = x;
        else
        {
            itr--;
            tmp = x + distance(B.begin(),itr) + 1;
        }
        ans = max(ans,tmp);
        x++;
    }
    cout << ans << endl;
}

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

int main() {
	int m, f, b; cin >> m >> f >> b;
	if (m >= b) cout << "0" << endl;
	else {
		if (m + f < b) cout << "NA" << endl;
		else cout << abs(m - b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define inf (1ll<<60)
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define MEMSET(a) memset(a,0,sizeof(a))
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
using ll = long long;

signed main(){
    set<int> set;
    int q;
    cin>>q;
    while(q--){
        int y,x;
        cin>>y>>x;
        if(y==0){
            set.insert(x);
            cout<<set.size()<<endl;
        }
        else if(y==1){
            cout<<(set.find(x)!=set.end())<<endl;
        }
        else{
            set.erase(x);
        }
    }
    return 0;
}


Measured memory_bytes: 12460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
ll n,a,b,c,d,lf;

int main(){
	cin>>n>>a>>b>>c>>d;
	lf=n-2;
	if(a-c*lf>=b && a-d*lf<=b)
		return cout<<"YES",0;
	if(a+c*lf<=b && a+d*lf>=b)
		return cout<<"YES",0;
	ll lo=1,hi=lf-1,md;
	while(lo<=hi){
		md=(lo+hi)/2;
		ll mn1=a+md*c;
		ll mx1=a+md*d;
		ll mn2=b+(lf-md+1)*c;
		ll mx2=b+(lf-md+1)*d;
		if(mn1>mx2)
			hi=md-1;
		else if(mn2>mx1)
			lo=md+1;
		else
			return cout<<"YES",0;
	}
	lo=1;
	hi=lf-1;
	while(lo<=hi){
		md=(lo+hi)/2;
		ll mn1=a-md*d;
		ll mx1=a-md*c;
		ll mn2=b-(lf-md+1)*d;
		ll mx2=b-(lf-md+1)*c;
		if(mx1<mn2)
			hi=md-1;
		else if(mx2<mn1)
			lo=md+1;
		else
			return cout<<"YES",0;
	}
	cout<<"NO";
}




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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.rbegin(), h.rend());
    ll ans = 0;
    for (int i = k; i < n; ++i) ans += h[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const long long INF = 1LL << 60;
ll MOD = 1e9+7;

int main() {

    int N; cin>>N;

    set<int> d;

    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        d.insert(tmp);
    }

    cout<<d.size()<<endl;

    return 0;
}

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

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

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

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(){
    int n, m; cin>>n>>m;
    int cnt=0;
    for(int i=0; i<m; i++) {
        int a; cin>>a;
        if(a>m) cnt++;
    }
    cout << cnt << endl;
}


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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;

vector <ll> a;
vector < pair <int, int> > v;

void add(int y, int x) {
  a[y] += a[x];
  v.emplace_back(x, y);
}

void run() {
  int n;
  cin >> n;
  a = vector <ll>(n, 0);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int t1 = abs(*max_element(a.begin(), a.end()));
  int t2 = abs(*min_element(a.begin(), a.end()));
  debug(t1, t2);
  if (t1 > t2) {
    int who = max_element(a.begin(), a.end()) - a.begin();
    while (a[0] < a[who]) {
      add(0, who);
    }
    for (int i = 0; i < n - 1; ++i) {
      while (a[i + 1] < a[i]) {
        add(i + 1, i);
      }
    }
  } else {
    int who = min_element(a.begin(), a.end()) - a.begin();
    while (a[n - 1] > a[who]) {
      add(n - 1, who);
    }
    for (int i = n - 1; i > 0; --i) {
      while (a[i - 1] > a[i]) {
        add(i - 1, i);
      }
    }
  }

  debug(a);
  
  cout << v.size() << endl;
  for (auto p : v) {
    cout << p.first + 1 << " " << p.second + 1 << endl;
  }
}

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


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

static int h[200000];
int comparator(const void *a, const void *b)
{
    return ( *(int*)a - *(int*)b );
}
int main(n, k)
{
    scanf("%d%d", &n, &k);

    if(k>=n) printf("0\n");
    else 
    {
        for(int i=0; i<n; ++i)
            scanf("%d", &h[i]);

        qsort(h, n, sizeof(int), comparator);

        unsigned long x=0;
        for(int i=n-k-1; i>=0; --i)
            x += h[i];

        printf("%lu\n", x);
    }

    return 0;
}

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

int main() {
  int64_t h,n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i,n) {
   cin >> a.at(i);
  }
  
  bool defeat = false;
  
  int64_t sum = 0;
  rep(i,n) {
    sum += a.at(i);
    if(sum >=h) {
     defeat = true;
      break;
    }
   }
  
  if (defeat) {
   cout << "Yes"; }
  else {
  cout << "No";
  }
  
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        String t = sc.next();
        boolean can = false;
        for(int i=0;i<s.length;i++){
            StringBuilder builder = new StringBuilder();
            char[] rotated = rotateArray(s, i);
            if(!builder.append(rotated).toString().equals(t)){
                continue;
            }
            can = true;
            break;
        }
        if(can){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

    private static char[] rotateArray(char[] c, int d){
        char[] newc = new char[c.length];
        for(int i=0;i<c.length;i++){
            newc[(i+d)%c.length] = c[i];
        }
        return newc;
    }
    
    private static void sort(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right;
        int tmp;
        while(l<=r){
            while(d[l]<p){l++;}
            while(d[r]>p){r--;}
            if(l<=r){
                tmp=d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
        }
        sort(d, left, r);
        sort(d, l, right);
    }
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <vector>
using namespace std;



int main(){
    int n;
    cin >> n;
    
    vector<string> words;
    
    string s;
    string last_word;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (i == 0) {
            words.push_back(s);
            continue;
        }
        for (auto j: words) {
            if (j == s) {
                cout << "No" << endl;
                return 0;
            }
        }
        
        last_word = words.back();
        if ( last_word[last_word.length() - 1] != s[0]) {
            cout << "No" << endl;
            return 0;
        }
        
        words.push_back(s);
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};
#define MAXN 1005


int main(){
    FIO;
    ll n; cin >> n;
    map<ll,ll> m;
    for(ll i = 1;i*i<=n;i++){
        for(ll j = 1;j*j<=n;j++){
            for(ll k = 1;k*k<=n;k++){
                m[i*i+j*j+k*k+i*j+j*k+k*i]++;

            }
        }
    }
    forn(i,1,n+1){
        cout << m[i] << endl;
    }
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    long A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int count = 0;
    while (1)
    {
        for (int i = 0; i < N; i++)
        {
            if(A[i] % 2 != 0)
            {
                cout << count << endl;
                return 0;
            }
            A[i] = A[i]/2;
            if(i == N-1)
            {
                count++;
            }
        }
    }
}

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

using namespace std;

using ll = long long;

const int nax = 2e5 + 5;
vector < pair < int ,int > > intervals[nax];
const ll INF = 1e18L + 5;

struct S {
  ll small, lazy;
  inline void Merge (const S& a, const S& b) {
    small = min (a.small, b.small);
  }
  inline void add (ll x) {
    small += x, lazy += x;
  }
};

vector < S > tree;

const int TYPE_ADD = 1, TYPE_MIN = 2;

void rec (int id, int low, int high, int q_low, int q_high, int type, ll& x) {
  if (high < q_low || q_high < low)
    return;
  if (q_low <= low && high <= q_high) {
    if (type == TYPE_ADD)
      tree[id].add (x);
    else
      x = min (x, tree[id].small);
    return;
  }
  for (int b : {id << 1, (id << 1) + 1})
    tree[b].add (tree[id].lazy);
  tree[id].lazy = 0;
  int last_left = (low + high) >> 1;
  rec (id << 1, low, last_left, q_low, q_high, type, x);
  rec ((id << 1) + 1, last_left + 1, high, q_low, q_high, type, x);
  tree[id].Merge (tree[id << 1], tree[(id << 1) + 1]);
}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  ll sum_of_scores = 0;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    intervals[b].emplace_back (a, c);
    sum_of_scores += c;
  }
  ll answer = 0;
  int base = 1;
  while (base <= n + 1)
    base <<= 1;
  tree.resize (base << 1, {INF, 0});
  ll whatever = 0 - INF;
  rec (1, 0, base - 1, 0, 0, TYPE_ADD, whatever);
  for (int i = 1; i <= n + 1; ++i) {
    for (pair < int , int > p : intervals[i - 1]) {
      whatever = p.second;
      rec (1, 0, base - 1, 0, p.first - 1, TYPE_ADD, whatever);
    }
    ll best = INF;
    rec (1, 0, base - 1, 0, base - 1, TYPE_MIN, best);
    if (i == n + 1)
      answer = best;
    whatever = best - INF;
    rec (1, 0, base - 1, i, i, TYPE_ADD, whatever);
  }
  cout << sum_of_scores - answer;
}


Measured memory_bytes: 22388
using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    namespace Competitive
    {
        internal class Solution
        {
            int age;
            public void Run()
            {
                age = Input.ReadInt();
                if (age == 3 || age == 5 || age == 7)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }

        // libs ----------


        // common ----------

        internal static class Input
        {
            public static string ReadString()
            {
                string line = Console.ReadLine();
                return line;
            }

            public static int ReadInt()
            {
                string line = Console.ReadLine();
                return int.Parse(line);
            }

            public static int[] ReadIntArray()
            {
                string line = Console.ReadLine();
                return line.Split(' ').Select(int.Parse).ToArray();
            }

            public static long ReadLong()
            {
                string line = Console.ReadLine();
                return long.Parse(line);
            }

            public static long[] ReadLongArray()
            {
                string line = Console.ReadLine();
                return line.Split(' ').Select(long.Parse).ToArray();
            }

            public static double[] ReadDoubleArray()
            {
                string line = Console.ReadLine();
                return line.Split(' ').Select(double.Parse).ToArray();
            }
        }

        internal class Program
        {
            public static void Main(string[] args)
            {
                var s = new Solution();
                s.Run();
            }
        }
    }

Measured memory_bytes: 11092
N=input() # 文字型
K=int(input())
m=len(N) # 桁数

# dp0[i][j]はi桁目までで、j個の0でない数があり、Nより小さいのが確定
# dp1[i][j]はi桁目までで、j個の0でない数があり、Nより小さいのが確定していない
dp0=[[0]*(m+1) for _ in range(m+1)]
dp1=[[0]*(m+1) for _ in range(m+1)]
dp1[0][0]=1
for i in range(1,m+1):
    dp0[i][0]=1

for i in range(m):
    for j in range(m):
        if N[i]=='0':
            dp0[i+1][j+1]=dp0[i][j]*9 + dp0[i][j+1]
            dp1[i+1][j+1]=dp1[i][j+1]
        else:
            dp0[i+1][j+1]=dp0[i][j]*9 + dp0[i][j+1]+ dp1[i][j]*(int(N[i])-1)+dp1[i][j+1]
            dp1[i+1][j+1]=dp1[i][j]
            
if m<K:
    print(0)
else:
    print(dp0[-1][K]+dp1[-1][K])

Measured memory_bytes: 43248
N,K = map(int,input().split())
S = input()+"W"
A = []
a = 0
b = ""
for s in S:
    if b!="" and b!=s:
        A.append(a)
        a=1
    else:a+=1
    b = s
ans = 0
for a in A:ans+=(a-1)
print(min(N-1,ans+2*K))

Measured memory_bytes: 3956
import java.util.*;
public class Main {
	

	static int[] ps;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[][] connections = new int[n][m];

		ps = new int[m];
		int ans = 0;

		for(int i = 0; i < m ; i++) {
			int k = sc.nextInt();
			for(int j = 0; j<k ; j++) {
				int s = sc.nextInt() - 1 ;
				connections[s][i] = 1;
			}
		}
		
		for(int i = 0; i < m ; i++) {
			
			ps[i] = sc.nextInt();
		}
		
		double NUM = Math.pow(2, (double)n);
		for(int i=0;i<NUM;i++) {

			ans += isOn(m,n,i,connections);
		}
		

		System.out.println(ans);

	}
	
	public static int isOn(int m, int n, int NUM, int[][] connections) {
		for(int j=0;j<m;j++) {
			int count = 0;
			for(int k=0;k<n;k++) {
				count += connections[k][j] * (NUM / (int)Math.pow(2,k) % 2);
			}
			if((count % 2) != ps[j]) {
				return 0;
			}
			
		}
		return 1;
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) print((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}



string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

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

int legal(string s,string t,int k){
  int n=s.size();
  repa(i,k,n){
    if(s[i]!=t[i-k]) return 0;
  }
  return 1;
}

string merge(string s,string t,int k){
  int n=s.size();
  string ret;
  rep(i,k) ret.push_back(s[i]);
  rep(i,n) ret.push_back(t[i]);
  return ret;
}


int main(){
  li d,t,s; cin >>d >>t >>s;
  yn(d<=s*t);
}





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

using namespace std;
vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<class T>
istream &operator>>(istream &ist, vector<T> &vec)
{
	for (auto i = vec.begin(); i != vec.end(); ++i)
	{ ist >> vec[i]; }
	return ist;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

bool check(char ch)
{
	if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T')
	{
		return true;
	}
	return false;
}

int main()
{
	IOS
	string st;
	cin >> st;
	ll ans = 0;
	for (int i = 0; i < st.size(); ++i)
	{
		ll cnt = 0;
		for (int j = i; j < st.size() && check(st[j]); ++j)
		{
			++cnt;
		}
		ans = max(ans, cnt);
	}
	cout << ans;
	return 0;
}

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

int main(){
    int n; cin >>n;
    ll mat[100001][3];
    mat[0][0]=0;
    mat[0][1]=0;mat[0][2]=0;
    for(int i=1;i<=n;i++){
        int a,b,c;
        cin >>a>>b>>c;
        mat[i][0]=max(mat[i-1][1],mat[i-1][2])+a;
        mat[i][1]=max(mat[i-1][0],mat[i-1][2])+b;
        mat[i][2]=max(mat[i-1][1],mat[i-1][0])+c;
    }
    cout <<max(mat[n][0],max(mat[n][1],mat[n][2]));
}



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    
    if(abs(x-a) < abs(x-b))
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"B"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256