akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    vl a(3);
    ll k;
    rep (i, 3) cin >> a[i];
    cin >> k;

    ll score = 0;
    rep (i, 3) {
        if (k >= a[i]) {
            k -= a[i];
            score += a[i] * (-i + 1);
        }
        else {
            score += k * (-i + 1);
            k = 0;
        }
    }
    cout << score << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int w, h, n, a[110], x[110], y[110], ans;

int main()
{
	scanf("%d%d%d", &w, &h, &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d%d", &x[i], &y[i], &a[i]);
	for (int i = 0; i < w; i++)
		for (int j = 0; j < h; j++)
		{
			bool ok = 1;
			for (int k = 1; k <= n; k++)
			{
				if (a[k] == 1 && i < x[k])
				{
					ok = 0;
					break;
				}
				if (a[k] == 2 && i >= x[k])
				{
					ok = 0;
					break;
				}
				if (a[k] == 3 && j < y[k])
				{
					ok = 0;
					break;
				}
				if (a[k] == 4 && j >= y[k])
				{
					ok = 0;
					break;
				}
			}
			if (ok) ans++;
		}
	//if (ans != 0)
		printf("%d\n", ans);
	return 0;
}

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

int main()
{
long long H,W;
cin>>H>>W;

if (H==1 || W==1){
    cout << 1 <<endl;
    return 0;
}
if(H*W % 2 ==0){
    cout << H*W/2 <<endl;
}else{
    cout << (H*W+1)/2 <<endl;
}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int FiveCount = 0;
    int SevenCount = 0;
    if(a == 5)
        FiveCount += 1;
    else if(a == 7)
        SevenCount += 1;
    if(b == 5)
        FiveCount += 1;
    else if(b == 7)
        SevenCount += 1;
    if(c == 5)
        FiveCount += 1;
    else if(c == 7)
        SevenCount += 1;
    if(FiveCount == 2 && SevenCount == 1)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007;
const int MAX = 100005;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b;
    cin>>a>>b;
    int mn=min(a,b);
    int x = 16-2*mn;
    int y = a+b-mn-mn;
    if(y*2<=x) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           node(a,b,c)                 mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=500005;
int n,m;
vector<int>adj[M];
int vis[M],dis[M];
 main()

{
    fast
    cin>>n>>m;
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v+n);
        adj[u+n].pb(v+2*n);
        adj[u+2*n].pb(v);
    }
    int st,en;
    cin>>st>>en;
    queue<int>q;
    q.push(st);
    vis[st]=1;
    dis[st]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(auto v:adj[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            dis[v]=dis[u]+1;
            q.push(v);
        }
    }
    if(vis[en]==0)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<dis[en]/3<<endl;
    }
    return 0;

}





































Measured memory_bytes: 29416
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    string S,T;
    int K,X;
    cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>


using namespace std;

int main()
{
    //method 1
    // string text;
    
    // getline(cin, text);

    // for (int i = 0; i < text.size(); i++)
    // {
    //     if (text[i] >= 'a' && text[i] <= 'z')
    //         text[i] -= 'a' - 'A';
    //     else if (text[i] >= 'A' && text[i] <= 'Z')
    //         text[i] += 'a' - 'A';
    // }

    // cout << text << endl;


    //method 2
    // char ch;
    // while ((ch = cin.get()) != EOF)
    // {
    //     if (ch>='a' && ch<='z')
    //         cout << (char)(ch - ('a' - 'A'));
    //     else if (ch>='A' && ch<='Z')
    //         cout << (char)(ch + ('a' - 'A'));
    //     else 
    //         cout << ch;
    // }



    //method 3
    char ch;
    while (cin.get(ch))
    {
        if (ch>='a' && ch<='z')
            printf("%c", ch - ('a' - 'A'));
        else if (ch>='A' && ch<='Z')
            printf("%c", ch + ('a' - 'A'));
        else 
            cout << ch;
    }

    
}


Measured memory_bytes: 3072
import java.util.*;class Main{public static void main(String[]z){Scanner s =new Scanner(System.in);for(int n,i,j,k;(n=s.nextInt())!=0;System.out.println(i))for(i=0,j=2,k=1;n>=(k+=j);)if((n-k)%j++==0)i++;}}

Measured memory_bytes: 18124
n = int(input())
a = list(map(int,input().split()))

i_plus_Ai = [0]*n
j_minus_Aj = [0]*n
for i in range(n):
    if 0 <= i+a[i] < n:
        i_plus_Ai[i+a[i]] += 1
    if 0 <= i-a[i] < n:
        j_minus_Aj[i-a[i]] += 1

