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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            string[] str = Console.ReadLine().Split(' ');

             long n = long.Parse(str[0]);
            long m = long.Parse(str[1]);
            long k = long.Parse(str[2]);

            long[] a = ReadArray(n);
            long[] b = ReadArray(m);

            if(a.Sum()+b.Sum()<=k) { Cout(n + m); return; }


            long asum = 0;
            long bsum;
            long bcount=0;

            if (b.Sum() <= k) { bsum = b.Sum(); bcount = m; }
            else
            {
                bsum = 0;
                for (long i = 0; i < m; i++)
                {
                    if (bsum + b[i] > k) { bcount = i; break; }
                    bsum += b[i];
                }
            }

            long maxbook = bcount;

            if (a.Sum() <= k && maxbook<n) maxbook=n;

            for (long i = 0; i < n; i++)
            {
                long sum = asum;

                if ( bcount > 0 && sum + bsum > k ) {
                    while (sum + bsum > k && bcount>0)
                    {
                        bsum -= b[bcount-1];
                        bcount--;
                    }
                }

                if (maxbook < i + bcount) maxbook = i + bcount;

                asum += a[i];
                if (asum > k) break;
            }

            Cout(maxbook);

            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


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

using namespace std;

int main(void){
    long long n, k;
    cin >> n >> k;
    //nがkの倍数なら、答えは0
    if(n % k == 0){
        cout << 0 << endl;
        return 0;
    }
    long long minj = n % k;
    minj = min(minj, k - minj);
    cout << minj << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		final int N = s.nextInt();

		int[] input = new int[N];
		for(int i = 0; i < N; i++) {
			input[i] = Integer.parseInt(s.next());
		}
		s.close();

		int[] answer = new int[N];
		int i;
		for(i = 0; i < N/2; i++) {
			answer[0+i] = input[N-1-i*2];
			answer[N-1-i] = input[N-2-i*2];
		}
		if(N%2 == 1) {
			answer[i] = input[N-1-i*2];
		}

		System.out.print(answer[0]);
		for(i = 1; i < N; i++) {
			System.out.print(" " + answer[i]);
		}

	}

}

Measured memory_bytes: 64496
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <deque>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  
  int main(){
    int n,m;
    string s;
    cin >> n >> m;
    int ans1=1,ans2=1;
    ans1*=n*(n-1)/2;
    ans2*=m*(m-1)/2;
    cout << ans1+ans2 << endl;
    return 0;
  }


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

int main(){
	int n,ans=0;

	cin >>n;
	n*=2;
	int *array=new int[n];
	for(int i=0;i<n;i++)cin>>array[i];
	sort(array,array+n);
	for(int i=0;i<n;i=i+2)ans+=array[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,go[20][20],dp[N][20],bit[N],q1[20],q2[20];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) bit[1<<i]=i;
	for (int i=1;i<=m;i++){
		int u,v,l;
		scanf("%d%d%d",&u,&v,&l);u--;v--;
		go[u][v]=go[v][u]=l;
	}
	int to=1<<(n-1);
	for (int S=0;S<to;S++){
		for (int i=0;i<n;i++) dp[S][i]=1e9;
		for (int T=(S-1)&S;T<S;T=(T-1)&S){
			int s1=0,s2=0,v=0;
			for (int now=S^T;now;now-=now&-now) q2[++s2]=bit[now&-now];//可能的起点
			for (int now=T|to;now;now-=now&-now) q1[++s1]=bit[now&-now];//可能的终点
			for (int i=1;i<=s1;i++) for (int j=1;j<=s2;j++) v+=go[q1[i]][q2[j]];
			for (int i=1;i<=s1;i++) for (int j=1;j<=s2;j++) if (go[q1[i]][q2[j]])
				dp[S][q2[j]]=min(dp[S][q2[j]],dp[T][q1[i]]+v-go[q1[i]][q2[j]]);
		}
		dp[S][n-1]=0;
	}
	printf("%d\n",dp[to-1][0]);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main()
{
	int n, k, p[1000], sum = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n-1; j++) {
			if (p[j] > p[j+1])
				swap(p[j], p[j+1]);
		 }
	}
	for (int i = 0; i < k; i++) {
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list=new ArrayList<>();
        for(int i=0;i<10;i++) {
            list.add(sc.nextInt());
        }
        list.stream().sorted(Comparator.reverseOrder()).limit(3).forEach(System.out::println);
    }
}


