akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            Console.WriteLine(Program.Judge(S)? "Yes" : "No");
        }


        static bool Judge(string S)
        {
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0 && S[i] != 'R' && S[i] != 'U' && S[i] != 'D')
                {
                    return false;
                }
                else if (i % 2 == 1 && S[i] != 'L' && S[i] != 'U' && S[i] != 'D')
                {
                    return false;
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    long double a,b;
    cin >>a >>b;
    a*=b;
    ll ans = a;
    cout <<ans<<endl;
}
    



Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#define inf 1000000000

using namespace std;

struct SegTree{
	int size;
	vector<int> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}
	
	void update(int i, int val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	int query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		int lval = query(a, b, k*2, l, (l+r)/2);
		int rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	int query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

int N, Q;
int b[200005];

vector<int> vec[200005];
SegTree seg(18);

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> b[i];
	
	cin >> Q;
	int l, r;
	for(int i = 0; i < Q; i++){
		cin >> l >> r;
		vec[l].push_back(r);
	}
	
	seg.init();
	seg.update(0, 0);
	
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < vec[i].size(); j++){
			seg.update(vec[i][j], min(seg.query(vec[i][j], vec[i][j]), seg.query(i-1, vec[i][j]-1)));
		}
		if(b[i]) seg.update(i, min(seg.query(i, i), seg.query(i-1, i-1) + 1));
		else seg.update(i, min(seg.query(i, i), seg.query(i-1, i-1) - 1));
	}
	
	int ans = seg.query(N, N);
	for(int i = 1; i <= N; i++) if(b[i] == 0) ans++;
	cout << ans << endl;
	
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	bool good=true;
	for(int i=1;i<4;++i){
		if(s.at(i-1)==s.at(i))good=false;
	}
	cout<<(good?"Good"s:"Bad"s)<<"\n"s;
}

Measured memory_bytes: 256
N=int(input())
b=list(map(int,input().split()))

a=[]
while b:
    f=True
    if len(b)==1:
        if b[0]!=1:
            print(-1)
            exit()
        else:
            a.append(b.pop())
        break
    for i in range(len(b)-1,-1,-1):
        if b[i]==i+1:
            temp=b.pop(i)
            a.append(temp)
            f=False
            break
    if f:
        print(-1)
        exit()

for i in range(N):
    print(a[-1*(i+1)])


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

char s[MAXN], s1[MAXN];

int main() {
    int K, len, cnt, last;
    ll ans = 0;
    cin >> s >> K;
    len = strlen(s);
    last = 0;
    for(int i = 1; i < len; i++)
        if(s[i] != s[i - 1]) last = i;
    if(last == 0) ans = 1ll * len * K / 2;
    else{
        for(int i = 0; i < len; i++) s1[i] = s[i];
        for(int i = 1; i < last; i++) {
            if(s1[i] == s1[i - 1]){
                ++ans;
                s1[i] = '#';
            }
        }
        ans += (len - last) / 2;
        for(int i = last, j = 0; j < len; ++j, i = (i + 1) % len)
            s1[j] = s[i];
        cnt = 0;
        for (int i = 1; i < len; i++) {
            if (s1[i] == s1[i - 1]) {
                ++cnt;
                s1[i] = '#';
            }
        }
        ans += 1ll * cnt * (K - 1);
    }
    cout << ans << endl;
}

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

