akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    map<string,int> mp;
    int maxi = 0;
    for(int i = 0; i < N; ++i) {
        string S; cin >> S; 
        mp[S]++; 
        chmax(maxi,mp[S]);   
    }
    vector<string> ans;
    for(auto& e:mp) {
        if(e.second==maxi) {
            ans.push_back(e.first);
        }
    } 
    sort(ALL(ans));
    for(auto e:ans) cout << e << endl;


    return 0;
}

Measured memory_bytes: 28020
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N,cnt;
string s;

int main() {
	cin >> s;
	N = s.length();
	FOR(i, 0, N) {
		if (s[i] == 'g') {
			cnt++;
		}
		else {
			cnt--;
		}
	}
	ct(cnt / 2);


	
	system("pause");
	return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#include <stack>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	stack<int> st;
	string s;
	int a, b;
	while (cin >> s) {
		if (s == "+") {
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(a + b);
		}
		else if (s == "-") {
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(b - a);
		}
		else if (s == "*") {
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(a * b);
		}
		else st.push(atoi(s.c_str()));
	}

	cout << st.top() << endl;
	return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

int dp[45];

void init() {
    dp[0] = dp[1] = 1;
    rep(i, 2, 45) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
}

signed main() {
    int N;
    cin >> N;
    init();
    cout << dp[N] << "\n";
}



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

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N+2), B(N+2);
    for(int64_t i=0; i<=N; i++) {
        cin >> A[i];
    }
    for(int64_t i=N; i>=0; i--) {
        B[i] = B[i+1] + A[i];
    }

    int64_t ans = 0;
    int64_t now = 1;
    for(int64_t i=0; i<=N; i++) {
        if(A[i] > now) {
            cout << -1 << endl;
            return 0;
        } else {
            ans += now;
            now = (now - A[i]) * 2;
            now = min(now, B[i+1]);
        }
    }

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


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int a,b;
    cin >> a >> b;
    if((a+b)%2 == 0)
        cout << (a+b)/2;
    else
        cout << "IMPOSSIBLE";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll N, M;

vector<vector<edge>> g;

vector<ll> go;
vector<ll> back;

stack<ll> hist;

bool dfs(ll v){//サイクルが検出出来たらtrueを返す
	go[v] = 1;
	
	hist.push(v);

	for (edge e : g[v]) {
		ll w = e.to;

		if (go[w] == 0) {
			bool b = dfs(w);
			if (b == 1) { return 1; }
		}

		if (go[w] == 1 && back[w] == 0) { hist.push(w); return 1; }
	}

	back[v] = 1;
	hist.pop();

	return 0;

}


int main() {

	cin >> N >> M;

	g.resize(N + 1);

	vector<vector<ll>> mat(N + 1, vector<ll>(N + 1, 0));

	repn(i, M) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back({ i,b,0 });
		mat[a][b] = 1;
	}

	go.assign(N + 1, 0);
	back.assign(N + 1, 0);

	repn(i, N+1) {

		if (i == N+1) { cout << -1; return 0; }

		if (go[i] == 1) { continue; }
		
		while (!hist.empty()) { hist.pop(); }

		bool b=dfs(i);

		if (b == 1) { break; }
		
	}

	vector<ll> cycle;

	while (!hist.empty()) {
		if (cycle.size() > 1 && cycle[0] == hist.top()) { break; }
		cycle.push_back(hist.top());

		hist.pop();
	}

	reverse(cycle.begin(), cycle.end());

	ll M = cycle.size();

	vector<bool> sub(M, 1);

	rep(i, M) {
		if (sub[i] == 0) { continue; }

		int J = i + 1;

		repn(j, M - 1) {
			if (sub[(i+j)%M]==1&&mat[cycle[i]][cycle[(i + j) % M]] == 1) { J = i + j; }
			//cout << cycle[i] << cycle[(i + j) % M] << mat[cycle[i]][cycle[(i + j) % M]] << endl;
		}

		//cout << i << J << endl;

		for (int j = i + 1; j < J; j++) {
			sub[j%M] = 0;
		}
	}

	ll K = 0;
	rep(i, M) { if (sub[i] == 1) { K++; } }

	cout << K << endl;

	rep(i, M) {
		if (sub[i] == 1) { cout << cycle[i] << endl; }
	}



	


	
	system("PAUSE");

	

}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

vi a,c,d;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,k;
    cin>>n>>k;
    in(a,n);
    c.assign(n,n);
    for(int i=0;i<k;i++){
        d.assign(n+1,0);
        if(a==c)break;
        for(int j=0;j<n;j++){
            d[max(0ll,j-a[j])]++;
            d[min(n-1,j+a[j])+1]--;
        }
        for(int j=1;j<n;j++){
            d[j]+=d[j-1];
        }
        for(int j=0;j<n;j++){
            a[j]=d[j];
        }
    }
    print(a);

    return 0;
}

