akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
public class Main {
    public void sol(int a, int b){

            System.out.println(a*b);
    }
    Map<Long,Long> memo = new HashMap<>();
    static Map<Long, Long> cache;

    public static void main(String[] args)  throws IOException {
        // Use the Scanner class
        Main aka = new Main();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        //int tot = Integer.parseInt(br.readLine());
        String[] ss = s.split(" ");
        aka.sol(Integer.parseInt(ss[0]),Integer.parseInt(ss[1]));
//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

}


Measured memory_bytes: 32540
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a[3];
    rep(i, 3) cin >> a[i];
    map<int, int> mp;
    rep(i, 3) mp[a[i]]++;
    int ans = mp.size();
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

class Data
{
public:
    string name;
    int p, a, b, c, d, e, f, s, m;
    double efficient() const
    {
        int t = a + b + c + (d + e) * m;
        int money = f * s * m - p;
        return money / (double)t;
    }
    bool operator<(const Data& d) const
    {
        double eff1 = efficient();
        double eff2 = d.efficient();
        if(abs(eff1 - eff2) < EPS)
            return name < d.name;
        return eff1 > eff2;
    }
};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<Data> d(n);
        for(int i=0; i<n; ++i)
            cin >> d[i].name >> d[i].p >> d[i].a >> d[i].b >> d[i].c >> d[i].d >> d[i].e >> d[i].f >> d[i].s >> d[i].m;
        sort(d.begin(), d.end());

        for(int i=0; i<n; ++i)
            cout << d[i].name << endl;
        cout << '#' << endl;
    }
}