int main(){
    long long n;
    cin >> n;
    long long ans=0;
    long long t;
    for(long long i=1;i<=sqrt(n);i++){
        if(n<=i)break;
        if((n-i)%i==0&&(n-i)/i>0){
        t=(n-i)/i;
        if(n%t!=n/t)continue;
        ans+=t;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a == b && a == c) cout << 1 << endl;
  else if (a == b || a == c) cout << 2 << endl;
  else if (b == c) cout << 2 << endl;
  else cout << 3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

ll bin(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1) res=((res%mod)*(a%mod))%mod;
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res%mod;
}

ll inv(const ll& a)
{
    return bin(a, mod-2)%mod;
}

ll fact[2000005];
ll inverse[2000005];

ll ncr(ll n, ll r)
{
    if(r==0 || n==r)
        return 1;

    return ((fact[n]%mod) * (((inverse[r] % mod) * (inverse[n-r]%mod)%mod))%mod)%mod;
}

int32_t main() 
{ 
    fastio
    fact[0] = 1;
    for(ll i = 1; i<=2000000; ++i) 
        fact[i] = fact[i-1]*i, fact[i] %= mod;
    for(ll i = 0; i<=2000000; ++i)
        inverse[i] = inv(fact[i])%mod;  

    ll k, n;
    string s;
    cin>>k>>s;
    n = s.length();

    ll ans = bin(26, k+n)%mod;
    ll ans1 = 0;
    for(ll i = 0; i<n; ++i) {
        ans1 = ans1 + ((ncr(n+k, i)*bin(25, n+k-i))%mod);
        ans1 %= mod; 
    } 

    cout<<((ans-ans1%mod)+mod)%mod<<endl;
}

Measured memory_bytes: 35500
def resolve():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]
    ans = [["#"]*w for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                mine = 0
                for k in range(max(0, i-1), min(h, i+2)):
                    for l in range(max(0, j-1), min(w, j+2)):
                        if s[k][l] == "#":
                            mine += 1
                ans[i][j] = str(mine)
    for m in range(h):
        print("".join(ans[m]))

resolve()

Measured memory_bytes: 42992
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int N=100005;
int n;
vector<pair<int,int> >res;
int main()
{
	scanf("%d",&n);
	int k=1;
	while(k<n) k<<=1;
	if(k==n)
	{
		printf("No");
		return 0;
	}
	res.push_back(make_pair(1,2));
	res.push_back(make_pair(2,3));
	res.push_back(make_pair(3,n+1));
	res.push_back(make_pair(n+1,n+2));
	res.push_back(make_pair(n+2,n+3));
	for(int i=2;2*i+1<=n;i++)
	{
		res.push_back(make_pair(2*i,2*i+1));
		res.push_back(make_pair(2*i+1,n+1));
		res.push_back(make_pair(n+1,n+2*i));
		res.push_back(make_pair(n+2*i,n+2*i+1));
	}
	if(n%2==0)
	{
		for(int x=2;x<=n-1;x++)
		{
			int y=n^1^x;
			if(y!=x&&y>=2&&y<=n-1)
			{
				int i,j;
				if(x&1) i=x;
				else i=x+n;
				if(y&1) j=y;
				else j=y+n;
//				cerr<<"x"<<x<<" "<<y<<" "<<i<<" "<<j<<"\n";
				res.push_back(make_pair(n,i));
				res.push_back(make_pair(n+n,j));
				break;
			}
		}
	}
	printf("Yes\n");
	for(auto [x,y]:res)
		printf("%d %d\n",x,y);
	return 0;
}


Measured memory_bytes: 5268
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	string s;
	bool flgA = false, flgB = false;

	std::cin >> s;

	rep(i, 0, s.size()) {
		if (s[i] == 'A') {
			flgA = true;
		}
		else if (s[i] == 'B') {
			flgB = true;
		}
	}

	if (flgA && flgB) {
		std::cout << "Yes" << endl;
	}
	else {
		std::cout << "No" << endl;
	}
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define MAX_L 8
using namespace std;
typedef pair<int, int> P;
char table[MAX_L + 1][MAX_L + 1];

P next(int x, int y) {
    //上
    for(int r = 1; r <= 3&&y-r>=0; r++) {
        if(table[y-r][x] == '1') {
            return(P(x, y-r));
        }
    }
    //下
    for(int r = 1; r <= 3&&y+r<8; r++) {
        if(table[y+r][x] == '1') {
            return(P(x, y+r));
        }
    }
    //右
    for(int r = 1; r <= 3&&x+r<8; r++) {
        if(table[y][x+r] == '1') {
            return(P(x+r, y));
        }
    }
    //左
    for(int r = 1; r <= 3&&x-r>=0; r++) {
        if(table[y][x-r] == '1') {
            return(P(x-r, y));
        }
    }
    return(P(-1, -1)); //爆弾は巻き込まれなかった
}

//再帰的にtableを更新していく
void solve(int x, int y) {
    table[y][x] = '0'; //爆発した
    P chain;
    while(true) {
        chain = next(x, y);
        if(chain.first == -1 && chain.second == -1) break;
        solve(chain.first, chain.second);
    }
    return;
}

void output() {
    for(int r = 0; r < MAX_L; r++) {
        for(int c = 0; c < MAX_L; c++) {
            cout << table[r][c];
        }
        putchar('\n');
    }
}

int main(void) {
    int num; cin >> num;
    
    for(int r = 0; r < num; r++) {
        //盤面読み込み
        for(int c = 0; c < MAX_L; c++) {
            cin >> table[c];
        }
        //爆発する座標読み込み
        int x, y; cin >> x >> y;
        solve(x - 1, y - 1);
        cout << "Data " << (r + 1) << ":" << endl;
        output();
    }
    return(0);
}

Measured memory_bytes: 1164
import java.util.Scanner;

// bit全探索、greedy
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        long G = sc.nextInt();
        long[] C = new long[D];
        long[] P = new long[D];
        for (int i = 0; i < D; i++) {
            P[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }

        long res = 1 << 29;
        for (int bit = 0; bit < (1 << D); bit++) {
            long sum = 0;
            long num = 0;
            for (int i = 0; i < D; i++) {
                if (((bit >> i) & 1) == 1) {
                    sum += C[i] + P[i] * 100 * (i + 1);
                    num += P[i];
                }
            }
            if (sum >= G) {
                res = Math.min(res, num);
            } else {
                for (int i = D - 1; i >= 0; --i) {
                    if (((bit >> i) & 1) == 1) continue;
                    for (int j = 0; j < P[i]; ++j) {
                        if (sum >= G) break;
                        sum += 100 * (i + 1);
                        ++num;
                    }
                }
                res = Math.min(res, num);
            }
        }
        System.out.println(res);
    }

}




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