Measured memory_bytes: 7964
// D - 3N Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VL = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define pq priority_queue
#define pb push_back

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

	int N2 = N*2, N3 = N*3;
	VL A1, A2, A3, F(N+1), B(N+1);
	ll fsum = 0, bsum = 0;
	pq<int> fque, bque;

	rp(i, 0, N3){
		int a;cin>>a;
		if(i < N){
			fque.push(-a);
			fsum += a;
			A1.pb(a);
		}
		else if(i >= N2){
			bque.push(a);
			bsum += a;
			A3.pb(a);
		}
		else A2.pb(a);
	}

	F[0] = fsum;
	for(int i=0; i<N; ++i){
		fque.push(-A2[i]);
		fsum += A2[i] - (-fque.top());
		F[i+1] = fsum;
		fque.pop();
	}

	B[N] = bsum;
	for(int i=N-1; i>-1; --i){
		bque.push(A2[i]);
		bsum += A2[i] - (bque.top());
		B[i] = bsum;
		bque.pop();
	}

	ll maxfb = LLONG_MIN;
	rp(i, 0, N+1) maxfb = max(maxfb, F[i]-B[i]);
	cout<< maxfb <<endl;
}

Measured memory_bytes: 5872
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,sum;
	int a[50+5];
	while (cin>>n>>k)
	{
		sum=0;
		for (int i=0;i<n;i++)
		cin>>a[i];
		sort(a,a+n);
		for (int i=n-1;i>=n-k;i--)
		sum=sum+a[i];
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,ans=0;cin>>n>>m;
  lvector v(m,0);rep(i,m) cin>>v[i];
  if(m!=1&&n<m) {
    sort(v.begin(),v.end());
    lvector d(m-1,0);
    rep(i,m-1) d[i]=v[i+1]-v[i];
    sort(d.begin(),d.end());
    rep(i,m-n) ans+=d[i];
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin >> b;
  if(b == 'A') cout << "T" <<endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'G') cout << 'C' << endl;
  else if(b == 'C') cout << 'G' << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int k,s,i,j,x,c=0;
    scanf("%d %d",&k,&s);
    for(i=0; i<=k; i++)
    {
        for(j=0; j<=k; j++)
        {
            x=s-(i+j);
                if(x>=0 && x<=k)
                {
                    c++;
                }
        }
    }
    printf("%d\n",c);
    return 0;
}


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

using namespace std;

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

ll mod = 1e9 + 7;

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

	ll a[100001];
	ll b[100000];
	for(int i=0;i<=n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];

	ll ans = 0;
	for(int i=0;i<n;i++){
		ll m = min(a[i], b[i]);
		b[i] -= m;
		ans += m;
		ll m2 = min(a[i+1], b[i]);
		b[i] -= m2;
		a[i+1] -= m2;
		ans += m2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
}


Measured memory_bytes: 256
A=[list(map(int,input().split()))for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
flag = True
for i in range(N):
    for n in range(3):
        for m in range(3):
            if A[n][m]==b[i]:
                A[n][m]='o'
for i in range(3):
    if A[i][0]=='o' and A[i][1]=='o' and A[i][2]=='o':
        flag = False
for i in range(3):
    if A[0][i]=='o' and A[1][i]=='o' and A[2][i]=='o':
        flag = False
if A[0][0] == A[1][1]==A[2][2] =='o':
    flag = False
if A[0][2] == A[1][1] ==A[2][0]=='o':
    flag = False
if flag == False:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int m, f, n;
    do
    {
        scanf("%d %d %d ", &m, &f, &n);
        if (m != -1 || f != -1 || n != -1)
        {
            if (m == -1 || f == -1)
            {
                printf("F\n");
            }
            else if (m + f >= 80)
            {
                printf("A\n");
            }
            else if (m + f >= 65)
            {
                printf("B\n");
            }
            else if (m + f >= 50)
            {
                printf("C\n");
            }
            else if (m + f >= 30)
            {
                if (n >= 50)
{
                    printf("C\n");
                }
                else{
                    printf("D\n");
                }
            }
            else{
                printf("F\n");
            }
        }
    } while (m != -1 || f != -1 || n != -1);

    return 0;
}


Measured memory_bytes: 2032
n, k = [int(i) for i in input().split()]

si = [1]*n
di = [0]*k
ai = [0]*k
#di[0] = int(input())
#ai = [int(j) for j in input().split()]