cnt = 0
for i, j in zip(i_plus_Ai, j_minus_Aj):
    cnt += i*j
print(cnt)

Measured memory_bytes: 32232
a,b = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ls = (make_divisors(a))
ls2 = (make_divisors(b))
ls3 = (set(ls)&set(ls2))


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

ans = 0
if 1 in ls3:
    ans += 1
for i in ls3:
    if is_prime(i) == True:
        ans += 1
        
print(ans)
        

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

struct lazyRMQ {
    const ll INF = 1ll<<60;
    int n;
    vector<ll> data, lazy;

    lazyRMQ() {}
    lazyRMQ(int n_) { init(n_); }
    lazyRMQ(int n_, vector<ll> &vec) { init(n_); set(vec); build(); }
    void init(int n_) {
        n = 1; while (n < n_) n <<= 1;
        data.assign(n<<1,INF);
        lazy.assign(n<<1,INF);
    }
    void set(vector<ll> &vec) {
        for (int i = 0; i < (int)vec.size(); i++) data[i+n] = vec[i];
    }
    void build() {
        for (int i = n-1; i > 0; i--) data[i] = min(data[i<<1],data[(i<<1)|1]);
    }

    void eval(int k) {
        if (lazy[k] = INF) return;
        data[k] = min(data[k],lazy[k]);
        if (k < n) {
            lazy[(k<<1)|0] = min(lazy[(k<<1)|0],lazy[k]);
            lazy[(k<<1)|1] = min(lazy[(k<<1)|1],lazy[k]);
        }
        lazy[k] = INF;
    }
    void update(int a, int b, ll x, int k = 1, int l = 0, int r = 0) {
        if (r == 0) r = n;
        eval(k);
        if (r <= a || b <= l) return;
        else if (a <= l && r <= b) { lazy[k] = x; eval(k); }
        else {
            update(a, b, x, (k<<1)|0, l, (l+r)/2);
            update(a, b, x, (k<<1)|1, (l+r)/2, r);
            data[k] = min(data[k<<1],data[(k<<1)|1]);
        }
    }
    ll query(int a, int b, int k = 1, int l = 0, int r = 0){
        if (r == 0) r = n;
        if (r <= a || b <= l) return INF;
        eval(k);
        if (a <= l && r <= b) return data[k];
        else {
            ll vl = query(a, b, (k<<1)|0, l, (l+r)/2);
            ll vr = query(a, b, (k<<1)|1, (l+r)/2, r);
            return min(vl,vr);
        }
    }
};