int main(){
    int n,y;
    cin>>n>>y;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            int r,k=n-j-i;
            r=10000*i+5000*j+1000*k;
            if(r==y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;
 
int main(){
  long long a,b,c,d,e,f;
  cin >> a >> b>> c >> d >> e >> f;
  
  long long sum = 0;
  vector <long long> A;
  for(int i = 0;i < f/a+1;i++){
    
    for(int j = 0;j < f/b+1;j++){
      
      sum = a*100*i+ b*100*j;
      if(sum <= f){
	A.push_back(sum);
      }
      else
	break;
    }
 
  }
  vector <long long> B;
  for(int i = 0;i < f/c+1;i++){
    
    for(int j = 0;j < f/d+1;j++){
    
      sum = c*i+ d*j;
      if(sum <= f){
	B.push_back(sum);
      }
      else
	break;
    }
 
  }
  
  double res,E,bres = 0;
  long long sum1=0,sum2=0;
  for(int i = 0;i < A.size();i++){

    for(int j = 0;j < B.size();j++){
      
      if(A[i] != 0){
	res = (double)B[j]/(A[i]+B[j])*100;
	E = (double)e/(100+e)*100;
	
	if(A[i]+B[j] <= f && res <= E){
	  if(res >= bres){
	    sum1 = A[i]+B[j];
	    sum2 = B[j];
	    bres = res;
	  }
	}
      }
    }
  }
  /*if(sum1 == 0)
    sum1 = A[2];*/
  cout << sum1 << " " << sum2 << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

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

    int sum = 0;
    int head_B = 0;
    int tail_A = 0;
    int head_tail = 0;

    for (int i = 0; i < N; ++i) {
        string s = S[i];
        if (s[0] == 'B') ++head_B;
        if (s[s.size()-1] == 'A') ++tail_A;
        if (s[0] == 'B' && s[s.size()-1] == 'A') ++head_tail;

        int count = 0;
        for (int j = 0; j < s.size() - 1; ++j) {
            if (s[j] == 'A' && s[j+1] == 'B') ++count;
        }
        sum += count;
    }
    int tmp = max(0, min(head_B, tail_A));
    if (tmp == N) tmp -= 1;
    if (tmp == head_tail && head_B == tail_A) tmp -= 1;
    if (tmp > 0) sum += tmp;

    cout << sum << endl;

}


Measured memory_bytes: 768
using System;
using System.Linq;

namespace ConsoleApp_ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            for (; ; )
            {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var n = input[0];
                var x = input[1];

                if(n == 0 && x == 0)
                {
                    break;
                }
                else
                {
                    int counter = 0;

                    for (int i = 1; i <= n; i++)
                    {
                        for (int j = 1; j <= n; j++)
                        {
                            if (i == j)
                            {
                                continue;
                            }
                            else
                            {
                                for (int k = 1; k <= n; k++)
                                {
                                    if (i == k || j == k)
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        if (i + j + k == x)
                                        {
                                            counter += 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    Console.WriteLine(counter/6);
                }
            }
        }
    }
}



Measured memory_bytes: 9572
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
using namespace std;

struct point{
   int a, cnt;
};

int cmp(point p1, point p2){
    return p1.a < p2.a;
}
int main(){

   long long  n, k;
   while(cin >> n >>k){
     point p[100001];
      for(int i = 0; i < n; ++i){
          cin >>p[i].a >> p[i].cnt;
      }
      sort(p, p + n, cmp);
      int d=0;
      //for(int i = 0; i < n; ++i) cout <<p[i].a <<"  "<<p[i].cnt<<endl;
      for(long long i = k; i > 0; ){
         i -= p[d++].cnt;
      }
      cout << p[d-1].a <<endl;
   }


   return 0;
}


Measured memory_bytes: 1024
### constant

MAX_N = 300000

### subroutines

def msnum_generator(max_n)
  yield 6
  k = 7
  loop do
    n = k + 1
    break if n > max_n
    yield n

    n = k + 6
    break if n > max_n
    yield n

    k += 7
  end
end

def gen_msprimes(max_p, msnums)
  msprimes = (max_p + 1).times.map{false}
  msnums.each{|msn| msprimes[msn] = true}

  msps = []

  for p in msnums
    if msprimes[p]
      msps << p
      for q in msnums
        pq = p * q
        break if pq > max_p
        msprimes[pq] = false
      end
    end
  end

  msps
end

### main

msnums = []
msnum_generator(MAX_N){|msn| msnums << msn}
#p msnums

msps = gen_msprimes(MAX_N, msnums)

loop do
  n = gets.to_i
  break if n == 1

  msds = []

  for msp in msps
    if n % msp == 0
      n17 = (n / msp) % 7
      if n17 == 1 || n17 == 6
        msds << msp
      end
    end
  end

  puts "#{n}: " + msds.join(' ')
end

Measured memory_bytes: 9420
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s[n];
	int p[n];
	for(int i=0;i<n;i++)
	{
		cin>>s[i]>>p[i];
	}
	int o[n];
	for(int i=0;i<n;i++)
	{
		o[i]=1;
		for(int j=0;j<n;j++)
		{
			if(i!=j)
			{
				
			if(s[i]>s[j]) o[i]+=1;
			if(s[i]==s[j])
			{
				
				if(p[i]<p[j]) o[i]+=1;
			}
			
		    }
		}
		
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==o[j]) cout<<j+1<<endl;
		}
	}
}
	
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
typedef long long ll;
using namespace std;

struct UnionFind{
	vector<int> parent, rank;
	UnionFind(int n){ parent = vector<int>(n, -1); rank = vector<int>(n, 0); }
	int find(int x){
		if(parent[x] == -1) return x;
		else return (parent[x] = find(parent[x]));
	}
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return false;
		if(rank[x] < rank[y])
			parent[x] = y;
		else
			parent[y] = x;
		if(rank[x] == rank[y])
		++rank[x];
		return true;
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(){
	int N, M;
	cin >> N >> M;
	vector<vector<int>> L(N);
	vector<vector<int>> a(M);
	for(int i = 0; i < N; ++i){
		int k;
		cin >> k;
		L[i].resize(k);
		for(int j = 0; j < k; ++j){
			cin >> L[i][j];
			L[i][j]--;
			a[L[i][j]].push_back(i);
		}
	}
	UnionFind uf(N);
	for(int i = 0; i < M; ++i){
		for(int j  =0; j < a[i].size(); ++j){
			uf.unite(a[i][0], a[i][j]);
		}
	}
	bool res = true;
	for(int i = 0; i < N; ++i){
		res = res && uf.same(0, i);
	}
	cout << (res ? "YES": "NO") << endl;
	return 0;
}


Measured memory_bytes: 9208
/* SPARROW 2019 */
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long

#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)

#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})
#define sv(a) sort(a.begin(),a.end())
#define zero(arr,a) memset(arr,a,sizeof arr)
#define mk
#define mx

int fx[]={0,1,1,1,0,-1,-1,-1};
int fy[]={1,1,0,-1,-1,-1,0,1};

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);
    //freopen("1015.txt","w",stdout);

    int n,d;
    sci(n);sci(d);

    int res=0;

    int pos=0;
    while(pos<n)
    {
        res++;
        pos+= (d+d+1);
    }

    pfi(res);pn;
    return 0;
}