for l in range(k):
    #print(l)
    d = int(input())
    di[l] = d
    a = [int(m) for m in input().split()]
    #ai[l] = a
    for o in range(len(a)):
        if (si[a[o-1]-1] == 1):
            si[a[o-1]-1] = 0

print(sum(si))


Measured memory_bytes: 9208
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;


const int dx[] = {+1, 0, 0, 0, 0,+1,+1,+1,-1,+1,+1,-1,-1};
const int dy[] = {0, +1, 0,+1,+1, 0, 0,+1,+1,+1,+1,+1,+1};
const int dz[] = {0, 0, +1,+1,-1,+1,-1, 0, 0,+1,-1,+1,-1};


bool inRange(int a, int x, int b){
	return (a <= x && x <= b);
}

int Check(vector<vector<vector<int> > > &cube, int &n, int &m){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				int p = cube[i][j][k];
				if(p == 0) continue;
//				cout<< i<< " "<< j<< " "<< k<< " "<< p<< endl;
				for(int a=0;a<13;a++){
					int i2 = i + (m-1)*dx[a], j2 = j + (m-1) * dy[a], k2 = k + (m-1) * dz[a];
					if(inRange(0, i2, n-1) && inRange(0, j2, n-1) && inRange(0, k2, n-1)){
						bool flag = true;
						for(int b=0;b<m;b++){
							int q = cube[i + b*dx[a]][j + b*dy[a]][k + b*dz[a]];
							if(q != p){
								flag = false;
								break;
							}
						}
						if(flag) return p;
					}
				}
			}
		}
	}
	return 0;
}



bool solve(){
	int n, m, p;
	cin>> n>> m>> p;
	if(n==0 && m==0 && p==0) return false;
//	cout<< endl; cout<< n<< " "<< m<< " "<< p<< endl;
	
	vector<vector<vector<int> > > cube(n, vector<vector<int> >(n, vector<int>(n, 0) ) );
	int turn = -1;
	int ans1 = 0, ans2 = -1;
	for(int i=0;i<p;i++){
		int x, y;
		cin>> x>> y;
		x = x-1; y = y-1;
		for(int j=0;j<n;j++){
			if(cube[j][y][x] == 0){
				cube[j][y][x] = turn;
				break;
			}
		}
		
		if(ans1 == 0){
			ans1 = Check(cube, n, m);
			if(ans1 != 0) ans2 = i+1;
		}
		turn *= -1;
	}
	
/*	for(int i=n-1;i>=0;i--){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				cout<< " "<< cube[i][j][k];
			}
			cout<< endl;
		}
		cout<< endl;
	}
*/	
	if(ans1){
		cout<< ((ans1 == 1) ? "White" : "Black")<< " "<< ans2<< endl;
	}else{
		cout<< "Draw"<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());
	return 0;
}

 

Measured memory_bytes: 1220
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
 
void init();
void solve();
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
 
#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
 
#define MOD 1000000007
 
signed main()
{
	init();
	solve();
}
 
int H, W;
vector<vector<string> > v;

void init()
{
  cin >> H >> W;
  v.resize(H);
  rep(i, H) {
    v[i].resize(W);
    rep(j, W) {
      cin >> v[i][j];
    }
  }
}
 
void solve()
{
  rep(i, H) rep(j, W) {
    if (v[i][j] == "snuke") {
      cout << (char) ('A' + j) << i + 1 << endl;
    }
  }
}

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

int main(){
    cin>>N>>M;
    vector<int> lst[M];
    rep(i,M){
        int k;cin>>k;
        rep(j,k){
            int s;cin>>s;
            lst[i].push_back(s);
        }
    }
    vector<int> P(M,0);
    rep(i,M)cin>>P[i];
    //bitで全通り試す.
    int ans = 0;
    rep(i,pow(2,N)){
        bool flg = 0;
        rep(j,M){
            //電球jがついているか否かを調べる.
            int cnt = 0;
            rep(k,lst[j].size()){
                if((i >> (lst[j][k]-1)) & 1){
                    cnt++;
                }
            }
            if(cnt%2 != P[j])flg = 1;
        }
        if(flg == 1)continue;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define FOR(k,a,b) for(ll k=(a); k < (b); k++)
#define FORE(k,a,b) for(ll k=(a); k <= (b); k++)
#define REP(k,a) for(ll k=0; k < (a); k++)

int main()
{
   int n;
   cin >> n;
   int arr[n];

   for(int i=1; i<=n; i++)
   	cin >> arr[i];

   int t;
   int sum1 = 0,sum2=0;
   for(int i=1; i<=n; i++)
   	sum2+=arr[i];

   int ans = INT_MAX;
   for(t=1; t<n; t++)
   {
   		sum1+=arr[t];
   		sum2-=arr[t];
   		//cout<<sum1<<" "<<sum2<<endl;
   		ans = min(abs(sum1-sum2),ans);
   }
   cout<<ans;
   cout << endl;
   return 0;
}
 

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

ll N;
ll A[100002];
ll sum;
int main()
{
	cin>>N;
	sum=0;
	rep1(i,N){
		cin>>A[i];
		sum+=abs(A[i]-A[i-1]);
	}
	sum+=abs(A[N]);
	ll res;
	rep1(i,N){
		res=sum;
		res=res-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]);
		cout<<res<<endl;
	}
}

Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <algorithm>

