akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

bool U[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    ll a = 0, b = 0;
    REP(i, N) {
        if (S[i] == 'a' && a + b < A + B) {
            U[i] = true;
            a++;
        }
        else if (S[i] == 'b' && a + b < A + B && b < B) {
            U[i] = true;
            b++;
        }
    }

    REP(i, N) {
        if (U[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

const int INF = 1e9;

int main() {
	int n;
	cin >> n;
	int dig = n % 10;
	if (dig == 3)
		cout << "bon" << endl;
	else if (dig == 1 || dig == 6 || dig == 0 || dig == 8)
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
	return 0;
}

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

using namespace std;

const int maxn = 4040;

int b[maxn][maxn], w[maxn][maxn], d;

int fw(int i, int j) {
  return w[i + d][j + d] - w[i + d][j] - w[i][j + d] + w[i][j];
};


int fb(int i, int j) {
  return b[i + d][j + d] - b[i + d][j] - b[i][j + d] + b[i][j];
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);

  int n, k; cin >> n >> k;

  int t = k + k; d = k;
  vector<vector<int>> req(t, vector<int>(t, -1));

  for(int i = 0; i < n; ++i) {
    int x, y; cin >> x >> y;
    char c; cin >> c;
    c = (c == 'B');

    x %= t;
    y %= t;
    if(c) ++b[x + 1][y + 1];
    else ++w[x + 1][y + 1];
  }

  for(int i = 1; i <= t; ++i) {
    for(int j = 1; j <= t; ++j) {
      w[i + t][j] = w[i][j];
      w[i][j + t] = w[i][j];
      w[i + t][j + t] = w[i][j];
      b[i + t][j] = b[i][j];
      b[i][j + t] = b[i][j];
      b[i + t][j + t] = b[i][j];
    }
  }


  for(int i = 1; i <= t + t; ++i) {
    for(int j = 1; j <= t + t; ++j) {
      w[i][j] += w[i - 1][j] + w[i][j - 1] - w[i - 1][j - 1];
      b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
    }
  }

  int ans = 0;
  for(int i = 0; i < t; ++i) {
    for(int j = 0; j < t; ++j) {
      int cw = fw(i, j) + fw(i + d, j + d);
      int cb = fb(i + d, j) + fb(i, j + d);
      ans = max(ans, cw + cb);
    }
  }

  cout << ans << endl;

  return 0;
}


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

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[];
		try {
			str = br.readLine().split(" ");
			int n = Integer.parseInt(str[0]);
			int m = Integer.parseInt(str[1]);
			int l = Integer.parseInt(str[2]);
			int a[][] = new int[n][m];
			int b[][] = new int[m][l];
			long c[][] = new long[n][l];
			for(int i=0;i<n;i++){
				str = br.readLine().split(" ");
				for(int j=0;j<m;j++){
					a[i][j]=Integer.parseInt(str[j]);
				}
			}
			for(int i=0;i<m;i++){
				str = br.readLine().split(" ");
				for(int j=0;j<l;j++){
					b[i][j]=Integer.parseInt(str[j]);
				}
			}

			for(int i=0;i<n;i++){
				for(int j=0;j<l;j++){
					for(int k=0;k<m;k++){
						c[i][j]+=a[i][k]*b[k][j];
					}
				}
			}
			for(int i=0;i<n;i++){
				for(int j=0;j<l;j++){
					if(j != 0){
						System.out.print(" ");
					}
					System.out.print(c[i][j]);
				}
				System.out.println();
			}
		} catch (Exception e) {
			System.err.println(e);
		}
	}
}

Measured memory_bytes: 32120
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N,M; cin >> N >> M;
    vector<int> like(M,0);
    for(int i=0;i<N;i++){
        int K;cin >> K;
        for(int k=0;k<K;k++){
            int a; cin >> a; a--;
            like[a] += 1;
        }
    }

    int ans = 0;
    for(int i=0;i<M;i++) {
        if(like[i] == N) ans++;
    }
    cout << ans << endl;
}


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

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            
            int num = 0;
            int i;
            string prev = "";

            for( i = 0; i < str.Length; i++) 
            {
                if (prev == str.Substring(i,1))
                {
                    if ( i < str.Length - 1)
                    {
                        prev = str.Substring(i,2);
                        i++;
                        num++;
                    }
                    else
                    {
                        prev = "*";
                    }
                }
                else
                {
                    prev = str.Substring(i,1);
                    num++;
                }
                //Console.Write(prev+" ");
            }

            Console.WriteLine(num);

            return;

        }
    }
}


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

using namespace std;

const int MX = 2005;

int n;
int fst[MX], nxt[MX*2], v[MX*2], lnum;
char str[MX];

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	v[lnum] = nv;
}

void input()
{
	scanf("%d", &n);
	scanf("%s", str+1);
	for(int i=1; i<n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		addeg(a, b);
		addeg(b, a);
	}
}

int sdp[MX], sum[MX];
int mn[MX], mx[MX];