int main(){
    ll n, x; cin >> n >> x;
    vector<ll> a(n<<1);
    rep(i,n) { cin >> a[i]; a[i+n] = a[i]; }

    lazyRMQ data(n<<1,a);
    ll ans = 1ll<<60;
    rep(i,n) {
        ll ch = i * x;
        rep(j,n) ch += data.query(n+j-i,n+j+1);
        if (ch < ans) ans = ch;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>

#define MAX_N 100000

int two, four, other;

int n;
std::string s;
std::string res;

int main() {
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        long a;
        std::cin >> a;
        if (a%4 == 0) {
            ++four;
        } else if (a%2 == 0) {
            ++two;
        } else {
            ++other;
        }
    }

    if (four >= two + other) {
        res = "Yes";
    } else {
        if (four >= other) {
            res = "Yes";
        } else if (two + other-1 == four) {
            res = "Yes";
        } else {
            res = "No";
        }
    }
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a + 1):
    if x - (500 * i) >= 0:
        x_0 = x - (500 * i)
        for j in range(b + 1):
            if x_0 - (100 * j) >= 0:
                x_1 = x_0 - (100 * j)
                for k in range(c + 1):
                    if x_1 - (50 * k) == 0:
                        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

struct Elem {
    int num;
    char pict;
    int id;
} a[100000];

int partition(Elem *a, int p, int r) {
    int x = a[r].num;
    int i = p;
    for (int j = p; j < r; ++j) {
        if (a[j].num <= x)
            swap(a[i++], a[j]);
    }
    swap(a[i], a[r]);
    return i;
}

void quickSort(Elem *a, int p, int r) {
    if (p < r) {
        int q = partition(a, p, r);
        quickSort(a, p, q - 1);
        quickSort(a, q + 1, r);
    }
}

bool isStable(Elem *a, int n) {
    for (int i = 0; i < n - 1; ++i) {
        if (a[i].num == a[i + 1].num) {
            if (a[i].id > a[i + 1].id)
                return false;
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].pict >> a[i].num;
        a[i].id = i;
    }
    quickSort(a, 0, n - 1);
    if (isStable(a, n))
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
    
    for (int i = 0; i < n; ++i) {
        cout << a[i].pict << " " << a[i].num << endl;
    }

    return 0;
}


Measured memory_bytes: 4220
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize(3)
const int N = 222;
int f[2][N][N][N];
int n, m;
char mp[N][N];
int main(){
//	freopen("land.in", "r", stdin);
//	freopen("land.out", "w", stdout);
	cin>>n>>m;
	memset(f, -1, sizeof(f));
	for(int i = 1;i <= n; i++){
		scanf("%s", mp[i] + 1);
	}
	for(int i = m;i >= 1; i--){
		for(int l = 1;l <= n; l++){
			for(int r = l;r <= n; r++){
				if(mp[l][i] != mp[r][i])break;
				f[0][l][r][i] = i;
				if(mp[l][i+1] == mp[l][i])f[0][l][r][i] = max(f[0][l][r][i+1], i);
			}
		}
	}
	int fl = 0;
	for(int ans = 0;ans <= 20; ans++){
		if(f[fl][1][n][1] == m){
			printf("%d\n", ans);
			return 0;
		}
		for(int i = 1;i <= m; i++){
			for(int l = 1;l <= n; l++){
				for(int r = n;r >= l; r--){
					if(!f[fl][l][r][i])continue;
					if(f[fl][l][r][i] == m){
						f[fl^1][l][r][i] = m;
						continue;
					}
					int F = f[fl][l][r][i];
					F = max(F, f[fl][l][r][F+1]);
					int L = l, R = r - 1;
					while(L <= R){
						int mid = (L + R) >> 1;
						F = max(F, min(f[fl][l][mid][i], f[fl][mid+1][r][i]));
						if(f[fl][l][mid][i] > f[fl][mid+1][r][i])L = mid + 1;
						else R = mid - 1;
					}
					f[fl^1][l][r][i] = F;
				}
			}
		}
		fl ^= 1;
	}
	return 0;
}

Measured memory_bytes: 85760
def main():
    x = int(input())
    is_answered = False
    for a in range(-200, 201):
        if is_answered:
            break
        for b in range(-200, 201):
            if pow(a, 5) - pow(b, 5) == x:
                print(a, b)
                is_answered = True
                break


if __name__ == '__main__':
    main()



Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
vector<int> lj[510];
int main(){
int i,n,m,q,l,r;
scanf("%d%d%d",&n,&m,&q);
for (;m--;){
  scanf("%d%d",&l,&r);
  lj[l].push_back(r);
  }
for (i=1;i<=500;++i) sort(lj[i].begin(),lj[i].end());
for (;q--;){
  scanf("%d%d",&l,&r),m=0;
  for (i=l;i<=r;++i) m+=upper_bound(lj[i].begin(),lj[i].end(),r)-lj[i].begin();
  printf("%d\n",m);
  }
}

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

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

  string S; cin >> S;
  int ans = 700;
  for (int i = 0; i < 3; i++) if (S[i] == 'o') ans += 100;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }

typedef long long LL;

const int N = 1e3+5, M = 1e4+5;

int h, n, a[N], b[N];
int dp[M];

inline void update(int &a, int b)
{
    if (b == -1) return;
    if (a > b || a == -1) a = b;
}

int main(int argc, char const *argv[])
{
    cin >> h >> n;
    for (int i=1; i<=n; ++i) cin >> a[i] >> b[i];
    memset(dp, -1, sizeof dp);
    dp[h] = 0;
    for (int i=0; i<n; ++i)
    for (int j=h; j>=0; --j)
    {
        if (!~dp[j]) continue;
        update(dp[max(j-a[i+1], 0)], dp[j] + b[i+1]);
    }
    // dbg(dp[1][1]);
    printf("%d\n", dp[0]);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <climits>

const int MAXN=200005;
int a[MAXN];

class FHQ_Treap{
	private:
		int rt;
		struct node{int val,key,sz,ls,rs;}d[MAXN<<2];
		struct dual_rt{
			int lrt,rrt;
			dual_rt(){lrt=rrt=0;}
		};
		void upd(int u){
			d[u].sz=d[d[u].ls].sz+d[d[u].rs].sz+1;
		}
		int new_nd(int val){
			static int cnt=0;
			d[++cnt]=(node){val,rand(),1};
			return cnt;
		}
		dual_rt split(int u,int val){
			dual_rt ret;
			if(!u) return ret;
			if(val<d[u].val){
				ret=split(d[u].ls,val);
				d[u].ls=ret.rrt;
				ret.rrt=u;
			}
			else{
				ret=split(d[u].rs,val);
				d[u].rs=ret.lrt;
				ret.lrt=u;
			}
			upd(u);
			return ret;
		}
		int merge(int u,int v){
			if(!u || !v) return u|v;
			if(d[u].key<d[v].key){
				d[u].rs=merge(d[u].rs,v);
				upd(u);
				return u;
			}
			else{
				d[v].ls=merge(u,d[v].ls);
				upd(v);
				return v;
			}
		}
		int kth_val(int u,int k){
			while(true){
				if(k>d[d[u].ls].sz+1){
					k-=d[d[u].ls].sz+1;
					u=d[u].rs;
				}
				else if(k<=d[d[u].ls].sz)
					u=d[u].ls;
				else return d[u].val;
			}
		}
	public:
		void ist(int val){
			dual_rt x=split(rt,val);
			rt=merge(merge(x.lrt,new_nd(val)),x.rrt);
		}
		void del(int val){
			dual_rt x=split(rt,val);
			dual_rt y=split(x.lrt,val-1);
			y.rrt=merge(d[y.rrt].ls,d[y.rrt].rs);
			rt=merge(merge(y.lrt,y.rrt),x.rrt);
		}
		int kth_val(int k){return kth_val(rt,k);}
}T;

int main(){
	srand((size_t)new(char));
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		T.ist(a[i]);
	}
	for(int i=1;i<=n;++i){
		T.del(a[i]);
		printf("%d\n",T.kth_val(n>>1));
		T.ist(a[i]);
	}
	return 0;
}

