akhauriyash/Code-Regression huggingface dataset:
N,M=map(int,input().split())
combiList = []
for i in range (M):
  combiList.append(list(map(int, input().split())))
kakuninList = list(map(int, input().split()))
statusList = [0]*M

for j in range (M):
  combiList[j].pop(0)
res = 0
# 010 なら2番目のみ派閥 
for bits in range(2**N): #k番目のグループ
  flag = True
  statusList = [0]*M
  for j in range(N):
    if((bits>>j) & 1): 
      for k in range(M):
        if j+1 in combiList[k]:
          statusList[k] +=1
  for k in range(M):
    if statusList[k] % 2 != kakuninList[k]:
      flag = False
      break
  if flag:
    res +=1
print(res)

Measured memory_bytes: 9240
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] rgbStr = sc.nextLine().split(" ");
        int rgb = Integer.parseInt(rgbStr[0]+rgbStr[1]+rgbStr[2]);

        if(rgb % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        sc.close();
    }
}


Measured memory_bytes: 23892
h={}
t={}
`read a;factor`.lines.map{|e|
	x=y=1
	e.gsub(/( \d+)\1*\b/){|m|
		x*=(n=m.to_i)**(a=m.count(' ')%3);y*=n**(-a%3)
	}
	h[x]=1.+h[x]||0
	t[x]=y
}
h[1]&&=1
h.keys.map{|k|
	$.+=[h[k],h[t[k]]||0].max
	h[k]=h[t[k]]=0
}
p$.


Measured memory_bytes: 58788
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

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

  int cnt = 0;
  while(!(a == b & b == c)) {
    if(a <= b & b <= c) {
      if(a == b) {
        a++; b++; cnt++;
      } else {
          a += 2; cnt++;
      }
    } else if(a <= c & c <= b) {
        if(a == c) {
          a++; c++; cnt++;
        } else {
            a += 2; cnt++;
        }
    } else if(b <= a & a <= c) {
        if(b == a) {
          b++; a++; cnt++;
        } else {
            b += 2; cnt++;
        }
    } else if(b <= c & c <= a) {
        if(b == c) {
          b++; c++; cnt++;
        } else {
            b += 2; cnt++;
        }
    } else if(c <= a & a <= b) {
        if(c == a) {
          c++; a++; cnt++;
        } else {
            c += 2; cnt++;
        }
    } else if(c <= b & b <= a) {
        if(c == b) {
          c++; b++; cnt++;
        } else {
            c += 2; cnt++;
        }
    }
  }  
  cout << cnt << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll get(string &s){
    vector<int> v(8);
    rep(i,8) v[i] = s[i] - '0';
    ll ret = 0;
    ret += (v[0]*10+v[1])*3600 + (v[3]*10+v[4])*60 + v[6]*10+v[7];
    return ret;
}

ll dep[100000];
ll arr[100000];

int main(){
    while(1){
        int n; cin >> n;
        if(n == 0) break;
        rep(i,n){
            string s,t; cin >> s >> t;
            dep[get(s)]++;
            arr[get(t)]++;
        }
        int ans = 0;
        int rest = 0;
        rep(i,86401){
            if(arr[i]){
                rest += arr[i];
            }
            if(dep[i]){
                if(rest < dep[i]){
                    ans += dep[i] - rest;
                    rest = 0;
                }else{
                    rest -= dep[i];
                }
            }
        }
        cout << ans << endl;
        rep(i,100000) dep[i] = arr[i] = 0;
    }
}


Measured memory_bytes: 4756
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	int num;
	cin >> num;
	int count=0;

	string s = to_string(num);
	
	for (char c : s) {
		if (c == '2') {
			count++;
		}
	}
	cout << count;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming2
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] array = new int[n];
            for(int i = 0; i < n; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }
            int minv = array[0];
            int maxv = int.MinValue;
            for (int i = 1; i < n; i++)
            {
                if (array[i] - minv > maxv)
                {
                    maxv = array[i] - minv;
                }
                if (array[i] < minv)
                {
                    minv = array[i];
                }
            }
            Console.WriteLine(maxv);
        }

    }
}