const int maxn = 1e5 + 20;

int N, K;
int a[maxn];
long long ans;

int main()
{
	scanf("%d%*d", &N);
	
	for(int i = 1; i <= N; i++) scanf("%d", &a[i]);
	
	for(int i = 2, pmin = a[1]; i <= N; i++)
	{
		K = std::max(a[i] - pmin, K);
		pmin = std::min(pmin, a[i]);	
	}
	
	for(int i = 2, pmin = a[1]; i <= N; i++)
	{
		if(a[i] - pmin >= K)
		{
			ans += a[i] - (pmin + K - 1);
			a[i] = pmin + K - 1;
		}
		
		pmin = std::min(pmin, a[i]);
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	int n;
	cin >> n;
	set<int> a;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		a.insert(x);
	}
	int m;
	cin >> m;
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		a.insert(x);
	}
	for(auto i:a)cout << i << '\n';
    return 0;
}



Measured memory_bytes: 21956
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;


static class P
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToList();
        //次数が3以上の頂点がサーキットの交差になる
        //いい感じでほどくことでグラフが輪っかに分かれる
        //サーキットを小さく砕いていく
        //次数2の部分は0にして辺を短縮
        //そして2方向に再帰を飛ばす
        //もし自己ループがあったら自己ループ2つを消去して再帰を登る
        //
        //短縮先が次数2であれば同様に
        //
        //偶数なのであれば
        HashSet<int>[] neighbours = Enumerable.Repeat(0, nm[0]).Select(_ => new HashSet<int>()).ToArray();
        for (int i = 0; i < nm[1]; i++)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            neighbours[ab[0]].Add(ab[1]);
            neighbours[ab[1]].Add(ab[0]);
        }
        if(neighbours.Any(x => x.Count % 2 != 0))
        {
            Console.WriteLine("No");
            return;
        }

        int loopCount = 0;
        Stack<int> stack = new Stack<int>();
        for (int i = 0; i < nm[0]; i++) stack.Push(i);
        while (stack.Count > 0)
        {
            var elem = stack.Pop();
            if (neighbours[elem].Count != 2) continue;

            var arr = neighbours[elem].ToArray();

            neighbours[elem].Clear();
            neighbours[arr[0]].Remove(elem);
            neighbours[arr[1]].Remove(elem);
            if (!neighbours[arr[0]].Add(arr[1]) & !neighbours[arr[1]].Add(arr[0]))
            {
                neighbours[arr[0]].Remove(arr[1]);
                neighbours[arr[1]].Remove(arr[0]);
                loopCount++;
            }
            stack.Push(arr[0]);
            stack.Push(arr[1]);
        }

        Console.WriteLine(neighbours.Any(x => x.Count > 2) || loopCount >= 3 ? "Yes" : "No");
    }
}

Measured memory_bytes: 39300
#include <stdio.h>
 
#define BAGGAGE 132000
#define TRACK 132000
 
int checkP(int n, int k, int w[], int P) {
  int i, j, W[TRACK]= {0};
 
 
  j = 1;
  for (i = 0; i < n; i++) {
    if ((W[j] + w[i]) <= P) {
      W[j] += w[i];
    
    }
    else {
      i--;
      j++;
      //     
      if (k < j) {
    //  
    return checkP(n, k, w, P + 1);
      }
    }
  }
 
  return P;
}
 
 
int main(void) {
  int i, n, k, w[BAGGAGE] = {0}, P;
  double W = 0;
   
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    W += w[i];
  }

  P = (int)(W / k + 0.9);
  for (i = 0; i < n; i++) {
    if (P < w[i])
      P = w[i];
  }
 
  P = checkP(n, k, w, P);
  printf("%d\n", P);
 
  return 0;
}