Measured memory_bytes: 12416
#include <stdio.h>
int main(){
	int a, b, count=0;
	scanf("%d %d", &a, &b);
	char c[a+b+2];
	scanf("%s", c);
	for(int i=0; i<a+b+1; i++){
		if(i!=a){
			if(c[i]>=48 && c[i]<=57){
                count++;
            } 
		}else {
			if (c[i]=='-'){
				count++;
			}
		}
	}
	count==a+b+1? printf("Yes\n"): printf("No\n");
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=3e3+10,P=1e9+7;
int n,m;
int F[N][N][2];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,m);
  for(int i=1;i<=n;++i) F[0][i][0]=1;
  F[0][0][1]=1;
  for(int i=0;i<m;++i) {
    for(int j=0;j<=n;++j) {
      for(int k=0;k<2;++k) if(F[i][j][k]) {
        if(j) (F[i+1][j][k|(j==1)]+=F[i][j][k])%=P,(F[i+1][j-1][k|(j==1)]+=F[i][j][k])%=P;
        if(n-j) (F[i+1][j][k]+=F[i][j][k])%=P,(F[i+1][j+1][k]+=F[i][j][k])%=P;
      }
    }
  }
  int res=0;
  for(int i=0;i<=n;++i) (res+=F[m][i][1])%=P;
  printf("%d\n",res);
  return 0;
}


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

