akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

string s, t;

int dp[3100][3100];

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

    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0) 
    {
        if (dp[i][j] == dp[i-1][j]) {
            --i;
        }

        else if (dp[i][j] == dp[i][j-1]) {
            --j;
        }

        else {
            res = s[i-1] + res;
            --i, --j;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 37120
let  [|N; M|] = stdin.ReadLine().Split(' ') |> Array.map int

let mutable (b:bool[]) = [|for i in 0 .. N -> false|]
let mutable a = [|0 .. N|]
let mutable m = false
 
for i in 1 .. M do
    let [|s; c|] = stdin.ReadLine().Split(' ') |> Array.map int
    if b.[s] = false 
        then
            b.[s] <- true
            a.[s] <- c
        else if a.[s] <> c 
            then
                m <- true
             
if m = true || a.[1] = 0 && N <> 1 then
        printf "%d" -1
    else
        let mutable ans = ""
        for i in 1 .. N do 
            let j =
                if b.[i] = true 
                    then a.[i] 
                    else if i <> 1 || N = 1 then 
                        0
                        else 1         
            ans <- ans + j.ToString()
        printfn "%s" ans


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

int main() {
  int n;
  cin >> n;
  
  vector<int> seito(n);
  for (int i = 0; i < n; i++) {
    cin >> seito.at(i);
  }
  
  vector<int> ans(n);
  
  for (int i = 0; i < n; i++) {
    ans.at(seito.at(i) - 1) = i;
  }
  for (int i = 0; i < n; i++) {
    cout << ans.at(i) + 1 << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;

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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string s; cin >> s;
    bool flag=1;
    
    if(s[0]!='A') flag=0;
    
    int cnt=0;
    for(int i=2; i<s.length()-1; ++i){
        if(s[i]=='C') cnt++;
    }
    if(cnt!=1) flag=0;
    
    int cam=0;
    rep(i,s.length()){
        if(s[i]+0<97) cam++;
    }
    if(cam>2) flag=0;

    if(flag) pr("AC");
    else pr("WA");
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x,y,r,tmp;

    scanf("%d%d",&x,&y);

    if (x<y) {
        tmp=x;
        x=y;
        y=tmp;
    }

    while(1){
        r=x%y;
        if (r == 0) break;
        x=y;
        y=r;
    }
    printf("%d\n",y);

    return 0;
}



Measured memory_bytes: 2140
#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>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> x(n);
  vector<ll> y(m);
  rep(i,n){
    cin >> x[i];
  }
  rep(i,m){
    cin >> y[i];
  }

  mint xe=0, ye=0;
  REP(i,1,n){
    xe += (x[i]-x[i-1])*(n-i)*i;
  }
  REP(i,1,m){
    ye += (y[i]-y[i-1])*(m-i)*i;
  }
  mint ans = xe*ye;
  cout << ans.x << ln;
  return 0;
}

Measured memory_bytes: 4788
import std.algorithm, std.array, std.bitmanip, std.conv, std.stdio, std.string,std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

void main() {
    immutable ip = readln.split.to!(ulong[]);
    immutable n = ip[0], m = ip[1];

    auto sw_vec = new BitArray[m];

    for (int i = 0; i < m; i++) {
        immutable ip1 = readln.split.to!(ulong[]);
        sw_vec[i] = BitArray(new bool[n]);
        for (int j = 0; j < ip1[0]; j++) {
            sw_vec[i][ip1[j+1]-1] = true;
        }
    }

    immutable res_vec = readln.split.to!(ulong[]);

    auto check_vec = BitArray(new bool[n]);
    const auto all_set = {
        auto b = BitArray(new bool[n]);
        foreach (ref v ; b) {
            v = !v;
        }
        return b;
    }();

    ulong valid = 0;
    while(check_vec != all_set) {
        for(int i = 0; i < m; i++) {
            ulong cnt = (sw_vec[i] & check_vec).bitsSet.count % 2;
            if (cnt != res_vec[i]) goto LEND;
        }
        valid++;
LEND:;
     for (int i = 0; i < n; i++) {
         if (check_vec[i] == true) check_vec[i] = false;
         else { check_vec[i] = true; break; }
     }
    }

    for(int i = 0; i < m; i++) {
        ulong cnt = (sw_vec[i] & check_vec).bitsSet.count % 2;
        if (cnt != res_vec[i]) goto FINAL;
    }
    valid++;
FINAL:

    writeln(valid);
}


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


using namespace std;

int main() {
    long long int N, A, B, ans;
    cin >> N >> A >> B;
    
    if (A % 2 == B % 2) {
        ans = (B - A) / 2;
    }
    else {
        ans = min(A - 1, N - B) + (B - A + 1) / 2;
    }

    cout << ans;

    return 0;

}



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

using namespace std;
typedef long long ll;

int N;
int a[100020];

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

  int c1 = 0, c2 = 0, c4 = 0;
  for(int i = 0; i < N; i++){
    if(a[i] % 2 == 1) c1++;
    else if(a[i] % 4 == 0)  c4++;
    else c2++;
  }

  if(c4 >= c1)  cout << "Yes" << endl;
  else if(c1 - c4 == 1 && c2 == 0)  cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
#include"iostream"
using namespace std;
int main() {
	while (1) {
		int n, m,p[10000],sum=0;
		cin >> n >> m;
		
		if (n == 0 && m == 0)break;

		for (int i = 1; i <= n; i++) {
			cin >> p[i];
	}

		for (int j = 0; j < n - 1; j++) {
			for (int i = 1; i < n ; i++) {
				if (p[i] < p[i + 1]) {
					swap(p[i], p[i + 1]);

				}
			}
		}
		for (int i = 1; i <= n; i++) {
					if (i%m != 0) {
						sum += p[i];
					}

			}
		
		cout << sum << endl;
	}
		
	return 0;
}




Measured memory_bytes: 3084
implicit none
integer :: n,m
integer,allocatable :: t(:),c(:)
integer :: i,j,k

read *,n,m

allocate(t(m))
allocate(c(m))

c(:) = 0

do i = 1, n
   read *,k,(t(j),j=1,k)
   do j = 1, k
      c(t(j)) = c(t(j)) + 1
   enddo
enddo

j = 0
do i = 1, m
   if (c(i) == n) then
      j = j + 1
   endif
enddo
write(*,'(i0)') j

end

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    if(__builtin_popcount(n) == 1){
        cout << "No" << "\n";
        return 0;
    }
    cout << "Yes" << "\n";
    for(int i = 1; i < 3; i++){
        cout << i << " " << i + 1 << "\n";
    }
    cout << 3 << " " << n + 1 << "\n";
    for(int i = 1; i < 3; i++){
        cout << i + n << " " << i + 1 + n << "\n";
    }
    if(n == 3)return 0;
    for(int i = 4; i + 1 <= n; i+= 2){
        cout << n + 1 << " " << i + 1 << "\n";
        cout << i + 1 << " " << i  << "\n";
        cout << n + 1 << " " << i + n << "\n";
        cout << i + n << " " << i + 1 + n << "\n";
    }
    if(n % 2 == 0){
        int k = n ^ 1;
        for(int i = 2; i < n; i++){
            int kk = k ^ i;
            if(kk < i and kk != 1){
                if(i % 2){
                    cout << kk + n << " " << n << "\n";
                    cout << i << " " << n + n << "\n";
                }else{
                    cout << kk << " " << n << "\n";
                    cout << i + n << " " << n + n << "\n";
                }
                return 0;
            }
        }
    }
}

Measured memory_bytes: 2816
fun main(args: Array<String>) {
    val p = Array(5) {
        readLine()!!.toInt()
    }
    val k = readLine()!!.toInt()

    println(if(f(p, k)) "Yay!" else ":(")
}

private fun f(p: Array<Int>, k: Int) : Boolean {
    var size = p.size
    for (i in 0..size-1) {
        for (j in (i+1)..size-1) {
            if (p[j] - p[i] > k) {
                return false
            }
        }
    }

    return true
}

Measured memory_bytes: 33668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    set<string>ss;
    for(int i=0;i<n;i++){
        cin>>s;
        ss.insert(s);
    }
    cout<<ss.size()<<endl;
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]-=(i+1);
    }

    sort(a.begin(),a.end());
    ll opt=a[n/2];
    ll ans=0;
    for(int j = 0; j < n; j++) {
        ans+=abs(a[j]-opt);
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  queue<pair<int, int>> que;
  vector<vector<int>> count(H, vector<int>(W, -1));
  
  vector<vector<char>> maze(H, vector<char>(W, ' '));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze.at(i).at(j);
      if (maze.at(i).at(j) == '#') {
        que.push(make_pair(i, j));
        count.at(i).at(j) = 0;
      }
    }
  }
  
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  int result = 0;
  
  while (!que.empty()) {
    pair<int, int> pos = que.front();
    que.pop();
    
    for (int i = 0; i < 4; i++) {
      int nx = pos.first + dx[i];
      int ny = pos.second + dy[i];
      
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (maze.at(nx).at(ny) == '#') continue;
      if (count.at(nx).at(ny) != -1) continue;
      
      count.at(nx).at(ny) = count.at(pos.first).at(pos.second) + 1;
      result = max(result, count.at(nx).at(ny));
      que.push(make_pair(nx, ny));
    }
  }
  
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll min(ll a,ll b){
    return a<b?a:b;
}
ll n,k;
vector<ll> arr;
int main()
{
    cin>>n>>k;
    arr.resize(n);
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    vector<ll> prev(k+1,1);
    vector<ll> curr(k+1,1);
    
    vector<vector<ll> > dp(n+1,vector<ll> (k+1));
    for(ll i=0;i<=n;i++)
    dp[i][0]=1;
    for(ll i=1;i<=k;i++)
    dp[0][i]=0;
    
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            ll a = min(j,arr[i-1]);
            if(a==j)
            dp[i][j]=(prev[j])%mod;
            else
            dp[i][j]=(prev[j] - prev[j - min(j,arr[i-1]) -1] + mod)%mod;
            curr[j]=(curr[j-1]+dp[i][j])%mod;
        }
        prev=curr;
    }
    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
    cout<<dp[n][k];
    return 0;
}

