akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する


signed main(void){
    int n, k; cin >> n >> k;
    int cnt = 0, ans;
    for(int i = 1; i <= n; i++){
        if(i % k == 0) cnt++;
    }
    ans = pow(cnt, 3);
    if(k % 2 == 0){// k偶数
        cnt = 0;
        for(int i = 1; i <= n; i++){
            if(i % k == (k / 2)) cnt++;
        }
        ans += pow(cnt, 3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define INF 9223372036854;
#define ll long long
const long long m = 1000000007;


int main()
{
    ll n,k;
    cin>>n>>k;
    ll dp[2][k+1];
    memset(dp,0,sizeof(dp));
    ll arr[n] = {0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll i,j,x,l,c;
    for(i=0;i<2;i++)
    {
        dp[i][0] = 1;
    }
    for(i=0;i<=k;i++)
    {
        dp[0][i] = 1;
    }
    for(c=1;c<=n;c++)
    {
        for(j=1;j<=k;j++)
        {
            x = min(arr[c-1],j);
            i = c%2;
            if(x==j)
            {
                if(i==0)
                dp[i][j] = dp[i+1][j];
                else
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                if(i==0)
                dp[i][j] = (dp[i+1][j] - dp[i+1][j-x-1] + m)%m;
                else
                dp[i][j] = (dp[i-1][j] - dp[i-1][j-x-1] + m)%m;
            }
            dp[i][j] = (dp[i][j]%m+dp[i][j-1]%m)%m;
        }
    }
    if(k==0) cout << dp[n%2][k];
    else cout << (dp[n%2][k]-dp[n%2][k-1] + m)%m;

}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[110000];
int main(){
	scanf("%s",in);
	for(int i=0;in[i];i+=2)printf("%c",in[i]);printf("\n");
}

Measured memory_bytes: 256
//ProblemE

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

//ProblemE
void Solve() {
	int n;
	cin >> n;
	int N = 1 << n;
	vector<int> a(N, 0);
	for (int i = 0; i < N; i++) cin >> a[i];

	vector<vector<int>> max2(N, { 0, 0 });
	max2[0] = { 0, 0 };
	for (int i = 1; i < N; i++) {
		max2[i] = a[0] < a[i] ? vector<int>{ i, 0 } : vector<int>{ 0, i };
		int j = i;
		while (j) {
			int mask = j & -j;
			for (auto x : max2[i & ~mask]) {
				if (max2[i][0] == x || max2[i][1] == x) continue;
				if (a[x] >= a[max2[i][0]]) {
					max2[i] = { x, max2[i][0] };
				}
				else if (a[x] >= a[max2[i][1]]) {
					max2[i][1] = x;
				}
			}
			j &= ~mask;
		}
	}

	int ans = 0;
	for (int i = 1; i < N; i++) {
		int t = a[max2[i][0]] + a[max2[i][1]];
		ans = max(ans, t);
		cout << ans << endl;
	}
}


Measured memory_bytes: 19328
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, T = map(int, input().split())

ans = min(map(lambda t: t[0], filter(lambda t: t[1] <= T, [list(map(int, input().split())) for _ in range(N)] + [[1 << 28, 0]])))

print(ans if ans != 1 << 28 else "TLE")

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
//#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define ps(ch) printf("%s",ch)
#define Afridi 0
#define NL printf("\n")
#define debug(x) printf("wow  %d !!\n",x)
#define Max 300005
#define INF 100000000
#define mod 1000000007
#define un(x) x.erase( unique( x.begin() , x.end() ) , x.end() )
#define pii pair<int,int>
#define _mp make_pair

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << (x) << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;


LL bigmod(LL b,LL p,LL m)
{
    if(p == 0)return 1;
    LL my = bigmod(b,p/2,m);
    my*=my;my%=m;
    if(p & 1)my*=b,my%=m;
    return my;
}
int setb(int n,int pos){return n=n | (1 << pos);}
int resb(int n,int pos){return n=n & ~(1 << pos);}
bool checkb(int n,int pos){return (bool)(n & (1 << pos));}

int n,m;
char str[2005][2005];
int ara[2005][2005];
int a[2005],lft[2005],rgt[2005],col[2005][2005];
#define MAXN 2005

int histogram()
{
	a[0] = a[m] = -1;
	stack < int > st;
	st.push(0);
	for(int i = 1; i <= m - 1; i++)
	{
		while( st.empty() == 0 )
		{
			int id = st.top();
			st.pop();
			if( a[id] < a[i] )
			{
				st.push(id);
				break;
			}
		}
		lft[i] = i - st.top();
		st.push(i);
	}
	while( st.empty() == 0 ) st.pop();
	st.push(m);
	for(int i = m - 1; i >= 1; i--)
	{
		while( st.empty() == 0 )
		{
			int id = st.top();
			st.pop();
			if( a[id] < a[i] )
			{
				st.push(id);
				break;
			}
		}
		rgt[i] = st.top() - i;
		st.push(i);
	}
	int ret = max( n , m );
	for(int i = 1; i <= m - 1; i++) ret = max( ret , (a[i] + 1) * ( rgt[i] + lft[i] ) );
	return ret;
}

int solve()
{
	int ret = 0;
	for(int i = 1; i <= n - 1; i++)
	{
		for(int j = 1; j <= m - 1; j++)
		{
			if( ara[i][j] == 0 )a[j] = 0;
			else a[j]++;
		}
		ret = max( ret , histogram() );
	}
	return ret;
}

int main()
{
	//FI;
	int i,j;
	sii(n,m);
	Rep(i,n)ss(str[i]);
	Rep(i,n-1)
	{
		Rep(j,m-1)
		{
			int cnt = 0;
			if( str[i][j] == '#' )cnt++;
			if( str[i+1][j] == '#' )cnt++;
			if( str[i][j+1] == '#' )cnt++;
			if( str[i+1][j+1] == '#' )cnt++;
			if( cnt & 1 )ara[i+1][j+1] = 0;
			else ara[i+1][j+1] = 1;
			//printf("%d ",ara[i+1][j+1]);
		}
		//puts("");
	}
	pi( solve() ); NL;
	return 0;
}


Measured memory_bytes: 21248
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int con = 0;
	vector<int> A;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		if(i && A[i-1] >= A[i]) con++;
	}
	
	cout<<con+1<<endl;
	cout<<N<<endl;
	
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};

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

    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            cin >> a[i][j];
        }
    }
    vector<vector<int>> sum(2, vector<int>(n, -1));
    sum[0][0] = a[0][0];
    queue<P> que;
    que.push(P(0, 0));
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        for(int i = 0; i < 2; ++i){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx < 0 || nx >= 2 || ny < 0 || ny >= n)  continue;
            chmax(sum[nx][ny], sum[x][y] + a[nx][ny]);
            que.push(P(nx, ny));
        }
    }
    cout << sum[1][n-1] << endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> boat(n), bad(n,0);
  for(int i=0;i<k;i++){
    int m;
    cin >> m;
    for(int j=0;j<m;j++){
      int b;
      cin >> b; b--;
      boat[b] = i;
    }
  }

  int r;
  cin >> r;
  for(int i=0;i<r;i++){
    int p,q;
    cin >> p >> q;
    p--; q--;
    if(boat[p] == boat[q])bad[p] = bad[q] = 1;
  }

  cout << accumulate(bad.begin(),bad.end(),0) << endl;
}