Measured memory_bytes: 10888
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	int n;
	cin>>n;
	int x[n],y[n],h[n];

	rep(i,n)cin>>x[i]>>y[i]>>h[i];
	int wx,wy,wh;
	rep(i,n){
		if(h[i]!=0){
			wx=x[i];
			wy=y[i];
			wh=h[i];
		}
	}


	int ansx,ansy,ansh;
	rep(i,101){
		rep(j,101){
			int curh=wh+abs(i-wx)+abs(j-wy);
			bool flag=true;
			rep(k,n){
				int tmph=curh-abs(i-x[k])-abs(j-y[k]);
				if(tmph < 0)tmph=0;
				if(tmph != h[k]){
					flag=false;
					break;
				}
			}
			if(flag){
				ansx=i;
				ansy=j;
				ansh=curh;
			}
		}
	}

	cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;

  cin >> N ;

  int ans=0;

  for(int i=1;i<=N;i+=2){
    int count=0;
    for(int j=1;j<=i;j++){
      if(i%j==0) count++;    
    }
    
    if(count==8) ans++;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    ll a,b,c,d;
    cin >> a >> b >>c >> d;
    ll e = c / __gcd(c,d) * d;
    cout <<  b - a + 1 - (b/c - (a-1)/c + b/d - (a-1)/d - (b/e - (a-1)/e)) << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main() {
	int n, k; cin >> n >> k;
	int p = 1;
	for (int i = 0; i < n; i++) {
		if (p <= k)p *= 2;
		else p += k;
	}
	cout << p << endl;
}

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

int main(){
  int masu[100000];
  int i,j,k,n,m,ans,sai[1000000],l,me;

  while(1){
    me=1;
    cin >> n >> m;
    if(n == 0 && m == 0)break;

    for(k=1;k<=n;k++)cin >> masu[k];
    for(l=1;l<=m;l++)cin >> sai[l];
    // int tes = -4;
    // cout << "tes " <<6 + tes << endl;

    //  for(k=0;k<n;k++)cout <<"masu ="  <<masu[k] << endl;

    // cout << "GOOL =" << k << endl;

    for(i=1;i<=m;i++){
      // cout << "first me =" << me << endl;
      me=sai[i]+me;
      //cout << "masu["<<me<<"] =" << masu[me]<< endl;
      me=me + masu[me];
     
      //cout << "sai[i] =" << sai[i] << endl;
     
      //cout << "me =" << me << endl;
      if(me >= k-1){
	cout << i << endl;
	break;
      }



    }




  }


}

Measured memory_bytes: 0
#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 keta(int x){
    int ans = 0;
    while(x > 0) {
        ans += x%10;
        x /= 10;
    }
    return ans;
}
int main() {
    int n, a, b; cin >> n >> a >> b;
    int ans = 0;
    for (int i=1;i<=n;i++) {
        int x = keta(i);
        if(a<=x && x<=b) {
            ans += i;
        }
    }
    cout << ans;
}


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

template <typename T>
vector<T> make_vector(int sz)
{
	return vector<T>(sz);
}

template <typename T, typename... U>
auto make_vector(int sz, U... tails)
{
	return vector<decltype(make_vector<T>(tails...))>(sz, make_vector<T>(tails...));
}

template <typename T>
void fill_vector(vector<T> &v, T init)
{
	fill(v.begin(), v.end(), init);
}

template <typename T, typename U>
void fill_vector(vector<U> &vec, T init)
{
	for (auto &&v : vec)
	{
		fill_vector(v, init);
	}
}

template <typename T>
struct Undirected_Graph
{
	struct edge
	{
		int64_t from, to;
		T cost_money, cost_time;
	};

	int64_t n;
	vector<edge> edges;
	vector<vector<int64_t>> g;

	Undirected_Graph(int64_t n) : n(n), g(n)
	{
	}

	void add(int64_t from, int64_t to, T cost_money, T cost_time)
	{
		assert(0 <= from && from < n && 0 <= to && to < n);

		g[from].emplace_back(edges.size());
		g[to].emplace_back(edges.size());
		edges.push_back({from, to, cost_money, cost_time});
	}
};

int main()
{
	int64_t n, m, s;
	cin >> n >> m >> s;
	vector<int64_t> us(m), vs(m), as(m), bs(m);
	for (int64_t i = 0; i < m; i++)
	{
		cin >> us[i] >> vs[i] >> as[i] >> bs[i];
		us[i]--;
		vs[i]--;
	}
	vector<int64_t> cs(n), ds(n);
	for (int64_t i = 0; i < n; i++)
	{
		cin >> cs[i] >> ds[i];
	}

	Undirected_Graph<int64_t> g(n);
	for (int64_t i = 0; i < m; i++)
	{
		g.add(us[i], vs[i], as[i], bs[i]);
	}

	int64_t inf = (1LL << 60);

	auto dist = make_vector<int64_t>(n, 2501);
	fill_vector(dist, inf);

	dist[0][min<int64_t>(2500, s)] = 0;

	using U = pair<int64_t, pair<int64_t, int64_t>>;
	priority_queue<U, vector<U>, greater<>> pq;

	pq.push({dist[0][min<int64_t>(2500, s)], {0, min<int64_t>(2500, s)}});

	while (!pq.empty())
	{
		int64_t t = pq.top().first;
		int64_t i = pq.top().second.first;
		int64_t j = pq.top().second.second;
		pq.pop();

		if (dist[i][j] != t)
		{
			continue;
		}

		if (dist[i][j] + ds[i] < dist[i][min<int64_t>(2500, j + cs[i])])
		{
			dist[i][min<int64_t>(2500, j + cs[i])] = dist[i][j] + ds[i];
			pq.push({dist[i][min<int64_t>(2500, j + cs[i])], {i, min<int64_t>(2500, j + cs[i])}});
		}

		for (int id : g.g[i])
		{
			auto &e = g.edges[id];

			int to = e.from ^ e.to ^ i;

			if (j - e.cost_money < 0)
			{
				continue;
			}

			if (dist[i][j] + e.cost_time < dist[to][j - e.cost_money])
			{
				dist[to][j - e.cost_money] = dist[i][j] + e.cost_time;
				pq.push({dist[to][j - e.cost_money], {to, j - e.cost_money}});
			}
		}
	}

	for (int64_t t = 1; t < n; t++)
	{
		cout << *min_element(dist[t].begin(), dist[t].end()) << endl;
	}

	return 0;
}

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

