akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

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

void css(int x, int y, int id, vector<vector<char>>& s, vector<vector<int>>& cs) {
    if (x < 0 || y < 0 || x >= (int)s.size() || y >= (int)s[0].size()) return;
    if (s[x][y] == '#') return;
    if (cs[x][y] != -1) return;
    cs[x][y] = id;
    for (int i = 0; i < 4; i++) {
        css(x + dx[i], y + dy[i], id, s, cs);
    }
}

int main() {
    int h, w;
    cin >> h >> w;
    int ch, cw;
    cin >> ch >> cw;
    int dh, dw;
    cin >> dh >> dw;
    vector<vector<char>> s(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    vector<vector<int>> cs(h, vector<int>(w, -1));
    int id = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') continue;
            if (cs[i][j] != -1) continue;
            css(i, j, id, s, cs);
            id += 1;
        }
    }

    int cid = cs[ch - 1][cw - 1];
    int did = cs[dh - 1][dw - 1];

    vector<unordered_set<int>> g(id);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int ijid = cs[i][j];
            if (ijid == -1) continue;
            for (int x = i - 2; x <= i + 2; x++) {
                for (int y = j - 2; y <= j + 2; y++) {
                    if (x < 0 || y < 0 || h <= x || w <= y) continue;
                    int xyid = cs[x][y];
                    if (xyid == -1) continue;
                    if (ijid == xyid) continue;
                    g[ijid].insert(xyid);
                    g[xyid].insert(ijid);
                }
            }
        }
    }

    queue<int> q;
    vector<int> dist(id, -1);
    q.push(cid);
    dist[cid] = 0;
    bool br = false;
    while (!q.empty()) {
        int f = q.front();
        q.pop();
        for (int i : g[f]) {
            if (dist[i] != -1) continue;
            q.push(i);
            dist[i] = dist[f] + 1;
            if (i == did) {
                br = true;
                break;
            }
        }
        if (br) break;
    }

    cout << dist[did] << endl;
}


Measured memory_bytes: 33436
#include<cstdio>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define DivHim() cout<<">>>>>>>>>>>>>>>"<<endl
#define DivHer() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

template<typename T> bool GetMin(T &a,T b)
{
	return ((a<=b)?false:(a=b,true));
}

template<typename T> bool GetMax(T &a,T b)
{
	return ((a>=b)?false:(a=b,true));
}

/*
	 -<Unlimited Blade Works>-
 */

#define int long long

const int N=2e5+10;

int n,x;
int s[N];

signed main()
{
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",s+i);
		s[i]+=s[i-1];
	}
	int ans=0x3f3f3f3f3f3f3f3f;
	for(int i=1,t;i<=n;++i)
	{
		t=i*x;
		for(int j=n,k,c=1;j>=1;j=k,++c)
		{
			k=max(0ll,j-i);
			t+=(s[j]-s[k])*max(5ll,(c*2+1));
			if(t>=ans)
				break;
		}
		GetMin(ans,t);
	}
	printf("%lld",ans+n*x);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
