akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;

vvi ans;
int N;

void dfs(int x,vvi &a,int ma) {
  if(x==N) {
    rep(i,sz(a)) {
      ans.push_back(a[i]);
    }
    return;
  }
  srep(k,0,ma+2) {
    vvi b(a);
    rep(i,sz(b)) {
      b[i].push_back(k);
    }
    dfs(x+1,b,max(ma,k));
  }
}
  
int main() {
  cin >> N;
  vvi a(1,vi{0});
  dfs(1,a,0);
  rep(i,sz(ans)) {
    vi k = ans[i];
    string s = "";
    rep(j,sz(k)) {
      s += k[j]+'a';
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 9648
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, K, S, i;

    cin >> N >> K >> S;

    if(K == 0){
        for(i=1; i<=N; i++){
            cout << S/2+1 << " ";
        }
        cout << endl;
    }

    else{
        for(i=1; i<=N; i++){
            if(i <= K){
                cout << S << " ";
            }
            else{
                //cout << 1 << " ";
                if(S == 1000000000){
                    cout << 99999999 << " ";
                }
                else{
                    cout << 1000000000 << " ";
                }
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
typedef long long int ll;
#define pb         push_back
#define mp         make_pair
#define F          first
#define S          second
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define pll        pair<ll,ll>
#define pii        pair<int,int>
#define all(v)     v.begin(),v.end()
#define M          1000000007
#define M2         1000000009
#define M3         1000000000000007

using namespace std;
bool isPrime(ll n)
{
    if(n<=1)
        return false;
    if(n<=3)
        return true;
    if(n%2==0 || n%3==0)
        return false;

    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0|| n%(i+2)==0)
            return false;

    return true;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b,a%b);

}

bool sortbydesc(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    if(a.S < b.S)
        return true;
    else
        return false;
}

vector<ll> v;
ll dp[3005][3005][2];

ll sol(ll i, ll j, ll turn)
{
    if(dp[i][j][turn]!=M3)
        return dp[i][j][turn];
    if(i==j)
    {
        if(turn==0)
        dp[i][j][turn]=v[i];
        else
            dp[i][j][turn]=-v[i];
        return dp[i][j][turn];
    }
    if(turn == 0)
        dp[i][j][turn]=max(v[i]+sol(i+1,j,1-turn),v[j]+sol(i,j-1,1-turn));
    else
        dp[i][j][turn]=min(sol(i+1,j,1-turn)-v[i],sol(i,j-1,1-turn)-v[j]);
    return dp[i][j][turn];
}

int main()
{
 ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 ll n;
 cin>>n;
 
 v.pb(0);
 ll a;
 fl(i,0,n)
 {
    cin>>a;
    v.pb(a);
 }
 fl(i,0,3005)
 {
    fl(j,0,3005)
    {
        dp[i][j][0]=M3;
        dp[i][j][1]=M3;
    }
 }
 ll ans=sol(1,n,0);
 cout<<ans;
}






Measured memory_bytes: 141568
#include <stdio.h>
int bubbleSort(int *,int );
int main(){
  int kazu,A[100],count,i;
    scanf("%d",&kazu);
  for(i=0;i<kazu;i++){
    scanf("%d",&A[i]);
  }
  count=bubbleSort(A,kazu);
  for(i=0;i<kazu;i++){
    if(i!=kazu-1){
    printf("%d ",A[i]);
    }
    else{printf("%d",A[i]);
    }
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}


int bubbleSort(int *A,int N){
  int flag=1,reset,count=0;
  while(flag){
    flag=0;
    for(int j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	reset=A[j];
	A[j]=A[j-1];
	A[j-1]=reset;
	flag=1;
	count++;
      }
    }
  }
  
    return count;
}

    
  



Measured memory_bytes: 2104
#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 29996224275833
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    set<int> s;
    fo(i,k){
        int d;
        cin >> d;
        int x;
        fo(j, d)
            { cin >>x;
              s.insert(x);}
    }
    cout << n - s.size();

}
    


Measured memory_bytes: 3664
#include <iostream>
#include<math.h>
#include<string.h>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll n,a,s,x,i,j;
    cin>>n>>a;
    ll k[n],sum[10000][n+1];
    memset(sum,10000*n*sizeof(int),0);
    for(i=0;i<n;i++){
        cin>>s;
        k[i]=s-a;
    }

    sum[5000][0]=1;
    for(i=0;i<n;i++){
        for(j=0;j<10000;j++){
            if(0<=j-k[i]&&j-k[i]<10000)x=sum[j-k[i]][i];
            else x=0;
            sum[j][i+1]=sum[j][i]+x;
        }
    }

    cout<<sum[5000][n]-1<<endl;

}

Measured memory_bytes: 4224
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 110
using namespace std;
int n,d;
bool used[MAXN];
bool check(int x){
	while(x){
		if(used[x%10]==1)
			return 0;
		x/=10;
	}
	return 1;
}
int main(){
	SF("%d%d",&n,&d);
	int x;
	for(int i=0;i<d;i++){
		SF("%d",&x);
		used[x]=1;
	}
	for(int i=n;;i++)
		if(check(i)){
			PF("%d",i);
			return 0;	
		}
}

Measured memory_bytes: 128
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	//
	LL ans = LINF;
	LL res,sum;
	//
	res = 0;
	sum = 0;
	for(int i=0;i<N;++i){
		sum += A[i];
		if( i & 1 ){
			if( sum >= 0 ){
				res += sum+1;
				sum = -1;
			}
		}else{
			if( sum <= 0 ){
				res += abs(sum)+1;//sum<=0
				sum = 1;
			}
		}
	}
	ans = res;

	res = 0;
	sum = 0;
	for(int i=0;i<N;++i){
		sum += A[i];
		if( i & 1 ){
			if( sum <= 0 ){
				res += abs(sum)+1;
				sum = 1;
			}
		}else{
			if( sum >= 0 ){
				res += sum+1;
				sum = -1;
			}
		}
	}
	ans = min(ans,res);
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 640
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-4 16:30:58
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <iterator>
#include <bitset>
#include <random>
#include <assert.h>
#include <unordered_map>
#include <array>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define MP make_pair
#define umap unordered_map

using namespace std;

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

vector<pair<ll, int>> v;

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

int ans;
void dfs(int n, ll a, ll b){
	if (n == v.size()){
		if (a <= b){
			//cout << a << ' ' << b << endl;
			++ans;
		}
		return;
	}

	int x = v[n].first;
	int m = v[n].second;
	for (int i = 0; i < m; ++i){
		dfs(n + 1, a*_pow(x, i), b*_pow(x, m));
		dfs(n + 1, a*_pow(x, m), b*_pow(x, i));
	}
	dfs(n + 1, a*_pow(x, m), b*_pow(x, m));
}

int main(){
	ll L;
	while (cin >> L, L){
		ans = 0;
		v.clear();
		for (ll i = 2; i*i <= L; ++i){
			int cnt = 0;
			while (L % i == 0) {
				++cnt;
				L /= i;
			}
			if (cnt) v.push_back(MP(i, cnt));
		}
		if (L != 1) v.push_back(MP(L, 1));

		dfs(0, 1, 1);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

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

	using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

vector<ll> x, y;
int main() {
	ll N, K;

	cin >> N >> K;

	if (K == 1)
		cout << 0 << endl;
	else
	cout << (N - K) << endl;


	return 0;
}


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


void swap(int x,int y)
{
    int work=x;
    x=y;
    y=work;
}

int gcd(int x,int y)
{
    int r;
    if(y>x)
        swap(x, y);
    while(y){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

int main(){
    int x;scanf("%d",&x);
    int y;scanf("%d",&y);
    
    printf("%d\n",gcd(x,y));
}



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

int main() {
    int N, M; cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
	vector<pair<int,int>> f(3);
 	for (auto& x : f) cin >> x.first >> x.second;
    for (int x=0;x<8;++x) {
      auto e = f;
      for (int i = 0; i < 3; ++i) {
       	if ((x>>i)&1) swap(e[i].first, e[i].second); 
      }
     sort(e.begin(), e.end());
	do {
    	if (e[0].second == e[1].first && e[1].second == e[2].first && e[0].first != e[2].second) {
          cout << "YES\n";
          return 0;
        }
    } while (next_permutation(e.begin(), e.end()) ); 
      
    }
    cout << "NO\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e5;  
using  p = pair<int,int>;

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

  auto ans=0;
  for (auto i:n)
  {
    ans += i-'0';
  }
  
  if(stoi(n)%ans==0){
    cout << "Yes";
  }else{
    cout << "No";
  }

}
  
  

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int x = sc.nextInt();
      	if(x < 1200){
        	System.out.println("ABC");
        }else{
        	System.out.println("ARC");
        }
    }
}

Measured memory_bytes: 35412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

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

  int a,b;
  cin >> a >> b;
  
  int n = a + b;
  if(a % 3 == 0 || b % 3 == 0 || n % 3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}

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

int main(){
    string S; cin >> S;
    int Q; cin >> Q;
    deque<char> que;
    for(int i = 0; i < S.size(); i++){
        char s = S.at(i);
        que.push_back(s);
    }
    int cnt = 0; //何回リバースしたか。奇数回リバースの時,１は末尾につけるのと一緒
    for(int i = 0; i < Q; i++){
        int q; cin >> q;
        if(q == 1) cnt++;
        else{
            int a; cin >> a;
            char s; cin >> s;
            if(cnt % 2 == 1){
                if(a == 1) que.push_back(s);
                else que.push_front(s);
            }
            else{
                if(a == 1) que.push_front(s);
                else que.push_back(s);
            }
        }
    }
    if(cnt % 2 == 0){
        while(!que.empty()){
            char ans = que.front(); que.pop_front();
            cout << ans;
        }
    }
    else{
        while(!que.empty()){
            char ans = que.back(); que.pop_back();
            cout << ans;
        }
    }
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>

int main() {
	int *A, n, i, j, cnt = 0, tmp;

	scanf("%d", &n);
	A = (int *)malloc(sizeof(int)*n);
	for (i = 0; i < n; ++i) scanf("%d", A + i);

	for (i = 0; i < n; i++)
		for (j = n - 1; j > i; --j)
			if (*(A + j - 1) > *(A + j))
				tmp = *(A + j), *(A + j) = *(A + j - 1), *(A + j - 1) = tmp, cnt++;
	for (i = 0; i < n; i++) printf("%d%c", A[i], i < n - 1 ? ' ' : '\n');
	printf("%d\n", cnt);
	free(A);
	return 0;
}

Measured memory_bytes: 600
n, l = gets.split.map(&:to_i)

aji = []
(1..n).each{ |i| aji.push(l + i -1) }

foo = 10 ** 5
for var in aji do
    foo = var if var.abs < foo.abs
end
aji.delete(foo)

puts aji.inject(:+)

Measured memory_bytes: 1788
require 'set'
N,K,L = gets.split.map(&:to_i)

class UnionFindTree
  def initialize(n)
    @n = n
    @parent = (0...n).to_a
    @size = Array.new(n, 1)
  end

  def root_of(x)
    if @parent[x] == x
      x
    else
      (@parent[x] = root_of(@parent[x]))
    end
  end

  def unite(a, b)
    x = root_of(a)
    y = root_of(b)
    return if x == y
    x, y = y, x if @size[x] > @size[y]
    @size[y] += @size[x]
    @parent[x] = y
  end

  def roots
    (0...@n).map{|i| root_of(i)}
  end
end

def load_edges(n_edges)
  UnionFindTree.new(N+1).tap{|ret|
    n_edges.times do
      a, b = gets.split.map(&:to_i).sort
      ret.unite(a, b)
    end
  }
end

trees1 = load_edges(K)
trees2 = load_edges(L)
ans = Array.new(N+1)
groups = (0..N).zip(trees1.roots, trees2.roots).group_by{|i, a, b| [a, b]}
groups.each do |key, items|
  items.each{|i, _, _| ans[i] = items.size}
end
puts ans.drop(1).join(' ')


Measured memory_bytes: 59260
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=4010;
const int Mod=998244353;
int C[MAXN][MAXN],Two[MAXN]={1};
int k,n;
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
	while(b!='-'&&(b<'0'||b>'9'))b=getchar();
	if(b=='-')c=-1,b=getchar();
	while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
	return a*c;
}
inline int Min(rg int A,rg int B){   return A<B?A:B;   }
inline int Calc(int Ban,int Tot)
{   int M=Min(Ban/2,k-(Ban-1)/2),Back=C[n+k-1][n];
	for(rg int i=1,K=-1;i<=M&&i<=n/2;i++,K=-K)
		Back=(Back+1ll*K*C[M][i]*C[k+n-2*i-1][k-1]%Mod)%Mod;
	return Back;
}
int main()
{   k=Read(),n=Read(),C[0][0]=1;
	for(rg int i=1;i<=4000;i++)
	{   C[i][0]=1;
		for(rg int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%Mod;
	}
	for(rg int i=2;i<=2*k;i++)
		printf("%d\n",(Calc(i,n)%Mod+Mod)%Mod);
}


Measured memory_bytes: 61440
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=100000;i++)
	{
		if(floor((double)i*0.08)==a&&floor((double)i*0.1)==b)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(1e5 + 5)], ans[int(1e5 + 5)];
ll Limit[int(1e5 + 5)];

int main(){
  scanf("%d", &N);
  for (int i = 0; i <= N; i++) scanf("%lld", A + i);
  for (int i = N; i >= 0; i--) Limit[i] = Limit[i + 1] + A[i];

  if (N == 0){
    if (A[0] == 1) cout << 1 << endl;
    else cout << -1 << endl;
    return 0;
  }
  
  if (A[0] > 0){
    cout << -1 << endl;
    return 0;
  }

  ans[0] = 1;
  ll now = 1;
  for (int i = 0; i <= N; i++){
    ans[i] = now;
    if (now < A[i]){
      cout << -1 << endl;
      return 0;
    }
    now -= A[i];
    now = min(now * 2, Limit[i + 1]);
  }

  ll sum = 0;
  for (int i = 0; i <= N; i++) sum += ans[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6032
#include<stdio.h>
int main()
{
	int n,num,sum=0;
	scanf("%d",&n);
	if(n==1)
		printf("Hello World\n");
	else
	{
		for(int i=0;i<n;i++)
		{
			scanf("%d",&num);
			sum=sum+num;
		}	
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
N = input()

summation = 0
for i in range(int(N) + 1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        summation += i

print(summation)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define pair<int,int> pii;
typedef long long ll;

int main(){
    int N;string S;
    cin >> N >> S;
    if(N % 2 == 1){
        puts("No");
    }else{
        if(S.substr(0, N / 2) == S.substr(N / 2, N / 2)) puts("Yes");
        else puts("No");
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(void){
  char s[MAX],t[MAX];
  int i,j,save,l,judge=0;
  scanf("%s %s",s,t);
  for(i=0;i<strlen(s);i++){
    for(j=i+1;j<strlen(s);j++){
      if(s[i] > s[j]){
        save = s[i];
        s[i] = s[j];
        s[j] = save;
      }
    }
  }
  for(i=0;i<strlen(t);i++){
    for(j=i+1;j<strlen(t);j++){
      if(t[i] < t[j]){
        save = t[i];
        t[i] = t[j];
        t[j] = save;
      }
    }
  }
  if(strlen(s) <= strlen(t)){
    l = strlen(s);
  }
  else{
    l = strlen(t);
  }
  for(i=0;i<l;i++){
    if(s[i] <t[i]){
      printf("Yes");
      judge++;
      break;
    }
    else if(s[i] >t[i]){
      printf("No");
      judge++;
      break;
    }
  }
  if(judge == 0 && strlen(s) < strlen(t)){
    printf("Yes");
  }
  else if(judge == 0){
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    long long r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++) {
        long long next = r * x - D;
        cout << next << endl;

        x = next;
    }

    return 0;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    int x = s.length();

    bool check = 1;
    REP(i,x){
        if(s.at(i) != t.at(i)){
            check = 0;
            break;
        }
    }

    cout << ((check == 1) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    string S;
    cin >> S;
    int l = S.length();
    int m = 100000;
    REP(i, l - 2) {
        int a = (int)(S[i] - '0') * 100 + (int)(S[i + 1] - '0') * 10 + (int)(S[i + 2] - '0');
        if (abs(a - 753) < m) m = abs(a - 753);
    }
    cout << m << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = s; 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> a(n,0);
  rep(i,0,n) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  rep(i,0,n-k) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(void) {
	int N, K, Q;
	scanf("%d %d %d", &N, &K, &Q);
	vector<int> A(Q);
	// 正当数
	vector<int> cor(N);
	for (int i = 0; i < Q; i++) {
		scanf("%d", &A[i]);
		cor[A[i] - 1]++;

	}

	int threshold = Q - K + 1;
	for (int i = 0; i < N; i++) {
		if (cor[i] >= threshold) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}

	return 0;
}


Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        List<String> dat = new ArrayList<String>();
        for (int i = 0; i < H; i++)
        {
            dat.add(scan.next());
        }
        scan.close();
        for (int i = -1; i < H + 1; i++)
        {
            if (i == -1 || i == H)
            {
                for (int j = 0; j < W + 2; j++)
                {
                    System.out.print("#");
                }
                System.out.println();
            }
            else
                System.out.println("#" + dat.get(i) + "#");
        }
    }
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  string s;
  cin>>s;
  int cnt(0);
  string t = "CODEFESTIVAL2016";
  for(int i(0);i<16;i++){
    if(s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}



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

int main() {

  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  int res = 0,ans = 0;
  int m = min(x,y);
  while( m-- ) res += 2;
  if(x >= y) res = c*res + a*(x-y);
  else res = c*res + b*(y-x);
  ans = min( min(a*x+b*y,2*c*max(x,y)),res );

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int N, max = 0, cnt = 0, h;
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d ", &h);
    if(max <= h) {
      max = h;
      cnt++;
    }
  }
  printf("%d\n", cnt);
}
  

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

const int INF = 1001001001;

int t[16][17];
int dp[17][65536];

void init()
{
	memset(t, 0, sizeof(t));
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i < 17; i++){
		for (int j = 0; j < 65536; j++){
			dp[i][j] = INF;
		}
	}
}

int main()
{
	int n;
	while (scanf("%d", &n), n){
		init();
		const int all = (1 << n) - 1;
		
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n + 1; j++){
				scanf("%d", &t[i][j]);
			}
		}
		
		for (int i = 0; i < n; i++){
			for (int j = 0; j <= all; j++){
				for (int k = 0; k < n; k++){
					int to = 1 << k;
					if (j & to) continue;
					
					int mini = t[k][0];
					for (int l = 1; l <= n; l++){
						int f = 1 << (l - 1);
						if (j & f){
							mini = min(mini, t[k][l]);
						}
					}
					dp[i + 1][j | to] = min(dp[i + 1][j | to], dp[i][j] + mini);
				}
			}
		}
		
		printf("%d\n", dp[n][all]);
	}
	
	return 0;
}

Measured memory_bytes: 5548
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
    int a,c;
    char b;
    cin>>a>>b>>c;
    if(b=='+'){
        cout<<a+c;
    }else{
        cout<<a-c;
    }
cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll n, k, a[15];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> a[i];
  ll ans = linf;
  FOR(i, 0, 1<<n){
    if(pcnt(i) != k) continue;
    ll m = 0, c = 0;
    FOR(j, 0, n){
      if(i&(1<<j)){
        if(m < a[j]){
          m = a[j];
        }else{
          c += m + 1 - a[j];
          m++;
        }
      }else{
        maxs(m, a[j]);
      }
    }
    mins(ans, c);
  }
  cout << ans << endl;
  return 0;
}


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

int dp[200020];

int p[200020];

int main(){
   int n;
   cin >> n;
   p[0] = -1;
   
   for(int i = 0 ; i < n ; i++){
    int j;
    cin >> j;
    p[j] = i;
   }
   
   int ans = 1;
   for(int i = 1 ; i <= n ; i++){
      dp[i] = 1;
      if( p[i-1] < p[i] ){
        dp[i] = dp[i-1] + 1;
        ans = max(ans, dp[i]);
      }
   }
   cout << n - ans << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9;

int main() {
    string s;
    cin >> s;
    int n = s.length();

    map<ll, int> mp;
    VI dp(n+1, INF);
    mp[0] = 0;
    dp[0] = 0;
    int mask = 0;
    REP(i,n){
        int x = s[i] - 'a';
        mask ^= (1 << x);
        REP(j,26){
            if (mp.count(mask ^ (1 << j))){
                dp[i+1] = min(dp[i+1], dp[mp[mask ^ (1 << j)]] + 1);
            }
        }
        if (mp.count(mask)){
            dp[i+1] = min(dp[i+1], dp[mp[mask]] + 1);
        }
        if (mp.count(mask) == 0 || (mp.count(mask) > 0 && dp[mp[mask]] > dp[i+1])){
            mp[mask] = i + 1;
        }
    }
    cout << dp[n] << endl;

    // REP(i,n+1) cout << dp[i] << " ";
    // cout << endl;

    return 0;
}


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

int main() {
  int n, i=0;
  string s;
  cin >> n >> s;
  while(i+1<s.size()){
    if(s[i]==s[i+1]) s.erase(s.begin()+i+1);
    else i+=1;
  }
  cout << s.size() << endl;
  return 0;
}

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

using namespace std;

int main(){
  string s = "abcd";
  string AI;
  map<string,bool> judge;

  judge[s] = true;

  while(true){
    cout << "?" << s << endl;
    cin >> AI;

    if(s[s.size()-1] != AI[0] || judge[AI]){
      cout << "!OUT" << endl;
      break;
    }
    judge[AI] = true;

    s[0] = AI[AI.size()-1];
    for(int i = 1 ; i < 3 ; i++){
      if(s[i] < 122){
	s[i]++;
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
ball_num = [1] * n
red_exist = [0] * n
red_exist[0] = 1
flag = False
red_box = 0
for _ in range(m):
    x, y = LI()
    ball_num[x - 1] -= 1
    ball_num[y - 1] += 1
    if red_exist[x - 1]:
        red_exist[y - 1] = 1
    if ball_num[x - 1] == 0:
        red_exist[x - 1] = 0




cnt = 0
for i in range(n):
    if red_exist[i] and ball_num[i]:
        cnt += 1


print(cnt)




Measured memory_bytes: 44252
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        if A[i + 1] >= B[i]:
            ans += B[i]
            A[i + 1] -= B[i]
        else:
            ans += A[i + 1]
            A[i + 1] = 0

print(ans)


Measured memory_bytes: 18476
n,k=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  if n>m:
    a=n
    b=m
  else:
    a=m
    b=n
  while b!=0:
    a,b=b,a%b
  return a
g=l[0]
max=l[0]
for i in range(1,1+n-1):
  g=gcd(g,l[i])
  if max<l[i]:
    max=l[i]
if max<k:
  print("IMPOSSIBLE")
elif max==k:
  print("POSSIBLE")
else:
  if k%g==0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")


Measured memory_bytes: 14224
#include<stdio.h>

int main(void){
	double x1,x2,y1,y2,x3,x4,y4,y3;
	double kata1,kata2;
	int n;
	scanf("%d",&n);
	while(n--){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
	
		kata1=(y2-y1)*(x4-x3);
		kata2=(y4-y3)*(x2-x1);
	
		if(kata1==kata2){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

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

#define MAX 100005
#define INF INT_MAX

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

int main(int, char**)
{
    int n;
    cin >> n;

    vector<int> a(n+1);
    rep(i,n+1) {
        if (i <= 1) {
            a[i] = 1;
            continue;
        }
        a[i] = a[i-1] + a[i-2];
    }
    cout << a[n] << endl;
    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=35;
ll f[N];
ll dis(ll x1,ll y1,ll x2,ll y2){return abs(x1-x2)+abs(y1-y2);}
ll solve(ll x1,ll y1,ll x2,ll y2,ll level)
{
    if(level==0) return abs(y1-y2);
    ll w=f[level-1];
    if(x1/w!=x2/w) return dis(x1,y1,x2,y2);
    if(x1/w==1&&abs(y1/w-y2/w)>=2)
        return abs(y1-y2)+min(x1%w+x2%w+2,(w-x1%w)+(w-x2%w));
    return solve(x1%w,y1,x2%w,y2,level-1);
}
int main()
{
    f[0]=1;for(int i=1;i<N;i++) f[i]=f[i-1]*3;
    int q;scanf("%d",&q);
    while(q--)
    {
        ll x1,y1,x2,y2;
        scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
        x1--;y1--;x2--;y2--;
        if(abs(x1-x2)>abs(y1-y2)) swap(x1,y1),swap(x2,y2);
        printf("%lld\n",solve(x1,y1,x2,y2,30));
    }
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]

    res = []
    for h in range(H):
        for w in range(W) if h % 2 == 0 else reversed(range(W)):
            if h % 2 == 0:
                if w < W - 1:
                    if A[h][w] % 2 != 0:
                        A[h][w] -= 1
                        A[h][w + 1] += 1
                        res.append([h + 1, w + 1, h + 1, w + 2])
                else:
                    if A[h][w] % 2 != 0:
                        if h + 1 < H:
                            A[h][w] -= 1
                            A[h + 1][w] += 1
                            res.append([h + 1, w + 1, h + 2, w + 1])
            else:
                if w > 0:
                    if A[h][w] % 2 != 0:
                        A[h][w] -= 1
                        A[h][w - 1] += 1
                        res.append([h + 1, w + 1, h + 1, w])
                else:
                    if A[h][w] % 2 != 0:
                        if h + 1 < H:
                            A[h][w] -= 1
                            A[h + 1][w] += 1
                            res.append([h + 1, w + 1, h + 2, w + 1])

    print(len(res))
    for i in res:
        print(*i)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0); 
  int n, t, l, b;
  while (cin >> n) {
    cin >> t >> l >> b;
    if (n == 0) return 0;
    vector<int> g(n + 1);
    for (int i = 0; i < l; i++) {
      int x;
      cin >> x;
      g[x] = 1;
    }
    for (int i = 0; i < b; i++) {
      int x;
      cin >> x;
      g[x] = 2;
    }
    vector<vector<double>> dp(t + 1, vector<double>(n + 1));
    dp[0][0] = 1;
    for (int j = 0; j < t; j++) {
      for (int i = 0; i < n; i++) {
        for (int k = 1; k <= 6; k++) {
          int ii = (i + k > n ? (n - (i + k - n)) : i + k);
          if (g[ii] == 0) dp[j + 1][ii] += dp[j][i] / 6;
          if (g[ii] == 1) {
            if (j + 2 <= t) dp[j + 2][ii] += dp[j][i] / 6;
          }
          if (g[ii] == 2) dp[j + 1][0] += dp[j][i] / 6;
        }
      }
    }
    double ans = 0;
    for (int i = 0; i <= t; i++) {
      ans += dp[i][n];
    }
    cout << setprecision(20) << fixed << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 3232
#include <stdio.h>
#include <math.h>

int main(){
	int N,K;
	scanf("%d%d",&N,&K);
	int i=0,k;
	double work=1,ans=0;
	
	for(k=N;k>0;k--){
		 while(k*work < K){
			i++;
			work = work * 2;
		}
		ans = ans + 1/(N*work);
	}
	printf("%.15f",ans);
	return 0;
}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int R;
  cin >> R;
  cout << fixed << setprecision(3) << 2 * R * 3.14159265 << endl;
}


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

signed main() {
    int d, t, s;
    
    cin >> d >> t >> s;
    
    if (t*s >= d) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return (0);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void dfs(vvi&adj,int v,vb&vis,vi&dis){
	vis[v]=true;
	for(int nbs:adj[v]){
		if(!vis[nbs]){
			dfs(adj,nbs,vis,dis);
		}
		dis[v]=max(dis[v],dis[nbs]);
	}
	if(adj[v].size()) dis[v]++;
}
void solve(){
	ll n,m;
	cin>>n>>m;
	vvi adj(n);
	vl in(n);
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		adj[x].pb(y);
		in[y]++;
	}
	vector<bool> vis(n);
	ll ans=inf;
	vi dis(n);
	for(int i=0;i<n;i++){
		if(in[i]==0 && !vis[i]) dfs(adj,i,vis,dis);
	}
//	cout<<dis;
	cout<<*max_element(all(dis));
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
 
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  string s;
  cin>>s;
  //cout<<s[6]-'0'<<"  "<<s[8]-'0'<<"  "<<s[9]-'0'<<endl;
  if(s[5]-'0'==0&&s[6]-'0'==4&&s[8]-'0'==3&&s[9]-'0'==1)
    cout<<"TBD"<<endl;
  else if(s[5]-'0'==0&&s[6]-'0'<=4)
    cout<<"Heisei"<<endl;
  else
    cout<<"TBD"<<endl;  
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<int> par;

    UnionFind(int n) {
        par.resize(n);
        rep(i, n) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[ry] = rx;
    }

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

int main() {
    int n, q; cin >> n >> q;
    UnionFind tree(n);

    rep(i, q) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c) {
            cout << tree.same(x, y) << endl;
        } else {
            tree.unite(x, y);
        }
    }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        char ch;
        cin>>ch;
        if(ch>='a')
            cout<<"a"<<endl;
        else
            cout<<"A"<<endl;
        
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3648