int main(){
  string A,B;

  cin >> A >> B;
  string _C = A + B;
  int C = stoi(_C);

  for(int i=0 ;i<1000;i++){
  if(C == i*i){
    cout << "Yes" << endl;
    return 0;
  
  }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include<math.h>
#include <stdlib.h>
#include <queue>
#include <string.h>
using namespace std;
#define Minf -1e9
#define scan(n) scanf("%lld",&n)
typedef long long ll;
const int maxn = 2*1e5+10;
const ll INF = 1e9+100;
const int mod = 998244353;

int  a[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	ll ans = 0;
	for (int i = 2; i <= n; i++) {
		if (a[i] < a[i - 1]) {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	printf("%lld", ans);
}

Measured memory_bytes: 4532
#include <iostream>
#include <vector>

using namespace std;

int cnt = 0;
vector<int> seq;
int m;
int g[100];

void insertsort(int g) {
  for (int i = g; i < seq.size(); ++i) {
    int j = i - g;
    int v = seq[i];
    for (;0 <= j; j = j - g) {
      if (seq[j] <= v)
        break;
      seq[j+g] = seq[j];
      ++cnt;
    }
    seq[j+g] = v;
  }
}

void shellsort() {

  for (int i = 0; i < 100; ++i) {
    if (i == 0) {
      m = 1;
      g[i] = 1;
    }
    else {
      ++m;
      g[i] = 3 * g[i-1] + 1;
    }

    if (seq.size() < g[i]) {
      --m;
      break;
    }
  }

  for (int i = m-1; 0 <= i; --i)
    insertsort(g[i]);
}

int main() {
  int v;
  cin >> v;
  while (cin >> v)
    seq.push_back(v);

  shellsort();

  cout << m << endl;
  cout << g[m-1];
  for (int i = m-2; 0 <= i; --i)
    cout << " " << g[i];
  cout << endl << cnt << endl;
  for (auto &v : seq)
    cout << v << endl;
}


Measured memory_bytes: 6964
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

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

int main() {
    int n;
    cin >> n;
    vector<ll> x(n);
    for (auto &v : x) cin >> v;
    auto sortedX = x;
    sort(sortedX.begin(), sortedX.end());
    
    auto mL = sortedX[n / 2 - 1], mR = sortedX[n / 2];
    for (auto xi : x) {
        cout << ((xi <= mL) ? mR : mL) << endl;
    }
}





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

int main() {
        int H,W;

        while(1) {
                cin >> H >> W;
                if (H==0 && W==0) break;

                for (int j = 0; j < W;   j++)
                        cout << "#";
                cout << endl;
                for (int i = 1; i < H-1; i++) {
                        cout << "#";
                        for (int j = 1; j < W-1; j++)
                                cout << ".";
                        cout << "#" << endl;
                }
                for (int j = 0; j < W;   j++)
                        cout << "#";
                cout << endl << endl;
        }

        return 0;
}

Measured memory_bytes: 2936
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        short x = scanner.nextShort();
        short y = scanner.nextShort();
        short z = scanner.nextShort();
        System.out.println(z + " " + x + " " + y);

    }
    
}

Measured memory_bytes: 39348
#include<stdio.h>
int main(){
  char a[4];
  scanf("%s",a);
  if(a[0]=='M'){
    printf("6\n");
  }else if(a[0]=='W'){
    printf("4\n");
  }else if(a[0]=='F'){
    printf("2\n");
  }else if(a[2]=='N'){
    printf("7\n");
  }else if(a[1]=='A'){
    printf("1\n");
  }else if(a[1]=='H'){
    printf("3\n");
  }else if(a[1]=='U'){
    printf("5\n");
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    a, b = map(int, input().split())

    if a < 6:
        print(0)
    elif a < 13:
        print(b // 2)
    else:
        print(b)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29036
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
double hoge(double x1,double y1,double x2,double y2){
  return sqrt((max(x1,x2)-min(x1,x2))*(max(x1,x2)-min(x1,x2))+(max(y1,y2)-min(y1,y2))*(max(y1,y2)-min(y1,y2)));
}
int main(void){
  int n;
  double x1,y1,x2,y2,x3,y3,xp,yp,a,b,c,r,a1,b1,c1,a2,b2,c2;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    a=hoge(x1,y1,x2,y2);
    b=hoge(x2,y2,x3,y3);
    c=hoge(x1,y1,x3,y3);
    r=(a*b*c)/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
    a1=2*(x2-x1);
    b1=2*(y2-y1);
    c1=x1*x1-x2*x2+y1*y1-y2*y2;
    a2=2*(x3-x1);
    b2=2*(y3-y1);
    c2=x1*x1-x3*x3+y1*y1-y3*y3;
    xp=(b1*c2-b2*c1)/(a1*b2-a2*b1);
    yp=(c1*a2-c2*a1)/(a1*b2-a2*b1);
    printf("%.3f %.3f %.3f\n",xp,yp,r);
  }
}


Measured memory_bytes: 1244
n,a,b=map(int,input().split())
m=10**9+7

#(a*x)をmで割った余りが1になるようなxを求める
#aで割ったときの余りはa^(-1)をかけた余りと同じ
#逆元a^(-1)を求める
#aとmが互いに素であることが条件

def gyakugen( a, m ):
  b = m
  x, y = 1, 0
  while b>0:
    q = a // b
    a, b = b, a-q*b
    x, y = y, x-q*y
  return x if x>0 else x+m

#nPrをmで割った余りを求める(ただしn<m、mは素数)
import sys
sys.setrecursionlimit(10**9)#再帰の回数の上限を設定

def perm_remainder(n,r,m):
    if r>=1:
        return (perm_remainder(n-1,r-1,m)*n)%m
    else:
        return 1

#nCrをmで割った余りを求める(ただしn<m,mは素数)

def comb_remainder(n,r,m):
    r=min(r,n-r)
    return (perm_remainder(n,r,m)*gyakugen(perm_remainder(r,r,m),m))%m

#(a**n)を素数mで割った余りを求める
#当然aはmで割り切れない整数

def power_remainder(a,x,m):
    a=a%m
    bi=str(format(x,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %m
        if bi[i]=="1":
            res=(res*a) %m
    return res

#2^n-nCa-nCb-1を計算
print((power_remainder(2,n,m)-1-comb_remainder(n,a,m)-comb_remainder(n,b,m))%m)

Measured memory_bytes: 181236
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	memset(b,0,sizeof(b));
	int len=n-1,s=0,f=1;
	for(int k=n-1;k>=0;k--){
		b[s]=a[k];
		if(f==1){
			s+=len;
			f=0;
			len--;
		}
		else{
			s-=len;
			f=1;
			len--;
		}
	}
	printf("%d",b[0]);
	for(int i=1;i<n;i++){
		printf(" %d",b[i]);
	}printf("\n");
	return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		char S[] =  new char[100];
		S=sc.nextLine().toCharArray();
		int x=0;
		int xmax=0;
		for(int i=0 ; i<N;i++){
			if(S[i]=='I'){x++;}
			else if(S[i]=='D'){x--;}
			if(x>xmax)xmax=x;
		}
		System.out.println(xmax);
	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define ll long long
#define mx 200005
#define mod 1000000007
#define mxm 999999999999
using namespace std;

ll dp[mx][3];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    
    ll n,a[mx][3],i,j;
    cin>>n;
    for(i=1;i<n+1;i++)
    for(j=0;j<3;j++)
    cin>>a[i][j];
    
    for(j=0;j<3;j++)
    dp[1][j]=a[1][j];
    
    for(i=2;i<n+1;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][2],dp[i-1][1]);
        dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][0]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    i=n;
    ll ans=max(dp[i][0],max(dp[i][1],dp[i][2]));
    cout<<ans;
	return 0;
}

Measured memory_bytes: 8576
#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int N;
  cin >> N;

  vector<int> value;
  for(int i=0; i<N; i++)
  {
    int x;
    cin >> x;

    value.push_back(x);
  }

  vector<int> cost;
  for(int i=0; i<N; i++)
  {
    int x;
    cin >> x;

    cost.push_back(x);
  }

  int benefit = 0;
  for(int i=0; i<N; i++)
  {
    int x = value[i] - cost[i];

    if(x>0) benefit += x;
  }

  cout << benefit;

  return 0;
}


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

int main() {
 string S; cin >> S;
 int sum = 0;
 for(int i = 0; i<4; i++){
   if(S.at(i)=='+') sum++;
   else sum--;
 }
  
 cout << sum << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,s;
	cin>>n>>k;
	s=1;
	for (int i=0;n>i;i++){
		if (s<=k){
			s=s*2;
		}
		else {
			s=s+k;
		}
	}
	cout <<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define M 1000000007
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define what_is(x)  cout << #x << " is " << x << endl;
#define U 1000000007
#define N 100005
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
 

  int n;
  cin>>n;
  int ans=0;
  cout<<n*n*n;

}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

void solve() {
	int h, w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }
    rep(i, h) {
        rep(j, w) {
            int tmp = 0;
            rep(k, 8) {
                int nx = i + dx[k], ny = j + dy[k];
                if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '#') {
                    ++ tmp;
                }
            }
            if(s[i][j] == '.') {
                cout << tmp;
            } else {
                cout << s[i][j];
            }
        }
        cout << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
# E - Yutori


def find_workdays(
    total_days: int, workdays_length: int, days_off_length: int, schedule: list
) -> list:
    if days_off_length == 0:
        workdays = [i for i, can_work in enumerate(schedule, 1) if can_work]
        return workdays if len(workdays) <= workdays_length else []

    workdays_left, workdays_right = set(), set()

    for cur_workdays, gen in [
        (workdays_left, enumerate(schedule, 1)),
        (workdays_right, ((total_days - i, x) for i, x in enumerate(schedule[::-1]))),
    ]:
        cur_days_off = 0
        for i, can_work in gen:
            if cur_days_off:
                cur_days_off -= 1
                continue
            if can_work:
                cur_workdays.add(i)
                cur_days_off = days_off_length
                if len(cur_workdays) == workdays_length:
                    break

    return sorted(workdays_left & workdays_right)


def main():
    N, K, C = map(int, input().split())
    S = input().rstrip()
    workdays = find_workdays(N, K, C, [s == "o" for s in S])
    print("\n".join(map(str, workdays)))


if __name__ == "__main__":
    main()


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int H, W; cin>>H>>W;
    int Ch, Cw; cin>>Ch>>Cw;
    int Dh, Dw; cin>>Dh>>Dw;
    vector<string> S(H);
    rep(i,H){
        cin>>S.at(i);
    }

    priority_queue<T, vector<T>, greater<T>> pq;
    pq.push(make_tuple(0,Ch-1,Cw-1));

    vector<vector<int>> DP(H, vector<int>(W,INT_MAX));

    while(pq.size()>0){
        T temp = pq.top();pq.pop();
        int cost, h, w;
        tie(cost,h,w) = temp;
//        cout<<cost<<" "<<h<<" "<<w<<" "<<pq.size()<<endl;
        if(h==Dh-1 && w==Dw-1){
            cout<<cost<<endl;
            return 0;
        }
        if(DP.at(h).at(w)<INT_MAX)continue;
        DP.at(h).at(w) = cost;

        // 次に移動する候補をpqに入れる
        //一コマ移動する場合
        for(int i=-1;i<2;i++){
            for(int j=-1;j<2;j++){
//                if(i!=0 || j!=0)continue;
//                if(i==0 && j==0)continue;
                if(abs(i)+abs(j)!=1)continue;
                int next_h = h+i;
                int next_w = w+j;
                if(next_h<0||next_h>=H || next_w<0 ||next_w>=W )continue;
                if(S.at(next_h).at(next_w)=='#')continue;
                if(DP.at(next_h).at(next_w)<INT_MAX)continue;
                pq.push(make_tuple(cost, next_h, next_w));
            }
        }
        // ワープするとき
        for(int i=-2;i<3;i++){
            for(int j=-2;j<3;j++){
                if(abs(i)+abs(j)<2)continue;
                int next_h = h+i;
                int next_w = w+j;
                if(next_h<0||next_h>=H || next_w<0 ||next_w>=W )continue;
                if(S.at(next_h).at(next_w)=='#')continue;
                if(DP.at(next_h).at(next_w)<INT_MAX)continue;
                pq.push(make_tuple(cost+1, next_h, next_w));
            }
        }
    }
    cout<<"-1"<<endl;


    return 0;
}

Measured memory_bytes: 14756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	V<bool> a(n);
	rep(i, n) {
		int k;
		cin >> k;
		if (k)a[i] = true;
	}

	V<bool> ball(n);
	int m = 0;

	rep(i, n) {

		int k = n - i;
		int kk = 2 * k;

		int cnt = 0;

		while (kk <= n) {
			if (ball[kk - 1])cnt++;
			kk += k;
		}

		cnt %= 2;
		if (cnt == a[n - 1 - i])continue;
		ball[n - 1 - i]=true;
		m++;

	}

	cout << m << endl;
	rep(i, n)if (ball[i])cout << i + 1 << " ";
	cout << endl;

}