string s;
int n, tem;
vector<int> L;
int sum;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tem;
    L.push_back(tem);
  }
  sort(L.begin(), L.end());
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++)
        if (L[i] != L[j] && L[j] != L[k] && L[i] + L[j] > L[k]) sum++;
  cout << sum << endl;
  system("pause");
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static boolean calcThisLevel(long[] a, long[] b, long mod, long ans) {
		// bがひとつ前の位の10として
		// 0がすべて一致するか，
		// 0がすべて1になるかしないといけない
		int cnt = 0;
		int cnt0 = 0;
		//int mode = 0;
		//System.out.println("cnt=" + cnt + ":" + "cnt0=" + cnt0 + ":" + "ans=" + ans);
		for (int i = 0; i < a.length; i++) {
			//System.out.println(a[i] + ":" + a[i] % mod + ":" + "b[i]=" + b[i]);
			/*if (b[i] == 0) {
				//System.out.println("mode:" + mode + ":" + (mode == 2 && a[i] == ans));
				if (mode == 0 && a[i] == 0)
					mode = 2;
				else if (mode == 0 && a[i] == ans)
					mode = 1;
				else if (mode == 1 && a[i] == 0)
					return false;
				else if (mode == 2 && a[i] == ans)
					return false;
			}*/

			if (a[i] % mod == ans) {
				cnt++;
				a[i] -= ans;
				b[i] = 1;
			} else {
				cnt0++;
				b[i] = 0;
			}
		}
		//System.out.println("cnt=" + cnt + ":" + "cnt0=" + cnt0 + ":" + "ans=" + ans);
		if (cnt == a.length * 2 / 3 || cnt0 == a.length)
			return true;
		else
			return false;
	}

	public static boolean calcThisLevel1st(long[] a, long[] b, long mod, long ans) {
		int cnt = 0;
		int cnt0 = 0;
		for (int i = 0; i < a.length; i++) {
			//System.out.println(a[i] + ":" + a[i] % mod);

			if (a[i] % mod == ans) {
				cnt++;
				a[i] -= ans;
				b[i] = 1;
			} else {
				cnt0++;
				b[i] = 0;
			}
		}
		if (cnt == a.length * 2 / 3 || cnt0 == a.length)
			return true;
		else
			return false;
	}

	public static boolean check0(long[] a) {
		for (int i = 0; i < a.length; i++) {
			if (a[i] != 0) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];
		long MaxA = 0;
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextLong();
			b[i] = 0;
			if (a[i] > MaxA)
				MaxA = a[i];
		}
		MaxA *= 2;
		sc.close();

		//System.out.println(MaxA);
		// 9
		// 3 2 3 3 2 3 1 0 1
		// これでNoが出せないそれがWA
		// というか嘘解法
		// 6
		// 59157337 55005153 12707000 59157337 55005153 12707000

		if (check0(a)) {
			System.out.println("Yes");
			return;
		}

		if (N % 3 != 0) {
			System.out.println("No");
			return;
		}

		long mod = 2;
		long ans = 1;
		do {
			if (mod == 2) {
				if (!calcThisLevel1st(a, b, mod, ans)) {
					System.out.println("No");
					return;
				}
			} else {
				if (!calcThisLevel(a, b, mod, ans)) {
					System.out.println("No");
					return;
				}
			}
			mod *= 2;
			ans *= 2;
		} while (mod < MaxA);

		System.out.println("Yes");
		return;
	}
}

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    int k;
    cin>>k;
    int result=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                result+=gcd(a,gcd(b,c));
            }
        }
    }
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
const int maxn=1e5+5;
int T,i,j,now,r[maxn],Q,t,x,mx,mi,c,k,ans,lami,lamx;
bool bz;
int main(){
	T=read(),k=read();
	fo(i,1,k) r[i]=read();
	Q=read();
	mi=0,mx=T,c=0;
	now=1,bz=1;
	for(;Q--;){
		t=read(),x=read();
		for(;now<=k&&t>r[now];now++,bz^=1){
			int len=r[now]-r[now-1];
			if (bz) lami=mi,mi=max(mi,min(mx,len-c)),c=max(0,lami+c-len)-mi;
			else lamx=mx,mx=min(mx,max(mi,T-len-c)),c=min(lamx+c+len,T)-mx;
		}
		if (x<mi) ans=mi+c;else
		if (x<=mx) ans=x+c;else
		ans=mx+c;
		if (bz) ans=max(0,ans-(t-r[now-1]));else
		ans=min(T,ans+(t-r[now-1]));
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1536
#include<stdio.h>

int main(){
int a[4];
int j,i;

scanf("%d %d %d",&a[0],&a[1],&a[2]);

for(i=0;i<2;i++){
for(j=1;j<3;j++){
    if(a[i] > a[j]){
      a[3]=a[i];a[i]=a[j];a[j]=a[3];
    }
}
}

printf("%d %d %d\n",a[0],a[1],a[2]);
return 0;
}

Measured memory_bytes: 596
package main

import "fmt"

func main() {
        N, K, c := 0, 0, 0
        fmt.Scan(&N, &K)
        for i := 0; i < N; i++ {
                h := 0
                fmt.Scan(&h)
                if h >= K {
                        c++
                }
        }
        fmt.Println(c)
}

Measured memory_bytes: 5504
N,M = map(int,input().split())
A = [-int(_) for _ in input().split()]

# 優先度つきキューに変換
import heapq
heapq.heapify(A)

for m in range(0,M):
  a = heapq.heappop(A)
  heapq.heappush(A, a/2)

ans = -sum(int(a) for a in A)
print(ans)

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;
int A[100000];
vector<pair<int,int>> p(100000);

signed main() {
    int H,W,D; cin >> H >> W >> D;
    rep(i,H) rep(j,W){
        int a; cin >> a;
        a--;
        p[a].first = i; p[a].second = j;
    }
    rep(i,D){
        for(int j=i;j<=H*W;j+=D){
            if(j==i) A[j]=0;
            else {
                A[j] = A[j-D] + abs(p[j].first-p[j-D].first) + abs(p[j].second-p[j-D].second);
            }
        }
    }
    int Q; cin >> Q;
    rep(i,Q){
        int L,R; cin >> L >> R;
        L--; R--;
        cout << A[R]-A[L] << endl;
    }

}

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

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  for(int i = 0; i < d; i++){
    cin >> p.at(i) >> c.at(i);
  }
  
  int ans = 10000000;
  for(int bit = 0; bit < (1 << d); bit++){
    int num = 0;
    int total = 0;
    for(int i = 0; i < d; i++){
      if(bit & (1 << i)){
        total += p.at(i) * 100 * (i + 1) + c.at(i);
        num += p.at(i);
      }
    }
    if(total >= g) ans = min(ans, num);
    else{
      for(int i = d - 1; i >= 0; i--){
        if(bit & (1 << i)) continue;
        for(int j = 0; j < p.at(i); j++){
          if(total >= g) break;
          total += 100 * (i + 1);
          num++;
        }
      }
      ans = min(ans, num);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認
using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    mint a, b;
};

S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{r.a * l.a + r.size * l.b, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }

F id() { return F{1, 0}; }

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

    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a[i] = S{x, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int l, r;
            int c, d;
            scanf("%d %d %d %d", &l, &r, &c, &d);
            seg.apply(l, r, F{c, d});
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%d\n", seg.prod(l, r).a.val());
        }
    }
}


Measured memory_bytes: 19272
// 2012アジア地区予選 F : Never Wait for Weights

#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cstdio>

using namespace std;

struct Query{
	char type; int a, b, w;
};

int weight[100000];
int root[100000];
int getRoot(int v){ return root[v]==-1 ? v : root[v] = getRoot(root[v]); }

int main(){
	int N, M;
	while(cin >> N >> M && N){
		vector< vector< pair<int, int> > > vp(N);
		vector<Query> vq(M);
		for(int i=0;i<M;i++){
			cin >> vq[i].type;
			if(vq[i].type == '!') cin >> vq[i].a >> vq[i].b >> vq[i].w;
			else                  cin >> vq[i].a >> vq[i].b;
			--vq[i].a;
			--vq[i].b;
		}
		for(int i=0;i<M;i++){
			if(vq[i].type == '?') continue;
			vp[vq[i].a].push_back(make_pair(vq[i].b,  vq[i].w));
			vp[vq[i].b].push_back(make_pair(vq[i].a, -vq[i].w));
		}
		memset(root, 0, sizeof(root));
		for(int i=0;i<N;i++){
			if(root[i]) continue;
			weight[i] = 0;
			root[i] = 1;
			queue<int> qu; qu.push(i);
			while(!qu.empty()){
				int pos = qu.front(); qu.pop();
				for(int j=0;j<vp[pos].size();j++){
					int next = vp[pos][j].first;
					if(root[next]) continue;
					weight[next] = weight[pos] + vp[pos][j].second;
					qu.push(next);
					root[next] = 1;
				}
			}
		}
		memset(root, -1, sizeof(root));
		for(int i=0;i<M;i++){
			if(vq[i].type == '?'){
				if(getRoot(vq[i].a) == getRoot(vq[i].b)) printf("%d\n", weight[vq[i].b] - weight[vq[i].a]);
				else                                     printf("UNKNOWN\n");
			} else {
				int p = getRoot(vq[i].a);
				int q = getRoot(vq[i].b);
				if(p != q) root[q] = p;
			}
		}
	}
}

Measured memory_bytes: 8952
import java.util.*;

public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char[] orgChar = sc.next().toCharArray();
            boolean[] org = new boolean[orgChar.length];
            for (int j = 0; j < orgChar.length; j++) {
                org[j] = (orgChar[j] == '1');
            }
            HashMap<Long, Integer> map = new HashMap<>();
            map.put(getNum(org), 0);
            int orgCount = 1;
            for (int j = 1; j < org.length; j++) {
                if (org[org.length - j]) {
                    org[org.length - j] = false;
                    if (!org[org.length - j - 1]) {
                        org[org.length - j - 1] = true;
                    }
                    map.put(getNum(org), orgCount);
                    orgCount++;
                }
            }
            char[] nextChar = sc.next().toCharArray();
            boolean[] next = new boolean[nextChar.length];
            for (int j = 0; j < nextChar.length; j++) {
                next[j] = (nextChar[j] == '1');
            }
            if (map.containsKey(getNum(next))) {
                sb.append(map.get(getNum(next))).append("\n");
                continue;
            }
            int nextCount = 1;
            for (int j = 1; j < next.length; j++) {
                if (next[next.length - j]) {
                    next[next.length - j] = false;
                    if (!next[next.length - j - 1]) {
                        next[next.length - j - 1] = true;
                    }
                    if (map.containsKey(getNum(next))) {
                        sb.append(map.get(getNum(next)) + nextCount).append("\n");
                        break;
                    }
                    nextCount++;
                }
            }
            
        }
        System.out.print(sb);
    }
    
    static long getNum(boolean[] arr) {
        long ans = 0;
        for (boolean b : arr) {
            ans <<= 1;
            if (b) {
                ans++;
            }
        }
        return ans;
    }
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n,k; cin>>n>>k;
  int ans=1;
  rep(i,n)
  {
    ans=min(2*ans,ans+k);
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<ll,ll> P;

int main(){
    ll n;cin >> n;
    ll ans=1000000000009;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans = min(ans,(i-1)+n/i-1);
            if(n%(i*i)==0) ans = min(ans,(i*i-1)+n/(i*i)-1);
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int ans = 0;
    for(int i = 1; i <= (b-a); i++){
      ans += i;
    }
    
    System.out.println(ans - b);
      
  }  
}