Measured memory_bytes: 81792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    string str;
    cin >> str;
    for(int i=0; i<3; i++){
        if(str[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int MOD = 1e9+7;
const int N = 102, K = 1e5+2;
int dp[N][K], pre[N][K];
int main()
{
	int n, k;
	cin>>n>>k;
	int a[n+1];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<=k;i++)
	{
		if(i <= a[0])
			dp[0][i] = 1;
		if(i == 0)
			pre[0][i] = 1;
		else
			pre[0][i] = ((ll)dp[0][i] + (ll)pre[0][i-1])%MOD;
	}

	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(j-a[i]-1 >= 0)
				dp[i][j] = (((ll)pre[i-1][j])%MOD-((ll)pre[i-1][j-a[i]-1])%MOD+MOD)%MOD;
			else
				dp[i][j] = pre[i-1][j];

			if(j == 0)
				pre[i][j] = dp[i][j];
			else
				pre[i][j] = ((ll)pre[i][j-1] + (ll)dp[i][j])%MOD;
		}
	}

	cout<<dp[n-1][k];


}

Measured memory_bytes: 79104
N,A = map(int, input().split())
Xs = [0] + list(map(int, input().split()))

memo = [[[0]*(A*N+1) for _ in range(N+1)] for _ in range(N+1)]