Measured memory_bytes: 256
import Control.Monad

main = readLn >>= print . solve

solve :: Int -> Int
solve n = length . filter (<= n) $ map read xs

xs = filter check $ replicateM 9 " 753"
check x = '7' `elem` x &&
          '5' `elem` x &&
          '3' `elem` x &&
          ' ' `notElem` (dropWhile (== ' ') x)

Measured memory_bytes: 13692
n = int(raw_input())
s = raw_input()
left = 0
right = 0
for i in range(1, n):
  if s[i] == 'E':
    right += 1
total = left + right
for i in range(0, n-1):
  if s[i] == 'W':
    left += 1
  if s[i+1] == 'E':
    right -= 1
  if left + right < total:
    total = left + right
print(total)


Measured memory_bytes: 12480
///There is No God Besides Allah, Hazrat Muhammad (SAW) is the Messenger of Allah

#include<bits/stdc++.h>
using namespace std;

#define _FIO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define TC(t) while(t--){slove();}

#define all(v) (v).begin(),(v).end()
#define rall(v) reverse(all(v))
#define S(v) sort(all(v))
#define SP(v,s,e) sort(v.begin()+s,v.begin()+e)
#define Rs(v) sort(rall(v))
#define f(s,e) for(int i=s;i<e;i++)
#define rf(e,s) for(int i=e;i>=s;i--)
#define fi(it,v) for(auto it=v.begin();it!=v.end();++it)
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),v.end())
#define mi(v) *min_element(all(v))
#define ma(v) *max_element(all(v))
#define fup(v,n) fill(all(v),n)
#define point(x)  fixed<<setprecision(x)
#define endl "\n"