Measured memory_bytes: 32036
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,ans,a[100010],fa[100010];
int find(int x) 
{
	if(fa[x]==x) return x;
	else return fa[x]=find(fa[x]);
}
int main() 
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
    for(int i=1;i<=n;i++) 
	{
		fa[i]=i;
	}
    for(int i=1;i<=m;i++) 
	{
    	scanf("%d%d",&x,&y);
    	fa[find(x)]=find(y);
    }
    for(int i=1;i<=n;i++) 
	{
    	if(find(a[i])==find(i)) 
		{
			ans++;
		}
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    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;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> A(K);
    for(int i=0;i<K;i++) cin >> A[i];
    combination C(N);
    
    vvec<mint> dp(K+1,vec<mint>(N+1,0));
    dp[0][0] = 1;
    for(int k=0;k<K;k++) for(int i=0;i<=N;i++){
        for(int j=0;j<=A[k];j++) if(i+j<=N){
            dp[k+1][i+j] += dp[k][i]*C.comb(N-j,A[k]-j)*C.f(j).inv();
        }
    }

    mint ans = dp[K][N]*C.f(N);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
 using namespace std;
  int main(){
  	double r , s , l , x ;
  	cin >> r ;
  	x = 3.141592653589 ;
  	s = r * r * x ;
  	l = x * ( r + r ) ;
  	printf("%.8lf %.8lf\n", s, l);
  }

Measured memory_bytes: 1240
class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


K = int(input())
S = input()
N = len(S)

mod = 10 ** 9 + 7
comb = Combination(3 * 10 ** 6, mod)

ans = 0
for i in range(K + 1):
    cnt = 1
    L = pow(25, i, mod)
    L *= comb(i + N - 1, i)
    L %= mod
    R = pow(26, K-i, mod)
    ans += L * R % mod
    ans %= mod

print(ans)

Measured memory_bytes: 120380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    ll c[m];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--;
        c[i]*=-1;
    }
    ll d[n];
    fill(d,d+n,LINF);
    d[0]=0;
    bool flag=false,reach[n]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(d[a[j]]!=LINF&&d[b[j]]>d[a[j]]+c[j]){
                d[b[j]]=d[a[j]]+c[j];
                if(i==n-1){
                    flag=true;
                    reach[a[j]]=reach[b[j]]=true;
                }
            }
        }
    }
    if(flag){
        for(int i=0;i<n-1;i++){
            for(int j=0;j<m;j++){
                reach[b[j]]|=reach[a[j]];
            }
        }
    }
    if(reach[n-1])cout<<"inf"<<endl;
    else cout<<-d[n-1]<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  string s;
  cin >>s;
  int a[4];
  for(ll i=0;i<4;i++) {
    a[i]=s[i]-'0';
  }
  if(a[0]+a[1]+a[2]+a[3]==7){
    cout <<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if(a[0]+a[1]+a[2]-a[3]==7){
    cout <<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if(a[0]+a[1]-a[2]+a[3]==7){
    cout <<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if(a[0]-a[1]+a[2]+a[3]==7){
    cout <<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if(a[0]+a[1]-a[2]-a[3]==7){
    cout <<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if(a[0]-a[1]-a[2]+a[3]==7){
    cout <<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if(a[0]-a[1]+a[2]-a[3]==7){
    cout <<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if(a[0]-a[1]-a[2]-a[3]==7){
    cout <<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
}


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

int main(void)
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a + 3);
  if(a[2] == a[0] + a[1])
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_;
#define cout (c_?cerr:cout)
#define debug(...) {cerr<<(!c_?"\033[96;1m":"");\
++c_;__VA_ARGS__;--c_;cerr<<(!c_?"\033[0m":"");}
#else
#define debug(...) {}
#endif
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
using namespace std; using ll = long long;
template< typename... t > using V = vector< t... >;
void print(){cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":"");print(b...);}
int argc_; char** argv_;
/*thread_local mt19937 gen;
inline ll arg(int v, ll def = 0)
{return v < argc_? atoll(argv_[v]) : def;}
template< typename t >
t rng(t min, t max) 
{return uniform_int_distribution< t >{min, max}(gen);}*/
/*}}}*/


int main(int argc, char** argv)
{
    argc_ = argc; argv_ = argv;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //gen = mt19937(arg(1));
    
    int n;
    cin >> n;
    V< int > tab(2 * n);
    for (int& i : tab)
        cin >> i;

    sort(all(tab));
    reverse(all(tab));
    
    int sum = 0;
    for (int i = 1; i < 2 * n; i += 2)
        sum += tab[i];

    print(sum);
}

Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
for h in range(1,3501):
    for m in range(1,3501):
        x = 4*h*m-n*m-n*h
        if x>0 and n*h*m%x==0:
            w = n*h*m//x
            print("{} {} {}".format(h,m,w))
            #ddprint(f"{4/n} {1/h+1/m+1/w}")
            exit()


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

int N;
vector<int> A;
vector<int> B;
int temp;

signed main()
{
	cin >> N;
	rep(i,N) {
		cin >> temp;
		A.push_back(temp);
		B.push_back(temp);
	}

	sort(B.begin(), B.end());

	int kisu_zure_count = 0;
	rep(i,N) {
		int dis = abs(distance(B.begin(), lower_bound(B.begin(), B.end(), A[i])) - i);
		//printf("%d's dis = %d\n", A[i], dis);
		if (dis % 2 == 1) {
			kisu_zure_count++;
		}
	}

	cout << kisu_zure_count / 2 << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  int i = 1;
  int ans = 0;
  while(i*i <= N){
    ans = i;
    i++;
  }
  
  if(ans == N){
    cout << N << endl;
  } else {
    cout << ans*ans << endl;
  }
}
    

Measured memory_bytes: 256
#include<stdio.h>
#define swap( x, y) {int z; z = y; y = x; x = z}

int main()
{
	int a, i = 1;
	
	while(scanf("%d", &a)) 
	{
		if(a == 0)
		{
			break;
		}
		printf("Case %d: %d\n", i++, a);
	}
	return 0;
}


Measured memory_bytes: 2680
n, m = map(int,input().split())
a = [int(input()) for i in range(m)]
dp = [float('inf')] * (n+1)
dp[0] = 1
dp[1] = 1
for i in a:
    dp[i] = 0
for i in range(2, n+1):
    dp[i] = min(dp[i], (dp[i-1] + dp[i-2]) % 1000000007)
print(dp[n])

Measured memory_bytes: 7824
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;

#define MAX_N 500000

int n;
long double f[MAX_N]; int a[MAX_N], t[MAX_N];long double x[MAX_N], y[MAX_N];

vector<pair<long double, long double>>pass;
vector<pair<long double, long double>>pass2;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> f[i] >> a[i] >> t[i] >> x[i] >> y[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (a[i] != a[i + 1] && t[i] == t[i + 1]) {
			if (t[i] == 0) {
				pass.push_back(make_pair(sqrt((x[i] - x[i + 1])*(x[i] - x[i + 1]) + (y[i] - y[i + 1])*(y[i] - y[i + 1])), 1.0*MAX_N - (f[i + 1] - f[i]) / 60));
			}
			else {
				pass2.push_back(make_pair(sqrt((x[i] - x[i + 1])*(x[i] - x[i + 1]) + (y[i] - y[i + 1])*(y[i] - y[i + 1])), 1.0*MAX_N - (f[i + 1] - f[i]) / 60));
			}
		}
	}
	sort(pass.begin(), pass.end());
	sort(pass2.begin(), pass2.end());
	if (pass.size() == 0) { cout << "-1 -1" << endl; }
	else {
		cout << fixed << setprecision(15) << pass[pass.size() - 1].first << ' ' << fixed << setprecision(15) << 1.0*MAX_N - pass[pass.size() - 1].second << endl;
	}
	if (pass2.size() == 0) { cout << "-1 -1" << endl; }
	else {
		cout << fixed << setprecision(15) << pass2[pass2.size() - 1].first << ' ' << fixed << setprecision(15) << 1.0*MAX_N - pass2[pass2.size() - 1].second << endl;
	}
	return 0;
}

Measured memory_bytes: 3304
N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [0 for _ in range(K+1)]

for i in range(K+1):
    for j in range(N):
        if i-A[j] >= 0:
            dp[i] |= not dp[i-A[j]]
            
if dp[K]:
    print('First')
else:
    print('Second')

Measured memory_bytes: 45328
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ull x;
    cin>>x;
    if(x<7) cout<<1<<endl;
    else if(x<12) cout<<2<<endl;
    else{
        ll y,z;
        y=x/11;
        z=x-y*11;
        if(z==0) cout<<y*2<<endl;
        else if(z<7) cout<<y*2+1<<endl;
        else cout<<y*2+2<<endl;
    }
}

Measured memory_bytes: 256
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S, T = input(), input()

# border
lB, rB, uB, dB = 0, W + 1, 0, H + 1

ans = "YES"
for i, (s, t) in enumerate(zip(reversed(S), reversed(T))):
    if i != 0:
        if t == "R":
            lB = max(0, lB - 1)
        elif t == "L":
            rB = min(W + 1, rB + 1)
        elif t == "D":
            uB = max(0, uB - 1)
        elif t == "U":
            dB = min(H + 1, dB + 1)

    if s == "R":
        rB -= 1
    elif s == "L":
        lB += 1
    elif s == "D":
        dB -= 1
    elif s == "U":
        uB += 1

    if (rB - lB) == 1 or (dB - uB) == 1:
        ans = "NO"
        break

if not lB < sc < rB or not uB < sr < dB:
    ans = "NO"

print(ans)


Measured memory_bytes: 3888
#include <iostream>

using namespace std;

int main(void) {
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B) {
        cout << C << endl;
    } else if(B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
    return 0;
}


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

int main(){

    int a, b;
    char op;
    scanf("%d %c %d", &a, &op, &b);

    int ans=0;
    if(op=='+'){
        ans=a+b;
    }
    else{
        ans=a-b;
    }

    printf("%d", ans);



	return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    a0 = 0

    for i in range(N):
        for j in range(i+1, N):
            if A[i] > A[j]:
                a0 += 1
    a1 = 0
    A2 = A * 2
    for i in range(N*2):
        for j in range(i+1, N*2):
            if A2[i] > A2[j]:
                a1 += 1
    a2 = 0
    A3 = A * 3
    for i in range(N*3):
        for j in range(i+1, N*3):
            if A3[i] > A3[j]:
                a2 += 1

    d = (a2 - a1) - (a1 - a0)
    # d * K + a0
    # print(d)
    print((a0 + d * ((K * (K - 1)) // 2) + (K - 1) * a0) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43884
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

#define FOR(_i, s, e) for(_i = s; _i < e; ++_i)
#define FOR_INV(_i, s, e) for(_i = e - 1; _i >= s; --_i)

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


using pos = std::pair<LONG, LONG>;


int main(){
    LONG i, j, k;

    LONG N;
    cin >> N;
    if(N % 1000 == 0){
        cout << 0;
    }
    else{
        cout << 1000 - N % 1000;
    }
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),K=in();
	string S=in<string>();
	S[K-1] = tolower(S[K-1]);
	
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
n,y = map(int,input().split())
ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i - j
        if (i*1000 + j*5000 + k*10000) == y:
            ans = str(k) + ' ' + str(j) + ' ' + str(i)
            break
print(ans)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  std::string mojiretu[N];
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> mojiretu[i];
  cin >> vec.at(i);
  }
  string X;
  cin >> X;
  
  int i=0;
  while (X != mojiretu[i]) { 
  i++;
  }
  
  int j=0;
  for (int s = i+1; s < N; s++) {
  j = j + vec.at(s);
  }
 
  cout << j << endl;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b)    for (int i = (a); i < (b); i++)
#define F0R(i, a)       for (int i = 0; i < (a); i++)
#define FORd(i, a, b)   for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a)      for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)      for (auto& a : x)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

namespace __input {
    template<typename T1, typename T2> istream& operator >>(istream& i, pair<T1, T2>& p) {
        i >> p.first >> p.second; return i;
    }
    template<typename T, size_t N> istream& operator >>(istream& i, array<T, N>& v) {
        for (auto& e : v) { i >> e; } return i;
    }
    template<typename T> istream& operator >>(istream& i, vector<T>& v) {
        for (auto& e : v) { i >> e; } return i;
    }
}
using namespace __input;

namespace __output {
    template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& t) {
        return o << "(" << t.first << ", " << t.second << ")";
    }
    template<typename T, size_t N> ostream& operator<<(ostream& o, const array<T, N>& a) {
        o << "["; for (int i = 0; i < N; i++) { if (i) o << ", "; o << a[i]; } return o << "]";
    }
    template<typename T> ostream& operator<<(ostream& o, const vector<T>& v) {
        o << "["; for (int i = 0; i < sz(v); i++) { if (i) o << ", "; o << v[i]; } return o << "]";
    }
}
using namespace __output;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string inp;
    cin >> inp;

    sort(all(inp));

    bool good = (inp[0] == inp[1]) && (inp[2] == inp[3])
        && (inp[1] != inp[2]);
    cout << (good ? "Yes" : "No") << endl;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>

using namespace std;

int main(){
	int ans = 0;
	string str;
	while(cin>>str){
		int n=0;
		for(int i=0;i<str.size();i++){
			if('0'<=str[i] && str[i] <='9'){
				n+=str[i] - '0';
			}
			if( i+1 == str.size() ||'0'> str[i+1]  ||str[i+1]  > '9'){
				ans += n;
				n=0;
			}
			else{
				n*=10;
			}
		}
	}
	cout<<ans<<endl;
	return 0;

}

/*
Sample Input
Thereare100yenonthetable.Iam17yearsold.
Ishouldgohomeat6pm.
Output for the Sample Input
123
*/

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


int main(void) {
    using namespace std;

    long n, t;
    cin >> n >> t;

    vector<pair<long,long>> ab(n);
    for(auto &x: ab) cin >> x.first >> x.second;
    sort(ab.begin(), ab.end());

    vector<vector<long>> dp(n+1, vector<long>(t+1));
    for(int i=0; i<n; i++) {
        long a = ab[i].first;
        long b = ab[i].second;
        for(int j=0; j<t; j++)
            dp[i+1][j] = max(dp[i][j], j-a >= 0 ? dp[i][j-a] + b : 0);
        dp[i+1][t] = max(dp[i][t], dp[i][t-1] + b);
    }

    cout << dp[n][t] << endl;
}


Measured memory_bytes: 70784
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=105;
bool pr[N];
vector<int>p;
vector<int>fact;


void sieve(){
	pr[0]=pr[1]=true;
	for(int i=2;i*i<=100;i++)if(!pr[i])
		for(int j=i*i;j<=100;j+=i)pr[j]=true;
	FER(i,0,101)if(!pr[i])p.pb(i);
}


int main(){	
	fastio;
	sieve();
	//trace(sz(p));
	int n;cin>>n;
	vector<int>vec;
	FER(i,2,n+1)vec.pb(i);
	for(int pp: p){
		int c=0;
		FER(i,0,sz(vec))
			while(vec[i]%pp==0)c++,vec[i]/=pp;
		fact.pb(c);
		//trace(pp);
		//trace(c);
	}
	// solo 1;
	ll ans=0;
	for(int lel: fact)if(lel>=74)ans++;
	FER(i,0,sz(fact)){
		FER(j,i+1,sz(fact)){
			if(fact[i]>=2&&fact[j]>=24)ans++;
			if(fact[i]>=4&&fact[j]>=14)ans++;
			if(fact[i]>=14&&fact[j]>=4)ans++;
			if(fact[i]>=24&&fact[j]>=2)ans++;
		}
	}
	FER(i,0,sz(fact))FER(j,i+1,sz(fact))FER(k,j+1,sz(fact)){
		if(fact[i]>=2&&fact[j]>=4&&fact[k]>=4)ans++;
		if(fact[i]>=4&&fact[j]>=2&&fact[k]>=4)ans++;
		if(fact[i]>=4&&fact[j]>=4&&fact[k]>=2)ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn=2e5+10;
int n;
long long k,a[maxn],f[maxn];
bool check(long long x)
{
	long long sum=0LL;
	for(int i=0;i<n;i++)
	{
		sum+=max(0LL,a[i]-x/f[i]);
	}
	if(sum>k)
	{
		return false;
	}
	return true;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>f[i];
	}
	//小*大 
	sort(a,a+n);
	sort(f,f+n);
	reverse(f,f+n);
	long long l=0LL,r=1e12;
	for(int i=0;i<64;i++)
	{
		long long mid=(l+r)/2LL;
//		cout<<mid<<" ##"<<endl;
		if(!check(mid))
		{
			l=mid+1LL;
		}
		else
		{
			r=mid;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	x = 0;
	y = 0;
	scanf("%s", a);
	n = strlen(a);
	if (a[0] != 'A')v = false;

		f(i,n){
			if (a[i] < 97)x++;
		}
		if (x != 2)v = false;

		for (int i = 2; i < n - 1; i++){
			if (a[i] == 'C')y++;
		}
		if (y != 1)v = false;

	if(v)printf("AC\n");
	else printf("WA\n");


	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
bool can(ll n, ll d) {
    ll x = n, y = d;
    while(x%y==0) {
        x = x/y;
    }
    return x%y==1;
}

/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    ll n; cin >> n;
    set<ll> ans;
    for(ll i = 1; i*i <= n-1; ++i) {
        if ((n-1)%i==0) {
            if(i!=1) ans.insert(i);
            if(i*i!=n-1) ans.insert((n-1)/i);
        }
    }
    for(ll i = 1; i*i<=n; ++i) {
        if(n%i!=0) continue;
        if(i!=1 && can(n,i)) ans.insert(i);
        if(can(n,n/i)) ans.insert(n/i);
    }

    cout << ans.size() << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};
int main() {
    int n,q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> vec(n+1,-1);
    vector<vector<int>> range(n);
    rep(i,n) {
        int last = vec[a[i]];
        if (last != -1) range[last].push_back(i);
        vec[a[i]] = i;
    }
    vector<vector<P>> qs(n);
    rep(qi,q) {
        int l,r;
        cin >> l >> r;
        l--; r--;
        qs[l].emplace_back(r,qi); //x軸で走査するのでxをindexにとる。出力のためにクエリ番号を残す。上のrangeも構造を合わせた。
    }
    BIT<int> d(n);
    vector<int> ans(q);
    for (int x = n-1; x>=0 ; x--) {
        for (int y : range[x]) d.add(y,1);
        for (P query : qs[x]) {
            int qy = query.first, qn = query.second;
            ans[qn] = (qy-x+1) - d.sum(qy);
        }
    }
    rep(i,q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 59892
#include <bits/stdc++.h>                                                        
                                                                                
using namespace std;                                                            
                                                                                
#define loop(i, a, b, inc) for(int i = a; i < (b); i += inc)                    
#define rep(i, n) loop(i, 0, n, 1)                                              
#define endl "\n"                                                               
typedef long long ll;                                                           
typedef pair<int, int> pii;                                                     
typedef pair<ll, ll> pll;                                                       
typedef vector<int> vi;                                                         
typedef vector<ll> vll;                                                         
                                                                                
int main() {                                                                    
        // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
        std::ios::sync_with_stdio(false);                                       
        cin.tie(0);                                                             
                                                                                
        int n;                                                                  
        cin >> n;                                                               
        vi arr(n);                                                              
        vi dp(n+2, INT_MAX);                                                    
        rep(i, n) cin >> arr[i];                                                
                                                                                
        dp[0] = 0;                                                              
        rep(i, n) {                                                             
                dp[i+1] = min(dp[i+1], dp[i] + abs(arr[i] - arr[i+1]));         
                dp[i+2] = min(dp[i+2], dp[i] + abs(arr[i] - arr[i+2]));         
        }                                                                       
                                                                                
        cout << dp[n-1] << endl;                                                
}                                                                               

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n, m, p, x int
	fmt.Scan(&n)

	t := make([]int, n)
	for i := range t {
		fmt.Scan(&t[i])
	}

	fmt.Scan(&m)
	ans := make([]int, m)

	for i := range ans {
		fmt.Scan(&p, &x)
		ans[i] = sum(t) - t[p-1] + x
	}

	for i := range ans {
		fmt.Println(ans[i])
	}
}

func sum(t []int) int {
	result := 0
	for i := range t {
		result += t[i]
	}
	return result
}


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

void delete_space(char *x)
{
	while (*x != '\0')
	{
		if (*x == '\n')
		{
			*x = '\0';
		}
		x++;
	}
}

int main()
{
	char s[256], t[256];

	scanf("%s %s", &s, &t);
	delete_space(s);
	delete_space(t);

	strcat(t, s);

	printf("%s", t);


	
	return 0;
}


Measured memory_bytes: 128
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var a = nextbig();
  var b = nextstr();
  var b0 = +b[0];
  var b1 = +b[2];
  var b2 = +b[3];
  return (a*BigInt(b0) + (a*BigInt(b1)+a*BigInt(b2)/10n) /10n).toString();
}

Measured memory_bytes: 29636
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include <deque>

using namespace std;
typedef long long ll;

vector<ll> ans;

int main() {
	while (1) {
		ll n, p, stone[50] = {};
		cin >> n >> p;
		if (n == 0 && p == 0)break;
		for (int i = 0;; i++) {
			if (p > 0) {
				stone[i%n]++;
				p--;
				if (p == 0) {
					bool flag = false;
					for (int j = 0; j < n; j++) {
						if (j != i%n && stone[j] > 0) {
							flag = true;
							break;
						}
					}
					if (!flag) {
						ans.push_back(i%n);
						break;
					}
				}
			}
			else {
				p += stone[i%n];
				stone[i%n] = 0;
			}
		}
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main (){
    // ?´???°??????sqrt(max)??§??????
    vector<bool>check(MAX+1);
    rep(i, MAX+1)
    check[i] = true;
    vector<int>Primenumber(MAX+1,0); //Primearray
    int counter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(check[i]){
            for(int j = 2;i*j<MAX;j++)
                check[i*j] = false;//?´???°??????Primearray???????´??????????????????°?????¨???false???
            Primenumber[counter] = i;
            counter++;
        }
    }
    int a,d,n;
    while(cin>>a>>d>>n,a+d+n){
        int count=0;int ans=0;
        while (true) {
            if(check[a] && a!=1)count++;
            if(count==n) {ans=a;break;}
            a+=d;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;

    ll A[n + 1] = {};
    for(int i = 1; i <= n; i++){
        int tmp = i, j = 2;
        while(tmp > 1){
            if(tmp % j) j++;
            else{
                tmp /= j;
                A[j]++;
            }
        }
    }
    
    ll ans = 1;
    for(int i = 2; i <= n; i++){
        ans = (ans * (A[i] + 1)) % (int)(1e9 + 7);
    }
    cout << ans << endl; 

    return 0;
}


Measured memory_bytes: 256
def main():
 x = map(int, raw_input().split())
 if 2 <= x[0] <= 13 and  2 <= x[1] <= 13:
    if(x[0] > x[1]):
        return "Alice"
    elif(x[0] < x[1]):
        return "Bob"
    else:
        return "Draw"
 elif x[0] == 1 and  2 <= x[1] <= 13:
    return "Alice"
 elif x[1] == 1 and  2 <= x[0] <= 13:
    return "Bob"
 else:
    return "Draw"
print main()

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

// main.cpp

int main() {
  std::string s, t;
  std::cin >> s >> t;
  std::sort(s.begin(), s.end());
  std::sort(t.begin(), t.end(), std::greater<char>());
  std::cout << (s < t ? "Yes" : "No") << std::endl;
  return 0;
}

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

int n,p[1000000],dp[1000000],k;

 int solve (int i)
{
    int ans=INT_MAX;
if(i>=n)
  return 0;
if(i==(n-1))
  return dp[i]=abs(p[i+1]-p[i]);
if(dp[i] != -1)
return dp[i];
  for(int j=1;j<=k;j++)
  {  
      if(i+j<=n)
     ans= min( abs(p[i+j]-p[i]) + solve(i+j) , ans);
}
return dp[i]=ans;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<=n;i++)
    dp[i]=-1;
    for(int i=1;i<=n;i++)
    cin>>p[i];
    cout<<solve(1);
   
}

Measured memory_bytes: 9472
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
bool sd[11][11];
int main() {
    int n,m;
    cin>>n>>m;

    rep(i,m){

        int k;
        cin>>k;
        rep(j,k){
            int kk;
            cin>>kk;
            sd[i+1][kk]=true;
        }
    }
    //cout<<2<<endl;
    vector<int> oe(m);
    rep(i,m){cin>>oe[i];}
    int ans=0;

    for(int ii=0;ii<(1<<n);ii++){
       // cout<<ii<<endl;
        bool ont[11];
        rep(i, 11) { ont[i] = false; }
        for(int j=0;j<n;j++) {
            if ((ii >> j) & 1) {
                //cout<<3<<endl;
                ont[j +1] = true;
            }
        }
            //rep(bb,11)cout<<ont[bb];
            //cout<<endl;
            bool can=true;
            for(int k=1;k<=m;k++){
                int ons=0;
                for(int l=1;l<=n;l++){
                    if(sd[k][l]==true&&ont[l]==true){
                        ons++;
                    }
                }
                if(ons%2==oe[k-1]){

                }else{
                    can=false;
                    break;
                }
            }
            if(can==true)ans++;

    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll A,B;
    cin >> A >> B;
    if(A<=8 && B<=8){
        print("Yay!");
    }else{
        print(":(");
    }
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define REP(i, n) for(int i=0;i<(n);++i)
#define MOD 1e9+7;
typedef long long ll;

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

	int n, m, x[100000];
	vector<int> vec;
	cin >> n >> m;
	REP(i, m) cin >> x[i];

	sort(x, x+m);
	int all = x[m-1] - x[0];

	REP(i, m-1){
		vec.push_back(x[i+1] - x[i]);
	}
	sort(vec.begin(), vec.end(), greater<int>());

	REP(i, n-1){
		if(i >= vec.size()) break;
		all -= vec[i];
	}
	cout << all << endl;

	return 0;
}


Measured memory_bytes: 1276
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    string s;
    cin >> s;
    if (s.find('A') != string::npos && s.find('B') != string::npos)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(string& T, int K, int R, int S, int P) {
        vector<int> dp(3, 0);
        vector<int> ndp(3, 0);

        vector<int> SC{R, S, P};

        string H = "rsp";
        vector<int> indices(128, -1);
        for (int i = 0; i < H.length(); ++i) {
            indices[H[i]] = i;
        }

        int n = T.size();
        int res = 0;
        for (int i = 0; i < K; ++i) {
            fill(dp.begin(), dp.end(), 0);
            for (int j = i; j < n; j += K) {
                fill(ndp.begin(), ndp.end(), 0);

                for (int a = 0; a < 3; ++a) {
                    for (int b = 0; b < 3; ++b) {
                        if (a != b) {
                            ndp[b] = max(ndp[b], dp[a] + ((b + 1) % 3 == indices[T[j]]) * SC[b]); 
                        }
                    }
                }
                swap(ndp, dp);
            }
            res += max(dp[0], max(dp[1], dp[2]));
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int k;
    int r, s, p;
    cin >> n >> k >> r >> s >> p;
    string T;
    cin >> T;

    Solution sol;
    cout << sol.solve(T, k, r, s, p) << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
vector<int> E[maxn];
bool dfs(int x, int fa)
{
	int ret = 0;
	for(auto v : E[x])
		if(v != fa)
			ret += dfs(v, x);
	if(ret > 1) 
	{
		puts("First");
		exit(0);
	}
	return !ret;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i < n; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i)
		if(E[i].size() == 1)
		{
			if(dfs(i, 0)) puts("First");
			else puts("Second");
			break;
		}
	return 0;
}

Measured memory_bytes: 9336