memo[0][0][0] = 1

for i in range(1,N+1):
  for j in range(N+1):
    for k in range(A*N+1):
      if k - Xs[i] >= 0:
        memo[i][j][k] = memo[i-1][j-1][k-Xs[i]] + memo[i-1][j][k]
      else:
        memo[i][j][k] = memo[i-1][j][k]
        
rlt = 0
for i in range(1,N+1):
  rlt += memo[N][i][i*A]
  
print(rlt)

Measured memory_bytes: 118840
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  vi b(n-1);
  rep(i,n-1) cin >> b[i];
  vi a(n,0);
  rep(i,n){
    if(i==0) {
      a[i] = b[i];
      continue;
    }
    if(i==n-1) {
      a[i] = b[i-1];
      continue;
    }
    a[i] = min(b[i],b[i-1]);
  }
  ll sum = 0;
  rep(i,n){
    sum += a[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	int a, b; cin >> a >> b;
    cout << a*b << endl;

    system("pause");
}


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

int main() {
  int o =0;
  string date , turn;
  cin >> date;
  turn = "2019/04/30";
  for(int i = 5; i <= 9; i++){
    if(i==7)
      continue;
    int x=date.at(i);
    int y=turn.at(i);
    if (x>y){
      o=1;
      break;
    }
    else if(x<y){
      o=0;
      break;
    }
  }
  if(o==1)
    cout << "TBD" << endl;
    else
      cout << "Heisei" << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

n, k = map(int, input().split())

p = np.array([list(map(int, input().split()))]).reshape(-1)

p_a = 0
p_r = p[:k]
for j in p_r:
    if j == 1:
        p_a += 1
    else:
        p_a += (j + 1) / 2
p_b = p_a
for i in range(1, n-k+1):
    if (p[i-1] == 1):
        p_b -= 1
    else:
        p_b -= (p[i-1] + 1) / 2

    if (p[i+k-1] == 1):
        p_b += 1
    else:
        p_b += (p[i+k-1]  + 1) / 2
    if p_b > p_a:
        p_a = p_b
print(p_a)

Measured memory_bytes: 33964
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <climits>

//#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((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())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;

    REP(i,n){
        bool f=true;
        REP(j,n-i){
            if(s[i+j]!=t[j]){
                f = false;
                break;
            }
        }
        if(f){
            cout << n+i << ENDL;
            return 0;
        }
    }
    cout << 2*n << ENDL;
    
    return 0;
}

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

int main()
{
   int n, m;
   cin >> n;
   vector<string>s(n);
   for(int i = 0; i < n; i++) cin >> s[i];
   cin >> m;
   vector<string>t(m);
   for(int i = 0; i < m; i++) cin >> t[i];
   int count = 1;
   int max = 0;
   for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
         if(s[i] == s[j])count++;
      }
      for(int j = 0; j < m; j++){
         if(s[i] == t[j])count--;
      }
      if(max < count)max = count;
      count = 1;
   }
   cout << max << endl;
}


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