#define pb push_back
#define ff first
#define se second

const double pi = acos(-1.0);
const int mod=1000000007;///1e9+7
const int maxn = 2000010;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef set<ll> St;
typedef multiset<ll> MSt;
typedef map<ll,ll> M;
typedef map<string,ll> MS;
typedef map<char,char> MC;

ll b_exp(ll a,ll n)
{
    ll ans = 1;
    while(n>0)
    {
        if(n&1)
            ans*=a;
        a*=a;
        n>>=1;
    }
    return ans;
}

void slove()
{
    int n;
    cin>>n;
    ll x;
    ll b[n]={0};
    f(1,n)
    {
        cin>>x;
        b[x-1]++;
    }
    f(0,n)
    {
        cout<<b[i]<<endl;
    }
}


int main()
{
   // _FIO;
//   int t;
//   cin>>t;
//   TC(t);


slove();

}

///ALHAMDULILLAH

///Source_C0de-Fahim Shahriar


Measured memory_bytes: 5160
import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6

def dfs(r, c, now_c, next_c):
    tmp_board[r][c] = next_c
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
            dfs(nr, nc, now_c, next_c)


while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=4):
        # print(ope)
        if ope[0] == board[0][0] or ope[-1] == C - 1 or any(ope[i] == ope[i + 1] for i in range(3)):
            continue
        tmp_board = copy.deepcopy(board)
        for color in itertools.chain(ope, (C - 1, )):
            dfs(0, 0, tmp_board[0][0], color)
        dfs(0, 0, tmp_board[0][0], -1)
        cand = sum(row.count(-1) for row in tmp_board)
        if cand > ans:
            ans = cand
    print(ans)

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

using namespace std;