Measured memory_bytes: 1152
import java.util.*;

class Main{
  public static void main(String args[]){
    
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    
    List<Integer> xList = new ArrayList<Integer>();
    
    while (scan.hasNextInt()) {
    	xList.add(Integer.valueOf(scan.nextInt()));
    }
    
    int sum = 0;
    int sumCalcA = 0;
    int sumCalcB = 0;
    
    for (Integer i : xList) {
    	sumCalcA = calcA(i);
    	sumCalcB = calcB(i, k);
    	if (sumCalcA > sumCalcB) {
    		sum += sumCalcB;
    	} else {
    		sum += sumCalcA;
    	}	
    }
	System.out.println(String.valueOf(sum));
	return;
  }
  
  private static int calcA(Integer i){
  	return 2 * i;
  }

  private static int calcB(Integer i, Integer k){
  	return 2 *( k - i);
  }
  
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n, m;
	cin >> n >> m;
	Vec k(m);
	Vec2<ll> s(m);
	rep(i, m) {
		cin >> k[i];
		s[i].resize(k[i]);
		rep(j, k[i]) cin >> s[i][j];
	}
	Vec p(m);
	rep(i, m) cin >> p[i];

	ll ans = 0;
	rep(bit, pow2(n)) {
		bool flg = true;
		rep(i, m) {
			ll cnt = 0;
			rep(j, k[i]) {
				if (bit >> (s[i][j] - 1) & 1) cnt++;
			}
			// co({i, cnt});
			flg &= (cnt & 1) == p[i];
		}
		if (flg) ans++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3596
package main

import (
	"fmt"
	"sort"
)

func main()  {
	var n,m int
	fmt.Scan(&n, &m)
	var a [100001]int
	var b, c [100001]int
	arr_val := make([]int, n+m, n+m)
	d := map[int]int{}

	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
		arr_val[i] = a[i]
		d[a[i]]++
	}
	for i:=0;i<m;i++ {
		fmt.Scan(&b[i], &c[i])
		d[c[i]] += b[i]
		arr_val[i+n] = c[i]
	}
	sort.Ints(arr_val)

	//fmt.Println(arr_val)

	sum := 0
	for i:=len(arr_val); i>0; i-- {
		for d[arr_val[i-1]] > 0 && n > 0 {
			//fmt.Println(arr_val[i-1], d[arr_val[i-1]], n)
			d[arr_val[i-1]]--
			n--
			sum += arr_val[i-1]
		}
	}

	fmt.Println(sum)
}

Measured memory_bytes: 19584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, k;
	cin >> a >> b >> k;

