akhauriyash/Code-Regression huggingface dataset:
//間違えて打った文字を打ち消すことを考えると難しい（状態を減らせない）.
//間違えて打った文字を打ち消さないとどうなるか。
//とりあえずN回押して, |S|文字になったとする.
//当然文字列Sと一致しないバイナリ列ができうる。バイナリ列は2^|S|通りできうるが、
//それらは等確率でできるので、文字列Sを作る方法の個数は、「N回押して|S|文字にする方法の個数」
//を2^|S|で割ったものと等しい。よって、これをDPで求めればいいことになった。間に合う。
#include <iostream>
#include <string>
#include <algorithm>
#define int long long
using namespace std;

int mod = 1000000007;
int n, m;
string s;
int dp[5001][5001];	//dp[i][j] = i回打った直後にj文字存在する打ち方の個数

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

signed main()
{
	int i, j;
	
	cin >> n >> s;
	m = s.length();
	
	dp[0][0] = 1;
	for (i = 0; i < n; i++) {
		for (j = 0; j <= i; j++) {
			dp[i + 1][j + 1] += dp[i][j] * 2;
			dp[i + 1][j + 1] %= mod;
			dp[i + 1][max(0LL, j - 1)] += dp[i][j];
			dp[i + 1][max(0LL, j - 1)] %= mod;
		}
	}
	
	int inv = powmod(powmod(2, mod - 2, mod), m, mod);
	int ans = (dp[n][m] * inv) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 193920
//
// Created on 2020/01/12.
//

#include <istream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int N;
    int M;
    cin>>N>>M;
    
    map<int,int>q;
    map<int,bool>q2;
    for (int i = 0; i < M; ++i) {
        int p;
        cin>>p;
        string state;
        cin>>state;
        if (state=="AC"){
            q2[p] = true;
        }else if(state=="WA" && !q2[p]){
            q[p] += 1;
        }
    }
    int ansac = 0;
    int ans = 0;
    for (pair<int,bool> x :q2){
        if (x.second){
            ansac += 1;
            ans += q[x.first];
        }
    }

    cout<<ansac<<" "<<ans<<endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include<algorithm>
//#include<string.h>
using namespace std;
int main()
{
    int a[]={1,3,5,7,8,10,12};
    int b[]={4,6,9,11};
    int c[]={2};
    int x,y,m=0,n=0;
    cin>>x>>y;
    for(int i=0; i<7; i++)
    {
        if(a[i]==x || a[i]==y)
            m++;
    }
    for(int j=0; j<4; j++)
    {
        if(b[j]==x || b[j]==y)
            n++;
    }
    (m==2 || n==2)?cout<<"Yes":cout<<"No";}


Measured memory_bytes: 3620
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>
#include <iomanip>
 
using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810893;
 
#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}
 
#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}
 
#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}
 
#define LOAD(type,name) type name; \
cin >> name;
 
 
void proc();
 
signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}
 
/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/
 
 
 
 
 
void proc() {
	LOAD(int, M);
	LOAD(int, K);
	int MM = 1 << M;
	if (K == 0) {
		for (int i = 0; i < MM; ++i) {
			cout << i << ' ';
		}
		for (int i = 0; i < MM; ++i) {
			cout << MM - 1 - i;
			if (i != MM - 1) {
				cout << ' ';
			}
		}
	}
	else if (2 <= M && K < MM) {
		for (int i = 0; i < MM; ++i) {
			if (i != K) {
				cout << i << ' ';
			}
		}
		cout << K << ' ';
		for (int i = 0; i < MM; ++i) {
			if (MM - 1 - i != K) {
				cout << MM - 1 - i << ' ';
			}
		}
		cout << K;
	}
	else {
		cout << "-1";
	}
	cout << endl;
 
}
 
 
#endif

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[11];
int main(){
	int n,i,ans=0,mx=0,pos=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>mx){
			mx=a[i];
			pos=i;
		} 
	}
	for(i=1;i<=n;i++){
		if(i!=pos) ans+=a[i];
	}
	if(ans>mx) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main(){
    int a,b,d,r;
    double f;
    cin>> a >> b;
    d=a/b;
    r=a%b;
    f=1.0*a/b;
	cout<< d <<" "<< r <<" "<<endl;
    printf("%.5lf\n",f);
}


Measured memory_bytes: 3232
H,W=map(int,input().split())
List = []
for i in range (H):
  a=input()
  List.append(list(a))
New_List=[]
for i in range(H):
  New_List.append(List[i])
  New_List.append(List[i])
res = ""
for i in range(2*H):
  for j in range(W):
    res += New_List[i][j]
  print(res)
  res = ""