Measured memory_bytes: 3788
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let line: String = read();
    let mut cnt: i32 = 0;
    for x in 0..3 {
        if line.chars().nth(x).unwrap() == '1' {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

long long x[100][100];
long long y[100][100];

int main()
{
	unsigned int n, m, l;

	cin >> n >> m >> l;
	for (unsigned int i = 0; i < n; ++i) {
		for (unsigned int j = 0; j < m; ++j) {
			cin >> x[i][j];
		}
	}
	for (unsigned int i = 0; i < m; ++i) {
		for (unsigned int j = 0; j < l; ++j) {
			cin >> y[i][j];
		}
	}

	for (unsigned int i = 0; i < n; ++i) {
		for (unsigned int j = 0; j < l; ++j) {
			long long z = 0;
			for (unsigned int k = 0; k < m; ++k) {
				z += x[i][k] * y[k][j];
			}
			cout << z;
			if (j + 1 == l)
				cout << endl;
			else
				cout << " ";
		}
	}

	return 0;
}



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

int main()
{
	int n,t=0;
	cin>>n;
	double sum=0.0;
	for(int i=1;i<=n;i++)
	{
		if(i%2)
			t++;
	}
	sum=1.0*t/n;
	printf("%.10f",sum);

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	//0135 start
	//0157 cording end
	//dir is 0 = n, 1 = E, 2 = S, 3 = W

	int INF = 1 << 24;
	int [] vx = {0,1,0,-1};
	int [] vy = {-1,0,1,0};
	int w,h;

	class C implements Comparable<C>{
		int x,y,cost, dir;


		public C(int x, int y, int cost, int dir) {
			this.x = x;
			this.y = y;
			this.cost = cost;
			this.dir = dir;
		}

		@Override
		public int compareTo(C o) {
			if(this.cost < o.cost) return -1;
			if(this.cost > o.cost) return 1;
			return 0;
		}

		@Override
		public String toString() {
			return "C [x=" + x + ", y=" + y + ", cost=" + cost + ", dir=" + dir
					+ "]";
		}


	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h) == 0) break;
			int [][] data = new int[h][w];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					data[i][j] = sc.nextInt();
				}
			}
			int [] option = new int[4];
			for(int i = 0; i < 4; i++){
				option[i] = sc.nextInt();
			}

			PriorityQueue<C> open = new PriorityQueue<Main.C>();
			open.add(new C(0, 0, 0, 1));

			int [][][] close = new int[h][w][4];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					Arrays.fill(close[i][j], INF);
				}
			}
			close[0][0][1] = 0;
			int ans = -1;
			while(! open.isEmpty()){
				C now = open.poll();
				//System.out.println(now);
				if(now.x == w - 1 && now.y == h - 1){
					ans = now.cost;
					break;
				}
				//マップの命令
				int op = data[now.y][now.x];
				if(op != 4){
					int nextdir = (now.dir + op) % 4;
					int xx = now.x + vx[nextdir];
					int yy = now.y + vy[nextdir];
					//System.out.println("dir = " + nextdir + " xx = " + xx + " x = " + now.x + "yy = " + yy + " y = " + now.y);
					if(isOK(xx, yy)){
						int nextcost = now.cost;
						if(close[yy][xx][nextdir] > nextcost){
							open.add(new C(xx, yy, nextcost, nextdir));
							close[yy][xx][nextdir] = nextcost;
						}
					}
				}

				//オプション
				for(int i = 0; i < 4; i++){
					int nextdir = (now.dir + i) % 4;
					int xx = now.x + vx[nextdir];
					int yy = now.y + vy[nextdir];
					//System.out.println("adir = " + nextdir + " xx = " + xx + " x = " + now.x + "yy = " + yy + " y = " + now.y);
					if(! isOK(xx, yy)) continue;
					int nextcost = now.cost + option[i];
					if(close[yy][xx][nextdir] <= nextcost) continue;
					open.add(new C(xx, yy, nextcost, nextdir));
					close[yy][xx][nextdir] = nextcost;
				}
			}
			System.out.println(ans);


		}
	}

	private boolean isOK(int xx, int yy) {
		if(0 <= xx && xx < w && 0<= yy && yy < h){
			return true;
		}
		return false;
	}

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