Measured memory_bytes: 1196
#include<cstdio>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define _USE_MATH_DEFINES // M_PI????????????????????????
#include<math.h>
#pragma warning(disable:4996)
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
	if( l>=r ) return;
	int root = pre[pos++];
	int m = distance( in.begin(), find(in.begin(), in.end(), root) );
	rec(l,m);
	rec(m+1,r);
	post.push_back(root);
}


void solve(){
	pos = 0;
	rec(0,pre.size());
	for(int i=0; i<n; i++){
		if(i) cout << " ";
		cout << post[i];
	}
	cout << "\n";
}


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

	for(int i=0; i<n; i++){
		cin >> k;
		pre.push_back(k);
	}

	for(int i=0; i<n; i++){
		cin >> k;
		in.push_back(k);
	}

	solve();
	return 0;
}

Measured memory_bytes: 3140
#include<iostream>
using namespace std;
int k,s,j,i,ans,ij;
int main()
{

    cin>>k>>s;
    for(i=0;i<=k;i++)
    {
        for(j=0;j<=k;j++)
        {
            ij=s-(j+i);
            if(ij<=k&&ij>-1)++ans;
        }
    }
    cout<<ans<<'\n';
    return 0;
}

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

const int M = 1e5 + 100;
int n, m, x;
int c[15], a[15][15];
int algo[15], cost;
int ans = 1e9;