int main(void){
    int N;cin>>N;
    vector<int>H(N);
    for(int i = 0;i < N; i++){
        cin>>H[i];
    }

    bool flag = true;
    for(int i= N - 2; i >= 0; i--){
        if(H[i] > H[i+1]){
            if(H[i] -1 <= H[i+1])H[i] -= 1;
            else flag =false;
        }
    }

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

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
long long gcd(long long a,long long b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
int main()
{
    long long a,b;
    scanf("%lld%lld",&a,&b);
    long long ans=a*b/gcd(a,b);
    printf("%lld",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int h, w;
  cin >> h >> w;
  vs a(h);
  rep(i, h) { cin >> a[i]; }
  // 一つでも行と列に#があればフラグが立つ
  vector<bool> row(h, false);
  vector<bool> col(w, false);
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }
  // フラグが立っている文字のみを出力する
  rep(i, h) {
    if (row[i]) {
      rep(j, w) {
        if (col[j]) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int MOD = 10007;
        int n = sc.nextInt();
        String l = ("J" + sc.next()).replace('J', '0').replace('O', '1').replace('I', '2');
        int[][] dp = new int[n + 1][8];
        
        dp[0][1] = 1;
        
        for (int i = 0; i <n; i++) {
            for (int j = 1; j < (1 << 3); j++) 
            for (int nj = 1; nj < (1 << 3); nj++) {
                if ((j & (1 << (l.charAt(i) - '0'))) == 0) continue;
                if ((j & nj) == 0) continue;
                if ((nj & (1 << (l.charAt(i + 1) - '0'))) == 0) continue;
                dp[i + 1][nj] = (dp[i + 1][nj] + dp[i][j]) % MOD;
            }
        }
        int ans = 0;
        for (int i = 0; i < (1 << 3); i++) {
            ans = (ans + dp[n][i]) % MOD;
        }
        
        System.out.println(ans);
    }
        
    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 19640
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

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

	int n;
	cin >> n;
	ll* a = new ll[n];
	rep(i, n) cin >> a[i];
	sort(a, a + n);

	ll* sum = new ll[n];
	sum[0] = a[0];
	REP(i, 1, n) sum[i] = sum[i - 1] + a[i];

	int ans = 1;
	rrep(i, n-2) {
		if (sum[i] * 2 >= a[i + 1]) ++ans;
		else break;
	}

	cout << ans << "\n";

	return 0;
}



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

ji = {}
ans = 1
for i in range(n):
    tmp = i + 1
    j = 2
    while tmp != 1:
        if tmp % j == 0:
            if not j in ji:
                ji[j] = 0
            
            ji[j] += 1
            tmp /= j
        else:
            j += 1 

for i in ji.values():
    ans *= (i + 1)

print(ans % 1000000007)


Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main()
{
    char a1;
    cin>>a1;
    if((a1>=65)&&(a1<=90))
    {
        cout<<'A'<<endl;
    }
    else if((a1>=97)&&(a1<=122))
    {
        cout<<'a'<<endl;
    }

}

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

int N=1000;

int lcs(char x[],char y[])
{
    int c[N+1][N+1],m,n;
    m = strlen(x);
    n = strlen(y);

    int maxl=0,i,j;

    for(i=1;i<=m;i++)
        c[i][0]=0;
    
    for(j=1;j<=n;j++)
        c[0][j]=0;
    
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(x[i-1] == y[j-1])
            {
                c[i][j]=c[i-1][j-1]+1;
            }
            else
            {
                c[i][j]=c[i-1][j] > c[i][j-1] ? c[i-1][j] : c[i][j-1];
            }
           
            maxl = maxl > c[i][j] ? maxl : c[i][j];
        }
    }

    return maxl;
}


int main(void){
    char s1[N+1],s2[N+1];
    int n,i;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s %s",s1,s2);
        printf("%d\n",lcs(s1,s2));
    }

    return 0;
}


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

using namespace std;

int main()
{
    int n;
    int a[105];
    int ans = 0;

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

    for (int i = 1; i < n - 1; i++) {
        if (a[i] == a[i - 1] && a[i] == a[i + 1]) {
            a[i] += a[i - 1] + a[i + 1];
            i++;
            ans++;
        }
    }

    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void) {

    char s[20];
    int i;

    scanf("%s" ,s);

    for( i = 0; i < 19; i++) {
        if (i == 5 || i == 13) {
            s[i] = ' ';
        }
    }

    printf("%s\n" ,s);
    
    return 0;

}

Measured memory_bytes: 256
/*
	ID: Loxilante
	Time: 2020/08/29
	Prog: B
	Lang: cpp
*/
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#endif
#include <bits/extc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...) 97
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn = int> inline tn next(void) { tn k; cin>>k; return k; }
signed main(void)
{
	clock_t Begin = clock();

	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int ans = 1<<30;
	string s, t;
	cin>>s>>t;
	
	clock_t InputFinished = clock();
	
	hrp(i, 0, s.length()-t.length())
	{
		int res = 0;
		rep(j, 0, t.length())
		{
			if (s[i+j] != t[j]) res++;
		}
		ans = min(res, ans);
	}

	cout<<ans<<endl;

	clock_t End = clock();
	
	D((double)(End-Begin)/CLOCKS_PER_SEC);
	D((double)(End-InputFinished)/CLOCKS_PER_SEC);
	
	return 0;
}
/*

 */

Measured memory_bytes: 3684
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp
"""
class RootedTree:
    def __init__(self):
        self.id = None
        self.child = []
        self.parent = -1
        self.node_type = "root"
        self.depth = 0

    def show(self):
        print("node {}: parent = {}, depth = {}, {}, {}".format(self.id, self.parent, self.depth, self.node_type, self.child))

def cal_depth(tree, node, cur_depth):
    node.depth += cur_depth
    #node.show()
    for index in node.child:
        cal_depth(tree, tree[index], cur_depth + 1)
        
def make_tree(tree_data):#?????????,?¨???????n^2
    tree = [RootedTree() for i in range(len(tree_data))]
    
    for data in tree_data:
        focus = tree[data[0]]
        focus.id = data[0]
        
        if data[2:]:
            focus.child = data[2:]
            
            for child_index in data[2:]:
                tree[child_index].parent = data[0]
                
                if tree_data[[a[0] for a in tree_data].index(child_index)][2:]:
                    tree[child_index].node_type = "internal node"
                else:
                    tree[child_index].node_type = "leaf"
            
    root_index = [n.node_type for n in tree].index("root")
    cal_depth(tree, tree[root_index], 0)
    return tree
"""
def set_tree_data(tree, target, parent, depth):
    tree[target]["depth"] += depth
    tree[target]["parent"] = parent

    for c in tree[target]["child"]:
        set_tree_data(tree, c, target, depth + 1)

def make_tree_revision(tree_data, n_tree):#??????????¨???????n + n?
    tree = [{"parent": None, "depth":0, "child" : None} for i in range(n_tree)]
    root = sum(range(n_tree))
    
    for node_data in tree_data:
        tree[node_data[0]]["child"] = node_data[2:]
        root -= sum(node_data[2:])

    set_tree_data(tree, root, -1, 0)
    return tree

def main():
    n_tree = int(input())
    tree_data = [[int(a) for a in input().split()] for i in range(n_tree)]
    
    for i, node in enumerate(make_tree_revision(tree_data, n_tree)):
        category = "root"
        if (not node["parent"] == -1) and node["child"]:
            category = "internal node"
        elif not node["parent"] == -1:
            category = "leaf"

        print("node {}: parent = {}, depth = {}, {}, {}".format(i, node["parent"], node["depth"], category, node["child"]))
if __name__ == "__main__":
    main()

Measured memory_bytes: 66012
"use strict";

function main(arg) {
    const a = parseInt(arg.split("\n")[0].split(" ")[0]);
    const b = parseInt(arg.split("\n")[0].split(" ")[1]);
    
    const diff = b - a;
    let indexB = 0;
    
    for(let i=0; i<=diff; i++) {
        indexB += i;
    }
    
    console.log(indexB - b);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	ll N, M; cin >> N >> M;
	vector<ll> ac(N, 0);
	vector<ll> wa(N, 0);

	rep(i, M) {
		ll pnb; cin >> pnb; --pnb;
		string s; cin >> s;
		if (ac[pnb] == 1) continue;
		if (s == "AC") {
			++ac[pnb];
		}
		else
		{
			++wa[pnb];
		}
	}

	rep(i, N) {
		if (ac[i] == 0) wa[i] = 0;
	}

	ll cntAc = 0;
	ll cntWa = 0;
	rep(i, N) {
		cntAc += ac[i];
		cntWa += wa[i];
	}

	cout << cntAc << " " << cntWa;

}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int maxn = 1e6+7;
typedef long long ll;


ll n,m,pos[maxn],k,ans[maxn];
ll a[maxn],b[maxn],st[maxn];
ll move[maxn],vis[maxn];



int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&pos[i]);
	for(int i=1;i<=n;i++)
		b[i]=pos[i]-pos[i-1],a[i]=i;
	scanf("%lld%lld",&m,&k);
	for(int i=1;i<=m;i++)
	{
		ll x;
		scanf("%lld",&x);
		swap(a[x],a[x+1]);
	}
	for(int t=1;t<=n;t++)
	{
		if(vis[t])continue;
		int round = 0;
		for(int i=t;!vis[i];i=a[i])vis[i]=1,st[++round]=i;
		for(int i=1;i<=round;i++) ans[st[i]] = b[ st[(i+k-1)%round +1]];
	}
	for(int i=1;i<=n;i++)
	{
		ans[i]+=ans[i-1];
		printf("%.1lf\n",(double)ans[i]);
	}
	return 0;
}