void dfs(int x, int f)
{
	sdp[x] = 0;
	if(str[x] == '1') sum[x] = 1;
	else sum[x] = 0;
	mn[x] = mx[x] = 0;
	for(int i=fst[x]; i; i=nxt[i])
		if(v[i] != f)
		{
			int y = v[i];
			dfs(y, x);
			mn[y] += sum[y];
			mx[y] += sum[y];
			if(mx[x] < mn[y]) mn[x] = mn[y]-mx[x];
			else if(mx[y] < mn[x]) mn[x] = mn[x]-mx[y];
			else mn[x] = 0;
			mx[x] = mx[x] + mx[y];
			sum[x] += sum[y];
			sdp[x] += sdp[y]+sum[y];
		}
}

void work()
{
	int ans = MX*MX;
	for(int i=1; i<=n; i++)
	{
		dfs(i, 0);
		if(sdp[i]&1) continue;
		if(mn[i] == 0) ans = min(ans, sdp[i]/2);
	}
	if(ans == MX*MX) printf("-1");
	else printf("%d\n", ans);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
   int n,time,i,minc=1001,tle=0;
   scanf("%d%d",&n,&time);
   int c[n],t[n];

   for(i=0;i<n;i++)
      scanf("%d%d",&c[i],&t[i]);

   for(i=0;i<n;i++){
      if(t[i]<=time){
         if(minc>c[i]) minc=c[i];
      } else {tle++;}
   }

   if(tle==n) printf("TLE\n");
   else printf("%d\n",minc);
   return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>

int main() {
    int A, B;
    int i = 0, j = 0, k = 0;

    scanf("%d %d", &A, &B);

    if(A % 3 != 0) i = 1;
    if(B % 3 != 0) j = 1;
    if((A+B) % 3 != 0) k = 1;

    if(i == 1 && j == 1 && k == 1) {
        printf("Impossible\n");
    } else {
        printf("Possible");
    }

    return 0;
}

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

int main(int argc, char const *argv[])
{
	long long n,m;
	cin>>n>>m;
	long long ans=1;
	for (long long i = 1; i*i <= m; ++i)
	{
		if (m%i==0&&m>=n*i)
		{
			ans=max(ans,i);
		}
		if (m%i==0&&m%(m/i)==0&&m>=n*(m/i))
		{
			ans=max(ans,m/i);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int debt = 100000;

int main() {
    int n;
    cin >> n;
    while (n--) {
        debt = debt * 105 / 100;
        if (debt % 1000) {
            debt = debt - (debt % 1000) + 1000;
        }
    }
    cout << debt << endl;
}


Measured memory_bytes: 3072
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    residents = [[[0] * 10 for _ in range(3)] for _ in range(4)]
    n = int(input())
    for _ in range(n):
        b, f, r, v = map(int, input().split())
        residents[b-1][f-1][r-1] += v

    for i in range(4):
        for j in range(3):
            t = ''
            for k in range(10):
                t += '{:2d}'.format(residents[i][j][k])
            print(t)
        if i != 3:
            print('#' * 20)



if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int A,B,C;
    cin>>A>>B>>C;

    bool ans;
    ans=(A<C &&B>C)||(A>C && B<C);

    if(ans){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    
    return 0;
}

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

typedef struct D
{
	char S[20];
	int w;
}D;
D A[1005];
int i,j,N,t;
char M[100];

int cmp(const void *a,const void *b)
{
	D *x=((D*) a),*y=((D*) b);
	return strlen(x->S)<strlen(y->S);
}

int CN(char a){return '0'<=a&&a<='9';}

int dfs(int sp,int ep)
{
	int i,j,p=0,r[1000]={0},a=0;
	for(i=sp;i<=ep;i++)
	{
		if(M[i]=='(')//search ()
		{
			int j,c=1;
			for(j=i+1;;j++)
			{
				if(M[j]=='(')c++;
				if(M[j]==')')c--;
				if(!c)break;
			}
			r[p++]=dfs(i+1,j-1);
			if(r[p-1]<0)break;
			i=j;
		}
		else if(CN(M[i]))
		{
			int m=M[i]-'0';
			if(CN(M[i+1]))
			{
				i++;
				m=m*10+(M[i]-'0');
			}
			r[p-1]*=m;
		}
		else
		{
			for(j=0;j<N;j++)
			{
				if(strstr(M+i,A[j].S)==M+i)break;
			}
			if(j==N)return -10000000;
			i+=strlen(A[j].S)-1;
			r[p++]=A[j].w;
		}
	}
	for(i=0;i<p;i++)a+=r[i];
	return a;
}

int main()
{
	for(N=0;scanf("%s",A[N].S)&&strcmp(A[N].S,"END_OF_FIRST_PART");N++)
		scanf("%d\n",&A[N].w);
	qsort(A,N,sizeof(D),cmp);
	for(gets(M);gets(M),M[0]!='0';)
	{
		t=dfs(0,strlen(M)-1);
		if(t<0)puts("UNKNOWN");
		else printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 680
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

bool hyo[101][101] = {};

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	int x, y, a;
	REP(i, n){
		cin >> x >> y >> a;
		if(a == 1){
			REP(i, h){
				REP(j, x){
					hyo[j][i] = true;
				}
			}
		}else if(a == 2){
			REP(i, h){
				FOR(j, x, w){
					hyo[j][i] = true;
				}
			}
		}else if(a == 3){
			REP(i, y){
				REP(j, w){
					hyo[j][i] = true;
				}
			}
		}else if(a == 4){
			FOR(i, y, h){
				REP(j, w){
					hyo[j][i] = true;
				}
			}
		}
	}
	int ans = 0;
	REP(i, h){
		REP(j, w){
			if(hyo[j][i] == false) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin>>x>>y;
    if(x%y==0){
        cout << -1<<endl;
    }else{
        cout << x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;
static const double PI = 3.141592653589793;
vector<long long> vecmodfact(2,1);

long long modpow(long long x, long long n, long long mod = 0) {
  if (mod == 0) {
      long long res=1;
    while (n > 0) {
      if (n%2 == 1) {
        res = ( res*x );
      }
      x = (x*x);
      n /= 2;
    }
    return res;
  }

  long long res=1;
  while (n > 0) {
    if (n%2 == 1) {
      res = ( res*x ) % mod;
    }
    x = (x*x) % mod;
    n /= 2;
  }
  return res;
}

long long modinverse(long long x, long long mod) {
  // mod must be prime number.
  return modpow(x, mod-2, mod);
}

long long modfact(long long n, long long mod) {
  if (vecmodfact.size()-1 >= n) return vecmodfact.at(n);
  int i=vecmodfact.size();
  vecmodfact.resize(n+1);
  for (; i<=vecmodfact.size()-1; i++) {
    vecmodfact.at(i) = vecmodfact.at(i-1)*i % mod;
  }
  return vecmodfact.at(n);
}

long long modcomb(long long m, long long n, long long mod){
  if (m < n || n < 0) return 0;
  if (n == 0 || n == m) return 1;
  long long ans = modfact(m,mod) * modinverse(modfact(n,mod), mod) % mod;
  ans = ans * modinverse(modfact(m-n,mod), mod) % mod;
  return ans;
}



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

  if (n==1) {
    cout << 0 << endl;
    return 0;
  }
  long long m=n;

  long long ans=0;

  map<long long, long long> ma;
  for (long long i=2; i*i<=n; i++) {
    while (true) {
      if (m%i==0) {
        ++ma[i];
        m /= i;
      }
      else break;
    }
  }
  if (m!=1) ma[m]=1;

//  for (auto iter=ma.begin(); iter != ma.end(); iter++) {
//    cout << iter->first << " " << iter->second << endl;
//  }
  m = n;
  for (auto iter=ma.begin(); iter != ma.end(); iter++) {
    long long p=iter->first;
    long long d=p;
    long long e=iter->second;
    for (int i=1; i<=e; i++) {
      if (m%d==0) {
        ans++;
        m /= d;
        d *= p;
      }
      else break;
    }
  }

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

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    if (a == b) {
        cout << 1 << endl;
        quick_exit(0);
    }

    int j = 0;
    for (int i = 63; i >= 0; i--) {
        if ((a ^ b) & 1LL << i) {
            j = i;
            break;
        }
        a &= ~(1LL << i);
        b &= ~(1LL << i);
    }
    int64_t p = 1LL << j;
    int64_t r = 0;
    int k = -1;
    for (int i = j - 1; i >= 0; i--) {
        if (b & 1LL << i) {
            k = i;
            break;
        }
    }
    b = p + (1LL << (k + 1)) - 1;
    if (a > b - p) {
        r += p - a;
        r += b - p + 1;
        r += p - a;
    } else {
        r += p - a;
        r += p;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
  int N, D;
  cin >> N >> D;
  if(N%(2*D+1)==0) cout << N/(2*D+1) << endl;
  else cout << (N/(2*D+1))+1 << endl;
}


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

int main(){
  int q;
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    int c,a,n,team=0;
    scanf("%d %d %d",&c,&a,&n);

    while(1){
      if(n>0&&a>0&&c>0){
	n--;
	a--;
	c--;
	team++;
      }else if(a>0&&c>1){
	a--;
	c-=2;
	team++;
      }else if(c>2){
	c-=3;
	team++;
      }else break;
    }
    printf("%d\n",team);
  }

  return 0;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10,mod=998244353,B=1e18;
int n,ans,tmp=B%mod;
struct Graph{
	int m,cnt;
	int head[N],to[N],nxt[N],vis[N],sg[N],sum[N];
	void add(int u,int v){
		to[++cnt]=v,nxt[cnt]=head[u],head[u]=cnt;
	}
	void init(){
		scanf("%lld",&m);
		for(int i=1;i<=m;i++){ int u,v; scanf("%lld%lld",&u,&v),add(min(u,v),max(u,v)); }
		for(int i=n;i>=1;i--){
			for(int j=head[i];j;j=nxt[j]) vis[sg[to[j]]]=1;
			while(vis[sg[i]]) sg[i]++;
			for(int j=head[i];j;j=nxt[j]) vis[sg[to[j]]]=0; 
		}
		for(int i=1,mul=1;i<=n;i++) mul=mul*tmp%mod,sum[sg[i]]=(sum[sg[i]]+mul)%mod;
	}
}G[3];
signed main(){
	scanf("%lld",&n); 
	for(int i=0;i<3;i++) G[i].init();
	for(int i=0;i<512;i++) for(int j=0;j<512;j++) ans=(ans+G[0].sum[i]*G[1].sum[j]%mod*G[2].sum[i^j]%mod)%mod;
	printf("%lld",ans);
}

Measured memory_bytes: 13120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		int		cnt = parseCnt();
		int[][]	map = new int[9][9];
		int[]	chk = new int[9*9*3];

		for (int l = 0; l < cnt; l++) {
			parseMap(map, chk);

			if (l > 0) {
				System.out.println();
			}

			for (int i = 0; i < map.length; i++) {
				String	out = "";
				for (int j = 0; j < map[i].length; j++) {
					int	b   = (i / 3) * 3 + j / 3;
					int	num = map[i][j];

					if (chk[i*9+num-1] > 1 || chk[81+j*9+num-1] > 1 || chk[162+b*9+num-1] > 1) {
						out += "*"+num;
					} else {
						out += " "+num;
					}
				}
				System.out.println(out);
			}
		}
	}

	private static void parseMap(int[][] map, int[] chk) {
		String	stdin = null;

		Arrays.fill(chk, 0);
		for (int i = 0; i < map.length; i++) {
			stdin = parseStdin().replaceAll(" ", "");
			for (int j = 0; j < map[i].length; j++) {
				int	b   = (i / 3) * 3 + j / 3;
				int	num = stdin.charAt(j)-'0';
				map[i][j] = num;
				chk[i*9+num-1]++;
				chk[81+j*9+num-1]++;
				chk[162+b*9+num-1]++;
			}
		}
	}

	private static int parseCnt() {
		int		cnt = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 19604
#include<stdio.h>
int main(){ 
  int n,i,j,k;
  int b,f,r,v;
  int kita[10][3]={0};
  int mina[10][3]={0};
  int nisi[10][3]={0};
  int higa[10][3]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    if(b==1){
      kita[r-1][f-1]=kita[r-1][f-1]+v;
    }
    if(b==2){
      mina[r-1][f-1]=mina[r-1][f-1]+v;
    }
    if(b==3){
      nisi[r-1][f-1]=nisi[r-1][f-1]+v;
    }
    if(b==4){
      higa[r-1][f-1]=higa[r-1][f-1]+v;
    }
  }
  for(i=0;i<4;i++){ 
    for(k=0;k<3;k++){
      for(j=0;j<10;j++){
	if(i==0){
	  printf(" %d",kita[j][k]);
	}
	if(i==1){
	  printf(" %d",mina[j][k]);
	}
	if(i==2){
	  printf(" %d",nisi[j][k]);
	}
	if(i==3){
	  printf(" %d",higa[j][k]);
	}
      }
      printf("\n");
    }
    if(i==3) break;
    printf("####################\n");
  }
  return(0);
}

Measured memory_bytes: 1044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    string t = "CODEFESTIVAL2016";
    Cin(string, s);
    int ans = 0;
    For(i, 16) if(s[i] != t[i]) ans ++;
    Cout(ans);
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{

  int N, K;
  cin >> N >> K;

  int x[N];
  rep(i, N)
  {
    cin >> x[i];
  }
  int left = 0;
  int right = 0;
  int leftCnt = 0;
  int rightCnt = 0;
  int cost = 0;
  int ans = 1000000007;
  repd(i, 0, N - K + 1)
  {
    if (x[i] >= 0){
      cost = abs(x[K + i - 1]);
    }
    else if (x[K + i - 1] >= 0)
    {
      if (abs(x[i]) > abs(x[K + i - 1]))
      {
        cost = abs(x[K + i - 1]) * 2 + abs(x[i]);
      }
      else
      {
        cost = abs(x[K + i - 1]) + abs(x[i]) * 2;
      }
    }
    else if (x[K + i - 1] < 0)
    {
      cost = abs(x[i]);
    }

    if (cost < ans)
    {
      ans = cost;
    }
  }
  cout << ans;
}

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

int main() {
    long long N;
    cin >> N;
    vector <long long> A(N);
    long long b=0;
    long long b2=0;
    for (long long i=0; i<N; i++) {
        cin >> A.at(i);
        if (A.at(i)>=b) {
            b2 = b;
            b = A.at(i);
        }
        else {
            b2 = max(b2,A.at(i));
        }
    }
    for (long long i=0; i<N; i++) {
        if (A.at(i)==b) cout << b2 << endl;
        else cout << b << endl;
    }
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i, M) cin >> B[i];
  int ans = 0;
  rep(i, N) {
    int sum = 0;
    int a;
    rep(j, M) {
      cin >> a;
      sum += a * B[j];
    }
    if (sum + C > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(){
    int a, b, angle;
    double s, l, h;

    scanf("%d %d %d", &a, &b, &angle);
   
    h=b*sin(angle*M_PI/180.0);
    s=a*h/2;
    l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0)));
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);

    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()

int main(){
	int n;
	cin>>n;
	vi t(n+1,0), v(n+1,0);
	range(i,1,n+1){cin>>t[i]; t[i]*=2;}
	range(i,1,n+1){cin>>v[i]; v[i]*=2;}
	partial_sum(all(t),t.begin());
	vi m(t[n]+1,INF);
	rep(i,t[n]+1) m[i]=min(m[i],i);
	rep(i,t[n]+1) m[i]=min(m[i],t[n]-i);
	range(i,1,n+1){
		range(j,0,t[i-1]) m[j]=min(m[j],v[i]+t[i-1]-j);
		range(j,t[i-1],t[i]+1) m[j]=min(m[j],v[i]);
		range(j,t[i],t[n]+1) m[j]=min(m[j],v[i]+j-t[i]);
	}
	cout.precision(12);
	cout<<fixed<<accumulate(all(m),0)/4.0<<endl;
	return 0;
}


Measured memory_bytes: 384
import heapq

n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)

for i in range(m):
  top=heapq.heappop(a)
  heapq.heappush(a,(-1)*(-top//2))
  
print(-sum(a))

Measured memory_bytes: 20344
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 998244353;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T>
class BIT {
    vector<T> bit;
public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

    T sum(int k){
        T ret = 0;
        for (++k; k > 0; k -= (k & -k)) ret += bit[k];
        return ret;
    }

    void add(int k, T x){
        for (++k; k < bit.size(); k  += (k & -k)) bit[k] += x;
    }
};

template <ll M = MOD> struct modint {
public:
    ll val;
    explicit modint(const ll x = 0) : val(x) {}
    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint operator/(const modint a) const { return modint(*this) /= a; }
    modint operator-() const { return modint(M-val); }
    modint inv(){
        ll u = 1, v = 0, s = 0, t = 1, m = M, x = val;
        while (x) {ll q = m/x; swap(s -= q*u, u); swap(t -= q*v, v); swap(m -= q*x, x); }
        if(s < 0) s += M;
        return modint(s);
    }
    modint pow(ll n){
        ll u = 1, xx = val;
        while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; }
        return u;
    }
    modint &operator+=(const modint a){ val += a.val; if(val >= M) val -= M; return *this; }
    modint &operator-=(const modint a){ val -= a.val; if(val < 0) val += M; return *this; }
    modint &operator*=(const modint a){ val = val * a.val % M; return *this; }
    modint &operator/=(const modint a){ val = (val*a.inv()) %M; return *this;}
};

using mint = modint<MOD>;

int main() {
    int n;
    cin >> n;
    vector<mint> pow2(n+1, mint(1));
    for (int i = 0; i < n; ++i) {
        pow2[i+1] = pow2[i]*mint(2);
    }
    vector<pair<int, int>> v(n);
    for (auto &&i : v) scanf("%d %d", &i.first, &i.second);
    vector<int> z(n);
    for (int i = 0; i < n; ++i) {
        z[i] = v[i].second;
    }
    sort(z.begin(),z.end());
    for (int i = 0; i < n; ++i) {
        v[i].second = lower_bound(z.begin(),z.end(), v[i].second) - z.begin();
    }
    sort(v.begin(),v.end());
    vector<ll> A(n), B(n), C(n), D(n);
    BIT<ll> b(n);
    for (int i = 0; i < n; ++i) {
        A[i] = b.sum(v[i].second);
        B[i] = i - A[i];
        b.add(v[i].second+1, 1);
    }
    b = BIT<ll>(n);
    for (int i = n - 1; i >= 0; --i) {
        C[i] = b.sum(v[i].second);
        D[i] = n-i-1- C[i];
        b.add(v[i].second+1, 1);
    }
    mint ans = pow2[n]*mint(n)-mint(n), ans2(0);
    for (int i = 0; i < n; ++i) {
        ans2 += pow2[A[i]]+pow2[B[i]]+pow2[C[i]]+pow2[D[i]]+mint(-4)+(pow2[A[i]]+pow2[D[i]]+mint(-2))*(pow2[B[i]]+pow2[C[i]]+mint(-2));
    }
    cout << (ans-ans2).val << "\n";
    return 0;
}

Measured memory_bytes: 13568
n=int(input())
A=[[0]*2 for i in range(n)]
for i in range(n):
  A[i][0],A[i][1]=input().split()
  A[i][1]=int(A[i][1])
x=input()
for i in range(n):
  if A[i][0]==x:
    break
ans=0
for j in range(i+1,n):
  ans=ans+A[j][1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

struct Sieve {

  int n;
  //f:f[i]がiを最初に割った素数を表す配列 例）f[36] = 2;
  //primes:n以下の素数を集めた配列
  vector<int> f,primes;
  Sieve(int n = 1):n(n),f(n+1) {
    f[0] = f[1] = -1;
    for(int i = 2;i <= n;i++) {
      if(f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for(int j = i*2;j <= n;j += i) if(!f[j]) f[j] = i;
    }
  }
  //xが素数か判定する関数
  bool ifPrime(int x) {
    return f[x] == x;
  }
};

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  for(int i = 0;i < N;i++) cin >> A[i];

  int g = A[0];
  for(int i = 0;i < N;i++) g = gcd(g,A[i]);

  if(g != 1) cout << "not coprime" << endl;
  else {

    Sieve S(1e6);
    vector<bool> judge(1e6+10,false);
    for(int i = 0;i < N;i++) {
      int a = A[i];
      while(a != 1) {
        if(judge[a]) {
          cout << "setwise coprime" << endl;
          return 0;
        }

        judge[a] = true;
        a = a / S.f[a];
      }

    }

    cout << "pairwise coprime" << endl;

  }


}


Measured memory_bytes: 11732
#tenka1PC
#C:Align
import sys
input=sys.stdin.readline
from collections import deque
N=int(input())
A=[int(input()) for i in range(N)]
A.sort()
if N%2==0:
    ans=2*(-1*sum(A[0:N//2])+sum(A[N//2:N]))
    ans+=A[N//2-1]-A[N//2]
elif N%2==1:
    ans=2*(-1*sum(A[0:N//2])+sum(A[1+N//2:N]))
    a1,a2,a3=A[N//2-1],A[N//2],A[N//2+1]
    if 2*a2-a1-a3>=0:
        ans+=a2-a3
    else:
        ans+=a1-a2
print(ans)
#notsub

Measured memory_bytes: 7784
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* Aho Corasick */

struct ACNode{
  int val;
  ACNode *next[26], *failure;
  
  ACNode():val(0) { memset(next,0,sizeof(next)); }
  
  void insert(char *s){
    if(!*s){ val++; return; }
    int al = *s-'a';
    if(next[al]==NULL) next[al] = new ACNode;
    next[al]->insert(s+1);
  }

  ACNode *nextNode(char c){
    int al = c - 'a';
    if (next[al]) return next[al];
    return failure == this ? this : failure->nextNode(c);
  }
};

struct AhoCorasick{
  ACNode *node;

  AhoCorasick(){node = new ACNode;}
  
  void insert(char *s) {
    node->insert(s);
  }
  
  void build() {
    queue<ACNode*> que;
    que.push(node);
    node->failure = node;
    
    while(que.size()){
      ACNode *p = que.front();
      que.pop();
      
      for(int i=0;i<26;i++){
        if(p->next[i]){
          ACNode *failure = p->failure;
          while(!failure->next[i] && failure != node){
            failure = failure->failure;
          }
          if (failure->next[i] && failure != p){
            p->next[i]->failure = failure->next[i];
            p->next[i]->val += failure->next[i]->val;
          }else{
            p->next[i]->failure = node;
          }
          que.push(p->next[i]);
        }
      }
    }
  }
};



int main(){
  int n;
  char S[SIZE], p[SIZE];
  
  AhoCorasick ac;

  scanf("%s%d", S, &n);
  
  for(int i=0;i<n;i++){
    scanf("%s", p);
    ac.insert(p);
  }

  ac.build();

  int ans = 0;

  ACNode *cur = ac.node;
  for(int i=0;S[i];i++){
    cur = cur->nextNode(S[i]);
    if(cur->val){
      ans++;
      cur = ac.node;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}



Measured memory_bytes: 22908
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

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

int main(){
	for(int i=0;i<3;i++){
		scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
	}
	int ans=0;
	int tri=0;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			ans+=a[i][j];
			if(i==j)	tri+=a[i][j];
		}
	}
	if(ans==3*tri){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

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

class Program {
    static void Main() {
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        s += s;
        for(int i = 0; i + t.Length <= s.Length; i++) {
            if(s.Substring(i, t.Length) == t) {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}


Measured memory_bytes: 17820
#include <iostream>
#include <string>
#define SIZE 8
#define UNABLE -100
using namespace std;

string table[SIZE];

int p[8] = {1, 0, -1, 0, 1, 1, -1, -1}, q[8] = {0, 1, 0, -1, 1, -1, 1, -1};
string s = "ox";

void dfs_revise(int x, int y, int k, string c) {
  if (x < 0) return;
  if (x >= SIZE) return;
  if (y < 0) return;
  if (y >= SIZE) return;
  if (table[y][x] == '.') return;
  if (table[y][x] == c[0]) return;
  
  table[y].replace(x, 1, c);
  
  dfs_revise(x + p[k], y + q[k], k, c);
}

int dfs(int x, int y, int k, string c) {
  if (x < 0) return UNABLE;
  if (x >= SIZE) return UNABLE;
  if (y < 0) return UNABLE;
  if (y >= SIZE) return UNABLE;
  if (table[y][x] == '.') return UNABLE;
  
  if (c[0] == table[y][x]) return 0;
  return dfs(x + p[k], y + q[k], k, c) + 1;
}

void game() {
  int flag = 0;
  int max, maxx, maxy;
  int pass = 0;
  string c;
  for ( ; ; ) {
    max = 0;
    c.erase();
    if (flag == 0) c.push_back(s[0]);
    else c.push_back(s[1]);
    for (int i = 0; i < SIZE; i++) {
      for (int j = 0; j < SIZE; j++) {
	if (table[i][j] != '.') continue;
	int temp = 0;
	for (int k = 0; k < 8; k++) {
	  int x = j + p[k];
	  int y = i + q[k];
	  if (x < 0 || y < 0 || x >= SIZE || y >= SIZE) continue;
	  if (table[y][x] == '.') continue;
	  int s = dfs(x, y, k, c);
	  if (s >= 0) temp += s;
	}
	
	if (temp == 0) continue;
	if (flag == 0 && temp > max) {
	  max = temp;
	  maxx = j;
	  maxy = i;
	} else if (flag == 1 && temp >= max) {
	  max = temp;
	  maxx = j;
	  maxy = i;
	}
      }
    }
    if (max == 0) {
      pass++;
    } else {
      //cout << max << ' ' << maxx << ' ' << maxy << endl;
      pass = 0;
      table[maxy].replace(maxx, 1, c);
      for (int k = 0; k < 8; k++) {
	if (dfs(maxx + p[k], maxy + q[k], k, c) > 0) {
	  dfs_revise(maxx + p[k], maxy + q[k], k, c);
	}
      }
    }
    if (pass == 2) break;
    if (flag == 0) flag = 1;
    else flag = 0;
  }
}

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

  game();

  for (int i = 0; i < SIZE; i++) {
    cout << table[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>

using vector = std::vector<int>;
using iterator = vector::iterator;

auto print_vector = [](iterator begin, iterator end){
                      while (begin != end)
                        {
                          std::cout << *begin;
                          if (begin+1 == end) std::cout << std::endl;
                          else std::cout << " ";
                          begin++;
                        }
                    };

auto find_correct_pos = [](int key, vector vec_sorted){
                          for (int i=0; i<vec_sorted.size(); ++i)
                            {
                              if (vec_sorted[i] == key)
                                return i;
                            }
                          return -1;
                        };

int minimumCost(std::vector<int> vec)
{
  std::vector<std::vector<int> > cycles;
  std::vector<int> vec_sorted = vec;
  std::sort(vec_sorted.begin(), vec_sorted.end());

  const int NIL = -1;
  const int n = vec.size();

  
  for (int i=0; i<n; ++i)
    {
      if (vec[i] != vec_sorted[i])
        {
          int pos = i;
          std::vector<int> tmp;
          while (vec[pos] != NIL)
            {
              tmp.push_back(vec[pos]);
              vec[pos] = NIL;
              pos = find_correct_pos(*(tmp.end()-1), vec_sorted);
              //std::cout << "next=" << pos << std::endl;
            }
          if (tmp.size() != 0) cycles.push_back(tmp);
        }
      // print_vector(vec.begin(), vec.end());
    }

  // std::cout << "size = " << cycles.size() << std::endl;

  int cost = 0;
  int min_in_vec = vec_sorted[0];

  for (int i=0; i<cycles.size(); ++i)
    {
      // print_vector(cycles[i].begin(), cycles[i].end());

      auto cycle = cycles[i];
      int min = 10000;
      for (int j=0; j<cycle.size(); ++j)
        {
          cost += cycle[j];
          if (cycle[j] < min) min = cycle[j];
        }
      if (( min_in_vec*(cycle.size()-1) + (min_in_vec+min)*2 ) < ( min*(cycle.size()-1) ))
        {
          cost -= min;
          cost += min_in_vec*(cycle.size()-1) + (min_in_vec+min)*2;
        }
      else
        cost += min*(cycle.size()-2);
    }


  return cost;

}

int main ()
{
  int n;
  std::cin >> n;

  std::vector<int> vec;
  for (int i=0; i<n; ++i)
    {
      int tmp;
      std::cin >> tmp;
      vec.push_back(tmp);
    }

    std::cout << minimumCost(vec) << std::endl;
}



Measured memory_bytes: 3204
from collections import deque
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])

A=deque(A)
for b,c in BC[::-1]:
    for i in range(b):
        if A[0]<c:
            A.append(c)
            A.popleft()
        else:break
print(sum(A))

Measured memory_bytes: 34004
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(x, y, a, b, c) = in.readLine().split("\\s+").map(_.toInt)
    val ps = in.readLine().split("\\s+").map(_.toLong).sorted(Ordering[Long].reverse)
    val qs = in.readLine().split("\\s+").map(_.toLong).sorted(Ordering[Long].reverse)
    val rs = in.readLine().split("\\s+").map(_.toLong).sorted(Ordering[Long].reverse)

//    out.println((ps.take(x) ++ qs.take(y) ++ rs).sorted(Ordering[Long].reverse).take(x + y).sum)

    var result = 0L
    for (i <- 0 until x) {
      result += ps(i)
    }
    for (i <- 0 until y) {
      result += qs(i)
    }

    var pi = x - 1
    var qi = y - 1
    var ri = 0
    var break = false

    while (!break) {
      if ((pi < 0 || ps(pi) > rs(ri)) && (qi < 0 || qs(qi) > rs(ri))) {
        break = true
      } else if (pi >= 0 && (qi < 0 || ps(pi) < qs(qi))) {
        result = result - ps(pi) + rs(ri)
        pi -= 1
        ri += 1
      } else if (qi >= 0 && (pi < 0 || ps(pi) >= qs(qi))) {
        result = result - qs(qi) + rs(ri)
        qi -= 1
        ri += 1
      } else {
        break = true
      }
      if (ri == rs.length) {
        break = true
      }
    }

    out.println(result)
    out.flush()
  }
}


Measured memory_bytes: 88208
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define ll long long

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    int a, b;
    cin >> a >> b;
    int    d, r;
    double f;

    d = a / b;
    r = a % b;
    f = (double)a / b;
    cout << d << " " << r << " ";
    printf("%.5f\n", f);
    return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<bitset>
#include<vector>

template<size_t N>
void increment(std::bitset<N>& in){
    for(size_t i = 0; i < N; ++i){
        if(in[i] == 0){
            in[i] = 1;
            break;
        }
        in[i] = 0;
    }
}

int main(){
    size_t n, m;
    std::cin >> n >> m;

    std::vector<std::vector<size_t>> s(m);

    for(size_t i = 0; i < m; i++){
        size_t k;
        std::cin >> k;
        for(size_t j = 0; j < k; j++){
            size_t tmp;
            std::cin >> tmp;
            s.at(i).emplace_back(tmp);
        }
    }

    std::vector<size_t> p(m);

    for(auto&& e : p){
        std::cin >> e;
    }

    std::bitset<10> sw;
    size_t ans = 0;

    for(size_t i = 0; i < 1 << n; i++){
        size_t cnt = 0;
        for(size_t j = 0; j < m; j++){
            size_t cnt2 = 0;
            for(size_t k = 0; k < s[j].size(); k++){
                if(sw[s[j][k] - 1] == 1) cnt2++;
            }
            if(cnt2 % 2 == p[j]) cnt++;
        }

        if(cnt == m) ans++;
        increment(sw);
    }

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


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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  if(B-A+1>=2*K) {
    for(int i=0; i<K; i++) {
      cout << A+i << endl;
    }
    for(int i=K-1; i>=0; i--) {
      cout << B-i << endl;
    }
  }
  else {
    for(int i=A; i<=B; i++) {
      cout << i << endl;
    }
}
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc104/tasks/abc104
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

    int Y;
    cin >> Y;

    int ans = 0;

    for (int i = 0; i <= N; i++)
    {
        /* code */
        for (int j = 0; j <= N; j++)
        {
            /* code */
            ans = 10000*i + 5000*j + 1000*(N - i - j);
            if(ans == Y && (N-i-j) >= 0){
                cout << i << " " << j << " " << (N-i-j) << " "  << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    rep(i, n) cin >> x[i] >> y[i] >> h[i];
    const int inf = 1001001001;
    auto dist = [](int a, int b, int c, int d) { return abs(a - b) + abs(c - d);};
    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            bool flag = false;
            bool ok = true;
            int H = inf;
            rep(i, n) {
                if (h[i] != 0) {
                    if (flag) {
                        if (max(H - dist(cx, x[i], cy, y[i]), 0) != h[i]) {
                            ok = false;
                            break;
                        }
                    } else {
                        if (h[i] + dist(cx, x[i], cy, y[i]) > H) {
                            ok = false;
                            break;
                        }
                        flag = true;
                        H = h[i] + dist(cx, x[i], cy, y[i]);
                    }
                } else {
                    if (flag) {
                        if (max(H - dist(cx, x[i], cy, y[i]), 0) != h[i]) {
                            ok = false;
                            break;
                        }
                    } else {
                        chmin(H, dist(cx, x[i], cy, y[i]));
                    }
                }
            }
            if (ok) {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3640
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll X;
  cin >> X;
  ll ans500 = 0;
  ll ans5 = 0;
  while (X >= 500)
  {
    X -= 500;
    ans500++;
  }

  while (X >= 5)
  {
    X -= 5;
    ans5++;
  }

  cout << ans500 * 1000 + ans5 * 5 << endl;

  return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  ll count=0;REPS(i,N){
    if(int(log10(i))%2==0)count++;
  }
  cout<<count;
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL K; cin >> K;
	LL N = 50;
	VL a(N, 49);
	FOR(i, 0, N) {
		a[i] += K / N;
	}
	FOR(i, 0, N) {
		if (i < K%N)a[i]++;
		else a[i] -= K % N;
	}

	DD(De(a));

	if(0){
		LL cnt = 0;
		while (1) {
			int id = max_element(ALL(a)) - a.begin();
			if (a[id] < 50)break;
			FOR(i, 0, N) {
				if (i == id)a[id] -= 50;
				else a[i]++;
			}
			cnt++;

		}
		DD(de(cnt));
	}
	cout << N << endl;
	FOR(i, 0, N) {
		cout << a[i] << " \n"[i == N - 1];
	}

	return 0;
}


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

int main() {
	int A, B, C;
	int X, Y, Z;
	cin >> X >> Y >> Z;

	//箱Aと箱Bを入れ替える
	A = Y;
	B = X;

	//箱Aと箱Cを入れ替える
	A = Z;
	C = Y;

	cout << A << " " << B << " " << C << endl;

}

Measured memory_bytes: 256