Measured memory_bytes: 12000
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <cfloat>
using namespace std;
int main (){
int a,b,c,d;
cin >> a>>b>>c>>d;
if(a*b<c*d){
    cout << c*d;
}else if(c*d<a*b){
cout << a*b;
}else{
cout << a*b;
}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int N, K;
  string s;
  cin >> N >> s >> K;

  char ch = s[K-1];

  for(int i = 0; i < N; i++){
    if(s[i] != ch){
      s[i] = '*';
    }
  }

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,i,m,e,j;
	char s[10001];
	while(1){
		cin>>n;
		if(n==0) break;
		for(i=0;i<n;i++){
			cin>>m>>e>>j;
			if(m==100||e==100||j==100||(m+e)/2>=90||(m+e+j)/3>=80) s[i]='A';
			else if((m+e+j)/3>=70||((m+e+j)/3>=50&&(m>=80||e>=80))) s[i]='B';
			else s[i]='C';
		}
		for(i=0;i<n;i++) cout<<s[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
using namespace std;
int arr[maxn];
int n,a,b;
bool check(ll mid) {
	int base = (1e9 / b + 1 >= mid ? b * mid : 1e9) , dif = a - b;
	for(int i=1;i<=n;i++)
		if(arr[i] > base)
			mid -= (arr[i] - base - 1) / dif + 1;
	return mid >= 0;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	ll l = 1 , r = (ll)1e14 , mid;
	while(true) {
		if(r - l < 3) {
			for(mid=r;mid>=l && check(mid);mid--);
			mid++;
			break;
		}
		mid = (l+r)>>1;
		if(check(mid))
			r = mid;
		else
			l = mid + 1;
	}
	cout << mid << endl;
	return 0;
}


Measured memory_bytes: 764
x1,y1,x2,y2 = map(int, input().split())

d1 = x2-x1
d2 = y2-y1

x3 = x2 -y2 +y1
y3 = y2 +x2 -x1

x4 = x3 +x1 -x2
y4 = y3 +y1 -y2

print(x3,y3,x4,y4)

Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DScoreAttack solver = new DScoreAttack();
        solver.solve(1, in, out);
        out.close();
    }

    static class DScoreAttack {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            BellmanFord bf = new BellmanFord(n);
            for (int i = 0; i < m; i++) {
                bf.addEdge(in.nextInt() - 1, in.nextInt() - 1, -in.nextInt());
            }
            try {
                out.println(-bf.shortestPath(0, n - 1));
            } catch (RuntimeException ex) {
                out.println("inf");
            }
        }

    }

    static class BellmanFord {
        int nodes;
        List<BellmanFord.Edge> edges;
        long[] distance;

        public BellmanFord(int n) {
            nodes = n;
            edges = new ArrayList<>();
            distance = new long[n];
        }

        public void addEdge(int from, int to, int cost) {
            edges.add(new BellmanFord.Edge(from, to, cost));
        }

        public long shortestPath(int src, int dst) {
            Arrays.fill(distance, Long.MAX_VALUE);
            distance[src] = 0;
            for (int i = 0; i < 2 * nodes; i++) {
            	boolean updated = false;
                for (BellmanFord.Edge e : edges) {
                    updated = true;
                    if (distance[e.from] < Long.MAX_VALUE && distance[e.to] > distance[e.from] + e.cost) {
                        distance[e.to] = distance[e.from] + e.cost;
                        if (i == nodes - 1 && e.to == dst) {
                            throw new RuntimeException("negative loop");
                        }
                    }
                }
                if (!updated) {
                    break;
                }
            }
            return distance[dst];
        }

        private static class Edge {
            int from;
            int to;
            long cost;

            public Edge(int from, int to, long cost) {
                this.from = from;
                this.to = to;
                this.cost = cost;
            }

        }

    }
}



Measured memory_bytes: 28624
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		double n = Integer.parseInt(sc.next());
		double k = Integer.parseInt(sc.next());

		double sum = 0;

		for (int i = 1; i <= n; i++) {
			if (i >= k) {
				sum += 1.0;
			} else {
				sum += Math.pow(0.5, Math.ceil(log2(k/i)));
			}
		}

		System.out.println(sum / n);

		sc.close();
	}

	public static double log2(double d)
	{
		return Math.log(d) / Math.log(2);
	}
}


Measured memory_bytes: 21844
N, k = map(int, input().split())
b = input()


score = 0
up1_num = 0
up2_num = 0

switch = []

prev = None
cnt =0
for i in range(N):
  if prev == None:
    prev = b[i]
    cnt = 1
    continue
    
  if prev==b[i]:
    cnt += 1
  else:
    score += (cnt-1)
    cnt = 1
    prev = b[i]
    switch.append(i)

if cnt != 0:
  score += (cnt-1)
  
  
if k <= len(switch)/2:
  score += 2*k