Measured memory_bytes: 9248
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
vector<int> L = {1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    set<int> colors;
    int lgm = 0;
    for(int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        for(int x = 0; x < L.size() - 1; x++) {
            if(L[x] <= ai and ai < L[x + 1]) {
                colors.insert(x);
            }
        }
        if(ai >= 3200) {
            lgm++;
        }
    }
    cout << max((int)colors.size(), lgm > 0 ? 1 : 0) << " " << colors.size() + lgm << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};

ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
int par[100010], rr[100010];
void init(){
    for(int i=0; i<100010; ++i){
        par[i]=i;
        rr[i]=0;
    }
}
int root(int x){
    return par[x] == x ? x:par[x] = root(par[x]);
}
bool same(int x, int y){
    return root(x)==root(y);
}
void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y) return ;
    
    if(rr[x]<rr[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rr[x]==rr[y]) rr[x]++;
    }
}

ll pow_mod(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res*x%MOD;
        }
        x = x*x%MOD;
        n>>=1;
    }
    return res;
}
int main() {
    ll n, m, e=1;
    string s, t; cin >> n >> m >> s >> t;
    
    e = GCD(n, m);
    
    ll a = n/e;
    ll b=m/e;
    
    ll ans = a*b*e;
    
    for(int i=0; i<e; ++i){
        if(s[i*a]!=t[i*b]){
            ans = -1;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

int count(int x)
{
	if (x == 0) return 0;
	return count(x >> 1) + (x & 1);
}

void Main()
{
	int N; cin >> N;
	int A[20];
	int x[20][20];
	int y[20][20];
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
		for (int j = 1; j <= A[i]; j++)
		{
			cin >> x[i][j] >> y[i][j];
		}
	}
	int ans = 0;
	for (int bits = 1; bits < (1 << N); bits++)
	{
		bool ok = true;
		for (int i = 1; i <= N; i++)
		{
			if (!(bits&(1 << (i - 1)))) continue;
			for (int j = 1; j <= A[i]; j++)
			{
				if (((bits >> x[i][j] - 1) & 1) ^ y[i][j]) ok = false;
			}
		}
		if (ok) ans = max(ans, count(bits));
	}
	cout << ans << endl;
}

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

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

int main()
{
  int n, k; cin >> n >> k;
  ll ans = 0;
  for (int b=k+1; b<=n; b++) {
    ans += ((n/b) * (b-k)) + max((n%b)-max(k, 1)+1, 0);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int a,b;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
    cin>>a>>b;
    int sol=0,ans=b-a,ans1;
    for(int i=1;i<=ans;i++){
    	sol+=i;
	}
	cout<<sol-b;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> g[100005];
int a[100005],b[100005];
int erfen(int s,int e,int c,int x)
{
    while(s<=e)
    {
        int mid=(s+e)/2;
        if(g[x][mid]==c)return mid;
        if(g[x][mid]>c)e=mid-1;
        else s=mid+1;
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a[i]>>b[i];
        g[a[i]].push_back(b[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if(g[i].size())sort(g[i].begin(),g[i].end());
    }
    for(int i=1;i<=m;i++)
    {
        string str="";
        int c=a[i];
        while(c)
        {
            char d=c%10+'0';
            str.push_back(d);
            c/=10;
        }
        while(str.size()<6)
        {
            str.push_back('0');
        }
        c=erfen(0,g[a[i]].size()-1,b[i],a[i])+1;
        while(c)
        {
            char d=c%10+'0';
            str.push_back(d);
            c/=10;
        }
        while(str.size()<12)
        {
            str.push_back('0');
        }
        for(int j=5;j>=0;j--)cout<<str[j];
        for(int j=11;j>=6;j--)cout<<str[j];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 7808
int main()
{
  long a, b, x;
  scanf("%ld %ld %ld", &a, &b, &x);
  long ans;
  if (a % x == 0)
    ans = b / x - a / x + 1;
  else
    ans = b / x - a / x;
  printf("%ld", ans);
}

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

int main() {
  int N;
  cin >> N;
  ll A[N];
  ll s = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    s += A[i];
  }
  ll x = s;
  for (int i = 0; i < N / 2; i++) {
    //cout << i << "\n";
    x -= 2 * A[2 * i];
  }
  vector<ll> v;
  v.push_back(x);
  for (int i = N - 2; i >= 0; i--) {
    x = 2 * A[i] - x;
    v.push_back(x);
  }
  for (int i = N - 1; i >= 0; i--) {
    if (i == 0) cout << v[i] << "\n";
    else cout << v[i] << " ";
  }
  return 0;
}

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

//scanf("%d",&x);
//printf("%d",x);
//for(i=0;i<N;i++){  }
//if( == ){  }else{  }
//while( ){  }

int main()
{
	int i = 0;
	
	int A, B;
	
	scanf("%d", &A);
	scanf("%d", &B);

	if (B == 1) {
		printf("0");
		return 0;
	}
	else if (A >= B){ 
		printf("1");
		return 0;
	}else {
    int t = A - 1;
	while (A < B) {
		A = A + t;
		i++;
	}
	}
	printf("%d", i+1);
}


Measured memory_bytes: 128
n,x,y=map(int,input().split())

ans=[0]*n
for i in range(1,n):
    for j in range(i+1,n+1):
        k=min(abs(i-j),abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)
        ans[k]+=1
for i in range(1,n):
    print(ans[i])



Measured memory_bytes: 3444
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    s1=int(s[:2])
    s2=int(s[2:])
    l=list(range(1,13))
    if s1 in l and s2 in l:
        print('AMBIGUOUS')
    elif s1 in l and s2 not in l:
        print('MMYY')
    elif s1 not in l and s2 in l:
        print('YYMM')
    else:
        print('NA')
resolve()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;

int main() {
	ll ans=0, n;
	cin >> n;
	while (n > 0) {
		n--;
		ans += n;
	}
	print(ans);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,n,l,a,b,c;
int main(){
  cin>>a>>b>>c>>i>>j;
  if(a+b>2*c){
    l=2*c*max(i,j);
    if(i>j)cout<< min(l,a*(i-j)+2*c*j);
    else cout<< min(l,b*(j-i)+2*c*i);
  }
  else cout<<i*a+j*b;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = []
h = {}
m = 0
x, y = [], []
n.times do |i|
  x[i], y[i] = gets.chomp.split.map(&:to_i)
end
n.times do |i|
  n.times do |j|
    l = [x[i] - x[j], y[i] - y[j]]
    next if l == [0, 0]
    if !s.include?(l)
      s << l
      h[l] = 1
      m = 1 if m == 0
    else
      h[l] += 1
      m = h[l] if m < h[l]
    end
  end
end
puts n - m


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,C,q,n0 = 0,n1 = 0,n2 = 0;
  long int ans = 10000000000000;
  cin >> N >> C;
  int D[C+1][C+1];
  for(int i = 1;i <= C;i++){
    for(int j = 1;j <= C;j++)cin >> D[i][j];
  }
  int cost[3][C+1];
  for(int i = 0;i <= C;i++){
    cost[0][i] = 0;
    cost[1][i] = 0;
    cost[2][i] = 0;
  }
  for(int i = 1;i <= N;i++){
    for(int j = 1;j <= N;j++){
      cin >> q;
      if((i+j)%3 == 0){
        for(int i = 1;i <= C;i++){
          cost[0][i] += D[q][i];
        }
      }
      else if((i+j)%3 == 1){
        for(int i = 1;i <= C;i++){
          cost[1][i] += D[q][i];
        }
      }
      else if((i+j)%3 == 2){
        for(int i = 1;i <= C;i++){
          cost[2][i] += D[q][i];
        }
      }
    }
  }
  for(int i = 1;i <= C;i++){
    for(int j = 1;j <= C;j++){
      for(int k = 1;k <= C;k++){
        if(i != j && j != k && k != i){
          long int ans2 = cost[0][i]+cost[1][j]+cost[2][k];
          ans = min(ans,ans2);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x) do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<#x<<': "';\
for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;

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

  int N, M; cin >> N >> M;
  vector<int> s[M];
  rep(i, 0,M-1) {
      int k; cin >> k;
      rep(j, 0, k-1) {int si; cin >> si; s[i].push_back(--si);}
  }

  int p[M]; rep(i,0,M-1) cin>> p[i];

  ll ans = 0; 
  rep(sw,0, exp2(N)-1) {
      debug(sw);
      vector<int> cc(M,0);
      bool flag=false;
      rep(j,0,M-1) {
          for(auto e: s[j]) if (sw & exp2(e)) cc[j]++;
          debug(cc[j]);
          debug(p[j]);
          if (cc[j]%2 != p[j]) { flag=true; break; }
      }
      if (!flag) ans++;
      
  }
  END(ans);
}


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

using namespace std;

const int MX = 100000;

char s[MX + 1], t[MX + 1];

int main() {
	int n, m;
	ignore = scanf("%d %d %s %s", &n, &m, s, t);
	
	if (s[0] != t[0]) {
		printf("%d\n", -1);
		return 0;
	}
	
	long long k = n * 1ll * m / __gcd(n, m);
	for (int i = 0; i < n; i++) {
		long long x = (k / n) * i + 1;
		if (x % (k / m) == 1) {
			int j = x / (k / m);
			if (s[i] != t[j]) {
				printf("%d\n", -1);
				return 0;
			}
		}
	}
	
	printf("%lld\n", k);
	
	return 0;
}


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

using namespace std;

const int N = (int)2e5 + 5, inf = (int)1e9 + 123;
int n, b[N], q;
vector<int> query[N];

struct It {
    struct Node {
        int mn, lz;
        Node(int _mn = inf, int _lz = 0) : mn(_mn), lz(_lz) {}
    } node[N << 2];

    void trueVal(int nd, int Left, int Right) {
        if (!node[nd].lz) return ;
        node[nd].mn += node[nd].lz;
        if (Left != Right) {
            node[nd << 1].lz += node[nd].lz;
            node[nd << 1  | 1].lz += node[nd].lz;
        }
        node[nd].lz = 0;
    }

    void upd(int nd, int Left, int Right, int l, int r, int val) {
        trueVal(nd, Left, Right);
        if (r < Left || Right < l) return ;
        if (l <= Left && Right <= r) {
            node[nd].lz = val; trueVal(nd, Left, Right);
            return ;
        }
        int mid = (Left + Right) >> 1;
        upd(nd << 1, Left, mid, l, r, val);
        upd(nd << 1 | 1, mid + 1, Right, l, r, val);
        node[nd].mn = min(node[nd << 1].mn, node[nd << 1 | 1].mn);
    }

    void upd(int nd, int Left, int Right, int pos, int val) {
        trueVal(nd, Left, Right);
        if (Right < pos || pos < Left) return ;
        if (Left == Right) {
            node[nd].mn = min(node[nd].mn, val);
            return ;
        }
        int mid = (Left + Right) >> 1;
        upd(nd << 1, Left, mid, pos, val);
        upd(nd << 1 | 1, mid + 1, Right, pos, val);
        node[nd].mn = min(node[nd << 1].mn, node[nd << 1 | 1].mn);
    }

    int get(int nd, int Left, int Right, int l, int r) {
        trueVal(nd, Left, Right);
        if (r < Left || Right < l) return inf;
        if (l <= Left && Right <= r) return node[nd].mn;
        int mid = (Left + Right) >> 1;
        return min(get(nd << 1, Left, mid, l, r), get(nd << 1 | 1, mid + 1, Right, l, r) );
    }
} it;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", b + i);
    scanf("%d", &q);
    while (q --) {
        int l, r; scanf("%d %d", &l, &r);
        query[l].push_back(r);
    }

    for (int i = 1; i <= n; ++i) sort(query[i].begin(), query[i].end() );

    it.upd(1, 0, n, 0, 0);
    for (int i = 1; i <= n; ++i) {
        for (int r : query[i]) {
            it.upd(1, 0, n, r, it.get(1, 0, n, 0, r - 1) );
        }
        if (b[i]) it.upd(1, 0, n, 0, i - 1, 1);
        else it.upd(1, 0, n, i, n, 1);
    }

    printf("%d\n", it.node[1].mn);

    return 0;
}


Measured memory_bytes: 15872
from heapq import heappop, heappush
n, m, *AB = map(int, open(0).read().split())
B = [[] for _ in range(m)]
for a, b in zip(AB[::2], AB[1::2]):
    if a <= m:
        B[a-1].append(b)

ans = 0
heap = []
for b in B:
    for x in b:
        heappush(heap, -x)
    if heap:
        ans -= heappop(heap)
print(ans)


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

int main(){
  string S;
  cin >> S;
  int N = S.length();
  vector<int> L, R, P(N,0);
  for(int i = 0; i < N; ++i){
    if(S[i] == 'R') R.push_back(i);
    else L.push_back(i);
  }
  for(int i = 0; i < N; ++i){
    int idx;
    if(S[i] == 'R'){
      idx = *lower_bound(L.begin(), L.end(), i);
      int d = abs(i-idx);
      if(d%2){
        --idx;
      }
    }else{
      idx = *(--lower_bound(R.begin(), R.end(), i));
      int d = abs(i-idx);
      if(d%2){
        ++idx;
      }
    }
    ++P[idx];
  }
  for(int i = 0; i < N; ++i){
    cout << P[i];
    if(i+1 < N) cout << " ";
    else cout << endl;
  }
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll a, b; cin >> a >> b;

    if (a <= 0 && 0 <= b) {
        puts("Zero");
        return 0;
    }

    if (a > 0) {
        puts("Positive");
        return 0;
    }

    if ((b - a) % 2 == 0) {
        puts("Negative");
        return 0;
    } else {
        puts("Positive");
        return 0;
    }
}

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

int main(){
    int h, w, i, j, k, l, c;
    cin >> h >> w;
    string s[h];
    for(i=0; i<h; i++){
        cin >> s[i];
    }
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            if(s[i][j] == '#'){
                cout << '#';
              	continue;
            }
            c = 0;
            for(k=-1; k<2; k++){
                for(l=-1; l<2; l++){
                    if(i+k == -1 || j+l == -1 || i+k == h || j+l == w || (k == 0 && l == 0)){
                        continue;
                    }else if(s[i+k][j+l] == '#'){
                        c++;
                    }
                }
            }
            cout << c;
        }
      	cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

lli dp[3002][3002];
int ar[3002][3002];
int br[3002][3002];

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

    string s1,s2;
    cin >> s1 >> s2;
    for(int i=0; i<s1.size(); i++)
    {
        for(int j=0; j<s2.size(); j++)
        {
            if(s1[i]==s2[j])
            {
                if(i-1>=0 && j-1>=0)
                {
                    dp[i][j] = dp[i-1][j-1]+1;
                    ar[i][j] = i-1;
                    br[i][j] = j-1;
                }
                else
                {
                    dp[i][j] = 1;
                    //ans[i][j].pb(s1[i]);
                    ar[i][j] = -1;
                    br[i][j] = -1;
                }
            }
            else
            {
                int x=0,y=0;
                string ok1,ok2;
                if(i-1>=0)
                {
                    x = dp[i-1][j];
                }
                if(j-1>=0)
                {
                    y = dp[i][j-1];
                }
                dp[i][j] = max(x,y);
                if(x>=y)
                {
                    ar[i][j] = i-1;
                    br[i][j] = j;

                }
                else
                {
                    ar[i][j] = i;
                    br[i][j] = j-1;
                }

            }
           // cout << i << " " << j << " " << ar[i][j] << " " << br[i][j] << endl;
        }
    }

    string ans;

    int i=s1.size()-1,j=s2.size()-1;
    while(i>=0 && j>=0)
    {
        if(s1[i]==s2[j])
            ans.pb(s1[i]);
        int a = i;
        i = ar[i][j];
        j = br[a][j];
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 144392
#include <bits/stdc++.h>
using namespace std;
int ans,i,n;
char st[200010];
deque<char>dq;
int main()
{
   // freopen("a.in","r",stdin);
   // freopen("a.out","w",stdout);
    scanf("%s",&st);
    n=strlen(st);
    for(i=0; i<n; ++i)
    {
        if(st[i]=='S')dq.push_back(st[i]);
        else
        {
            if(!dq.empty()&&dq.back()=='S')
            {
                dq.pop_back();
                while(!dq.empty()&&dq.back()=='T')
                {
                    dq.pop_back();
                    if(!dq.empty()&&dq.back()=='S')dq.pop_back();
                    else
                    {
                        dq.push_front('T');
                        break;
                    }
                }
            }
            else dq.push_back(st[i]);
        }
        while(!dq.empty()&&dq.front()=='T')dq.pop_front(),++ans;
    }
    while(!dq.empty())dq.pop_back(),++ans;
    printf("%d\n",ans);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a,b,c,i; cin >> a>>b>>c;
    bool can = false;
    for(; i < b; i++){
        if((a * i) % b == c){
            can = true;
            break;
        }
    }
    cout <<(can ? "YES" : "NO") <<endl;
    
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class WarshallFloyd{
	vector<vector<ll>> dist;
public:
	void CalcShortestPath(ConnectNodeInfo& connect){
		int V = connect.size();
		dist.resize(V,vector<ll>(V,1LL<<60));

		REP(i,V){
			dist[i][i]=0;
			int U = connect[i].size();
			REP(j,U){
				dist[i][connect[i][j].first] = connect[i][j].second;
			}
		}

		REP(k,V){
			REP(i,V){
				REP(j,V){
					if(dist[i][k]!=(1LL<<60) && dist[k][j]!=(1LL<<60)){
						dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
					}
				}
			}
		}
	}
	bool HasNegativeLoop(){
		bool flag = false;
		for(int i=0,ei=dist.size();i<ei;i++){
			if(dist[i][i]<0){
				flag = true;
				break;
			}
		}
		return flag;
	}
	ll CalcDiameter(){
		ll diameter = -(1LL<<60);
		int V = dist.size();
		REP(i,V){
			REP(j,V){
				if(dist[i][j]<1LL<<60){
					diameter = max(diameter,dist[i][j]);
				}
			}
		}
		return diameter;
	}
	ll GetDistance(int i,int j){
		return dist[i][j];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in();
	ConnectNodeInfo connect(10);
	REP(i,10){
		REP(j,10){
			int v=in();
			if(i==j) continue;
			connect.AddDirectionalConnection(i,j,v);
		}
	}

	WarshallFloyd WF;
	WF.CalcShortestPath(connect);
	
	ll S=0;
	REP(i,H){
		REP(j,W){
			int V=in();
			if(V>=0)  S+= WF.GetDistance(V,1);
		}
	}

	out(S);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int x=sc.nextInt();

        if(x<=500*k){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int gcd(int a, int b){
  if(a > b) swap(a,b);
  if(a == 0) return b;
  return gcd(b%a,a);
}

int main(){
  int p,n;
  while((p = getInt()) + (n = getInt())){
    double pp = sqrt((double)p);
    int x,y,u,v;
    double g1 = 1e10;
    double g2 = 1e10;

    rep(i,1,n+1){
      double jj = i / pp;
      int j1 = (int)(floor(jj) + 1e-10);
      int j2 = (int)(ceil(jj)  + 1e-10);

      if(gcd(i,j1) == 1){
        double t = (double) i / j1;
        double g = t - pp;
        //printf("i=%d, j1=%d, g=%f\n",i,j1,g);
        if(g < g1){
          g1 = g;
          x = i;
          y = j1;
        }
      }
      if(gcd(i,j2) == 1){
        double t = (double) i / j2;
        double g = pp - t;
        //printf("i=%d, j2=%d, g=%f\n",i,j2,g);
        if(g < g2){
          g2 = g;
          u = i;
          v = j2;
        }
      }
    }

    printf("%d/%d %d/%d\n",x,y,u,v);
  }
  return 0;
}

Measured memory_bytes: 832
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= H && A[r] > A[largest] ) largest = r;

  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if ( H < 1 ) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] ) {
    swap(A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  char com[10];

  while ( 1 ) {
    scanf("%s", com);
    if ( com[0] == 'e' && com[1] == 'n' ) break;
    if ( com[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\n", extract());
    }
  }

  return 0;
}


Measured memory_bytes: 6464
#include<stdio.h>

#define MOD 1000000007
#define MAX_GRID 100000

/*****memo vector for calculation n!*****/
long factorial[2*MAX_GRID];
long inverse_f[2*MAX_GRID];

long mod(long Num){
	if(Num>=MOD) Num%=MOD;
return Num;
}

long inverse_element(long Num){
	long inv=1;
	long k=MOD-2;

	while(k){
		if(k&1) inv=mod(inv*Num);
		Num=mod(Num*Num);
		k>>=1;
	}

return inv;
}

void setup(int *h, int *w, int *a, int *b){
	scanf("%d %d %d %d", h, w, a, b);
	
	factorial[0]=1;
	for(int n=1; n<(*h+*w); n++){
		factorial[n]=mod(n*factorial[n-1]);
	}

	inverse_f[*h+*w-1]=inverse_element(factorial[*h+*w-1]);
	for(int n=*h+*w-1; n>0; n--) {
		inverse_f[n-1]=mod(n*inverse_f[n]); 
	}
return;
}

long C(int n, int k){
return mod(factorial[n]*mod(inverse_f[k]*inverse_f[n-k]));
}

long sumup(int *h, int *w, int *a, int *b){
	long N=0;
	for(int k=1; k<=*h-*a; k++){
		N += mod(C(*b+k-2, k-1) * C(*w+*h-*b-k-1, *h-k));
	}
return mod(N);
}

int main(void){
	int height, width, a, b;

	setup(&height, &width, &a, &b);
	printf("%ld\n", sumup(&height, &width, &a, &b));
return 0;
}

Measured memory_bytes: 3328
#include<iostream>
int main(){int m=1,n=999999,o,c=n/2+1,d;bool*v=new bool[c],*p=v+c;for(;*--p=1,p!=v;);for(;m<499;m++)for(o=m*2+1,d=o*3;v[m]&&d<n+1;d+=o*2)v[d/2]=0;for(;!(std::cin>>n).eof();printf("%d\n",c))for(c=n-->1,m=1;m<n/2+1;)c+=v[m++];delete[]v;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ifor(i,n) for(i=0;i<n;i++)
#define ll long long
///vector<int>vec;
///sort(s.begin(),s.endl());
///sort(ara,ara+n);
bool sortby(const pair<int,string> &i,const pair<int,string> &j)
{
    if(i.first==j.first) return i.second<j.second; return i.first>j.first;
}
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int i,n,t,p,j=0;
     cin>>n;
     map<string,int> print;
     vector<pair<int,string>> arr;
     string s,m;
     while(n--)
     {
         cin>>s;
         print[s]+=1;
     }

     for(auto i:print)
     {
         arr.push_back(make_pair(i.second,i.first));
     }

     sort(arr.begin(),arr.end(),sortby);


  int x=arr[0].first;
    for (auto i:arr)
    {
        if(i.first<x)break;
        cout<<i.second<<endl;

    }




     return EXIT_SUCCESS;
}


Measured memory_bytes: 28272
#include <iostream>

typedef long long ll;

using namespace std;

int main() {
    ll n, sum = 0, prev = -1, now = 0;
    bool flag = true;
    cin >> n;
    for (ll i = 0; i < n; ++i) {
        cin >> now;
        if (now >= prev + 2) {
            flag = false;
            break;
        }
        if (now != prev + 1) sum += prev;
        prev = now;
    }
    if (prev != 0) sum += prev;
    cout << (flag ? sum : -1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

int main(){
    int n; cin >> n;
    double cnt = 0;
    rep(i, n){
        double u; cin >> u;
        string x; cin >> x;
        if(x=="BTC"){
            cnt += u*380000;
        }
        else{
            cnt += u;
        }
    }
    printf("%.6f\n", cnt);

}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void fnInput(llong& rnLow, llong& rnHigh, int& rnDivsor1, int& rnDivsor2)
{
  cin >> rnLow >> rnHigh >> rnDivsor1 >> rnDivsor2;
}

llong fnAntiDivCnt(llong nNum, int nDivsor1, int nDivsor2)
{
  static llong stnDivLcm = 0;

  if (!stnDivLcm)
  {
    int nDividend = max(nDivsor1, nDivsor2);
    int nDivisor  = min(nDivsor1, nDivsor2);

    while (nDividend % nDivisor)
    {
      int nRemndr = nDividend % nDivisor;
      nDividend = nDivisor;
      nDivisor  = nRemndr;
    }
    stnDivLcm = (llong)nDivsor1 * (nDivsor2 / nDivisor);
  }
  llong nDiv1Cnt = nNum / nDivsor1;
  llong nDiv2Cnt = nNum / nDivsor2;
  llong nDLcmCnt = nNum / stnDivLcm;

  return nNum - (nDiv1Cnt + nDiv2Cnt - nDLcmCnt);
}
  
int main()
{
  llong nLow, nHigh;
  int nDivsor1, nDivsor2;

  fnInput(nLow, nHigh, nDivsor1, nDivsor2);
  cout << fnAntiDivCnt(nHigh, nDivsor1, nDivsor2) - fnAntiDivCnt(nLow - 1, nDivsor1, nDivsor2);
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,mod;
ll fac[3010],ifac[3010],f[3010][3010];
ll C(int n,int m){return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
ll fp(ll a,ll k,ll mod){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
int main(){
	read(n);read(mod);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	ifac[n]=fp(fac[n],mod-2,mod);
	for(int i=n;i;i--) ifac[i-1]=ifac[i]*i%mod;
	for(int i=0;i<=n;i++) f[i][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			f[i][j]=(f[i-1][j]*(j+1)+f[i-1][j-1])%mod;
	ll ans=0;
	for(int i=0;i<=n;i++){
		ll now=0,tmp=fp(2,n-i,mod),cef=fp(2,fp(2,n-i,mod-1),mod),k=1;
		for(int j=0;j<=i;j++){
			now=(now+f[i][j]*k)%mod;
			k=k*tmp%mod;
		}
		now=now*cef%mod;
		ans=(ans+(i&1?-1:1)*now*C(n,i))%mod;
	}
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}


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


int main(){
	string S;
	cin >> S;
	vector<bool> alpha(26);
	int N = S.size();
	string s = "abcdefghijklmnopqrstuvwxyz";
	rep(i,N){
		alpha[S[i] - 'a'] = true;
	}
	rep(i,26){
		if(alpha[i] == false){
			cout << s[i] << endl;
			return 0;
		}
	}
	 cout << "None" << endl;
	 return 0;
}












Measured memory_bytes: 3708
#include <cstdio>
int N, M, p, d, val[100009], a[100009], dp[150009];
int main() {
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) scanf("%d %d", &d, &p), val[p - 1] = d;
	for (int i = 0; i < N - M; i++) scanf("%d", &a[i]);
	int l = 0, r = 1000000009;
	while (r - l > 1) {
		int m = (l + r) >> 1; p = 1;
		for (int i = 0; i < N - M; i++) {
			if (a[i] >= m) p++;
		}
		for (int i = 0; i < N; i++) dp[i] = (val[i] ? (val[i] >= m ? 0 : p) : 1);
		for (int i = 0; 2 * i < N; i++) {
			d = dp[i + N] = 0;
			for (int j = i * 3; j < i * 3 + 3; j++) dp[i + N] += dp[j], d = d > dp[j] ? d : dp[j];
			dp[i + N] -= d;
		}
		if (dp[N + (N >> 1) - 1] < p) l = m;
		else r = m;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}



//提出コード↓

int x, a;




int main() {
	cin >> x >> a;
	if (x < a) cout << 0 << endl;
	else cout << 10 << endl;


	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>
#include <algorithm>
#define rep(i,start,n) for(int i=start ; i<n ; i++)
#define REP(i,start,n) for(int j=start ; j<=n ; j++)

using namespace std;

int main(){

  int x=0;                               //???????????°
  int a=0,b=0;                           //??????????????¨??????
  string first,change,sent;                   //???????????¨??????????????§??????

  cin >> first;                            //???????????????????????\???
  cin >> x;                                //???????????°?????\???

  rep(i,0,x){                             //?????????????????¨????????????

    cin >> change >> a >> b ;                //?????????????????????????????¨???????????\???

    if(change == "replace"){                 //??????????????????????????´???
      cin >> sent;                           //?????????????????????????????\???
      REP(j,a,b){                            //a~b???????????§??????????????????
        first[j] = sent[j-a];                //???????????????????????\?????????????????????????§?????????????
      }
    }
    else if(change =="reverse"){                       //????????????????????\??????????????´???
      reverse(first.begin() + a,first.begin() + b + 1);                //reverse??¢??°?????¨??????????????????????????????
    }
    else if(change =="print"){                      //??¨????????´???
      REP(j,a,b){                                        //??¨?????¨??????????????????
        cout << first[j];                              //??¨???
        if(j==b){                                       //??????????????????????????£?????¨??????????????????
          cout << endl;
        }
      }
    }
  }

  return 0;

}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s;
    cin>>t;
    t.pop_back();

    if(t==s)

        cout<<"Yes";


    else
        cout<<"No";
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){
	int i, n;
	
		scanf("%d", &n);
		
		for(i = 0; i < n; i++){
			double x1, y1, x2, y2, x3, y3, px, py, x, s, r, a1 ,a2, b1, b2, c1, c2;
			
			scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
			a1 = 2 * (x2 - x1);
			b1 = 2 * (y2 - y1);
			c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		
			a2 = 2 * (x3 - x1);
			b2 = 2 * (y3 - y1);
			c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		
			px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
			py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
			
			x = 0.0;
			s = (x1 - px) * (x1 - px) + (y1 - py) * (y1 - py);
			r = s / 2.0;
			
			while(r != x){
				x = r;
				r = (r + s / r) / 2.0;
			}
			
			if(r < 0) r *= -1;
		
			printf("%.3lf %.3lf %.3lf\n", px, py, r);
		}
	
	return 0;
}

Measured memory_bytes: 664
import java.util.Scanner;

public class Main{
    double[] hgt = {185.0, 180.0, 175.0, 170.0, 165.0, 0.0};

    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = sc.nextInt();
	    if(n == 0) break;
	    String[] str = new String[6];
	    for(int i = 5; i >= 0; i--)
		str[i] = Integer.toString(6-i)+":";

	    for(int i = 0; i < n; i++){
		double t = sc.nextDouble();
		for(int j = 0; j < 6; j++)
		    if(t >= hgt[j]){
			str[j] += "*";
			break;
		    }
	    }

	    for(int i = 5; i >= 0; i--)
		System.out.println(str[i]);
	}
    }

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define gc getchar()
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){char ch=gc;int w=1,s=0;while(!isdigit(ch)){if(ch=='-') w=-1;ch=gc;};while(isdigit(ch)){s=s*10+ch-'0';ch=gc;} return w*s;}
multiset<string> q; 
int main()
{
	int a=read(),b=read(),c=read();
	for(rint i=1;i<=a;++i) q.insert("a");
	for(rint i=1;i<=b;++i) q.insert("b");
	for(rint i=1;i<=c;++i) q.insert("c");
	while(q.size()>=2)
	{
		string s=(*q.begin())+(*q.rbegin());
		q.erase(q.begin());
		q.erase(--q.end());
		q.insert(s);
	}
	cout<<(*q.begin());
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	double a,b;
	scanf("%lf %lf",&a,&b);
	printf("%f",a/b);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Comparator.reverseOrder());

        for(int i = 0; i < N; i++){
            pq.add(sc.nextInt());
        }

        for(int i = 0; i < M; i++){
            pq.add(pq.poll() / 2);
        }

        long minSum = 0;
        for(int i = 0; i < N; i++){
            minSum = minSum + pq.poll();
        }

        System.out.println(minSum);

    }
}






Measured memory_bytes: 61180
#include<bits/stdc++.h>
#define pb push_back
#define int long long
//#define M 998244353
#define M 1000000007
using namespace std;
const int inf=4e18;
const int MX=100;
const int MN=-100;
const double pi=3.14159265358979;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,a,b;cin>>n>>a>>b;
	if(b<a)
		swap(a,b);
	if((b-a)&1)
		cout<<min({a+(b-a)/2,b-1,n-a,n-b+1+(b-a)/2})<<endl;
	else
		cout<<(b-a)/2<<endl;
}

Measured memory_bytes: 256