bool check() {
	for (int i = 0; i < m; i++) {
		if (algo[i] < x) return false;
	}
	return true;
}

void dfs(int i) {
	if (i == n) {
		if (check()) {
			ans = min(ans, cost);
		}
		return;
	}
	cost += c[i];
	for (int j = 0; j < m; j++) {
		algo[j] += a[i][j];
	}
	dfs(i + 1);
	cost -= c[i];
	for (int j = 0; j < m; j++) {
		algo[j] -= a[i][j];
	}
	dfs(i + 1);
}

int main() {
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	dfs(0);
	cout << (ans == int(1e9) ? -1 : ans);
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int main() {

    fast
    int temp;
    int n;
    cin>>n;

    int cnt=1;

    pair<int,int>p[100002];
    map<int,int>m;
    for(int i=0;i<n;i++ )
    {
        cin>>temp;
        p[i].first=temp;
        p[i].second=i+1;
    }

    sort(p,p+n);

    for(int i=0;i<n;i++){
    cout<<p[i].second<<" ";
    }



	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/




Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys
import math
import numpy as np
import heapq
from functools import lru_cache

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

#### input
N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))

# sys.stdin = open('/dev/tty')

heapq.heapify(A)

#### functions
def discount(num_coupon):
  max = -heapq.heappop(A) / 2
  heapq.heappush(A, -max)

#### execution
# if em: embed()
for i in range(0, M):
  max = math.floor(-heapq.heappop(A) / 2)
  heapq.heappush(A, -max)