int main(){

    ll n;
    cin >> n;
    vector<pair<ll,bool> > a;
    vector<ll> d(n-1,0);
    ll t;
    for(ll i=0;i<n;i++){
        cin >> t;
        a.push_back({t,true});
    }

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

    for(ll i=0;i<n-1;i++){
        d[i]=a[i+1].first-a[i].first;
    }

    ll t1;
    bool f=true;
    for(ll i=n-2;i>=0;i--){
        if(d[i]==0&&f&&a[i].second&&a[i+1].second){
            f=false;
            a[i].second=false;
            a[i+1].second=false;
            t1=a[i].first;
        }else if(d[i]==0&&a[i].second&&a[i+1].second){
            cout << t1*a[i].first << endl;
            return 0;
        }
    }

    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3188
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

ans = [[None]*W for i in range(H)]
i = 0
for n,a in enumerate(A):
    for _ in range(a):
        y,x = divmod(i,W)
        ans[y][x] = n+1
        i += 1
for i,row in enumerate(ans):
    if i%2:
        print(*row[::-1])
    else:
        print(*row)

Measured memory_bytes: 3828
#include<stdio.h>

int main(void){
  int N,M,S=0;
  scanf("%d",&N);

  int TT[N+5];
  int t;
  for(int i=1; i <= N; i++){
    scanf("%d",&t);
    TT[i] = t;
    S += t;
  }

  scanf("%d", &M);
  int p,x,ans;
  for(int i=0; i < M; i++){
    scanf("%d%d",&p,&x);
    ans = S + (x - TT[p]);
    printf("%d\n",ans);
  }

  return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# Your code here!
N=input()
N=int(N)
C=int(N/4+1)
D=int(N/7+1)
count=0
for i in range(C+1):
    for j in range(D+1):
        if (i*4+j*7)==N:
            count=count+1
if count>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF=(1LL<<60);
const int mod=1000000007;

int main(void){
    string s; cin >> s;
    int ans=100000;
    for(int i=0; i<s.size()-2; i++){
        int a=stoi(s.substr(i,3));
        chmin(ans,abs(a-753));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# ABC 136, C
n = int(input())
H = [int(el) for el in input().split(' ')]

max_h = 0
for i in range(n):
    if H[i] < max_h:
        print('No')
        break

    if H[i] -1 >= max_h:
        max_h = H[i] - 1
else:
    print('Yes')


Measured memory_bytes: 15376
S = input()
N = len(S)
ans = True
for i in range(0,N,2):
    if S[i] == 'L':
        ans = False
for j in range(1,N,2):
    if S[j] == 'R':
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std; 
int N;
  
 
bool isPrime(int n)  
{  
    
    if (n <= 1)  return false;  
    if (n <= 3)  return true;  
    
   
    if (n%2 == 0 || n%3 == 0) return false;  
    
    for (int i=5; i*i<=n; i=i+6)  
        if (n%i == 0 || n%(i+2) == 0)  
           return false;  
    
    return true;  
}  
  
 
 
  
    
  
 
int main() 
{ 
  	int x;
 	cin>>x;
 	int p=x;
 	while(!isPrime(p)) p++;
 	cout<<p<<endl;
 	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#define MAXNUM 500001
using namespace std;
int A[MAXNUM];
int n;

int parent(int i){
    return i/2;
}
int left(int i){
    return i*2;
}
int right(int i){
    return i*2+1;
}

void maxHeapify(int A[],int i){
    int l=left(i),r=right(i);
    int k=0;
    if(l<=n && A[l]>A[i]){
        k=l;
    }else k=i;
    if(r<=n && A[r]>A[k])
        k=r;
    if(k!=i){
        int temp=A[k];
        A[k]=A[i];
        A[i]=temp;
        maxHeapify(A,k);
    }
}
void buildMaxHeap(int A[],int n){
    for(int i=n/2;i>0;i--){
        maxHeapify(A,i);
    }
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>A[i];
    }
    buildMaxHeap(A,n);
    for(int i=1;i<=n;i++){
        cout<<' ' <<A[i];
    }
    cout<<endl;
    return 0;
}



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

ll INF = 1e+18;
int iINF = 1e9;

bool
comp(pair<ll, ll> a, pair<ll, ll> b)
{
  return a.second < b.second;
}

int 
main()
{
  string S; cin >> S;
  int Q; cin >> Q;
  bool flag = true;

  rep(i, 0, Q){
    int tmp; cin >> tmp;
    if(tmp == 1){
      flag = !flag;
    } else {
      int F; cin >> F;
      string add; cin >> add;
      if(F == 1){
        if(flag) S.insert(0, add);
        else S.append(add);
      } else {
        if(flag) S.append(add);
        else S.insert(0, add);
      }
    }
  }

  if(flag){
    cout << S << endl;
  } else {
    reverse(S.begin(), S.end());
    cout << S << endl;
  }

}

Measured memory_bytes: 3932
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>

using namespace std;

#define N 200100
#define ll long long
#define RG register
#define MOD 924844033
const double Pi=acos(-1);

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

inline int Plu(const int &x,const int &y) { return x+y>=MOD?x+y-MOD:x+y; }
inline int Pow(int x,int y){ int ans=1;
	while(y) { if(y&1) ans=1LL*ans*x%MOD; x=1LL*x*x%MOD,y>>=1; }
	return ans;
}
struct NTT{
	int n,r[N<<2],a[N<<2],b[N<<2],W[N<<2];
	inline void Pre(){
		int to=n<<1,l=0;
		for(n=1;n<=to;n<<=1) ++l; --l;
		for(RG int i=0;i^n;++i) r[i]=(r[i>>1]>>1)|((i&1)<<l);
	}
	inline void Trans(int *P,int op){
		for(RG int i=0;i^n;++i) if(i<r[i]) swap(P[i],P[r[i]]);
		for(RG int i=1;i<n;i<<=1){
			int w=Pow(5,(MOD-1)/(i<<1));
			if(op==-1) w=Pow(w,MOD-2); W[0]=1;
			for(RG int k=1;k^i;++k) W[k]=1LL*W[k-1]*w%MOD;
			for(RG int p=i<<1,j=0;j<n;j+=p)
				for(RG int k=0;k^i;++k){
					int X=P[j+k],Y=1LL*P[i+j+k]*W[k]%MOD;
					P[j+k]=Plu(X,Y),P[i+j+k]=Plu(X,MOD-Y);
				}
		}
		if(op==-1)
			for(RG int i=0,Inv=Pow(n,MOD-2);i^n;++i)
				P[i]=1LL*P[i]*Inv%MOD;
	}
}   F;

int n,top,first[N],siz[N],num[N],sum[N];
struct mona { int nxt,en; } s[N<<1];
inline void Insert(int x,int y) { s[++top]=(mona) { first[x],y },first[x]=top; }
inline void Dfs(int k,int fa){
	siz[k]=1;
	for(RG int i=first[k];i;i=s[i].nxt){
		int en=s[i].en; if(en==fa) continue ;
		Dfs(en,k),siz[k]+=siz[en],++num[siz[en]];
	}   ++num[n-siz[k]];
}

int main(){
	n=read(),F.n=n+1,F.Pre(),sum[0]=1;
	for(RG int i=1;i<=n;++i) sum[i]=1LL*sum[i-1]*i%MOD;
	for(RG int i=1;i^n;++i){
		int x=read(),y=read(); Insert(x,y),Insert(y,x);
	}   Dfs(1,0);
	for(RG int i=0;i<=n;++i) F.a[i]=1LL*sum[i]*num[i]%MOD;
	for(RG int i=0;i<=n;++i) F.b[i]=Pow(sum[n-i],MOD-2);
	F.Trans(F.a,1),F.Trans(F.b,1);
	for(RG int i=0;i^F.n;++i) F.a[i]=1LL*F.a[i]*F.b[i]%MOD;
	F.Trans(F.a,-1);
	for(RG int i=1;i<=n;++i) printf("%d\n",Plu(1LL*n*sum[n]%MOD*Pow(1LL*sum[i]*sum[n-i]%MOD,MOD-2)%MOD,
											   MOD-1LL*F.a[i+n]*Pow(sum[i],MOD-2)%MOD));
}


Measured memory_bytes: 24704
#include <stdio.h>

int main(void)
{
 int n,t,R[200000],max,min;

 scanf("%d",&n);

 for(t=0;t<n;t++){
  scanf("%d",&R[t]);
 }

 min=R[0];
 max=R[1]-R[0];
 for(t=1;t<n;t++){
  if( max < R[t]-min ){
    max = R[t]-min;
  }
  if( min > R[t] ){
    min = R[t];
  }
 }

 printf("%d\n",max);

 return 0;

}

Measured memory_bytes: 2572
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,k[20],s[20][20],p[20],ans;
bool op[20];

void dfs(int pos)
{
	if(pos==n)
	{
		rep(i,m)
		{
			int num=0;
			rep(j,k[i]) if(op[s[i][j]]) num++;
			if(num%2!=p[i]) return;
		}
		ans++;
		return;
	}
	op[pos]=true;
	dfs(pos+1);
	op[pos]=false;
	dfs(pos+1);
}

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		cin>>k[i];
		rep(j,k[i])
		{
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	rep(i,m) cin>>p[i];
	dfs(0);
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		String[] nANDmStr = input.readLine().split(" ");
		
		int[] nANDm = new int[nANDmStr.length];
		
		for(int insert = 0; insert < nANDmStr.length; insert++)
		{
			nANDm[insert] = Integer.parseInt(nANDmStr[insert]);
		}
		
		int[][] matrix = new int[nANDm[0]][nANDm[1]];
		
		for(int row = 0; row < matrix.length; row++)
		{
			String[] matrixStr = input.readLine().split(" ");
			
			for(int column = 0; column < matrixStr.length; column++)
			{
				matrix[row][column] = Integer.parseInt(matrixStr[column]);
			}
		}

		
		String[] vectorStr = new String[nANDm[1]];
		
		int[] vector = new int[vectorStr.length];
		
		for(int insert = 0; insert < vector.length; insert++)
		{
			vectorStr[insert] = input.readLine();
			
			vector[insert] = Integer.parseInt(vectorStr[insert]);
		}
		
		for(int row = 0; row < nANDm[0]; row++)
		{
			int solution = 0;
			
			for(int column = 0; column < nANDm[1]; column++)
			{
				solution = matrix[row][column] * vector[column] + solution;
			}
			
			System.out.println(solution);
		}
	}

}



Measured memory_bytes: 27632
//-----------------------
// author : xyqkoala
// time : 2020-08-22
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n,x,t;
	cin>>n>>x>>t;
	cout<<((n-1)/x+1) * t<<endl;
}


Measured memory_bytes: 3576
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    pS = [list(input().split()) for _ in range(M)]

    score = [0] * (N + 1)
    ac = [False] * (N + 1)
    for p, S in pS:
        res = int(p)
        if S == 'AC':
            ac[res] = True
        if ac[res]:
            continue
        score[res] += 1
    penalty = 0
    for i in range(N + 1):
        if ac[i]:
            penalty += score[i]
    print(sum(ac), penalty)
    # print(ac)
    # print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31800
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	if(n==m)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var s string 
  fmt.Scan(&s)
  res := make(map[rune]bool)
  for _, c := range s {res[c] = true}
  ans := "None"
  for i := 'a'; i < 'z' + 1; i++ {
    if _, ok := res[i]; !ok {
      ans = string(i)
      break
    }
  }
  fmt.Println(ans)
}

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

int main()
{
int b=0 ;
  string x;
  cin>>x ;

for(int i=0 ;i<3;i++)
{
    if(x[i]=='1' ){b+=1 ;}
}
    cout<< b;



	return 0 ;

	}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
	int a=0;
	string s;

	cin >> s;

	rep(i,0,s.size()){
		if(s[i]=='x'){
			a++;
		}
	}
	
	if(a>=8){
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

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

namespace ABC154
{
    class D
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int K = input[1];
            double[] p = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double[] Kitai = new double[N];

            for (int i = 0; i < N; i++)
            {
                Kitai[i] = (1 + p[i]) / 2;
            }

            double[] S = new double[N + 1];
            for (int i = 1; i < N + 1; i++)
            {
                S[i] = Kitai[i - 1] + S[i - 1];
            }

            double res = 0.0;
            for (int i = 0; i < N - K + 1; i++)
            {
                res = Math.Max(res, S[i + K] - S[i]);
            }

            /*
            for (int i = 0; i < N - K + 1; i++)
            {
                double kitai = 0.0;
                for (int k = 0; k < K; k++)
                {
                    if (p[i + k] == 1) kitai += 1.0;
                    else kitai += (1 + p[i + k]) / 2;
                    //Console.WriteLine(kitai);
                }
                res = Math.Max(res, kitai);
            }
            */
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 34780
#include <stdio.h>

long long int a,b,x;
long long int ans=0;

int main(){
	scanf("%lld %lld %lld",&a,&b,&x);
	if(a%x!=0){
	    ans=(b-b%x)/x-(a-a%x)/x;
	}
    if(a%x==0){
		ans=(b-b%x)/x-(a-a%x)/x+1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize
    }
    println!("{}", if k == 1 {0} else {n - k});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll gcd(ll a, ll b){
	if(a < b){ll tmp = a; a = b; b = tmp;}
	if(a == b || b == 0){return a;}
	return gcd(b, a%b);
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m;
	cin >> n >> m;
	ll a[n];
	zep(i, 0, n){
		cin >> a[i];
		a[i] /= 2;
	}
	
	ll cnt = a[0];
	zep(i, 1, n){
		if(a[i]%cnt != 0){
			cnt = gcd(a[i], cnt);
		}
	}
	
	zep(i, 0, n){
		if((a[i]/cnt)%2 == 0){
			print(0)
			return 0;
		}
	}
	
	ll b = 1;
	zep(i, 0, n){
		if(b%a[i] != 0){
			b = (b*a[i])/gcd(b, a[i]);
			if(b > m){
				print(0)
				return 0;
			}
		}
	}
	print((m/b+1)/2)
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>

using ll = long long;

int main() {
    int N;
    std::cin >> N;
    if (N < 3) {
        std::cout << 0 << std::endl;
        return 0;
    }
    if (N % 3 == 0) {
        std::cout << N / 3 << std::endl;
        return 0;
    }
    if (N % 3 == 1) {
        std::cout << 1 + (N - 4) / 3 << std::endl;
        return 0;
    }
    std::cout << 1 + (N - 5) / 3 << std::endl;
}


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

int main(){
	long long  s, c;
	long long cnt = 0;
	scanf("%lld %lld", &s, &c);

	// sを消費
	if( c < 2 * s ) { // cがsに対して不足
		cnt += c / 2;
		c -= c / 2 * 2;
	}else{ // cはsに対して十分にある
		c -= 2 * s;
		cnt += s;
	}

	// 残りのcについて
	cnt += c / 4;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

main :: IO ()
main = do
  a <- readInt
  b <- readInt 
  c <- readInt 
  x <- readInt 
  print $ selection' a b c x

selection, selection'
  :: Int -> Int -> Int -> Int -> Int
selection a b c x
  = length [(s,t,u) | s<-[0..a], t<-[0..b], u<-[0..c]
                    , 500*s + 100*t + 50*u == x]

selection' a b c x = sum [ g b c (x-500*s) | s <- [0 .. a]]
  where
    g b c x = sum [h c (x-100*t) | t <- [0 .. b]]
    h c x 
      | x >= 0 && 50* c >= x = 1
      | otherwise            = 0

Measured memory_bytes: 380
# include <iostream>
# include <algorithm>
using namespace std;
int main()
{
	int p;
	p=0;
	string s;
	string a;
	cin>>s;
	cin>>a;
	if(s.size()==a.size()-1)
	{
	for(int i=0; i<s.size(); i++)
	{
		if(s[i]==a[i])
		{
			p=1;
		}
		else
		{
			p=0;
			cout<<"No";
			break;
		}
	}
	if(p==1)
	{
		cout<<"Yes";
	}
}
else
{
	cout<<"No";
}
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int count_digit(int i)
{
	int rem,count=0;
	while(i!=0)
	{
		rem=i%10;
		i=i/10;
		count++;
	}
	return count;
}
int main() {
  

    int n;
    cin>>n;
    int p,c=0;
    for(int i=1;i<=n;i++)
    {
    	p=count_digit(i);
    	if(p%2==1)
    		c++;
    }
    cout<<c;

    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> A>>B>>C>>K;
	if(K<=A) std::cout << K << std::endl;
	else if(K<=A+B)std::cout << A << std::endl;
	else std::cout << A-(K-(A+B)) << std::endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;
V< V< P<int, int> > > edges;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    edges.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }

    int q, k; cin >> q >> k;
    k--;
    
    vll dist(n, HIGHINF); dist[k] = 0;
    queue<int> que; que.push(k);
    while (!que.empty()) {
        int q = que.front(); que.pop();
        for (P<int, int> e: edges[q]) {
            if (chmin(dist[e.first], dist[q] + (ll)e.second)) que.push(e.first);
        }
    }

    for (int i = 0; i < q; i++) {
        int x, y; cin >> x >> y;
        x--, y--;
        cout << dist[x] + dist[y] << '\n';
    }
    return 0;
}


Measured memory_bytes: 8820
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>


int Sum(int *A, int a){
    return A[a - 2] + A[a - 1];
}
int Diff(int *A, int a){
    return A[a - 2] - A[a - 1];
}
int Prod(int *A, int a){
    return A[a - 2] * A[a - 1];
}
/*
 * 
 */
int main(int argc, char** argv) {
    
    int A[105];
    char C;
    char Storage[6];
    int PrevIsOperator, lim = 0;
    
    
    for(int a = 0;;){
        
        
    C = getchar();
    if(C == '\n')break;
    if(C == '+'){
        PrevIsOperator = 1;
        A[a-2] = Sum(&A,a);
        a = a - 1;
        continue;
    }
    
    if(C == '-'){
        PrevIsOperator = 1;
        A[a-2] = Diff(&A,a);
        a = a - 1;
        continue;
    }
    
    if(C == '*'){
        PrevIsOperator = 1;
        A[a-2] = Prod(&A,a);
        a = a - 1;
        continue;
    }
    
    if(isspace(C) && PrevIsOperator == 1)continue;
    if(isspace(C) && PrevIsOperator == 0){
        Storage[lim++] = '\n';
        A[a] = atoi(Storage);
        lim = 0;
        a++;
    }
    
    if(isdigit(C)){
        PrevIsOperator = 0;
        Storage[lim++] = C;
        continue;
    }
    }
    
    printf("%d\n",A[0]);
   
    

    return (0);
}



Measured memory_bytes: 2108
import bisect

n = int(input())
li = [int(x) for x in input().split()]
li.sort()
ans = 0
for i in range(n-1):
    for j in range(n-1):
        if i<j:
            a = bisect.bisect_left(li,li[i]+li[j])
            ans += a-1-j
print(ans)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, K, S; cin >> N >> K >> S;

  rep(i, K) {
    if (i) cout << " ";
    cout << S;
  }

  int const MagicNumber = 114514893;
  rep(i, N - K) {
    if (K || i) cout << " ";
    cout << MagicNumber;
  }
  cout << endl;
}


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

#define endl '\n'

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, sum = 0;
    cin >> N >> M;
    // odd + odd
    if(N > 1) 
        sum += (N * (N - 1) / 2);
    // even + even
    if(M > 1)
        sum +=  (M * (M - 1) / 2);
    cout << sum << endl;
    return 0;
}

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

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

  ll N;
  cin >> N;
  vector<pair<ll,ll>> A(N);
  rep(i, N) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(all(A));
  reverse(all(A));
  
  vector<vector<ll>> dp(N+1, vector<ll>(N+1));
  
  rep(i, N) rep(j, i+1) {
    
    if (j==0) {
      dp[i+1][j] = dp[i][j] + A[i].first * abs(A[i].second - (N-1-(i-j)));
    }else {
      dp[i+1][j] = max(dp[i][j-1] + A[i].first * abs(A[i].second - (j-1)),
                       dp[i][j] + A[i].first * abs(A[i].second - (N-1-i+j))
                      );
    }
    
    if (j==i) {
      dp[i+1][j+1] = dp[i][j] + A[i].first * abs(A[i].second - j);
    }else {
      dp[i+1][j+1] = max(dp[i][j] + A[i].first * abs(A[i].second - j),
                         dp[i][j+1] + A[i].first * abs(A[i].second - (N-1-i+j+1))
                         );
    }
  }
  
  ll ans = dp[N][0];
  rep2(i, N) ans = max(ans, dp[N][i]);
  
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 34608
#include <stdio.h>
#include <stdlib.h>

#define MAX 100

void push(int);
int pop(void);
int isEmpty(void);
int isFull(void);

int top = 0;
int stack[MAX];

int main() {
  int n = 0, result = 0;
  int operand[2];
  char input[100];

  while(scanf("%s", input) != EOF) {
    if(input[0] == '+') {
      operand[1] = pop();
      operand[0] = pop();
      push(operand[0] + operand[1]);
    }else if(input[0] == '-') {
      operand[1] = pop();
      operand[0] = pop();
      push(operand[0] - operand[1]);
    }else if(input[0] == '*') {
      operand[1] = pop();
      operand[0] = pop();
      push(operand[0] * operand[1]);
    }else {
      n = atoi(input);
      push(n);
    }
  }

  result = pop();

  printf("%d\n", result);

  return 0;
  
}

void push(int x) {
  if(isFull() != 1) {
  stack[top] = x;
  top++;
  }else printf("Stack is full.\n");
}

int pop(void) {
  int r = 0;
  if(isEmpty() != 1) {
    top--;
    r = stack[top];
    return r;
  }else printf("Stack is empty.\n");

  return;
}

int isFull(void) {
  if (top == MAX) return 1;
  else return 0;
}

int isEmpty(void) {
  if (top == 0) return 1;
  else return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL mod = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> A(n), B(m);
    rep(i, n) cin >> A[i];
    rep(i, m) cin >> B[i];
    sort(all(A));
    sort(all(B));
    if(unique(all(A)) != A.end() || unique(all(B)) != B.end()){
        cout << 0 << endl;
        return 0;
    }
    reverse(all(A));
    reverse(all(B));
    A.pb(-1);
    B.pb(-1);
    LL ans = 1;
    int a = 0, b = 0;
    for(int x = n*m; x>0; x--){
        if(A[a] == x && B[b] == x){
            a++; b++;
            continue;
        }else if(A[a] == x){
            (ans *= b) %= mod;
            a++;
        }else if(B[b] == x){
            (ans *= a) %= mod;
            b++;
        }else{
            (ans *= (a*b)-(n*m-x)+mod) %= mod;
        }
        // cout << a << " " << b << " " << ans << endl;
    }
    cout << ans << endl;

}





Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    M = int(input())
    T = [input() for _ in range(M)]
    result = {}
    for s in S:
        if s in result.keys():
            result[s] += 1
        else:
            result[s] = 1
    for t in T:
        if t in result.keys():
            result[t] -= 1
        else:
            result[t] = -1

    print(max(max(result.values()), 0))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if(a>8 || b>8) {
			System.out.println(":(");
		}else {
			System.out.println("Yay!");
		}

	}

}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

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

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

    vector<long long int> a(n+1), b(n);
    long long int i;
    for(i = 0; i < n+1; i++){
        cin >> a[i];
    }
    for(i = 0; i < n; i++){
        cin >> b[i];
    }

    long long int count = 0;
    for(i = 0; i < n; i++){
        if(b[i] >= a[i]){
            b[i] -= a[i];
            count += a[i];
            if(b[i] >= a[i+1]){
                count += a[i+1];
                a[i+1] = 0;
            }else{
                a[i+1] -= b[i];
                count += b[i];
            }
        }else{
            count += b[i];
        }
    }

    cout << count << endl;
}



Measured memory_bytes: 1792
#include <cstdio>
int n;
int C[10001];
void CountingSort(int* A, int* B, int k){
    for (int i = 0 ; i <= k ;++i)
        C[i] = 0;

    /* C[i] に i の出現数を記録する */
    for (int j = 0 ; j < n ; ++j)
        C[A[j]]++;

    /* C[i] に i 以下の数の出現数を記録する*/
    for (int i = 1 ; i <= k ; ++i)
        C[i] = C[i] + C[i-1];

    for (int j = n-1 ; j >= 0 ; --j){
        B[C[A[j]]-1] = A[j];
        C[A[j]]--;
    }
}

int a[2000000];
int b[2000000];
int main(){
  scanf("%d", &n);
  for (int i=0;i<n;i++){
    scanf("%d", a+i);
  }
  CountingSort(a, b, 10000);
  for (int i=0;i<n;i++){
    if (i!=0) printf(" ");
    printf("%d", b[i]);
  }
  printf("\n");
  return 0;
} 



Measured memory_bytes: 18400
w, a, b = input().split()
w2 = int(w)
a2 = int(a)
b2 = int(b)

if a2+w2 <= b2:
    print(b2-a2-w2)
elif a2 <= b2 < a2+w2:
    print(0)
else:
    print(a2-b2-w2)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;cin>>s;
    set<char> st;
    for(auto &ele:s)st.insert(ele);
    cout<<(st.size()==2?"Yes":"No");
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    int n, a;
    cin >> n;
    int A[n]={0};
    //nums.resize(n);
    for(int i=0;i<n-1;i++){
        cin >> a;
        A[a-1]++;
    }

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

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

long long N,K,tmp;

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

int main(){
	cin>>N>>K;
	long long curr; bool pos=false;
	cin>>curr;
	if(K<=curr)pos=true;
	for(int i=1; i<N; i++){
		cin>>tmp;
		if(K<=tmp)pos=true;
		curr=fpb(curr,tmp);
	}
	if(fpb(curr,K)!=curr||!pos){
		cout<<"IMPOSSIBLE"<<'\n';
	}else{
		cout<<"POSSIBLE"<<'\n';
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

void ShowResult(const vector<int> &result, int n) {
	for (int i = 0; i < n; ++i) {
		cout << result[i];
		
		if (i == n - 1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
}

void GetPrimeNums(vector<int> &primeNums, int numMax) {
	vector<bool> isPrime(numMax, true);
	
	isPrime[0] = false;
	isPrime[1] = false;
	
	int sqrtMax = sqrt(numMax);
	for (int i = 2; i < sqrtMax; ++i) {
		if (isPrime[i]) {
			for(int j = 0; i * (j + 2) < numMax; j++) {
				isPrime[i *(j + 2)] = false;
			}
		}
	}
	
	for (int i = 0; i < numMax; ++i) {
		if (isPrime[i]) {
			primeNums.push_back(i);
		}
	}
}

int main() {
	int n;
	cin >> n;
	
	vector<int> primeNums;
	GetPrimeNums(primeNums, 55555);
	
	vector<int> result(n);
	int j = 0;
	for (int i = 0; i < n; ++i) {
		for (; j < 55555; ++j) {
			if (primeNums[j] % 5 == 1) {
				result[i] = primeNums[j];
				++j;
				break;
			}
		}
	}
	
	ShowResult(result, n);
	return 0;
}

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

bool ok(int a, int b, int c) 
{ 
    if (a + b <= c || a + c <= b || b + c <= a || a == b || a == c || b == c) 
        return false; 
        return true; 
} 
  

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	for(int i = 0; i < n; i++){
		cin >> l[i];
	}
	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			for(int k = j+1; k < n; k++){
				if(ok(l[i],l[j],l[k])){
					++cnt;
				}
			}
		}
	}
	cout << cnt << "\n";
	return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {
  ll r;
  scanf("%lld", &r);
  printf("%.3lf\n", 2 * acos(-1.0) * r);
  return 0;
}

Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

inline char nc()
{
	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}

typedef long long ll;

const int mod = 1e9 + 7;
const int MAXN = 5000 + 5;
int N;

inline int dec(int x) {return x < 0 ? x + mod : x;}

int head[MAXN];
struct edge
{
	int to, nex;
	edge(int to=0,int nex=0):to(to),nex(nex){}
};
vector<edge> G;
inline void addedge(int u, int v)
{
	G.push_back(edge(v, head[u])), head[u] = G.size() - 1;
	G.push_back(edge(u, head[v])), head[v] = G.size() - 1;
}

int g[MAXN];
void init_g()
{
	g[0] = 1;
	for(int i = 2; i <= N; i += 2)
	{
		g[i] = (ll)(i - 1) * g[i - 2] % mod;
	}
}

int siz[MAXN];
int f[MAXN][MAXN];
void dp(int u, int fa)
{
	siz[u] = 1;
	f[u][1] = 1;
	for(int i = head[u]; ~i; i = G[i].nex)
	{
		int v = G[i].to; if(v == fa) continue;
		dp(v, u);
		for(int a = siz[u]; a >= 1; --a)
		{
			int d = 0;
			for(int b = siz[v]; b >= 1; --b)
			{
				f[u][a + b] = (f[u][a + b] + (ll)f[u][a] * f[v][b]) % mod;
				d = dec((d - (ll)f[u][a] * f[v][b] % mod * g[b]) % mod);
			}
			f[u][a] = d;
		}
		siz[u] += siz[v];
	}
}

int sol()
{
	init_g();
	dp(1, 0);
	int an = 0;
	for(int i = 1; i <= N; ++i)
	{
		an = (an + (ll)f[1][i] * g[i]) % mod;
	}
	return an;
}

int main()
{
	read(N);
	memset(head, -1, sizeof(head));
	for(int i = 1; i < N; ++i)
	{
		int u, v; read(u), read(v);
		addedge(u, v);
	}
	printf("%d\n", sol());
	return 0;
}


Measured memory_bytes: 97280
a = [0]*(5)
for l in range(5):
    a[l] = str(input())
ls = [a[0],a[1],a[2],a[3],a[4]]
new = [0]*(5)
s = 0
for i in range(5):
    new[i] = int(a[i][-1])
for p in ls:
    if int(p) % 10 ==0:
        s += int(p)
    else:
        s += ((int(p)//10) + 1) *10
if sum(new) !=0:
    ans = min([e for e in new if e !=0])
    print(s-10+ans)
else:
    print(s)

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

using namespace std;

int main() {
    long r, d, x;
    long ans = 0;

    cin >> r >> d >> x;
    ans = x;
    for(int i = 0; i<10;i++) {
        ans = r * ans - d;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256