int n, T[500001];

void maxheapify(int i)
{
	int l = 2 * i;
	int r = 2 * i + 1;
	int largest;

	if (l <= n && T[l] > T[i])
		largest = l;
	else
		largest = i;

	if (r <= n && T[r] > T[largest])
		largest = r;

	if (largest != i)
	{
		int t = T[largest];
		T[largest] = T[i];
		T[i] = t;
		maxheapify(largest);
	}	
}

int main()
{
	cin >> n;
	
	for (int i = 1; i <= n; i++)  cin >> T[i];

	for (int i = n / 2; i >= 1; i--)  maxheapify(i);
	
	for (int i = 1; i <= n; i++)  cout <<" "<< T[i];
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 4956
#include<iostream>
using namespace std;
int main()
{
	int n,i,a,b,c=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a>>b;
		c+=b-a;
		++c;
	}
	cout<<c;
	return 0;
}

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

int main(){
	int n,y;
	cin >> n >> y;
	int res10000 = -1;
	int res5000 = -1;
	int res1000 = -1;
	for(int i=0;i<=n;++i){
		for(int j=0;j<=n-i;++j){
			int k = n - i - j;
			int total = 10000*i+5000*j+1000*k;
			if(total==y){
				res10000 = i;
				res5000 = j;
				res1000 = k;
				break;
			}
		}
	}
	cout << res10000 <<' '<< res5000 <<' '<< res1000 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>
#include <typeinfo>

using namespace std;

int main()
{
	vector<int> city_tower;
	int k = 0;
	for (int i = 0; i < 6; ++i) {
		if (i == 5) {
			cin >> k;
		}
		else {
			int tmp;
			cin >> tmp;
			city_tower.push_back(tmp);
		}
	}

	sort(city_tower.begin(), city_tower.end());
	if (abs(city_tower[0] - city_tower[4]) > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}

	
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, t;
    int[][] island;
    boolean ans;

    void run(){
	while(true){
	    n = sc.nextInt();
	    if(n==0) break;

	    island = new int[n][2];
	    for(int i=0; i<n; i++){
		island[i][0] = sc.nextInt();
		island[i][1] = sc.nextInt();
	    }

	    Arrays.sort(island, new Comparator<int[]>(){
		    public int compare(int[] a, int[] b){
			int x1 = a[1];
			int x2 = b[1];
			if(x1!=x2) return x1-x2;
			else return a[0]-b[0];
		    }
		}
		);

	    t = 0;
	    ans = true;
	    for(int i=0; i<n; i++){
		t += island[i][0];
		if(t>island[i][1]){
		    ans = false;
		    break;
		}
	    }

	    System.out.println(ans ? "Yes" : "No");
	}
    }
}

Measured memory_bytes: 24484
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)

cntA = 0
ans = 0
i = 0
while i < N:
  if s[i] == "A":
    cntA += 1
  elif s[i:i+2] == "BC":
    ans += cntA
    i += 1
  else:
    cntA = 0
  i += 1

print(ans)

Measured memory_bytes: 12776
/*
    Zeolim - An AC a day keeps the bug away
*/

//pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <sstream>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;

const int MAXN = 1e3 + 10;

char arr[MAXN][MAXN];

signed used[MAXN][MAXN];

int ans = 1, n, m;