Measured memory_bytes: 35256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


const int MAX = 51;
vector<vector<ll>> COM(MAX+1,vector<ll>(MAX+1,0));
void COMinit(){
    COM[0][0] = 1;
    rep(i,MAX){
        rep(j,MAX){
            if(i == 0 || j == 0)COM[i][j] = 1;
            else COM[i][j] = COM[i][j-1] + COM[i-1][j];
        }
    }
}
ll com(ll n, ll k){
    return COM[n-k][k];
}
ll pow(ll a, ll b){
    ll ret = 1;
    rep(i,b)ret *= a;
    return ret;
}
int main(){
    ll n,p; cin >> n >> p;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> re(2,0);
    rep(i,n)re[a[i]%2]++;
    ll ans = 0;
    COMinit();
    // print(COM);
    if(p == 0){
        ll odd = 0, even = 0;
        rep(i,re[1]/2+1)odd += com(re[1],i*2);
        even = pow(2,re[0]);
        ans = odd * even;
    }
    else{
        ll odd = 0, even = 0;
        even = pow(2,re[0]);
        for(int i = 1;i < re[1]; i += 2)odd += com(re[1],i);
        ans = even * odd;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
	import java.lang.Math;
    public class Main
	{
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();
			String s = scan.next();
			String m="";
			for(int i=0;i<s.length();i++)
			{
				if(s.charAt(i)+n > 'Z')
				{
					m = m+ (char)('A'+(s.charAt(i)+n-'Z'-1));
				}
				else
					m = m+ (char)(s.charAt(i)+n);
			}
			System.out.println(m);
		}
    }

Measured memory_bytes: 147540
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val s = new Array[Int](N)
  for (i <- 0 until N)
    s(i) = in.next().toInt


  //
  var ans = 0L
  for (c <- 1 to N-2) { // c := A - B
    var score = 0L

    val dp = new Array[Boolean](N)
    dp(0) = true; dp(N-1) = true

    var x = 1
    breakable {
      while (true) {
        if (x*c >= N)
          break

        val A = (N-1)-x*c
        if (A <= c)
          break

        if (dp(x*c))
          break
        dp(x*c) = true

        if (dp((N-1)-x*c))
          break
        dp((N-1)-x*c) = true

        score += s(x*c)
        score += s((N-1)-x*c)

        ans = Math.max(ans, score)

        x += 1
      }
    }
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}


Measured memory_bytes: 117912
/**
*    created: 01.07.2020 21:55:21
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a1 = 0;
    int a2, a3, b1, b2, b3;
    cin >> b1 >> b2 >> b3;
    int tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
    cin >> tmp1 >> tmp2 >> tmp3 >> tmp4 >> tmp5 >> tmp6;
    a2 = tmp1 - b1;
    a3 = tmp4 - b1;
    if (a2 + b2 != tmp2) {cout << "No" << endl; return 0;}
    if (a2 + b3 != tmp3) {cout << "No" << endl; return 0;}
    if (a3 + b2 != tmp5) {cout << "No" << endl; return 0;}
    if (a3 + b3 != tmp6) {cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
typedef long long ll;

int main() {
    int n,m;
    cin >> n >> m;
    string a[50] = {}, b[50] = {};

    rep(i, n){
        cin >> a[i];
    }
    rep(i, m){
        cin >> b[i];
    }
    
    rep(i, n-m+1){
        rep(j , n-m+1){
            string sub = a[i].substr(j, m);
            if(sub == b[0]) {
                bool ok = true;
                for(int k = 1; k < m; k++){
                    string sub = a[i+k].substr(j, m);
                    if(sub != b[k]){
                        ok = false;
                        break;
                    }
                }
                if(ok){
                    cout << "Yes" << endl;
                    return 0;
                }
            }//一行目一致
        }
    }
    cout << "No" << endl;
    return 0;
}


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

typedef struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
} node;

node *root,*nil;

node *find(node *u,int k){
  while(u!=nil && k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  node *a=root;
  node *b=nil;
  node *c;
  c=(node *)malloc(sizeof(node));
  c->key=k;
  c->left=nil;
  c->right=nil;
  while(a!=nil){
    b=a;
    if(c->key<a->key){
      a=a->left;
    }else{
      a=a->right;
    }
  }
  c->parent=b;
  if(b==nil){
    root=c;
  }else{
    if(c->key<b->key){
      b->left=c;
    }else{
      b->right=c;
    }
  }
}

void inorder(node *u){
  if(u==nil)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(node *u){
  if(u==nil)return;
  printf(" %d",u->key );
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char c[100];
  scanf("%d",&n);
  for(i= 0;i<n;i++){
    scanf("%s",c);
    if('f'==c[0]){
      scanf("%d",&x);
      struct Node *t = find(root,x);
      if(t != nil)printf("yes\n" );
      else printf("no\n");
    }else if(strcmp(c,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(c,"print")==0){
      inorder(root);
      printf("\n" );
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20440
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    ai = list(input())
    a.append(ai)
for i in range(m):
    bi = list(input())
    b.append(bi)

hidariue = b[0][0]
hasikouho = []
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == hidariue:
            hasikouho.append([i,j])

x = []

for v in hasikouho:
    ans = "Yes"
    i = int(v[0])
    j = int(v[1])
    for p in range(m):
        if ans == "Yes":
            for q in range(m):
                if a[i+p][j+q] != b[p][q]:
                    ans = "No"
                    break
        else:
            break
    x.append(ans)

if "Yes" in x:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[allow(unused_macros)]
macro_rules ! max {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: max ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: max ($ a , max ! ($ ($ rest ) ,+ ) ) } } ; }
#[allow(unused_macros)]
macro_rules ! chmax {($ base : expr , $ ($ cmps : expr ) ,+ $ (, ) * ) => {{let cmp_max = max ! ($ ($ cmps ) ,+ ) ; if $ base < cmp_max {$ base = cmp_max ; true } else {false } } } ; }

fn main() {
    input! {
        n: usize,
        k: usize,
        v: [i64; n],
    }

    let mut ret = 0;
    for left in 0..=n {
        for right in 0..=n {
            // take [0, left) + [n - right, n)
            if left + right > n {
                continue;
            }

            let mut js = vec![];
            for i in 0..left {
                js.push(v[i].clone());
            }
            for i in n - right..n {
                js.push(v[i].clone());
            }
            if js.len() > k {
                continue;
            }

            let mut tmp: i64 = js.iter().sum();
            dbg!(&js);
            js.sort();
            for i in 0..k - js.len() {
                if i < js.len() && js[i] < 0 {
                    tmp -= js[i];
                }
            }
            chmax!(ret, tmp);
        }
    }

    println!("{}", ret)
}


Measured memory_bytes: 2208
var a,b,c,s:longint;
begin
  readln(a,b,c);
  s:=3;
  if a=b then dec(s);
  if a=c then dec(s);
  if b=c then dec(s);
  if (a=b) and (b=c) then inc(s);
  writeln(s);
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int n,m,p;

int main(){
	while(1){
		cin >> n >> m >> p;
		if(n==0&&m==0&&p==0) break;
		int sum = 0;
		int waru;
		REP(i,n){
			int tmp;
			cin >> tmp;
			if(i==m-1) waru = tmp;
			sum += tmp;
		}
		if(waru==0) cout << 0 << endl;
		else cout << sum*100*(100-p)/100/waru << endl;
	}
}

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




int main()
{
   
  


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    queue <ll> numbers;
    for(ll i=1;i<=9;i++)
        numbers.push(i);

    ll k;
    cin>>k;
    while(k>1)
    {
        //cout<<numbers.front()<<endl;
        ll curr = numbers.front();
        numbers.pop();

        if(curr%10!=0)
            numbers.push((curr*10 + ((curr%10)-1)));
        numbers.push((curr*10 + ((curr%10))));
        if(curr%10!=9)
            numbers.push((curr*10 + ((curr%10)+1)));
        k--;
        

    }
    cout<<numbers.front()<<endl;
    return 0;
}

Measured memory_bytes: 1792
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	cin >> s;
	int size = s.length();
	string ans = "AC";

	if (s[0] != 'A') {
		ans = "WA";
	}
	int cnt = 0;
	for (int i = 1; i < size; ++i) {
		if (isupper(s[i])) {
			if (i == 1 || i == size-1 || s[i] != 'C') {
				ans = "WA";
			}
			++cnt;
		}
	}
	if (cnt != 1) {
		ans = "WA";
	}
	cout << ans << endl;

	return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, m, t;
    cin >> n >> m >> t;
    cout << t / n * m << "\n";
    return 0;
}

Measured memory_bytes: 256
Alis=list(map(str,input()))
Blis=list(map(str,input()))
Clis=list(map(str,input()))
Acnt=0
Bcnt=0
Ccnt=0
p="a"
ans=0
while ans==0:
	if p=="a":
		if Acnt==len(Alis):
			ans='A'
			break
		p=Alis[Acnt]
		Acnt+=1
	if p=="b":
		if Bcnt==len(Blis):
			ans='B'
			break
		p=Blis[Bcnt]
		Bcnt+=1
	if p=="c":
		if Ccnt==len(Clis):
			ans='C'
			break
		p=Clis[Ccnt]
		Ccnt+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    string s, t;
    cin >> s >> t;

    vector<string> ans;
    REP(i, s.size()-t.size()+1){
        bool flag = true;
        REP(j, t.size()){
            if(s[i+j] != t[j] && s[i+j] != '?') flag = false;
        }
        if(flag){
            string str = "";
            REP(j, s.size()){
                if(j == i){
                    str = str + t;
                    j += t.size()-1;
                }else{
                    str = str + (s[j] != '?' ? s[j] : 'a');
                }
            }
            ans.pb(str);
        }
    }
    if(ans.size() >= 1){
        sort(all(ans));
        cout << ans[0] << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }

}


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

using namespace std;

int main(){
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  
  int lima = (F + A - 1) / A;
  int limb = (F + B - 1) / B;
  int limc = (F + C - 1) / C;
  int limd = (F + D - 1) / D;
  int sugarwater = 0;
  int sugar = 0;
  double p = 0.0;
  for(int a = 0; a < lima; a++){
    for(int b = 0; b < limb; b++){
      int X = 100 * a * A + 100 * b * B;
      if(X > F) continue;
      int Z = F - X;
      int maxsugar = min(X/100 * E, Z);
      int s = 0;
      for(int c = 0; c < limc; c++){
        for(int d = 0; d < limd; d++){
          if(c * C + d * D > maxsugar) continue;
          if(c * C + d * D >= s){
            s = c * C + d * D;
          }
        }
      }
      if(p <= ((double)s/((double)X + (double)s) * (double)100.0)){
        sugarwater = X + s;
        sugar = s;
        p = (double)s/((double)X + (double)s) * (double)100.0;
        //cout << p << endl;
      }
    }
  }
  cout  << sugarwater << " " << sugar;
}


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

typedef double                 ld;
typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define endl                        '\n'
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define kill(x)                     return cout << x << endl , 0;
#define pb                          push_back

const ll MXN = 3e3 + 10;
const ll MXM = 5e2 + 10;
const ll MX5 = 1e5 + 10;
const ll MX6 = 1e6 + 10;
const ll INF = 8e18;
const ld eps = 1e-9;
const ll MOD = 1e9 + 7; //998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
string base2(ll n){
    string a="";while(n>=2){a+=(char)(n%2+'0');n/=2;}a+=(char)(n+'0');reverse(all(a));return a;
}

ll n;
string s;

int main(){
    fast_io
    //file_io
    cin >> n >> s;
    for(int i = 0; i < s.size(); i ++){
        s[i] += n;
        while(s[i] > 'Z'){
            s[i] -= 'Z';
            s[i] += 'A';
            s[i]--;
        }
    }
    cout << s;
    return 0;
}

//! N.N


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int a = r*100 + g*10 + b;
		if (a%4 == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}


	}
}

Measured memory_bytes: 23892
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string str;
    cin >> str;
    if (str.size() % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    bool flag = true;
    for (int i = 0; i < str.size(); i += 2) {
        if (str[i] == 'h' && str[i+1] == 'i') {
        } else {
            flag = false;
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
package main
import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
	"unicode/utf8"
)
var sc = bufio.NewScanner(os.Stdin)
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	firstLine := nextLine()
	split := strings.Split(firstLine, " ")
	if len(split) != 2 {
		fmt.Println("error")
	}
	N, _ := strconv.Atoi(split[0])
	L, _ := strconv.Atoi(split[1])
	var S []string
	i := 0
	for i < N {
		line := nextLine()
		if utf8.RuneCountInString(line) != L {
			fmt.Println("error")
			return
		}
		S = append(S, line)
		i++
	}
	sort.Strings(S)
	answer := ""
	for _, s := range S {
		answer = answer + s
	}
	fmt.Println(answer)
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b,sum,nans,ans=0;
	cin >> n >> a >> b;
	for(int i=1;i <= n;i++) 
	{
		nans=0;
		sum=i;
		while(sum != sum/10)  
		{
			nans += sum%10;
			sum /= 10;
		}
		if(nans >= a && nans <= b)
			ans += i; 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int M = 1e9 + 7;

int sum(int a, int b) {
  int c = a + b;
  if (c >= M) c -= M;
  if (c < 0) c += M;
  return c;
}

void add(int &a, int b) {
  a = sum(a, b);
}

int mul(int a, int b) {
  return (a * (ll) b) % M;
}

const int N = 5000 + 7;

int ans[N][2];
int fans[N][2];
int bad_block[N][2][2];

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if (a < b) swap(a, b);
  ans[0][0] = ans[0][1] = 1;
  fans[0][0] = fans[0][1] = 1;
  bad_block[0][0][1] = 1;
  bad_block[0][1][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (i >= a) {
      for (int t = 0; t < 2; t++) {
        for (int z = 0; z < 2; z++) {
          bad_block[i][t][z] = 0;
        }
      }
    } else {
      for (int fir = 0; fir < 2; fir++) {
        for (int last = 0; last < 2; last++) {
          if (last) {
            for (int bl = b; bl <= i; bl++) {
              add(bad_block[i][fir][last], bad_block[i - bl][fir][last ^ 1]);
            }
          } else {
            for (int bl = 1; bl <= i; bl++) {
              add(bad_block[i][fir][last], bad_block[i - bl][fir][last ^ 1]);
            }
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int bl = 1; bl < b && bl <= i; bl++) {
      add(ans[i][1], ans[i - bl][0]);
      add(fans[i][1], ans[i - bl][0]);
    }
    for (int j = 1; j <= i; j++) {
      for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
          add(ans[i][y], mul(bad_block[j][x][y], fans[i - j][x ^ 1]));
        }
      }
    }
  }
  int tot = 1;
  for (int i= 1; i <= n; i++)
    tot = mul(tot, 2);
  add(tot, -ans[n][0]);
  add(tot, -ans[n][1]);
  cout << tot << endl;
}


Measured memory_bytes: 3764
n, c, k = map(int, input().split())
t_list = [int(input()) for i in range(n)]

t_sorted = sorted(t_list)

ans = 1
bus = 1
timer = 0
for i in range(1, len(t_sorted)):
    bus += 1
    timer += t_sorted[i] - t_sorted[i - 1]
    if bus > c or timer > k:
        ans += 1
        bus = 1
        timer = 0

print(ans)

Measured memory_bytes: 8256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        List<string> W = new List<string>();
        string s;
        for (int i = 0; i < N; i++) {
            s = Console.ReadLine();
            if (!W.Contains(s)) W.Add(s);
            else {
                Console.WriteLine("No");
                return;
            }
        }
        for (int i = 1; i < N; i++) {
            if (W[i][0] != strReverce(W[i - 1])[0]) {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


Measured memory_bytes: 13152
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String str = scanner.next();

        int index = 0;
        int last = str.length() -1;
        int count = 0;
        while(true) {
            if (index >= last) {
                break;
            }
            if (str.charAt(index) == str.charAt(last)) {
                index++;
                last--;
            } else if (str.charAt(index) != 'x' && str.charAt(last) == 'x') {
                count++;
                last--;
            } else if (str.charAt(index) == 'x' && str.charAt(last) != 'x') {
                count++;
                index++;
            } else {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(count);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 25044