print(-sum(A))


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numC = 0;
		int numD = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numC = scanner.nextInt();
			numD = scanner.nextInt();

			int wkBus = numA < numB ? numA : numB;
			int wkTrain = numC < numD ? numC : numD;

			System.out.println(wkBus + wkTrain);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int a, b;
    cin >> a >> b;
    int ans = -1;
    FORD(i, b * 10 + 9, b * 10 - 1)
    {
        if(i * 8 / 100 == a)
        {
            ans = i;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
program name
    implicit none
    integer(4):: h,w,cnt
    integer(4):: a_cnt(ichar('a'):ichar('z'))
    character(:),allocatable:: a
    integer(4):: i,j,d
    logical :: b

    read*, h,w
    allocate(character(w):: a)
    a_cnt(:) = 0
    do i=1,h
        read*, a(:)
        do j=1,w
            a_cnt(ichar(a(j:j))) = a_cnt(ichar(a(j:j))) + 1
        end do
    end do

    a_cnt(:) = mod(a_cnt(:),4)
    
    if (mod(w,2) == 0 .and. mod(h,2) == 0) then
        b = sum(a_cnt) == 0
    else if(mod(w,2) /= 0 .and. mod(h,2) /= 0) then
        b = sum(mod(a_cnt,2)) <= 1 .and. sum(a_cnt) <= w+h-1
    else
        if (mod(w,2) == 0) then
            d = w
        else
            d = h
        end if

        b = sum(mod(a_cnt,2)) == 0 .and. sum(a_cnt) <= d
    end if

    if (b) then
        print*, 'Yes'
    else
        print*, 'No'
    end if
end program name

Measured memory_bytes: 384
str_n = input()
n = int(str_n)
str_a = input()
arr_a = str_a.split(' ')
# newn
arr_ia = []
for i, item in enumerate(arr_a):
    arr_ia.append(int(item)-(i+1))

arr_ia.sort()
med = arr_ia[int(len(arr_ia)/2)]

score = 0
for n in arr_ia:
    score += abs(n-med)
    
print(score)

Measured memory_bytes: 27856
#include <stdio.h>

struct dice{
    int number[6];
};

int main(void){
    char order[120];
    int diceNumber;
    int j, q, k;
    int ans[25];
    struct dice x;
    
    fgets(order, 120, stdin);
    //printf("%s\n", order);
    sscanf(order, "%d %d %d %d %d %d",
           &x.number[0], &x.number[1], &x.number[2], &x.number[3], &x.number[4], &x.number[5]);
    //for(int i = 0; i < 6; i++){
    //    printf("%d", x.number[i]);
    //}
    //printf("\n");
    fgets(order, 10, stdin);
    sscanf(order, "%d", &j);
    //printf("%d\n", j);
    for(int t = 0; t < j; t++){
        fgets(order, 10, stdin);
        sscanf(order, "%d %d", &q, &k);
        //printf("%d %d\n", q, k);
        if(k == x.number[2] || k == x.number[3]){
            //W
            diceNumber = x.number[0];
            x.number[0] = x.number[2];
            x.number[2] = x.number[5];
            x.number[5] = x.number[3];
            x.number[3] = diceNumber;
        }
        if(k != x.number[1]){
            while(1){
                //N
                diceNumber = x.number[0];
                x.number[0] = x.number[1];
                x.number[1] = x.number[5];
                x.number[5] = x.number[4];
                x.number[4] = diceNumber;
                if(k == x.number[1])
                    break;
            }
        }
        if(q != x.number[0]){
            while(1){
                //W
                diceNumber = x.number[0];
                x.number[0] = x.number[2];
                x.number[2] = x.number[5];
                x.number[5] = x.number[3];
                x.number[3] = diceNumber;
                if(q == x.number[0])
                    break;
            }
        }
        ans[t] = x.number[2];
        //q == x.number[0], k == x.number[1]
    }
    
    //fgets(order, 120, stdin);
    /*for(int t = 0; order[t] != '\n'; t++){
        if(order[t] == 'N'){
            diceNumber = x.number[0];
            x.number[0] = x.number[1];
            x.number[1] = x.number[5];
            x.number[5] = x.number[4];
            x.number[4] = diceNumber;
        }else if(order[t] == 'S'){
            diceNumber = x.number[0];
            x.number[0] = x.number[4];
            x.number[4] = x.number[5];
            x.number[5] = x.number[1];
            x.number[1] = diceNumber;
        }else if(order[t] == 'E'){
            diceNumber = x.number[0];
            x.number[0] = x.number[3];
            x.number[3] = x.number[5];
            x.number[5] = x.number[2];
            x.number[2] = diceNumber;
        }else if(order[t] == 'W'){
            diceNumber = x.number[0];
            x.number[0] = x.number[2];
            x.number[2] = x.number[5];
            x.number[5] = x.number[3];
            x.number[3] = diceNumber;
        }
    }*/
    for(int t = 0; t < j; t++){
        printf("%d\n", ans[t]);
    }
    //printf("%d\n", x.number[0]);
    //printf("%d\n", diceNumber);
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    string s;
    cin >> s;
    
    if(s[0] == 'R'){
        if(s[1] == 'R'){
            if(s[2] == 'R') cout << 3 << endl;
            else cout << 2 << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    else{
        if(s[1] == 'R'){
            if(s[2] == 'R') cout << 2 << endl;
            else cout << 1 << endl;
        }
        else{
            if(s[2] == 'R') cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define lim 100010
#define mod 1000000007 
#define INF 1e9
#define REP(i,n) for(int i=0;i<n;i++)


ll calc(ll a, ll b){
    if(b == 0) return 1;
    if(b == 1) return a % mod;
    if(b % 2 == 0){
        ll d = calc(a, b / 2);
        return (d * d) % mod;
    }
    return (a * calc(a, b - 1)) % mod;
}

ll comb(ll n, ll m){
    ll s = 1, t = 1;
    for (ll i = n; i >= n - m + 1; i--) s = (s * i) % mod;
    for (ll i = 1; i <= m; i++) t = (t * i) % mod;
    return (s * calc(t, mod - 2)) % mod;
}


int main() {
	ll X,Y;
	scanf("%lld%lld",&X,&Y);
    ll ans;
    if( (X+Y) % 3 != 0)
        ans = 0;
    else{
        ll n = (2 * Y - X) / 3;
        ll m = (2 * X - Y) / 3;
        if( n < 0 || m < 0){
            ans = 0;
        }else{
            ans = comb(n + m, min(n, m));
        }
    }

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

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll R;

    cin >> R;
    cout << R * 2 * 3.14159 << endl;
}


Measured memory_bytes: 3776
#include <cmath>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

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

  cout.precision(16);
  cout << fixed;

  int n;
  cin >> n;

  vector<int> a(n);
  for (auto&& i : a)
    cin >> i;

  vector<int> l(n, 1);
  for (int i = 1, cur = a[0]; i < n; ++i) {
    cur = max(cur, a[i - 1]);

    l[i] = cur;
  }

  vector<int> r(n, 1);
  for (int i = n - 2, cur = a[n - 1]; i >= 0; --i) {
    cur = max(cur, a[i + 1]);

    r[i] = cur;
  }

  for (int i = 0; i < n; ++i)
    cout << max(l[i], r[i]) << '\n';
}


Measured memory_bytes: 3968
#include<stdio.h>
int main(){
	int i,j,s,w[101],k[101];
	for(i=0;i<10;i++)scanf("%d",&w[i]);
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(w[i]<w[j]){
				s=w[i];
				w[i]=w[j];
				w[j]=s;
			}
		}
	}
	s=0;
	for(i=0;i<10;i++)scanf("%d",&k[i]);
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(k[i]<k[j]){
				s=k[i];
				k[i]=k[j];
				k[j]=s;
			}
		}
	}
	printf("%d %d\n",w[0]+w[1]+w[2],k[0]+k[1]+k[2]);
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
int n, bx, by; pair<int, int> p[500009];
int main() {
	scanf("%d", &n);
	int sq = 7, cq = 24;
	for(int i = 0; i < n; i++) {
		scanf("%d%d", &bx, &by);
		int ex = bx * cq - by * sq;
		int ey = bx * sq + by * cq;
		p[i] = make_pair(ex, ey);
	}
	sort(p, p + n);
	long long ret = 1LL << 60;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int dx = p[i].first - p[j].first;
			if(dx * dx > ret) break;
			int dy = p[i].second - p[j].second;
			long long dist = 1LL * dx * dx + 1LL * dy * dy;
			ret = min(ret, dist);
		}
	}
	printf("%lld\n", ret / (sq * sq + cq * cq));
	return 0;
}

Measured memory_bytes: 6988
import itertools

n = int(input())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
x = sorted(p)
ans = int(0)

P = tuple(p)
ans1 = int(0)

Q = tuple(q)
ans2 = int(0)

for i in itertools.permutations(x, n):
    if P == i:
        break
    else:
        ans1 += 1

for i in itertools.permutations(x, n):
    if Q == i:
        break
    else:
        ans2 += 1

ans = ans1-ans2

print(abs(ans))


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



int main(){
     int a,b;
    cin>>a>>b;
    if(a<=b)cout<<a<<endl;
    else cout<<a-1<<endl;

}


Measured memory_bytes: 256
// attiribution : https://www.geeksforgeeks.org/minimum-number-of-increasing-subsequences/



#include <bits/stdc++.h> 
using namespace std; 
  
int M(int arr[], int n) 
{ 
    multiset<int> last; 
  
    
    for (int i = 0; i < n; i++) { 
  
       
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        
        if (it == last.begin()) 
  
            
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            
            last.erase(it); 
            last.insert(arr[i]); 
        } 
    } 
    return last.size(); 
} 
  