void dfs(int x, int y, char c)
{
    if(!(x >= 1 && x <= n && y >= 1 && y <= m && used[x][y] == -1 && arr[x][y] == c) )
        return ;

    used[x][y] = ans;

    dfs(x + 1, y, c);
    dfs(x - 1, y, c);
    dfs(x, y + 1, c);
    dfs(x, y - 1, c);   
}

int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);     cout.tie(0);
    //freopen("D://test.in", "r", stdin);
    //freopen("D://test.out", "w", stdout);
    
    //n åˆ— m è¡Œ
    
    while(cin>>n>>m && n && m)
    {
	    for(int i = 1; i <= n; i++)
	        for(int j = 1; j <= m; j++)
	            cin>>arr[i][j];
	        
	    memset(used, -1, sizeof(used));
	    
	    ans = 0;
	        
	    for(int i = 1; i <= n; i++)
	    {
	        for(int j = 1; j <= m; j++)
	        {
	            if(used[i][j] == -1)
	            {
	                dfs(i, j, arr[i][j]);
	                ans++;
	            }
	        }
	
	    }
	    
	    cout<<ans<<endl;
	}

    

    return 0;
}


Measured memory_bytes: 7412
N = int(input())

lst=[]
for i in range(N):
    lst.append(list(map(int,input().split())))

cnt = 0
for i in range(N):
  if i < N - 2:
    a, b = lst[i]
    c, d = lst[i + 1]
    e, f = lst[i + 2]
    if a == b and c == d and e == f:
      cnt += 1
    else:
      continue
if cnt >= 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9156
mod = 998244353
A, B, C, D = map(int,input().split())
dp = [[0 for i in range(D-B+1)] for j in range(C-A+1)]
dp[0][0] = 1

for i in range(C-A):
    dp[i+1][0] = B * dp[i][0]
    dp[i+1][0] %= mod

for i in range(D-B):
    dp[0][i+1] = A * dp[0][i]
    dp[0][i+1] %= mod

for i in range(C-A):
    for j in range(D-B):
        dp[i+1][j+1] = (i+A+1) * dp[i+1][j] + (j+B+1) * dp[i][j+1] - (i+A) * (j+B) * dp[i][j]
        dp[i+1][j+1] %= mod

print(dp[-1][-1])

Measured memory_bytes: 146628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0

lli calc(lli b,lli n){
	if(n<b) return n;
	else return calc(b,n/b)+n%b;
}

int main(){

	lli n,s;
	cin>>n>>s;

	if(s>n){
		cout<<-1<<endl;
		return 0;
	}
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}

	set<lli> S;
	for(lli b=2;b*b<=n;b++){
		if(calc(b,n)==s){
			S.insert(b);
		}
	}

	for(lli p=1;p*p<n && p<=s;p++){
		lli m = s-p;
		if(n-m>=0 && (n-m)%p==0){
			lli b = (n-m)/p;
			if(b>p && b>m){
				S.insert((n-m)/p);
			}
		}
	}

	if(S.size())cout<<*S.begin()<<endl;
	else cout<<-1<<endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	int count = 0;
	int start, end;
	int num;
	for (int i = 0; i < N; i++) {
		cin >> start >> end;
		num = end - start + 1;
		count += num;
	}
	cout << count << endl;
}

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

int Some_Sums(int number){
  int x = 0;
  int Dig = 0;
  while(number != 0){
    Dig = number % 10;
    x += Dig;
    number /= 10;
  }
  return x;
}