else:
  score += 2*(len(switch)//2)
  if len(switch)%2==1:
    score += 1
    
print(score)

Measured memory_bytes: 7164
#include <iostream>
using namespace std;
int main(){
  int x,y,s,i,j,max,s1,s2,sum,c;
  while(1){
    max=0;
    cin >> x >> y >> s;
    if(x==0&&y==0&&s==0) break;
    /*    for(i=1;i<s;i++){
      s1=i*(100+x)/100;
      cout << "s1 " << s1 << endl;
      cout << "s2 " << s2 << endl;
      cout << "s1+s2 " << s1+s2 << endl;
       
      }*/
    for(i=1;i<s;i++){
      s1=i*(100+x)/100;
      for(j=1;j<s;j++){
    s2=j*(100+x)/100;
    if(s1+s2==s){
      sum=i*(100+y)/100+j*(100+y)/100;
      if(sum>max) max=sum;  
    }
      }
    }
    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int a,b; cin >> a >> b;
	if(b > a) swap(a,b);
	forn(i,0,a) cout << b;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("1 5");
            WillReturn.Add("2 4");
            WillReturn.Add("3 6");
            //3
            //次の3種類の祭壇があります。
            //●上部に1個目、中部に1個目、下部に1個目のパーツを使った祭壇
            //●上部に1個目、中部に1個目、下部に2個目のパーツを使った祭壇
            //●上部に1個目、中部に2個目、下部に2個目のパーツを使った祭壇
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("1 1 1");
            WillReturn.Add("2 2 2");
            WillReturn.Add("3 3 3");
            //27
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("3 14 159 2 6 53");
            WillReturn.Add("58 9 79 323 84 6");
            WillReturn.Add("2643 383 2 79 50 288");
            //87
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static int UB;

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[1]);
        int[] AArr = wkArr;
        UB = AArr.GetUpperBound(0);

        SplitAct(InputList[2]);
        int[] BArr = wkArr;

        SplitAct(InputList[3]);
        int[] CArr = wkArr;

        Array.Sort(AArr);
        Array.Sort(BArr);
        Array.Sort(CArr);

        long Answer = 0;
        foreach (int EachInt in BArr) {

            int wkInd1 = ExecNibunhou1(AArr, EachInt);
            long CurrCnt = wkInd1 + 1;

            int wkInd2 = ExecNibunhou2(CArr, EachInt);
            CurrCnt *= (UB - wkInd2 + 1);

            Answer += CurrCnt;
        }
        Console.WriteLine(Answer);
    }

    //2分法で指定した値未満の最大の添字を求める
    static int ExecNibunhou1(int[] pArr, int pVal)
    {
        if (pArr[0] >= pVal) return -1;
        if (pArr[UB] < pVal) return UB;

        int L = 0;
        int R = UB;

        while (L + 1 < R) {
            int Mid = (L + R) / 2;

            bool IsOK = (pArr[Mid] < pVal);
            if (IsOK) L = Mid;
            else R = Mid;
        }
        return L;
    }

    //2分法で指定した値超えの最小の添字を求める
    static int ExecNibunhou2(int[] pArr, int pVal)
    {
        if (pArr[0] > pVal) return 0;
        if (pArr[UB] <= pVal) return UB + 1;

        int L = 0;
        int R = UB;

        while (L + 1 < R) {
            int Mid = (L + R) / 2;

            bool IsOK = (pArr[Mid] > pVal);
            if (IsOK) R = Mid;
            else L = Mid;
        }
        return R;
    }
}


Measured memory_bytes: 43284
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
struct edge{int to,cost;};
typedef pair<int,int> P;

int V,n,r,k,t,p,s,d,v,D[1001];
vector<edge> g[1001];

int main(){
	while(cin>>n&&n){
		rep(i,n)g[i].clear();
		rep(i,n){
			cin>>r>>k;
			rep(j,k){
				edge e;
				cin>>t;
				e.to=t;
				e.cost=1;
				g[r].push_back(e);
			}
		}
		cin>>p;
		rep(h,p){
			cin>>s>>d>>v;
			priority_queue<P,vector<P>,greater<P> > q;
			fill(D,D+n+1,INF);
			D[s]=0;
			q.push(P(0,s));
			while(!q.empty()){
				P pp=q.top();q.pop();
				int vv=pp.second;
				if(D[vv]<pp.first)continue;
				rep(j,g[vv].size()){
					edge e=g[vv][j];
					if(D[e.to]>D[vv]+e.cost){
						D[e.to]=D[vv]+e.cost;
						q.push(P(D[e.to],e.to));
					}
				}
			}
			if(D[d]<v)cout<<D[d]+1<<endl;
			else cout<<"NA"<<endl;
		}
	}
}

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

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cout << char('a' + 25) << endl;
    string s;
    int k;
    cin >> s;
    cin >> k;

    for (int i = 0; i < s.length(); ++i) {
        int to_fill = (26 - (s[i] - 'a')) % 26;
        if (to_fill <= k) {
            s[i] = 'a';
            k -= to_fill;
        }
    }

    k = k % 26;
    s[s.length() - 1] = (s[s.length() - 1] - 'a' + k) % 26 + 'a';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