	if (a >= k) {
		cout << a - k << ' ' << b << endl;
		return 0;
	}
	else {
		if (a + b >= k) {
			cout << 0 << ' ' << b - k + a << endl;
		}
		else {
			cout << 0 << ' ' << 0 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String S = in.readLine();
		for (int i = 0; i < S.length(); ++i) {
			System.out.print("x");
		}
		System.out.println("");
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 24532
//omajinai
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//omajinai

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n),b(n);
    for(ll i = 0;i < n;i ++){
        cin >> a.at(i) >> b.at(i);
    }

    vector<pair<ll,ll>> ab(n);
    for(ll i = 0;i < n;i ++){
        ab.at(i).first = a.at(i);
        ab.at(i).second = b.at(i);
    }

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

    ll count = 0;
    ll ans;

    for(ll i = 0;i < n;i ++){
        count += ab.at(i).second;
        ans = ab.at(i).first;
        if(count >= k){
            break;
        }
    }

    cout << ans << endl;
    
}

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

using namespace std;

bool StringToInt(string s, int &data)
{
	data=0;
	int sign=1;
	for(int i=0;i<s.length();i++){
		if(i==0 && s[i]=='-'){
            sign=-1;
            continue;
        }
		if('0'<=s[i] && s[i]<='9'){
			data*=10;
			data+=sign*(s[i]-'0');
		}
		else return false;
	}
	return true;
}

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