int main(void){
  int n;
  cin >> n;
  if(n%Some_Sums(n) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

result=0



b=list(map(int,input().split()))

for _ in range(n):
  d=list(map(int,input().split()))
  temp=0
  for bb,dd in zip(b,d):
    temp+=bb*dd
  if temp+c>0:
    result+=1

print(result)
  
  

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    int a=0,b=0,n;
    string A,B;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A>>B;
        if(A==B){
            a++;
            b++;
        }
        else if(A>B) a+=3;
        else b+=3;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
    }


Measured memory_bytes: 3192
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#include <stack>
#include <climits>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

const int N=200005;
int n;
LL ai[N];
LL f[N][5];
LL s[N];

/*
A      B
111111 222222
C       D    E
222222 11111 222222

nil -> A,C

A -> A,B
B -> B
C -> C,D
D -> D,E
E -> E

*/

int main(){
    scanf("%d",&n);
    rep(i,1,n){
        cin>>ai[i];
        s[i]=s[i-1]+ai[i];
        if(ai[i]!=0){
            if(ai[i]%2)ai[i]=1;
            else ai[i]=2;
        }
    }
    LL ans=s[n];
    rep(i,1,n){
        f[i][0]=min(f[i-1][0],s[i-1])+abs(ai[i]-1);
        f[i][1]=min(f[i-1][0],f[i-1][1])+abs(ai[i]-2);
        f[i][2]=min(f[i-1][2],s[i-1])+abs(ai[i]-2);
        f[i][3]=min(f[i-1][3],f[i-1][2])+abs(ai[i]-1);
        f[i][4]=min(f[i-1][4],f[i-1][3])+abs(ai[i]-2);
        rep(j,0,4)ans=min(ans,f[i][j]+s[n]-s[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N,M;cin>>N>>M;
  priority_queue<ll> pq{};
  rep(i,N){
    ll a;cin>>a;pq.push(a);
  }
  //while(!pq.empty()){cout<<pq.top();pq.pop();}
  rep(i,M){
    ll q = pq.top();
    pq.pop();
    q = ll(q/2);
    pq.push(q);
  }
  //while(!pq.empty()){cout<<"pq"<<pq.top();pq.pop();}
  ll ans=0;
  while(!pq.empty()){
    ans+=pq.top();
    pq.pop();
  }
  cout<<ans<<endl;
}

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

int main(){
    int A, B;
  	cin >> A >> B;
    
  	switch((A+1)/7){
      case 0:
        	cout << 0;
        	break;
      case 1:
        	cout << B/2;
        	break;
      default:
        	cout << B;
        	break;
    }
    return 0;
}


Measured memory_bytes: 504
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // ----------入力受付-----------//
        int N = sc.nextInt();               // 人数
        int K = sc.nextInt();               // お菓子の種類

        // -------状態を記憶する配列定義---------//
        boolean[] tricked = new boolean[N]; // お菓子を持っていない人はtrue
        Arrays.fill(tricked, true);         // 全員の初期状態としてtrueを指定

        // -----Aの入力より状態を記憶-----------//
        for (int i=0;i<K;i++){              // お菓子一種類ごとに確かめる
            int d = sc.nextInt();           // お菓子を持っている人数
            for(int j=0;j<d;j++){
                int a = sc.nextInt();       // お菓子iを持っている人はフラグを下ろす
                tricked[a-1]=false;
            }
        }
        //----------数える--------//
        int cnt = 0;                        // カウント用変数
        for(int l=0; l<N;l++){
            if(tricked[l]){                  // お菓子を受け取っていない人をカウント
                cnt++;
            }
        }
        //-----------出力----------//
        System.out.println(cnt);
    }
}

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

using namespace std;

// Problem https://atcoder.jp/contests/agc012/tasks/agc012_a



long long solver(int allCons,vector<long long> skills){
    int groupN = allCons/3;
    long long  result=0;
    // for(int j=0;j<allCons;j++){
    //    cout << skills.at(j) << " ";
    // }
    // cout << endl;
    vector<vector<long long>> skilltable;
    skilltable = vector<vector<long long>>(groupN, vector<long long>(3, 0));
    sort(skills.begin(),skills.end(),greater<long long>());
//    for(int j=0;j<allCons;j++){
//        cout << skills.at(j) << " ";
//    }
//    cout << endl;
   for(int j=0;j<groupN;j++){
       result = result + skills.at(j*2+1);
//       cout << result << ",";
   }
//    cout << endl;
    return result;
}

int main(void){
    int N;
    long long  answer=0;
    cin >> N ;
    int allMenber = N*3;
    vector<long long> a(allMenber);
      for(int j=0;j<allMenber;j++){
        cin >> a.at(j);
    } 
    answer = solver(allMenber,a);
    cout << answer << endl;
}

Measured memory_bytes: 10368
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    char a[1000];
    bool vis[100]={0};
    int sum=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0')
        {
            a[++sum]='0';
        }
         else if(s[i]=='1')
         {
           a[++sum]='1';
         }
        else
        {

            sum--;
            if(sum<0)
                sum=0;
        }
    }
    for(int i=1;i<=sum;i++)
        cout<<a[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back

signed main(){
    int N;cin>>N;
    map<int,int>memo;
    REP(i,N){
        int a;cin>>a;
        memo[a]++;
    }
    int ans=0;
    for(auto v:memo){
        if(v.second%2==1)ans++;
    }
    cout<<ans<<endl;
}

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

ll solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    while ( N > 0 ) {
        ans += N % 10;
        N /= 10;
    }
    if ( ans == 1 ) ans = 10;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mpp = boost::multiprecision;
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    mpp::cpp_dec_float_100 A;
    mpp::cpp_dec_float_100 B;
    cin>>A>>B;
    mpp::cpp_dec_float_100 result = A*B;
    cout<<ll(result)<<endl;
}



Measured memory_bytes: 3820
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
//#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


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


}