Measured memory_bytes: 16512
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
double distance(int a, int b, int c, int d) { return sqrt((a - c) * (a - c) + (b - d) * (b - d)); }
int main() {
  int N;
  cin >> N;
  int cnt = 0;
  while (N != 1) {
    N/=2;
    cnt++;
  }
  cout << pow(2,cnt);
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

*/


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
KS = [[int(_) for _ in input().split()] for _ in range(M)]
P = [int(_) for _ in input().split()]
ans = 0
for s_bit in range(1 << N):
    S = []
    while s_bit:
        S += [s_bit % 2]
        s_bit //= 2
    S = [0] + S + [0] * (N - len(S))
    ok = True
    for i in range(M):
        if sum([S[_] for _ in KS[i][1:]]) % 2 != P[i]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1e9;
const int MOD = 1000000007;

int main() {
  size_t a, b, c, d;
  cin >> a >> b >> c >> d;
  size_t tNeed = (c + (b - 1)) / b;
  size_t aNeed = (a + (d - 1)) / d;

  if (tNeed > aNeed) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


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

int main()
{
	char Taro[100], Hanako[100];
	int n, t(0), h(0);
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> Taro >> Hanako;
		if (strcmp( Taro,Hanako) > 0) t = t + 3;
		else if (strcmp(Taro, Hanako) < 0) h = h + 3;
		else if (strcmp(Taro, Hanako) == 0)
		{
			t++;
			h++;
		}
		
	}
	cout << t << " " << h << endl;



	
}


Measured memory_bytes: 3080
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var in = newIo(bufio.NewScanner(os.Stdin))

func main() {
	print(solve())
}

func print(result int) {
	fmt.Println(result)
}

func solve() int {
	var a = in.nextInt()
	var b = in.nextInt()
	return (a - 1) * (b - 1)
}

type io struct {
	sc *bufio.Scanner
}

func newIo(sc *bufio.Scanner) *io {
	i := new(io)
	i.sc = sc
	i.sc.Split(bufio.ScanWords)
	return i
}
func (i *io) next() string {
	i.sc.Scan()
	return i.sc.Text()
}
func (i *io) nextInt() int {
	in, _ := strconv.Atoi(i.next())
	return in
}


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


int main(){
    int a,b,c;
    cin>>a>>b>>c;

    cout<<( (c>=a && c<=b) ? "Yes" : "No")<<endl;


    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin>>n>>k;
    vll a(n);
    rep(i, n){
        cin>>a[i];
        a[i]--;
        a[i]%=k;
    }
    vll b(n+1, 0);
    map<ll,int> Map;
    FOR(i,1,n){
        b[i] = b[i-1]+a[i-1];
        b[i]%=k;
    }
    rep(i, min(n+1,k)){
        Map[b[i]]++;
    }
    ll ans=0;
    rep(i, n){
        ans += Map[b[i]]-1;
        Map[b[i]]--;
        if (i+k<=n) Map[b[i+k]]++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll M = 1000000007;

int main(){
    string S; cin >> S;
    ll a=0;
    for(int i=0; i<4; i++){
        if(S[i]=='+'){
            a++;
        }else{
            a--;
        }
    }
    cout << a;
}

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

bool s[200001];
bool g[200001];

int main(){
    int n, m;
    cin >> n >> m;
    for(int i=0; i < m; i++){
        int x, y;
        cin >> x >> y;
        //まずはｓのほうの判定
        if(x != 1 and y == 1) s[x] = true;
        else if(x == 1 and y != 1) s[y] = true;
        //次にgのほうを判定
        else if(x == n) g[y] = true;
        else if(y == n) g[x] = true;
    }

    //比べる
    int flag = 0;
    for(int i=0; i < n; i++){
        if(s[i] == true and g[i] == true) flag = 1;
    }

    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vvi abc(n, vi(3));
  rep(i, n) std::cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
  vvi dp(n+1, vi(3, 0));
  rrep(i, n) {
    rep(j, 3) rep(k, 3) if (j != k) {
      chmax(dp[i][j], dp[i-1][k]+abc[i-1][j]);
    }
  }
  int ans = 0;
  rep(i, 3) chmax(ans, dp[n][i]);
  std::cout << ans << "\n";
}


Measured memory_bytes: 11264