    int ans=1e9;
    for(int i=0;i<s.length()-2;i++){
        int x;
        StringToInt(s.substr(i,3),x);
        ans=min(ans,abs(x-753));
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int t[100][100];
int main() {
	int N, M, a, b;
	cin >> N >> M;
	vector<int> H(N);
	rep(i, 0, N)cin >> H[i];
	vector<vector<int>> G(N);
	rep(i, 0, M) {
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int C = 0;
	rep(i, 0, N) {
		bool flag = true;
		for (auto v : G[i]) {
			if (H[v] >= H[i]) {
				flag = false;
				break;
			}
		}
		if (flag)C++;
	}
	printf("%d\n", C);
	return 0;
}

Measured memory_bytes: 8752
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        if (r < 1200) {
            System.out.println("ABC");
        } else if (r < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }

    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
 
using namespace std;
 
typedef long long ll;

string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, k;
  cin >> n >> k;
  string s; 
  cin >> s;
  if (k > 15) {
    char mn = 'z';
    for (char c : s) mn = min(mn, c);
    for (int i = 0; i < n; ++i) cout << mn;
    cout << '\n';
    return 0;
  }
  for (int i = 0; i < k; ++i) {
    string u = s + rev(s);
    if (i == k - 1) {
      s = string(n, 'z');
      for (int i = 0; i <= n; ++i) {
        s = min(s, u.substr(i, n));
      }
    } else {
      s = string(n, 'z');
      for (int i = 0; i <= n; ++i) {
        s = min(s, rev(u.substr(i, n)));
      }
      s = rev(s);
    }
  }
  cout << s << '\n';
}
 


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

int main() {
	char kata1[15];
	char kata2[16];
	scanf("%s",kata1);
	scanf("%s",kata2);
	int str = strlen(kata1);
	int a = 0,count = 0;
	for(a = 0; a<str; a++){
		if(kata1[a] == kata2[a]){
			count++;	
		}
	}
	if(count == str){
		printf("Yes\n");
	}else{
		printf("No");
	}		
	return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int ans = 0;
  
  for(int j=0; j<K; j++){
    ans = ans + vec.at(N - j - 1);
  }
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long;
#define REP(i,a,b) for(i = (a); i < (b); i++)
#define rep(i,n) REP(i,0,n)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main()
{
	int n;
	int p[100001];
	cin >> n;
	REP(i, 1, n + 1){
		cin >> p[i];
	}
	int ans = 0;
	REP(i,1, n){
		if (p[i] == i){
			p[i] = p[i + 1];
			p[i + 1] = i;
			ans++;
		}
	}
	if (p[n] == n)ans++;
	cout << ans << endl;
	return 0;
}

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

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

    int res = 0;
    for (int i = 0; i < (s.size()/2); i++) {
        if (s.at(i) != s.at(s.size()-i-1)) res++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3536
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

    if (a + b == 15)
        cout << "+" << endl;
    else if (a * b == 15)
        cout << "*" << endl;
    else
        cout << "x" << endl;

    return 0;
}


Measured memory_bytes: 256