int min_one_way(int h, int w){
    return min(h,w);
}
int min_two_way(int h, int w){
    int divh = h/3;
    int divw = w/2;
    int s1 = divh*w;
    int s2 = (h-divh)*divw;
    int s3 = (h-divh)*(w-divw);
    int min_horizon1 = min(min(s1,s2),s3);
    int max_horizon1 = max(max(s1,s2),s3);
    divh++;
    s1 = divh*w;
    s2 = (h-divh)*divw;
    s3 = (h-divh)*(w-divw);
    int min_horizon2 = min(min(s1,s2),s3);
    int max_horizon2 = max(max(s1,s2),s3);
    divw = w/3;
    divh = h/2;
    s1 = divw*h;
    s2 = (w-divw)*divh;
    s3 = (w-divw)*(h-divh);
    int min_vertical1 = min(min(s1,s2),s3);
    int max_vertical1 = max(max(s1,s2),s3);
    divw++;
    s1 = divw*h;
    s2 = (w-divw)*divh;
    s3 = (w-divw)*(h-divh);
    int min_vertical2 = min(min(s1,s2),s3);
    int max_vertical2 = max(max(s1,s2),s3);
    return min(min(max_horizon1-min_horizon1,max_horizon2-min_horizon2),min(max_vertical1-min_vertical1,max_vertical2-min_vertical2));
}
int main(void){
    int h,w;
    cin>>h>>w;
    if(h%3==0 || w%3==0){
        cout<<0<<endl;
    }
    else{
        cout<<min(min_one_way(h,w),min_two_way(h,w))<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int main() {
	ll n, k; cin >> n >> k;
	cout << n - (k - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
typedef unsigned long long ull;
typedef long long ll;
//const int INF=0x3f3f3f3f;
const int INF=1e9;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const ll M=1e9+7;
const ll maxn=1e5+7;
const int MAXN=1005;
const int MAX=2e5+5;
const int MAX_N=MAX;
const ll MOD=1e9+7;
//const double eps=0.00000001;
//ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
inline ll powMM(ll a,ll b){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
    freopen("1007.in","r",stdin);
    freopen("out.txt","w",stdout);
}

int V;//顶点数
const int MAX_V=MAX;
vector<int> G[MAX_V];//图的邻接表表示
int match[MAX_V];//所匹配的顶点
bool used[MAX_V];//DFS中用到的访问标记
//向图中增加一条连接u和v的边
void add_edge(int u,int v)
{
    G[u].push_back(v);
//    G[v].push_back(u);
}
//通过DFS寻找增广路
bool dfs(int v)
{
    used[v]=true;
    for(int i=0;i<G[v].size();i++)
    {
        int u=G[v][i],w=match[u];
        if(w<0||(!used[w]&&dfs(w)))
        {
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}
//求解二分图的最大匹配
int bipartite_matching()
{
    int res=0;
    memset(match,-1,sizeof(match));
    for(int v=0;v<V;v++)
    {
        if(match[v]<0)
        {
            memset(used,0,sizeof(used));
            if(dfs(v))
                ++res;
        }
    }
    return res;//返回的是总点数的一半
}
bool isprime(int x)
{
    if(x==1)
        return false;
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int n;
int a[(int)1e7+2];
vector<int>pos[2];
int main()
{
    scanf("%d",&n);
    int tem;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tem);
        a[tem]=1;
    }
    for(int i=tem+1;i>=1;i--)
    {
        a[i]=a[i]^a[i-1];
        if(a[i])
            pos[i%2].push_back(i);
    }
    for(int i=0;i<pos[0].size();i++)
        for(int j=0;j<pos[1].size();j++)
            if(isprime(abs(pos[0][i]-pos[1][j])))
                add_edge(i,j+pos[0].size());
    V=pos[0].size()+pos[1].size();
    int cnt=bipartite_matching();
    cnt+=((pos[0].size()-cnt)/2+(pos[1].size()-cnt)/2)*2;
    cnt+=((pos[0].size()-cnt)%2)*3;
    printf("%d\n",cnt);
}


Measured memory_bytes: 44928
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
void solve() {
  string s;
  cin>>s;
  if(s[1]=='R') cout<<"ABC";
  else cout<<"ARC";
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //cout<<"Hello World"<<"\n";
    //int t;cin>>t;while(t--)
    solve();
}

Measured memory_bytes: 3700