int main() 
{ 
    int i,j;
    int n ;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    cout<< M(a, n); 
    return 0; 
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 9999999999;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	int n,k;
	string s;
	cin >> n >> k >> s;

	k--; 
	if(s[k]=='A') s[k] = 'a';
	else if(s[k]=='B') s[k] = 'b';
	else s[k] = 'c';
	cout << s << endl; 	



	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b, c;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc134_a
{
    static class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().ToInteger();
            Console.WriteLine($"{(3 * Math.Pow(r, 2))}");
        }

        static int ToInteger(this string s)
        {
            return int.Parse(s);
        }
    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n - 1];
		for(int i = 0; i < n; i++) a[i] = scan.nextInt();
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		for(int i = 0; i < n - 1; i++) c[i] = scan.nextInt();
		int out = 0;
		for(int i = 0; i < n - 1; i++) {
			if(a[i + 1] - a[i] == 1) {
				out += c[a[i] - 1];
			}
			out += b[a[i] - 1];
		}
		out += b[a[n - 1] - 1];
		System.out.println(out);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD = 998244353;
const int MAX_N = 300005;
int fact[MAX_N];
int fact_inv[MAX_N];
int bin_pow_mod(int x, int y) {
      if (x == 0) return 0;
      int prod=1;
      while(y>0) {
          if (y & 1) prod = (prod * x) % MOD;
          x = (x * x) % MOD;
          y >>= 1;
      }
      return prod % MOD;
}
struct init_fact {
    init_fact() {
        fact[0] = 1, fact_inv[0] = 1;
        for (int i = 1; i < MAX_N; ++i) {
            fact[i] = (fact[i - 1] * i) % MOD;
            fact_inv[i] = bin_pow_mod(fact[i], MOD - 2);
        }
    }
} init_fact;
int combination(int n, int r) {
    return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}
