akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
signed main() {
	while (1) {
		string s;
		cin >> s;
		if (s == "0")break;
		int n = s.size(), ans = 0;
		rep(i, n)ans += (s[i]-'0');
		cout << ans << endl;
	}
	ggr
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(n);
	makei(i);
	say(n - i + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

inline void solve(){
  int n, k;

  cin >> n >> k;
  cout << n+1 - k fin;

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


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 int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 998244353;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint dp[3005][3005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    for(int i = a; i <= c; ++i){
        for(int j = b; j <= d; ++j){
            if(i == a && j == b) continue;
            dp[i][j] = dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * (i-1) * (j-1);
        }
    }
    cout << dp[c][d].x << endl;
    return 0;
}


Measured memory_bytes: 74196
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,D,X;
    cin>>N>>D>>X;
    REP(i,N){
        int a; cin>>a;
        X+=1+(D-1)/a;
    }
    cout<<X<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;
const long long INF = 1LL<<60; // 仮想的な無限大の値
vector<bool> seen;

Graph G;


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

    //A-Z
    int l = 0;
    bool end= false;
    for(int i=0;i < s.length();i++){
        if(end) break;
        if(s[i] == 'A'){
            for(int j = s.length()-1;j > i;j--){

                if(s[j] == 'Z'){
                    l = j-i + 1;
                    end = true;
                    break;
                }
            }

        }

    }
    cout << l << endl;
    

    return 0;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+50;
const int mod=1e9+7;

ll pw(ll x,ll n){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return ans;
}

ll X,Y,n,m,fac[N],invfac[N];

int main(){
    fac[0]=1;
    for(int i=1;i<N;++i) fac[i]=1LL*fac[i-1]*i%mod;
    for(int i=0;i<N;++i) invfac[i]=pw(fac[i],mod-2);

    scanf("%lld%lld",&X,&Y);
    if((2*X-Y)%3!=0){
        puts("0");
        return 0;
    }
    n=(2*X-Y)/3;
    m=X-2*n;
    if(n<0 || m<0){
        puts("0");
        return 0;
    }
    ll ans=fac[n+m]*invfac[n];
    ans%=mod;
    ans*=invfac[m];
    ans%=mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 31488
from collections import deque
k=int(input())
d=deque()
for i in range(1,10):
    d.append(i)
for i in range(k-1):
    x=d.popleft()
    if x%10!=0:
        d.append(10*x+(x%10)-1)
    d.append(10*x+(x%10))
    if x%10!=9:
        d.append(10*x+(x%10)+1)
print(d.popleft())

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

int gcd(int a, int b) {
    if(a<b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }
    int r = a % b;
    while(r)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n;i++)
    {
        for (int j = 1; j <= n;j++)
        {
            for (int k = 1; k <= n;k++)
            {
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum << endl;
    return 0;
}   

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int n,dist[101010];

int bfs(){
  deque<pint> dq;
  dq.push_back({1,1});
  dist[1]=1;
  while(dq.size()){
    pint p=dq.front();
    dq.pop_front();
    int now=p.first,d=p.second;
    if(dist[now]<d)continue;
    int next=(now+1)%n;
    if(dist[next]>d+1){
      dist[next]=d+1;
      dq.push_back({next,d+1});
      }
    next=(now*10)%n;
    if(dist[next]>d){
      dist[next]=d;
      dq.push_front({next,d});
      }
    }
  return dist[0];
  }      

int main(){
  cin>>n;
  rep(i,n)dist[i]=inf;
  cout<<bfs()<<endl;
  return 0;
  }


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    vc<bool> B(2005);

    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    B[0] = true;
    rep(i, N) repr(j, 2001 - A[i]) B[j + A[i]] = B[j + A[i]] | B[j];

    ll M;
    cin >> M;
    rep(i, M){
        ll m;
        cin >> m;
        cout << (B[m] ? "yes" : "no") << endl;
    }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s;
	cin >> s;

	printf("%c%d%c\n", s.front(), s.size() - 2, s.back());
	return 0;
}

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

#define ll long long
#define pb push_back
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f

int main(){
    fcin;
    int a, b, t;
    cin >> a >> b >> t;
    int ans = 0;
    for(int i = 1; i <= t; i++){
        if(i % a == 0) ans+=b;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
MOD = 10**9 + 7

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

N = int(input())
comb = Combination(N + 10)

dis = 0
for i in range(1, N + 1):
    dis += comb.ncr(N, i) * 2 * pow(8, N - i, MOD)
    dis %= MOD
ans = pow(10, N, MOD) - dis - pow(8, N, MOD)
print(ans % MOD)


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




int main()
{
	int N;
	cin >> N;
	double ans;
	if (N % 2 == 0) {
		ans = (double)(N / 2) / N;
	}
	else {
		ans = (double)(N / 2 + 1) / N;
	}

	cout << setprecision(9) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*input
2 3
AB
1 1
1 2
2 2
*/

#include<bits/stdc++.h>
using namespace std;
#define mx 200005
char st[mx];
multiset<int> mst[mx];
set<int> edge[mx];
int vis[mx];
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	scanf("%s", st+1);
	for(int i = 0; i<m; i++){
		int u, v;
		scanf("%d %d", &u, &v);
		if(edge[u].count(v));else{
			mst[u].insert(st[v]);
			mst[v].insert(st[u]); 
		}
		edge[u].insert(v);
		edge[v].insert(u);
	}
	queue<int> Q;
	for(int i = 1; i<=n; i++)
	{
		if(mst[i].count('A') == 0 || mst[i].count('B') == 0){
			Q.push(i);
			vis[i] = 1;
			// cout << i << endl;
		}
	}
	while(!Q.empty())
	{
		int u = Q.front(); Q.pop();
		for(int v : edge[u])
		{
			// assert(vis[v]);
			if(vis[v]) continue;
			if(u==11){
				// cout << v << endl;
			}
				// if(v==12){
					// cout << "hi " << mst[v].size() << endl;
					// for(int x : mst[v])
					// 	cout << char(x) << endl;
				// }
			if(v != u){
				mst[v].erase(mst[v].find(st[u]));
				edge[v].erase(edge[v].find(u));
				if(mst[v].count('A') == 0 || mst[v].count('B') == 0){
					vis[v] = 1;
					// cout << v << endl;
					Q.push(v);
				}
			}
		}
		edge[u].clear();
		mst[u].clear();
	}
	int cnt = 0;
	for(int i = 1; i<=n; i++)
	{
		if(!vis[i]){
			printf("Yes\n");
			// cout << i << endl;
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 56448
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(x: i32);
    puts!("{}\n", 1 - x);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2196
import java.util.*;

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

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

    private void run() {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();

        int[] cnt = new int[n];

        for (int i = 0; i < q; i++) {
            cnt[sc.nextInt() - 1]++;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(k - (q - cnt[i]) > 0 ? "Yes" : "No");
        }
    }
}



Measured memory_bytes: 57092
#include <iostream>

int main() {
	int year, month, day;
	int num;
	
	while(std::cin >> year >> month >> day) {
		// YYYYMMDD
		num = 10000 * year + 100 * month + day;
		if(num<18680908) std::cout << "pre-meiji" << std::endl;
		else if(num<19120730) std::cout << "meiji " << (year-1867) << " " << month << " " << day << std::endl;
		else if(num<19261225) std::cout << "taisho " << (year-1911) << " " << month << " " << day << std::endl;
		else if(num<19890108) std::cout << "showa " << (year-1925) << " " << month << " " << day << std::endl;
		else std::cout << "heisei " << (year-1988) << " " << month << " " << day << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MIN(a, b) ((a) <= (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main(){
	int r,d;
	vector<int>x(12);
	cin >> r >> d>>x.at(0);
	
	for(int i=1;i<11;i++){
		x.at(i) = x.at(i-1)*r - d;
		cout << x.at(i) << endl;
	}
	
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

ans = set()
for i in range(2**n):
    total = 0
    bits = bin(i)[2:].zfill(n)
    for j, b in enumerate(bits):
        if b == '1':
            total += A[j]
    ans.add(total)

for i in range(q):
    if M[i] in ans:
        print('yes')
    else:
        print('no')



Measured memory_bytes: 5644
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
using ll = long long;

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

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

 int main() {
	 int n, a = 0, b = 0;
	 std::cin >> n;
	 for (int i = 0;i < n;i++) {
		 std::string s, t;
		 std::cin >> s >> t;
		 if (s > t) {
			 a += 3;
		 }
		 if (s < t) {
			 b += 3;
		 }
		 if (s == t) {
			 a++;
			 b++;
		 }
	 }
	 std::cout << a << ' ' << b << std::endl;
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;
using ll = long long int;

const ll MOD = 1000000007;

template <typename T>
int cin_vec(vector<T> &vec) {
    for (auto &i : vec) {
        cin >> i;
    }
    return 0;
}

template <typename T>
int cout_vec(vector<T> vec, bool insertNewLine = true) {
    if (insertNewLine) {
        for (const auto &i : vec) {
            cout << i << endl;
        }
    } else {
        for (const auto &i : vec) {
            cout << i << flush;
        }
    }
    return 0;
}

template <typename T>
ll min_vec(std::vector<T> vec) {
    auto iter = min_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

template <typename T>
ll max_vec(std::vector<T> vec) {
    auto iter = max_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
     
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    using namespace std;
     
    int main(){
    int A,B,C,D,min,max,ans;
     
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>D;
     
    if(A>=C){
    min = A;
     
    }else{
      min = C;
    }
     
    if(B>=D){
      max = D;
    }else{
      max = B;
    }
     
    ans = max-min;
    if(ans<0){
      ans = 0;
    }
     
    cout<<ans<<endl;
     
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define wh while
using namespace std;
string s;
int main(){
    string a,b;
    cin >> a >> b;
    for(int i = 0;i<a.size();i++){
        if(a[i] != b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3492
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func check(e error) {
	if e != nil {
		log.Fatalf("error: %v\n", e)
	}
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	input := strings.Split(stdin.Text(), " ")

	a, err := strconv.Atoi(input[0])
	check(err)
	b, err := strconv.Atoi(input[1])
	check(err)

	s := (a - 1) * (b - 1)
	fmt.Println(s)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+50;
int a[maxn], b[maxn], c[maxn];
vector<int> l;
vector<int> r;
int n;
int main(){ 

	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i <= n; i++) cin >> c[i];
	sort(a+1, a+1+n);
	sort(b+1, b+1+n);
	sort(c+1, c+1+n);
	int f = 1, t = n;
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		int cur = b[i];
		while(a[f] < cur && f <= n) f++;
		l.push_back(f-1);
	}
	for(int i = n; i >= 1; i--){
		int cur = b[i];
		while(c[t] > cur && t >= 1) t--;
		r.push_back(n-t);
	}
	for(int i = 0; i < n; i++)
		ans += (ll)l[i] * (ll)r[n-i-1];
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2680
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int x = Math.max(a,b);
        int y = Math.max(x,c);
        int z = a+b+c;
       
       System.out.print(z-y);
      
    }
}

Measured memory_bytes: 23380
import Control.Applicative
import Control.Monad
import qualified Data.List
import qualified Data.Char
import Debug.Trace

main ::IO()
main = do
  n <- read <$> getLine :: IO Int
  ws <- map read . words <$> getLine :: IO [Int]
  putStrLn $ show $ solve ws

solve :: [Int] -> Int 
solve ws =
  -- traceShow slws $
  -- traceShow srws $
  ans
  where
    slws = scanl (+) 0 ws
    srws = scanr (+) 0 ws
    ans = minimum $ zipWith (\a b -> abs (a-b)) slws srws

Measured memory_bytes: 1020
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		Integer red[] = new Integer[A];
		Integer green[] = new Integer[B];
		Integer clear[] = new Integer[C];
		
		for(int i = 0; i < A; i++){
			red[i] = sc.nextInt();
		}
		for(int i = 0; i < B; i++){
			green[i] = sc.nextInt();
		}
		for(int i = 0; i < C; i++){
			clear[i] = sc.nextInt();
		}
		
		Arrays.sort(red, Collections.reverseOrder());
		Arrays.sort(green, Collections.reverseOrder());

		Integer apple[] = new Integer[X + Y + C];
		for(int i = 0; i < X; i++)apple[i] = red[i];
		for(int i = 0; i < Y; i++)apple[i + X] = green[i];
		for(int i = 0; i < C; i++)apple[i + X + Y] = clear[i];
		Arrays.sort(apple, Collections.reverseOrder());
		
		long sum = 0;
		for(int i = 0; i < X + Y; i++){
			sum += apple[i];
		}
		System.out.println(sum);
	}
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

void print_exp(const bitset<3> &b, const vi a) {
    REP(i, 4) {
        if(i == 3) cout << a[i] << "=7\n";
        else {
            cout << a[i] << (b[i] ? '+' : '-');
        }
    }
}

int main() {
    vi a(4);
    REP(i, 4) {
        char c;
        cin >> c;
        a[i] = c - '0';
    }
    for(int bit = 0; bit < (1 << 3); bit++) {
        int ans = a[0];
        bitset<3> b(bit);
        REP(i, 3) {
            if(b[i]) {
                ans += a[i + 1];
            }
            else {
                ans -= a[i + 1];
            }
        }
        if(ans == 7)  {
            print_exp(b, a);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

int main() {
	ll A, B, M; cin >> A >> B >> M;
	vector<ll> a(A), b(B),c(A),d(B);
	rep(i, A) {
		cin >> a[i]; 
		c[i] = a[i];
	}
	rep(i, B) {
		cin >> b[i];
		d[i] = b[i];
	}
	vector<ll>x(M), y(M),z(M);
	rep(i, M)cin >> x[i] >> y[i] >> z[i];
	sort(ALL(c)); sort(ALL(d));

	ll ans = c[0] + d[0];

	rep(i,M){
		ans = min(ans, a[x[i] - 1] + b[y[i] - 1] - z[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef unsigned long long ull;
#define pb(x) push_back(x) 
vector<int> str[N];
vector<ull> ha[N];

ull base[N];
map<ull,vector<int>> mp;
int cnt[26];
ull GetHash(int i,int x,int y){
    return ha[i][y]-ha[i][x-1]*base[y-x+1];
}
int main(){
    base[0]=1;
    for(int i=1;i<N;++i)base[i]=base[i-1]*133331;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        str[i].pb(0);
        int ch;
        do{
            ch=getchar();
        }while(isspace(ch));
        do{
            str[i].pb(ch-'a');
        }while(!isspace(ch=getchar()));
        ha[i].resize(str[i].size(),0);

        for(int j=1;j<str[i].size();++j){
            ha[i][j]=ha[i][j-1]*133331+str[i][j]+17;
        }
        ull hash;
        if(str[i].size()==2)
            hash=0;
        else 
            hash=GetHash(i,2,str[i].size()-1);
            
        if(mp.find(hash)==mp.end())
            mp[hash]=vector<int>(26,0);
        ++mp[hash][str[i][1]];
    }
    ull ans=0;
    for(int i=1;i<=n;++i){
        memset(cnt,0,sizeof(cnt));
        for(unsigned int j=1;j<str[i].size();++j)
            ++cnt[str[i][j]];
        for(unsigned int j=str[i].size();j>1;--j){
            ull hash=0;
            if(j!=str[i].size()){
                hash=GetHash(i,j,str[i].size()-1);
                --cnt[str[i][j]];
            }
            if(mp.find(hash)==mp.end())continue;
            vector<int> &tmp=mp[hash];
            for(int k=0;k<26;++k)
                if(cnt[k]>0)
                    ans+=tmp[k];
        }
    }
    ans-=n;
    printf("%llu",ans);
    return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

bool IsPrime(ll num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    ll ans(1000000000000);

    if(IsPrime(n))
        cout << n-1 << endl;
    else{
        for(int i=1;i<=sqrt(n);i++){
            if(n%i==0){
                ans = min(ans,i+n/i-2);
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n ;i++ )
#define MAX 100
int H, W;
int dy[3] = { 0, 0, 1 }; int dx[3] = { 1, -1, 0 };
class State {public:	int l, r, y, x, o;
	State(int y = 0, int x = 0, int o = 0) :y(y), x(x), o(o) {reset();}
	void reset() {l = W;r = -1;}
	void visit(int j) {l = min(l, j);r = max(r, j);}
	bool visited(int j) {return l <= j && j <= r;}
	bool operator <(const State &s) const {
		if (o != s.o)return o < s.o;
		if (l != s.l)	return l < s.l;
		if (r != s.r)return r < s.r;
		if (y != s.y)return y < s.y;
		if (x != s.x)return x < s.x;
		return false;
	}
};
class QState {public:	State state;int cost;  QState() {}
	QState(State state, int cost) :state(state), cost(cost) {}
	bool operator <(const QState &s) const {return cost > s.cost;	}
};
int F, M, O, C[MAX][MAX];
int dijkstra() {
	if (O == 0)return -1;
	int ncost;	priority_queue<QState> PQ;	set<State> visited;
	rep(j, W){
		State source = State(0, j, O);
		source.visit(j);
		source.o--;
		if (source.o == 0)continue;
		if (C[0][j] >= 0) {
			source.o = min(M, source.o + C[0][j]);
			ncost = 0;
		} else {	ncost = C[0][j] * (-1);
		}
		visited.insert(source);
		PQ.push(QState(source, ncost));
	}
	QState u, v;int nx, ny;
	while (!PQ.empty()) {
		u = PQ.top();PQ.pop();
		if (u.cost > F)continue;
		if (u.state.y == H - 1)return u.cost;
		rep(r, 3){
			nx = u.state.x + dx[r]; ny = u.state.y + dy[r];
			if (nx < 0 || ny < 0 || nx >= W || ny >= H)continue;
			v = u;
			v.state.o--;
			if (v.state.o == 0)	continue;
			v.state.x = nx;v.state.y = ny;
			if (r == 2)	v.state.reset();
			if (!v.state.visited(nx)) {
				if (C[ny][nx] >= 0) {
					v.state.o = min(M, v.state.o + C[ny][nx]);
					v.state.visit(nx);
				} else if (C[ny][nx] < 0) {
					v.cost = u.cost + (C[ny][nx] * (-1));
					v.state.visit(nx);
				}
			}
			if (visited.find(v.state) == visited.end()) {
				visited.insert(v.state);
				PQ.push(v);
			}
		}
	}
	return -1;
}
int main() {	while( cin >> W >> H && W && H ) {
		cin >> F >> M >> O;
		rep(i, H) rep(j, W) cin >> C[i][j];
		int cost = dijkstra();
		if ( cost < 0 || F < cost) cout << "NA" << endl;
		else cout << cost << endl;}return 0;
}

Measured memory_bytes: 3284
N = int(input())
countA = 0
countB = 0
countC = 0
kcount = 0

for i in range(N):
    K = input()
    kcount += K.count("AB")
    K = list(K)
    if K[0] == "B" and K[-1] == "A":
        countC += 1 
    if K[-1] == "A":
        countA += 1
    if K[0] == "B":
        countB += 1
if countC>=1 and (countB-countC)==0 and (countA-countC)==0:
    print(kcount+countC-1)
elif countC >=1 and (countB-countC)==0 and (countA-countC)>=1:
    print(kcount+countC)
elif countC >=1 and (countB-countC)>=1 and (countA-countC)==0:
    print(kcount+countC)
elif countB > countA:
    print(kcount+countA)
else:
    print(kcount+countB)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

int main(){
    vector<P> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i].fs >> v[i].sc;
    }
    v[1]=mp(v[1].fs-v[0].fs,v[1].sc-v[0].sc);
    v[2]=mp(v[2].fs-v[0].fs,v[2].sc-v[0].sc);
    v[0]=mp(0,0);
    double s = 1./2*abs(v[1].fs*v[2].sc-v[1].sc*v[2].fs);
    double d = 0.0;
    double sum = 0.0;
    for (int i = 0; i < 3; i++) {
        double a = v[i].fs - v[(i+1)%3].fs;
        double b = v[i].sc - v[(i+1)%3].sc;
        d = max(d,sqrt(a*a+b*b));
        sum += sqrt(a*a+b*b);
    }
    cout << setprecision(30) << 2*s*d/(4*s+d*sum) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 2019;
int INF = (int)2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> a(N + 1, 0);
    for (int i = 1; i <= N; i++) cin >> a[i];
    vector<vector<int>> equid(200000 + 1, {1});
    for (int i = 2; i <= N; i++) {
        for (int j = i; j <= N; j += i) equid[j].push_back(i);
    }
    vector<int> count(N + 1, 0);
    vector<bool> check(N + 1, false);
    for (int i = N; i >= 1; i--) {
        if (i > N / 2) {
            if (a[i] == 1) {
                check[i] = true;
                for (int j = 0; j < equid[i].size(); j++) {
                    count[equid[i][j]]++;
                }
            }
        } else {
            if (count[i] % 2 != a[i]) {
                check[i] = true;
                for (int j = 0; j < equid[i].size(); j++) {
                    count[equid[i][j]]++;
                }
            }
        }
    }
    vector<int> ans;
    for (int i = 1; i <= N; i++) {
        if (count[i] % 2 != a[i]) {
            cout << -1 << endl;
            return 0;
        } else {
            if (check[i]) ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        if (i == N - 1) cout << ans[i] << endl;
        else cout << ans[i] << " ";
    }
}


Measured memory_bytes: 37876
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    int N;
    cin >> N;

    vector<ll> v(N-1);
    for(int i = 0; i < N-1; i++) cin >> v[i];

    vector<ll> ans(N);    
    for(int i = 0; i < N; i++) ans[i] = 999999;

    for(int i = 0; i < N-1; i++){
        if(v[i] < ans[i]) ans[i] = v[i];
        if(v[i] < ans[i+1]) ans[i+1] = v[i]; 
    }

    for(int i = 0; i < N; i++){
     //   cout << ans[i] << " ";
    }


    cout << accumulate(all(ans), 0ll) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  
  map<pii,int> d;
  reps(i,N){
    string s = to_string(i);
    d[make_pair(s[0],s[s.size()-1])]++;
  }

  ll ans = 0;
  for (auto p : d){
    if (p.first.first==p.first.second) ans += p.second*p.second;
    else ans += p.second * d[{p.first.second, p.first.first}]; 
  }
  cout << ans << endl;


 

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3620
n,m = map(int,input().split())
tbl=[[] for i in range(n)]
for i in range(n):
    tbl[i] = list(map(int,input().split()))
tbl2=[[]*1 for i in range(m)]
for i in range(m):
    tbl2[i] = int(input())
for k in range(n):
    x=0
    for l in range(m):
        x +=tbl[k][l]*tbl2[l]
    print("%d"%(x))


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll v[3];

int idx(char x)
{
  if(x == 'R')
    return 0;
  else if(x == 'G')
    return 1;
  else
    return 2;
}


int main()
{
  ios::sync_with_stdio(0);
  int n;
  string s;
  cin >> n >> s;
  for(int i = 0; i < n ; i++)
  {
    v[idx(s[i])]++;
  }

  ll ans = v[0] * v[1] * v[2];
  for(int i = 0; i < n; i++)
  {
    for(int j = i + 1; j < n; j++)
    {
      int k = 2*j - i;
      if(k < n && s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
        ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>

using namespace std;

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

	string s;
	cin >> s;

	int32_t num_passed{ a + b };
	for (auto i{ 0 }; i < s.size(); ++i) {
		if (s[i] == 'a' && num_passed > 0) {
			cout << "Yes\n" ;
			--num_passed;
		}else if (s[i] == 'b' && num_passed > 0 && b > 0) {
			cout << "Yes\n";
			--num_passed;
			--b;
		}else {
			cout << "No\n";
		}
	}
}


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

int n, m, a, b;

vector<int> graph[8];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
		cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	vector<int> perm;
	for (int i = 1; i < n; i++) perm.push_back(i);
	
	int ans = 0;
	do {
		bool val = false;
		for (auto& i : graph[0]) {
			if (i == perm[0]) val = true;
		} 
		
		if (val) {
			for (int i = 0; i < n - 2; i++) {
				bool found = false;
				for (auto& u : graph[perm[i]]) {
					if (u == perm[i + 1]) found = true;
				}
				if (!found) {
					val = false;
					break;
				}
			}
			
		}
		
		if (val) ans++;
	} while (next_permutation(perm.begin(), perm.end()));
	
	cout << ans;
    return 0;
}


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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

unsigned long long arr[52], dp[52][2501];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // count number of ways to get K items to sum up to A * K
    // dyNmaic PrGoaMmIng

    int n, a; cin >> n >> a;

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

    dp[0][0] = 1;

    for(int i = 1; i <= n; ++i)
        for(int weight = n - 1; weight >= 0; --weight)
            for(int value = 2501; value >= arr[i]; --value)
                dp[weight + 1][value] += dp[weight][value - arr[i]];

    unsigned long long tot = 0;

    for(int nums = 1; nums <= n; ++nums)
        tot += dp[nums][a * nums];

    cout << tot << "\n";

    return 0;

}


Measured memory_bytes: 1280
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)

using namespace std;

signed main()
{
    int N, K, Q;
    cin >> N;
    cin >> K;
    cin >> Q;
    vector<int> A_arr(N, K - Q);
    int x;
    rep(i, Q)
    {
        cin >> x;
        A_arr[x - 1] += 1;
    }
    rep(i, N)
    {
        if (A_arr[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1024
n = int(input())
card_input = list(input().split())

# bubble
card_bubble = card_input.copy()
for i in range(n):
    for j in range(n-1,i,-1):
        if int(card_bubble[j][1])<int(card_bubble[j-1][1]):
            card_bubble[j], card_bubble[j-1] = card_bubble[j-1], card_bubble[j]

# select
card_select = card_input.copy()
for i in range(n):
    mini = i
    for j in range(i,n):
        if  int(card_select[j][1])<int(card_select[mini][1]):
            mini = j
    card_select[mini], card_select[i] = card_select[i], card_select[mini]


    
def output(card):
    string = ''
    for i in card[:-1]:
        string += i + ' '
    string += card[-1]
    print(string)
    
output(card_bubble)
print('Stable')
output(card_select)
if card_bubble==card_select:print('Stable')
else:print('Not stable')


Measured memory_bytes: 5608