Measured memory_bytes: 256
s = input()
t = input()

s_sorted = ''.join(sorted(s))
t_sorted = ''.join(sorted(t, reverse=True))

word_list = [s_sorted, t_sorted]
word_list.sort()

if word_list[0] == s_sorted and s_sorted != t_sorted:
    print('Yes')
else:
    print('No')

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

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

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

    double l;
    cin >> l;

    printf("%.7lf\n", pow(l / 3, 3));

}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int score = 0;
		int hit = 0;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int i = 0;
		while(i < n*3){
			final String item = scanner.next();
			if(item.equals("HIT")){
				hit++;
				// ???????????????????????????
				if(hit == 4){
					score++;
					hit--;
				}
			}else if(item.equals("HOMERUN")){
				score += (hit+1);
				hit = 0;
			}else if(item.equals("OUT")){
				i++;
				if(i % 3 == 0){
					System.out.println(score);
					score = 0;
					hit = 0;			
				}
			}
		}
	}
}

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

X=[]

def j(n):
    if n%2==0:
        return False
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            return False
    return True

for i in range(2,55556):
    if j(i) and i%5==1:
        X.append(i)

print(*X[:n])












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

int main() {
    int n,k,d1,d2;
    cin>>n>>k;
    int d[k];
    vector<int> cnt(n);
    rep(i,k){
        cin>>d[i];
        int a[d[i]];
        rep(j,d[i]){
            cin>>a[j];
            cnt[a[j]-1]++;
        }
    }
    int ans = 0;
    rep(i,n){
        if(cnt[i]==0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int num=0;
	for (int i=0; i<=a; i++) {
		for (int j=0; j<=b; j++) {
			for (int k=0; k<=c; k++) {
				int total = 500*i+100*j+50*k;
				if (total == x) num++;
			}
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 3644
#include<cstdio>
int main(){
    int x,y;
    while(~scanf("%d%d",&x,&y)){
        if(x<y){
            printf("0\n");
        //    printf("%d is less than %d, so we should print 0.\n",x,y);
        }
        else{
            printf("10\n");
         //   printf("%d is not less than %d, so we should print 10.\n",x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   String S = sc.next();
   if(N%2 == 0)
   {
     if (S.substring(0,N/2).equals(S.substring(N/2 ,N)) ) System.out.println("Yes");
        else System.out.println("No");     
   }
   
        else System.out.println("No");
 }
}

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

void solve(long long N, long long W, std::vector<long long> w, std::vector<long long> v){
    int maxV = N*1000;
    ll maxW = N*1000000000ll+1;

    ll dp[N+1][maxV+1] ={};
    for(int i=0;i<=N;i++){
        for(int j=1;j<=maxV;j++){
            dp[i][j] = maxW;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=1;j<=maxV;j++){
            if(j<v[i]){
                dp[i+1][j] = dp[i][j];
                continue;
            }
            dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
        }
    }
    ll ans = 0;
    for(ll j=1;j<=maxV;j++){
        if(dp[N][j] <=W){
            ans = max(ans,j);
        }
    }
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long W;
    scanf("%lld",&W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&w[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, W, std::move(w), std::move(v));
    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 100000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
int beki(int n, int e) {
	int d = n;
	for (int i = 1; i < e; i++) {
		n = n * d;
	}
	return n;
}

int main() {
	int N, M; cin >> N >> M;
	int v[10][10]; int k[10];
	rep(i, M) {
		cin >> k[i];
		rep(j, k[i]) {
			cin >> v[i][j]; v[i][j]--;
		}
	}
	int p[10]; rep(i, M) cin >> p[i];
	int be = beki(2, N);
	int ans = 0;
	for (int i = 0; i < be; i++) {
		for (int j = 0; j < M; j++) {
			int cnt = 0;
			for (int s = 0; s < k[j]; s++) {
				if (i & (1 << v[j][s])) cnt++;
			}
			if (cnt % 2 != p[j]) break;
			if (j == M - 1) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define eb emplace_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3+5;
const lli INF = 1e18;
const lli MOD = 1e6+3;

bool mm[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)mm[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!mm[i])for(int j = i*i; j<N; j+=i)mm[j]=1;
	for(int i = 3; i<N; i+=2)if(!mm[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7




int main(){_
	map<string,int>s;
	int t; cin>>t;
	while(t--){
		string ss; cin>>ss;
		s[ss]++;
	}
	cout<<"AC x "<<s["AC"]<<ENDL;
	cout<<"WA x "<<s["WA"]<<ENDL;
	cout<<"TLE x "<<s["TLE"]<<ENDL;
	cout<<"RE x "<<s["RE"]<<ENDL;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (A > B) {
		cout << A + A - 1 << endl;
	}
	else if(A<B){
		cout << B + B - 1 << endl;
	}
	else {
		cout << A + B << endl;
	}
}

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

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> a(q);
    //参加者の持ち点
    vector<int> p(n, k-q);
    rep(i,q) {
        cin >> a[i];
        p[a[i]-1]++;
    }
    rep(i,n) {
        if (p[i] <=  0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Text;


class Program
{


    static void Main(string[] args)
    {

        char[] cs = new char[] { ' ', ',' };
        //int val = int.Parse(Console.ReadLine());
        //int[] vals = parseAry(Console.ReadLine().Split(cs));
        //string str = Console.ReadLine();
        //string[] strs = Console.ReadLine().Split(cs);

        //string res="";
        //int res = 0; ;
        //int t = int.Parse(Console.ReadLine());
        //string str = Console.ReadLine();
        ///int[] vals = parseAry(Console.ReadLine().Split(cs));
        //int n = int.Parse(Console.ReadLine());

        int res = 0;

        int[] vals = parseAry(Console.ReadLine().Split(cs));

        for (int i = 0; i < vals[0]; i++)
        {
            int[] v = parseAry(Console.ReadLine().Split(cs));
            if (v[0] >= vals[1] && v[1] >= vals[2]) {
                res++;
            }

        }

        Console.WriteLine(res);

        return;
    }

    //　String[]  ----->  int[]
    static int[] parseAry(string[] str)
    {
        int[] nums = new int[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
        return nums;
    }
    //　String[]  ----->  long[]
    static long[] parseAryL(string[] str)
    {
        long[] nums = new long[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
        return nums;
    }

    //文字列を1文字ずつString[]に入れる
    static string[] strAry(String str)
    {
        string[] re = new string[str.Length];
        for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
        return re;
    }

}

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

int main()
{
ll n ;
cin >> n ;
vector<pair<ll,ll>> v;
rep(i,n){
  ll a ;
  cin >> a ;
  v.emplace_back(0,a);
}
rep(i,n){
  ll b ;
  cin >> b ;
  v[i].first=b;
}
sort(v.begin(),v.end());
vector<pair<ll,ll>> vv;
rep(i,n){
  vv.emplace_back(v[i].second,i);
}
sort(vv.begin(),vv.end());
rep(i,n){
  if(vv[i].first>v[i].first){
    cout << "No" << endl;
    return 0;
  }
}
vector<bool> see(n);
see[0]=1;
ll num=1,to=vv[0].second;
while(1){
  if(see[to]==1)break;
  see[to]=1;
  to=vv[to].second;
  num++;
}
if(num!=n){
  cout << "Yes" << endl;
  return 0;
}
rep(i,n-1){
  if(v[i].first>=vv[i+1].first){
    cout << "Yes" << endl;
    return 0;
  }
}

cout << "No" << endl;
return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
ll t[100005],a[100005];
ll ans=1;
ll h[100005],u[100005];
int main(void){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    t[n+1]=0; a[n+1]=0;
    for(int i=1;i<=n;i++){
        if(t[i]>t[i-1]){
            h[i]=t[i];
        }else{
            u[i]=t[i];
        }
    }
    for(int i=n;i>0;i--){
        if(a[i]>a[i+1]){
            if(h[i]==0||h[i]==a[i]){
                if(t[i]<a[i]){
                    cout<<0<<endl;
                    return 0;
                }
                h[i]=a[i];
                u[i]=0;
            }else{
                cout<<0<<endl;
                return 0;
            }
        }else{
            if(h[i]>0){
                if(a[i]<h[i]){
                    cout<<0<<endl;
                    return 0;
                }
            }else{
                u[i]=min(u[i],a[i]);
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(h[i]>0){

        }else{
            ans=(ans*u[i])%MOD;
        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 6756