signed main() {
    int N, A, B, K;
    cin >> N >> A >> B >> K;
    int ans = 0;
    REP(x, N + 1) {
        if ((K - A * x) % B != 0) continue;
        int y = (K - A * x) / B;
        if (0 <= x && 0 <= y && x <= N && y <= N) {
            ans += combination(N, x) * combination(N, y) % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  vector<int> l(n);
  REP(i, n) cin >> l[i];
  sort(l.begin(), l.end());

  ll ans = 0;
  REP(i, n - 1) FOR(j, i + 1, n - 1) {
    int c = l[i] + l[j];
    auto it = lower_bound(l.begin() + j + 1, l.end(), c);
    ans += (it - 1) - (l.begin() + j);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int x = sc.nextInt();
		int t = sc.nextInt();
    
		// 出力
		System.out.println(t > x ? 0 : x - t);
	}
}


Measured memory_bytes: 23892
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Kagisys
// 2012/09/19
public class Main{
	Scanner sc=new Scanner(System.in);

	int n, m;
	String[] us, ts;

	void run(){
		n=sc.nextInt();
		us=new String[n];
		for(int i=0; i<n; i++){
			us[i]=sc.next();
		}
		m=sc.nextInt();
		ts=new String[m];
		for(int i=0; i<m; i++){
			ts[i]=sc.next();
		}
		solve();
	}

	void solve(){
		HashSet<String> registered=new HashSet<String>();
		for(String u : us){
			registered.add(u);
		}
		boolean opend=false;
		for(String t : ts){
			if(registered.contains(t)){
				if(opend){
					println("Closed by "+t);
				}else{
					println("Opened by "+t);
				}
				opend=!opend;
			}else{
				println("Unknown "+t);
			}
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {long long x, y; int home; };
info a[MAXN];
vector <int> b[MAXN];
int f[MAXN];
long long x[MAXN], y[MAXN], cnt, v[MAXN];
bool visited[MAXN];
bool cmpxy(info a, info b) {
	if (a.x == b.x) return a.y < b.y;
	else return a.x < b.x;
}
bool cmpyx(info a, info b) {
	if (a.y == b.y) return a.x < b.x;
	else return a.y < b.y;
}
int F(int x) {
	if (f[x] == x) return x;
	else return f[x] = F(f[x]);
}
void work(int pos) {
	visited[pos] = true;
	cnt += b[pos].size();
	cnt += v[pos];
	for (unsigned i = 0; i < b[pos].size(); i++)
		if (!visited[b[pos][i]]) work(b[pos][i]);
}
int main() {
	int n, sa, sb;
	read(n), read(sa), read(sb);
	for (int i = 1; i <= n; i++)
		read(x[i]), read(y[i]);
	long long d = abs(x[sa] - x[sb]) + abs(y[sa] - y[sb]);
	for (int i = 1; i <= n; i++) {
		long long tx = x[i] + y[i];
		long long ty = x[i] - y[i];
		x[i] = tx, y[i] = ty;
		a[i] = (info) {tx, ty, i};
	}
	sort(a + 1, a + n + 1, cmpxy);
	for (int i = 1; i <= n; i++)
		f[i] = i;
	for (int i = 1; i <= n; i++) {
		int l = 1, r = n + 1;
		while (l < r) {
			int mid = (l + r) / 2;
			if (a[mid].x < a[i].x - d || (a[mid].x == a[i].x - d && a[mid].y < a[i].y - d)) l = mid + 1;
			else r = mid;
		}
		int L = l;
		l = 0, r = n;
		while (l < r) {
			int mid = (l + r + 1) / 2;
			if (a[mid].x > a[i].x - d || (a[mid].x == a[i].x - d && a[mid].y > a[i].y + d)) r = mid - 1;
			else l = mid;
		}
		int R = l;
		if (L <= R) {
			b[a[i].home].push_back(a[L].home);
			b[a[L].home].push_back(a[i].home);
			int j = L - 1, ti = i;
			for (int i = F(L) + 1; i <= R; j = i, i = F(i) + 1) {
				b[a[i].home].push_back(a[i - 1].home);
				b[a[i - 1].home].push_back(a[i].home);
				f[F(i - 1)] = F(i);
				v[a[ti].home] += (i - j - 1) * 2;
			}
			v[a[ti].home] += (R - j - 1) * 2;
		}
	}
	sort(a + 1, a + n + 1, cmpyx);
	for (int i = 1; i <= n; i++) {
		f[i] = i;
		swap(a[i].x, a[i].y);
	}
	for (int i = 1; i <= n; i++) {
		int l = 1, r = n + 1;
		while (l < r) {
			int mid = (l + r) / 2;
			if (a[mid].x < a[i].x - d || (a[mid].x == a[i].x - d && a[mid].y <= a[i].y - d)) l = mid + 1;
			else r = mid;
		}
		int L = l;
		l = 0, r = n;
		while (l < r) {
			int mid = (l + r + 1) / 2;
			if (a[mid].x > a[i].x - d || (a[mid].x == a[i].x - d && a[mid].y >= a[i].y + d)) r = mid - 1;
			else l = mid;
		}
		int R = l;
		if (L <= R) {
			b[a[i].home].push_back(a[L].home);
			b[a[L].home].push_back(a[i].home);
			int j = L - 1, ti = i;
			for (int i = F(L) + 1; i <= R; j = i, i = F(i) + 1) {
				b[a[i].home].push_back(a[i - 1].home);
				b[a[i - 1].home].push_back(a[i].home);
				f[F(i - 1)] = F(i);
				v[a[ti].home] += (i - j - 1) * 2;
			}
			v[a[ti].home] += (R - j - 1) * 2;
		}
	}
	work(sa);
	cout << cnt / 2 << endl;
	return 0;
}

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

int main(){
  int n,a,b; cin >> n >> a >> b;
  if( abs(b-a)%2 ==1){ cout << "Borys" << endl;}
  else{ cout << "Alice" << endl;
      }
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

char t[105][105];

int main2() {
  int A = nextInt();
  int B = nextInt();

  int N = 100;
  REP(i, N) REP(j, N) {
    if (i < N / 2)
      t[i][j] = '.';
    else
      t[i][j] = '#';
  }

  int a = 0, b = 0;
  for (int i = 0; i < N/2; i+=2) {
    for (int j = 0; j < N; j += 2) {
      if (b < B-1) {
        t[i][j] = '#';
        b++;
      }
    }
  }
  for (int i = N/2 + 1; i < N; i +=2) {
    for (int j = 0; j < N; j += 2) {
      if (a < A-1) {
        t[i][j] = '.';
        a++;
      }
    }
  }

  cout << N << " " << N << endl;
  REP(i, N) {
    REP(j, N) cout << t[i][j];
    cout << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int kakutei=0, idx=0;
    int v[2] = {0};
    REP(i, n){
        if(idx == i) continue;
        if(a[idx] == a[i]){
            v[kakutei] = a[i];
            ++kakutei;
            idx = i+1;
        }
        else idx = i;
        if(kakutei == 2) break;
    }
    cout << (ll)v[0] * v[1] << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {

	int N, M, k[20], s[20][20], p[20];
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d", &k[i]);
		for (int j = 0; j < k[i]; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	for (int i = 0; i < M; i++) {
		scanf("%d", &p[i]);
	}

	int ans = 0;
	//　すべてのスイッチのパターンを考える
	for (int bit = 0; bit < 1 << N; bit++) {
		int sw[10];
		for (int j = 0; j < N; j++) {
			sw[j] = bit >> j & 1;
		}


		bool end = false;// フラグ
		// すべての電球について
		for (int j = 0; j < M && !end; j++) {
			int preP = 0;
			for (int i = 0; i < k[j]; i++) {
				preP += sw[s[j][i]-1];
			}
			if (preP % 2 != p[j]) {
				end = true;
				break;
			}
			
			if (!end && j == M - 1) {
				ans++;
			}
		}
	}

	printf("%d", ans);




}








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

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<int> d = new List<int>();
        for (int i = 0; i < n; i++)
        {
            d.Add(int.Parse(Console.ReadLine()));
        }
        IEnumerable<int> e = d.Distinct();
        Console.WriteLine(e.Count());
    }
}

Measured memory_bytes: 13152
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>



int main()
{
	int N,K,h[100000],i;
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) scanf("%d", &h[i]);

	int Ans = 0;
	for (i = 0; i < N; i ++) {
		if (h[i] >= K) Ans++;
	}

	
    printf("%d", Ans);
}






Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
A = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

n, m = map(int, input().split())
g = [set() for i in range(n+1)]
e = set();
for i in range(m):
    a,b=map(int,input().split())
    b<<A>>g[a].add
    a<<A>>g[b].add
    (a,b)<<A>>e.add

color = [0]*(n+1)
def dfs(u, p):
#    print(u, p);
    color[u] = 1
    for next_u in g[u]:
        if next_u == p:
            continue
        if not color[next_u]:
            dfs(next_u, u)

ret = 0
for edge in e:
    color = [0]*(n+1)
    g[edge[0]].remove(edge[1]);
    g[edge[1]].remove(edge[0]);
#    print(g)
    dfs(edge[0], -1)
    ret += color[edge[1]]
    g[edge[0]].add(edge[1]);
    g[edge[1]].add(edge[0]);

print(m-ret);


Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
const int limN = 1e5 + 5;

int crg[limN];

int main() {
    int N, T;
    int ans = 0;
    scanf("%d%d", &N, &T);
    for(int i=0, a, b; i<N; i++) {
        scanf("%d%d", &a, &b);
        crg[a]++;
        crg[b]--;
    }
    for(int i=0, s=0; i<=T; i++) {
        s += crg[i];
        ans = max(ans, s);
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k = 0;
	char str[5];
	scanf("%lld%lld",&n,&m);
	if (n == 2 || m == 2) { printf("No"); return 0; }
	if ((n == 4 || n == 6 || n == 9 || n == 11) && (m == 4 || m == 6 || m == 9 || m == 11)) { printf("Yes"); return 0; }
	if ((n == 1 || n == 3 || n == 5 || n == 7||n==8||n==10||n==12) && (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)) { printf("Yes"); return 0; }
	printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 125

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
inline int gcd(int a, int b){if(b == 0)return a; return gcd(b, a%b);}
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int main(){
    int j,k,i,T,ca=0, m, K = 0, n;
    scanf("%d%d", &n, &K);
    if(K > 1)
    printf("%d\n", n - (K-1) - 1);
    else printf("%d\n", 0);
}



Measured memory_bytes: 256
H, W = map(int, input().split())
A = [input() for _ in range(H)]
s = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            s += 1

if s == H + W - 1:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 2940
import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val A, B, K = sc.nextInt()

    val min = A.min(B)
    val a = 1.until(min + 1).foldRight(List.empty[Int]) {
      (index, pre) =>
        if (A % index == 0 && B % index == 0) index :: pre else pre
    }
    println(a.reverse(K-1))
  }

}


Measured memory_bytes: 25800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    int K,N;
    cin>>K>>N;
    int i,j,k;
    vector<int> v(N);
    for(i=0;i<N;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int l,r;
    int ans = K;
    for(i=0;i<N;i++){
        l = abs(v[(i-1)%N]-v[i]);
        l = min(abs(K-l),l);
        r = abs(v[(i+1)%N]-v[i]);
        r = min(abs(K-r),r);
        ans = min(ans, min(K-l,K-r));
    }
    cout<<ans<<"\n";
    
    return;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  bool ok=true;
  int n=s.size();
  rep(i,n){
    if(i%2==0){
      if(s[i]=='L') ok=false;
    }
    else{
      if(s[i]=='R') ok=false;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include <cstdio>
 
 int main(){
     int a,b;
     scanf("%d%d", &a,&b);

     if(a<b){
         printf("a < b\n");
     }
     else if(a>b){
         printf("a > b\n");
     }
     else if(a == b){
         printf("a == b\n");
     }
 }


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

const int MAX_N = 1e5 + 5, inf = 1e9 + 7;
int n;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	n = s.size();
	for (int i = 0; i + 1 < n; i++)
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << "\n";
			return 0;
		}

	for (int i = 0; i + 2 < n; i++)
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << "\n";
			return 0;
		}

	cout << "-1 -1\n";
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>

using namespace std;

const int N=2e5+10;

int n,m;
int p[N];
int Size[N];

int find(int x){
    if(x!=p[x]) p[x]=find(p[x]);
    return p[x];
}

int main(){
    cin>>n>>m;
    for(int i=1;i<=n;++i){
        p[i]=i;
        Size[i]=1;
    }
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        int u,v;
        u=find(a);
        v=find(b);
        if(u!=v){
            p[u]=v;
            Size[v]+=Size[u];
        }
    }
    int res=0;
    for(int i=1;i<=n;++i) res=max(res,Size[i]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 5116