Measured memory_bytes: 1220
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
int a[101010];

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	sort(a, a + n);
	LL ans = 0;
	if (n % 2==0) {
		vector<int> v;
		v.emplace_back(-1);
		v.emplace_back(1);
		REP(i, n / 2 - 1) {
			v.emplace_back(2);
			v.emplace_back(-2);
		}
		sort(ALL(v));
		REP(i, n) {
			ans += v[i] * a[i];
		}
	}
	else {
		vector<int> v;
		v.emplace_back(1);
		v.emplace_back(1);
		REP(i, (n - 2) / 2)v.emplace_back(2);
		REP(i, (n - 1) / 2)v.emplace_back(-2);
		sort(ALL(v));
		REP(i, n) {
			ans += v[i] * a[i];
		}
		v.clear();
		v.emplace_back(-1);
		v.emplace_back(-1);
		REP(i, (n - 2) / 2)v.emplace_back(-2);
		REP(i, (n - 1) / 2)v.emplace_back(2);
		sort(ALL(v));
		LL num = 0;
		REP(i, n) {
			num += v[i] * a[i];
		}
		ans = max(num, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h> 
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
int n,ans=100500;
int get(int x){
	int res=0;
	while (x) res+=x%10,x/=10;
	return res;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n-1){
		ans=min(ans,get(i)+get(n-i));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
h, w = list(map(int, input().split() ))

s = []
s.append("." * (w+2)) 
for _ in range(h):
	s.append("." + input() + ".")
s.append("." * (w+2)) 

ans = "Yes"
dx = [-1, 0, 1, 0]
dy = [ 0, 1, 0,-1]

for i in range(1, h+1):
	for j in range(1, w+1):
		if s[i][j] == "#":
			CanPaint = False
			for k in range(4):
				if s[i+dx[k]][j+dy[k]] == "#":
					CanPaint = True
			if not CanPaint:
				ans = "No"

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    for ( int i = 1; i < n - 1; ++i ) {
        if ( p[i] > p[i-1] && p[i] < p[i+1] || p[i] < p[i-1] && p[i] > p[i+1] ) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define MAX 200005

vector<int> seg(4*MAX, 0), adj[MAX];
int arr[MAX], brr[MAX], ans[MAX];
map<int, int> mp;
int ps = 0;

int query(int idx, int l, int r, int sl, int sr){
	if( l > sr || r < sl )
		return 0;
	if( sl <= l && sr >= r )
		return seg[idx];

	int md = (l+r)/2;
	return max(query(2*idx, l, md, sl, sr), query(2*idx+1, md+1, r, sl, sr));
}

int get(int idx, int l, int r, int pos){
	if( l == r )
		return seg[idx];
	int md = (l+r)/2;
	if( pos <= md )
		return get(2*idx, l, md, pos);
	else
		return get(2*idx+1, md+1, r, pos);
}

void update(int idx, int l, int r, int pos, int val){
	if( l == r ){
		seg[idx] = val;
		return;
	}
	int md = (l+r)/2;
	if( pos <= md )
		update(2*idx, l, md, pos, val);
	else
		update(2*idx+1, md+1, r, pos, val);
	seg[idx] = max(seg[2*idx], seg[2*idx+1]);
}

void dfs(int u, int p){
	int mpos = mp[arr[u]];
	ans[u] = mpos > 0 ? query(1, 0, ps-1, 0, mpos-1)+1 : 1;
	int prev = get(1, 0, ps-1, mpos);
	update(1, 0, ps-1, mpos, ans[u]);
	ans[u] = seg[1];
	for(int v : adj[u])
		if( v != p )
			dfs(v, u);

	update(1, 0, ps-1, mpos, prev);
}

int32_t main(){
	IOS;
	int n, a, b;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
		brr[i] = arr[i];
	}
	sort(brr, brr+n);
	mp[brr[0]] = ps++;
	for(int i = 1; i < n; i++)
		if( brr[i] != brr[i-1] )
			mp[brr[i]] = ps++;

	for(int i = 0; i < n-1; i++){
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dfs(0, -1);

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

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

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

    sort(arr,arr+n);
    int sum1 =0,sum2 =0;
    for(int i=n-1;i>=0;i-=2){
        sum1 += arr[i] ;
    }
    for(int i=n-2;i>=0;i-=2){
        sum2 +=arr[i];

    }

    cout << sum1 - sum2 <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int
main()
{
	int i;
	int n_nums;
	int nums[100];

	scanf("%d", &n_nums);
	for (i = 0; i < n_nums; i++)
	{
		scanf("%d", &nums[i]);
	}

	for (i = 0; i < n_nums; i++)
	{
		if (i != 0)
		{
			printf(" ");
		}
		printf("%d", nums[n_nums-i-1]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, **a, ma, mi, s;
	char *t, *t2;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		a = (int **)calloc(n, sizeof(int));
		for(int i = 0; i < n; i++){
			a[i] = (int *)calloc(3, sizeof(int));
		}
		t = (char *)malloc(n*sizeof(char));
		ma = 0;
		mi = 20;
		for(int i = 0; i < n; i++){
			cin >> t[i];
			for(int j = 1; j < n; j++){
				cin >> s;
				a[i][s]++;
			}
			if(a[i][0] > ma){
				ma = a[i][0];
			}
			if(a[i][0] < mi){
				mi = a[i][0];
			}
		}
		
		for(int i = ma, l=0, d=0; i >= mi; i--, l=0, d=0){
			t2 = (char *)malloc(n*sizeof(char));
			for(int j = 0; j < n; j++){
				if(a[j][0] == i){
					t2[l++] = t[j];
					if(d < a[j][1]){
						d = a[j][1];
					}
				}
			}
			if(l == 1){
				cout << t2[0] << endl;
			} else if(1 < l){
				for(int j = 0; j <= d; j++){
					for(int k = 0; k < l; k++){
						for(int o = 0; o < n; o++){
							if(a[o][1] == j && t[o] == t2[k]){
								cout << t[o] << endl;
							}
						}
					}
				}
			}
			
			free(t2);
		}
		for(int i = 0; i < n; i++){
			free(a[i]);
		}
		free(a);
		free(t);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#define long long
using namespace std;

int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c-1){
		cout<<c+b;
	}
	else{
		cout<<a+b+1+b;
	}
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> vec (N,0);
	for(int i = 0;i < M * 2;i++){
		int d;
		cin >> d;
		vec.at(d-1)++;
	}
	for(int i = 0;i < N;i++){
		cout << vec.at(i) << endl;
	}
}

Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline())
l = list(stdin.readline().split())
q = int(stdin.readline())

for i in range(q):
    inp_l = list(map(int,stdin.readline().split()))
    j = inp_l[0]
    k = inp_l[1] - 1
    while True:
        if j >= k:
            break
        l[j],l[k] = l[k],l[j]
        k -= 1
        j += 1

print(' '.join(l))


Measured memory_bytes: 5692
/*
 *  author : Atul Anand   
 *  created on : Tue Mar 31 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int A[] = new int[N];
        HashMap<Integer, Long> freq = new HashMap<>();
        for(int i = 0; i < N; i++){
            A[i] = in.nextInt();
            freq.put(A[i], freq.getOrDefault(A[i], 0L) + 1);
        }

        long sum = 0;
        HashMap<Integer, Long> ways = new HashMap<>();
        for(int a: freq.keySet()){
            long C = (freq.get(a) * (freq.get(a) - 1)) / 2;
            sum += C;
            ways.put(a, C);
        }

        for(int i = 0; i < N; i++){
            long add = ((freq.get(A[i]) - 2) * (freq.get(A[i]) - 1)) / 2;
            long ans = sum - ways.get(A[i]) + add;
            println(ans); 
        }

        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 83392
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


K = int(input())

ans = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        d = gcd(a, b)
        for c in range(1, K+1):
            ans += gcd(d, c)

print(ans)

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

int X[100], Y[100];


// 最大公約数を求める
long long int GCD (long long int a, long long int b) {
    long long int tmp, x, r;
    if (a<b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while (r!=0) {
      a = b;
      b = r;
      r = a % b;
    }
    return b;
}


int sib(long long A) {
    int i;
    int num;
    
    num=1;
    if (A%2==0) num++;
    if (A%3==0) num++;
    while (A%2==0) {A/=2;}
    while (A%3==0) {A/=3;}
    
    for (i=5;i<sqrt(A);i+=4) {
        if (A%i==0) num++;
        while (A%i==0) {A/=i;}
        i+=2;
        if (A%i==0) num++;
        while (A%i==0) {A/=i;}
    }
    if (A!=1) num++;
    return num;
}


int main() {
  long long A, B, G, result;
  int i;
  scanf ("%lld %lld", &A, &B);
  
  G = GCD(A,B);
//  printf("G=%lld\n",G);
  
  result = sib(G);
  
  printf("%lld", result);
  return 0;
}




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

int main() {
 int a,b;
 cin >> a >> b;
 int cnt = 0;
 for(int i = a; i <= b ;i++){
   string s = to_string(i);
   vector<char> x(s.size());
   rep(j,s.size()) x.at(j) = s.at(j);
   vector<char> y = x;
   reverse(x.begin(),x.end());
   if(x == y) cnt++;
 }
 cout << cnt << endl;
 } 

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

using namespace std;

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

    int k,a,b;
    cin>>k>>a>>b;

    int mult=1,val=k;

//    for(int i=a;i<=b;i++){
//        if(i%k==0){
//            cout<<"OK\n";return 0;
//        }
//    }

    while(val<=b){
        if(val>=a && val<=b){
            cout<<"OK\n";return 0;
        }
        val=k*mult;//cout<<val<<"\n";
        mult++;
    }

    cout<<"NG\n";


    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;

int main()
{
    sll(n);
    ll a[n]; fr(i,0,n)  cin>>a[i];
    ll ans=0;
    fr(i,1,n)
    {
        if(a[i-1]>a[i])
        {
            
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 5244
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=2010;
struct edge{
	int from,to,next,f,v;
}e[N*10];
int head[N],tot=1;
int n,nd,S,T,p0,p1,p2,p3;
int vis[N],q[N*10],from[N];
ll dis[N],ans;
void add(int x,int y,int f,int v){
	e[++tot]=(edge){x,y,head[x],f,v};
	head[x]=tot;
	e[++tot]=(edge){y,x,head[y],0,-v};
	head[y]=tot;
}
bool bfs(){
	For(i,1,nd){
		vis[i]=0;
		dis[i]=-(1ll<<60);
	}
	int h=0,t=1;
	q[1]=S; dis[S]=0;
	while (h!=t){
		int x=q[++h]; vis[x]=0;
		for (int i=head[x];i;i=e[i].next)
			if (dis[e[i].to]<dis[x]+e[i].v&&e[i].f){
				dis[e[i].to]=dis[x]+e[i].v;
				from[e[i].to]=i;
				if (!vis[e[i].to]){
					vis[e[i].to]=1;
					q[++t]=e[i].to;
				}
			}
	}
	return dis[T]!=-(1ll<<60);
}
void del(){
	ans+=dis[T];
	for (int i=from[T];i;i=from[e[i].from])
		e[i].f--,e[i^1].f++;
}
int main(){
	scanf("%d",&n);
	nd=2*n; S=++nd; T=++nd;
	p0=++nd; p1=++nd; p2=++nd; p3=++nd;
	For(i,1,n){
		int x,y,v;
		scanf("%d%d%d",&x,&y,&v);
		add(S,i,v,0);
		add(i,p0,1<<30,x+y);
		add(i,p1,1<<30,x-y);
		add(i,p2,1<<30,-x+y);
		add(i,p3,1<<30,-x-y);
	}
	For(i,1,n){
		int x,y,v;
		scanf("%d%d%d",&x,&y,&v);
		add(i+n,T,v,0);
		add(p0,i+n,1<<30,-x-y);
		add(p1,i+n,1<<30,-x+y);
		add(p2,i+n,1<<30,x-y);
		add(p3,i+n,1<<30,x+y);
	}
	while (bfs()) del();
	printf("%lld\n",ans);
}

Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int r, g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argcv[]) {
  int A, B;
  cin >> A >> B;
  int ans = 1;
  if(A == 1 || B == 1) {
    if(A == 2 || B == 2) {
      ans = 3;
    } else {
      ans = 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[3];
int t,ans;
int main()
{
	for (int i=0;i<3;i++)
		cin>>a[i];
	sort(a,a+3);
	t=a[1]-a[0];
	if (t%2==0)
	{
		ans+=t/2;
		ans+=a[2]-a[1];
	}
	else
	{
		ans+=t/2+1;
		if (a[0]%2==0 && a[1]%2==0)
			ans+=a[2]-a[1];
		else
			ans+=a[2]-a[1]+1;
	}
	cout<<ans<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 504
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
#define READINT(X) if(ci-cn+16>cm){while((ct=readchar())>='0')(X)=(X)*10+ct-'0';}else{while((ct=*ci++)>='0')(X)=(X)*10+ct-'0';}

using namespace std;

uint16_t d, k;
uint32_t M = 0;
int_fast64_t c, sd = 0, sc = 0;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;

inline char readchar() {
    if(ci-cn==cm){fread_unlocked(cn,1,cm,stdin);ci=cn;}
    return *ci++;
}

int main() {
    READINT(M);
    while(M--) {
        d = 0;
        READINT(d);
        c = 0;
        READINT(c);
        sc += c;
        while(d--) sd += c;
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int a, b;
  cin >> a >> b;
  if(a == 2 || b == 2)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())

    temp = 0
    ans = 'NO'
    # for i in range(1, b+1, 1):
    #     temp += a*i
    #     if temp % b == c:
    #         ans = 'YES'
    for i in range(200):
        temp = c + i*b
        if temp % a == 0:
            ans = 'YES'

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.*;
  
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] line = br.readLine().split(" ");
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[2]);
            if (line[1].equals("+")) System.out.println(a + b);
            else if (line[1].equals("-")) System.out.println(a - b);
            else if (line[1].equals("*")) System.out.println(a * b);
            else if (line[1].equals("/")) System.out.println(a / b);
            else break;
        }
    }
}

Measured memory_bytes: 24412
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,M,Q;
  cin >> N >> M >> Q;

  vector<vector<int> > m(N,vector<int>(N,0));

  int li,ri;
  for(int i=0;i<M;i++){
    cin >> li >> ri;
    li--;
    ri--;
    m[li][ri]++;
  }

  /*
  cout << "---------------------" << endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout << m[i][j] << " ";
    }
    cout << endl;
  }
  */

  for(int i=0;i<N;i++){
    for(int j=1;j<N;j++){
      m[i][j]+=m[i][j-1];
    }
  }

  for(int i=0;i<N;i++){
    for(int j=1;j<N;j++){
      m[N-j-1][i]+=m[N-j][i];
    }
  }

  int p,q;
  vector<pair<int,int> > pq(Q);
  
  for(int i=0;i<Q;i++){
    cin >> p >> q;
    pq[i]=make_pair(p-1, q-1);
  }

  for(int i=0;i<Q;i++){
    //cout << pq[i].first << " " << pq[i].second << endl;
    cout << m[pq[i].first][pq[i].second] << endl;
  }
  
  return 0;
  
}


Measured memory_bytes: 2688
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m,x=map(int,readline().split())
    c=[]
    a=[]
    for i in range(n):
        ca=list(map(int,readline().split()))
        c.append(ca[0])
        a.append(ca[1:])
    
    min_res=float("inf")
    for i in range(1<<n):
        output=[]
        res=0
        rikaido=[0]*m
        for j in range(n):
            if(i>>j)&1:
                output.append(j)
        for j in output:
            res+=c[j]
            for k in range(m):
                rikaido[k]+=a[j][k]
        for k in range(m):
            if rikaido[k]<x:
                break
        else:
            min_res=min(res,min_res)

    if min_res==float("inf"):
        min_res=-1

    print(min_res)
if __name__=="__main__":
    main()

Measured memory_bytes: 9260
N,M=map(int, input().split())
LR=[list(map(int,input().split())) for i in range(M)]
l=0
r=N
for m in range(M):
    l=max(LR[m][0]-1,l)
    r=min(LR[m][1],r)
print(max(0,r-l))

Measured memory_bytes: 27336
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<List<Integer>> Array = new ArrayList<>();
        
        int n = sc.nextInt();
        
        for(int i=0;i<n;i++){
            List<Integer> array = new ArrayList<>();
            Array.add(array);
        }
        
        int q = sc.nextInt();
        
        for(int i=0;i<q;i++){
            int a = sc.nextInt();
            
            if(a == 0){
                int t= sc.nextInt();
                int x = sc.nextInt();
                Array.get(t).add(x);
            }else if(a == 1){
                int t = sc.nextInt();
                if(Array.get(t).size() != 0)
                System.out.println(Array.get(t).get(0));
            }else{
                int t = sc.nextInt();
                if(Array.get(t).size() != 0)
                Array.get(t).remove(0);
        	}
        }
    }
}


Measured memory_bytes: 168488
//@Author: wxyww
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
#include<cmath>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
#define pi pair<double,double>
const int N = 110;
ll read() {
    ll x = 0,f = 1; char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1;c = getchar();}
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0',c = getchar();}
    return x * f;
}
pi a[N];
bool cmp(const pi &A,const pi &B) {
    return atan2(A.second , A.first) > atan2(B.second , B.first);
}
int main() {
    int n = read();
    for(int i = 0;i < n;++i) a[i].first = read(),a[i].second = read();
    sort(a,a + n,cmp);
    double ans = 0;
    for(int i = 0;i < n;++i) {
        double X = a[i].first,Y = a[i].second;
        ans = max(ans,X * X + Y * Y);
        for(int j = (i + 1) % n;j != i;j = (j + 1) % n) {
            X += a[j].first,Y += a[j].second;
            ans = max(ans,X * X + Y * Y);
        }
    }
    printf("%.10lf",sqrt(ans));
    return 0;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    int n;
    cin>>n;
    char c[n];
    int r_cnt=0;
    rep(i,n){
        cin>>c[i];
        if(c[i]=='R'){
            r_cnt++;
        }
    }
    int R_cnt=0;
    for(int i=r_cnt;i<n;i++){
        if(c[i]=='R'){
            R_cnt++;
        }
    }
    cout<<R_cnt<<endl;


    return 0;
}


Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=2e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,f[100][100],ans;

int find(int x)
{
    int res;
    while(x)
    {
        res=x%10;
        x/=10;
    }
    return res;
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    int a,b;
    cin>>n; 
    _rep(i,1,n)
    {
        a=i%10;
        b=find(i);
        f[b][a]++;
    }
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
            ans+=f[i][j]*f[j][i];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
*B="[>]\0%p_\0B$`\0jFc";*F=" %d %d %d\n\0 pre-meiji\0  taisho\0 showa\0  heisei";y,m,d;main(e){for(;~scanf(F,&y,&m,&d);e?printf(F,y-B[e-1]/3271+1,m,d,printf(F+e*2+2)):puts(F+3))for(e=0;e<4&&y*3271+m*64+d>B[e];e++);      }

Measured memory_bytes: 0
import java.util.Scanner;

class Main
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int value = scan.nextInt();
		int a = value;
		value = scan.nextInt();
		int b = value;
		value = scan.nextInt();
		int c = value;
		if(a<b&&b<c)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26144
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int n;
	int a;
	int count = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a;
		if (a % 2) count++;
	}
	if (count) {
		cout << "first" << endl;
	}
	else {
		cout << "second" << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

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

  // [0, left)の累積GCD
  // left[0] = 0
  // left[1] = A0の最大公約数
  // left[2] = A0, A1の最大公約数
  // left[N] = A0...An-1の最大公約数
  vector<ll> left(N + 1, 0);
  for (ll i = 0; i < N; i++) {
    left[i + 1] = gcd(a[i], left[i]);
  }
  // [right, N-1]の累積GCD
  // right[N] = 0
  // right[N-1] = An-1の最大公約数
  // right[N-2] = An-2...An-1の最大公約数
  // right[0] = A0...An-1の最大公約数
  vector<ll> right(N + 1, 0);
  for (int i = N - 1; i >= 0; --i) {
    right[i] = gcd(right[i + 1], a[i]);
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ll l = left[i];
    ll r = right[i + 1];

    ans = max(ans, gcd(l, r));
  }

  cout << ans << endl;

  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
const int N=55;
ll fact[N],inv[N];
void solve()
{
    ll a,b,x;
    cin>>a>>b>>x;
    ll c=(a)/x;
    ll d=b/x;
    if((a-1)>=0)d-=(a-1)/x;
    else
        d++;

    cout<<d<<endl;

    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3648
n = input()
A = []
for i in range(4) :
    A.append(int(n[i]))

aa = ""
for i in range(8) :
    t = format(i,"03b")
    an = ""
    ans = A[0]
    for j in range(3) :

        if t[j] == "0" :
            ans += A[j+1]
            an += "+"
        else :
            ans -= A[j+1]
            an += "-"
    #print(ans)
    if ans == 7 :
        aa = an[:]
        #print(aa)

#print(aa)
res = ""
for i in range(3) :
    res += str(A[i]) + aa[i]
res += str(A[3]) + "=7"

print(res)


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    rep(i,n) {
        if(a[i] == 0) {
            cout << "0" << endl;
            return 0;
        }
    }

    ll ans = a[0];
    if(ans > (ll)1e18) {
        cout << "-1";
        return 0;
    }
    rep(i,n-1) {
        ll tmp = (ll)1e18/a[i+1];
        if(ans > tmp) {
            cout << "-1";
            return 0;
        }
        ans *= a[i+1];
        if(ans > (ll)1e18) {
            cout << "-1";
            return 0;
        }
    }
    
    
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}

int A,B;

int main(){
	int t;
	for(int i=0;i<4;i++){
		cin>>t;
		A+=t;
	}
	for(int i=0;i<4;i++){
		cin>>t;
		B+=t;
	}
	cout<<((A>B)?A:B)<<endl;
	
}

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

template <typename A, typename B>string to_string(pair<A, B> p);template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p);template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p);string to_string(const string& s) {  return '"' + s + '"';}string to_string(const char* s) {  return to_string((string) s);}string to_string(bool b) {  return (b ? "true" : "false");}string to_string(vector<bool> v) {  bool first = true;  string res = "{";  for (int i = 0; i < static_cast<int>(v.size()); i++) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(v[i]);  }  res += "}";  return res;}template <size_t N>string to_string(bitset<N> v) {  string res = "";  for (size_t i = 0; i < N; i++) {    res += static_cast<char>('0' + v[i]);  }  return res;}template <typename A>string to_string(A v) {  bool first = true;  string res = "{";  for (const auto &x : v) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(x);  }  res += "}";  return res;}template <typename A, typename B>string to_string(pair<A, B> p) {  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {  cerr << " " << to_string(H);  debug_out(T...);}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define set0(x) memset(x,0,sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args) {
	read(first);
	read(args...);
}

char s[200020];
int main() {
	cin>>(s+1);
    int cp = 1,la = 2,ans = 0,n = strlen(s+1);
    while(cp<=n){
        if(la == 2 || s[cp]!=s[cp-1]){
            la = 1;
            cp+=1;
            ans+=1;
        }else{
            la = 2;
            cp+=2;
            if(cp<=n+1)ans+=1;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;

    if (n >= b)
    {
        ll ans = 0;
        ll x = b;
        for (ll i = 0; i <= a + 10; i++)
        {
            ans = max(ans, a * (x - i) / b - a * ((x - i) / b));
        }
        cout << ans << endl;
    }
    else
    {
        ll ans = 0;
        ll x = n;
        for (ll i = 0; i <= a + 10; i++)
        {
            ans = max(ans, a * (x - i) / b - a * ((x - i) / b));
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))
a.sort()
ai = a[-1]
aj = a[0]
center = ai // 2
diff = 10**10

for i in range(n-1):
    if abs(center - a[i]) <= diff and aj < a[i]:
        diff = abs(center - a[i])
        aj = a[i]

print(str(ai) + " " + str(aj))

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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////


int s[20][20],k[20],p[20],n,m;

void solve() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> k[i];
		for (int j = 0; j < k[i]; ++j) {
			cin >> s[i][j];
			s[i][j]--;
		}
	} 

	for (int i = 0; i < m; ++i) {
		cin >> p[i];
	}
	int ans = 0;
	for (int mask = 0; mask < (1<<n); ++mask) {
		bool fl = true;
		for (int i = 0; i < m; ++i) {
			int cnt = 0;
			for (int j = 0; j < k[i]; ++j) {
				if (mask&(1<<(s[i][j]))) {
					++cnt;
				}
			}
			if (cnt%2 != p[i]%2) {
				fl = false;
				break;
			}
		}
		if (fl) {
			++ans;
		}
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

			#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
			#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

			#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
			#endif

	return 0;
}

		//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;
        int T = cin.Nextint;
        long ans = 0;
        long time = 0;

        for (int i = 0; i < N; i++)
        {
            long d = cin.Nextint;
            if (d < time)
            {
                ans += T - (time - d);
                time = d + T;
            }
            else
            {
                ans += T;
                time = d + T;
            }
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 28636
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long ans = 0;
        for(int b=1; b<=n; b++) {
          if(b <= k) continue;
          int remainders_per_b = b-1-k+1;
          ans += 1L * n/b * remainders_per_b;
          if(n % b >= k) ans += (n % b) - k + 1;
          if(k==0) ans--;
        }

        System.out.println(ans);
        // int[] a = new int[n];
        // for(int i=0; i<n; i++) a[i] =  Integer.parseInt(st.nextToken());

        // out.close(); System.exit(0);
    }


}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
struct Point {
	int x, y;

	double dis(Point a, Point b) {
		double x = a.x - b.x;
		double y = a.y - b.y;
		return sqrt(x*x + y * y);
	}
};

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

	string s;
	string t = "CODEFESTIVAL2016";
	cin >> s;

	int ans = 0;

	for (int i = 0; i < 16; i++)
	{
		if (s[i] != t[i]) {
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


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

int main() {

	string S;
	cin >> S;

	//初期値は大きい値
	int ans = S.size();

	//iは最初に使う色 (0 or 1)
	for (int i = 0; i < 2; i++)
	{
		// iを最初に使った時に変えなければならないタイルの数
		int cnt = 0;

		for (int j = 0; j < S.size(); j++)
		{
			if ((j % 2 == 0) ^ (S[j] == (char)(i + '0'))) cnt++;
		}

		ans = min(ans, cnt);
	}

	cout << ans << endl;
}



Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int a, b, c, N;
	while (scanf("%d%d%d", &a, &b, &c), a|b|c)
	{
		scanf("%d", &N);
		int q[301];
		for (int i = 1; i <= a+b+c; ++i)
			q[i] = 2;

		int x[1000][3], ok[1000];
		for (int i = 0; i < N; ++i)
		{
			for (int j = 0; j < 3; ++j)
				scanf("%d", &x[i][j]);
			scanf("%d", ok+i);
		}

		for (int i = 0; i < N; ++i)
			if (ok[i])
				for (int j = 0; j < 3; ++j)
					q[x[i][j]] = 1;

		for (int i = 0; i < N; ++i)
		{
			if (!ok[i])
			{
				int normal = 0;
				int ab;
				for (int j = 0; j < 3; ++j)
					if (q[x[i][j]] == 1)
						++normal;
					else
						ab = x[i][j];
				if (normal == 2)
					q[ab] = 0;
			}
		}

		for (int i = 1; i <= a+b+c; ++i)
			printf("%d\n", q[i]);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    long long a[N];
    long long s[N+1];
    s[0]=0;
    rep(i,N){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    long long ans=INFL;
    for(int i=1;i<N;i++){
        long long x=abs(s[N]-2*s[i]);
        ans=min(x,ans);
    }
    cout << ans << endl;



}


Measured memory_bytes: 3328
n = gets.to_i
w = []
n.times do |i|
  w[i] = gets.strip
  if i>=1
    if w[i-1][-1] != w[i][0]
      puts 'No'
      exit
    end
  end
end
if w != w.uniq
  puts 'No'
  exit
end
puts 'Yes'

Measured memory_bytes: 1788
N, M = [int(i) for i in input().split()]

surveys = []

for i in range(N):
    z = [int(i) for i in input().split()]
    surveys.append(z[1:])

joint_surveys = []

for i in surveys:
    joint_surveys = joint_surveys + i

res = []

for i in range(1, M+1):
    if joint_surveys.count(i) == N:
        res.append('x')

print(len(res))

Measured memory_bytes: 3064