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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,M;
ll i, j, k,l;
ll anss[101010],ans;
ll mk[101010],mkr[101010];
ll fnd(ll a){
    if(mk[a]==a)
        return a;
    return mk[a] = fnd(mk[a]);
}
ll rfnd(ll a){
    if(mkr[a]==0)
        return 0;
    return mkr[a] = fnd(mkr[a]);
}

int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i,0,N){
        mk[i + 1] = i + 1;
    }
    fornum(i,0,M){
        ll x, y, z;
        scanf("%lld%lld%lld", &x, &y, &z);
        mk[fnd(x)] = fnd(y);
    }
/*
    fornum(i,0,N){
        //printf("%lld %lld\n", mk[i + 1], mkr[i + 1]);
        mk[rfnd(i + 1)] = fnd(i + 1);
    }*/
    /*
    fornum(i,0,N){
        printf("%lld %lld\n", mk[i + 1], mkr[i + 1]);
    }*/
    fornum(i,0,N){
        ll a = fnd(i + 1);
        if(anss[a]==0){
            ans ++;
            anss[a]++;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int cnt = 0;
    rep(i, n) {
        if (s.substr(i, 3) == "ABC") ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3628
//
// Created by vishal on 7/7/20.
//

//
// Created by vishal on 6/14/20.
//

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff            first
#define ss            second
#define int           long long
#define pb            push_back
#define mp            make_pair
#define pii           pair<int,int>
#define vi            vector<int>
#define mii           map<int,int>
#define pqb           priority_queue<int>
#define pqs           priority_queue<int,vi,greater<int>>
#define setbits(x)    __builtin_popcountll(x)
#define zrobits(x)    __builtin_ctzll(x)
#define mod           1000000007
#define inf           1e18
#define ps(x,y)       fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w           int x;cin>>x;while(x--)
#define F10            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
const int mex=405;
int arr[mex][mex];
void self_min(int& a,int b)
{
    a=min(a,b);
}
int32_t main()
{
    int n,val[mex];
    cin>>n;
    val[0]=0;
    for (int k = 0; k < mex; ++k) {
        for (int i = k; i < mex; ++i) {
            arr[k][i]=inf;
        }
    }
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i][i];
        val[i]=arr[i][i]+val[i-1];
        arr[i][i]=0;
    }

    for (int dist = 1; dist < n ; ++dist) {
        for (int i = 1; i <= n-dist; ++i) {
            for (int j = i; j <=i+dist ; ++j) {
                if(j < i+dist)
                    self_min(arr[i][i+dist],arr[i][j]+arr[j+1][i+dist]+val[i+dist]-val[i-1]);
                else
                    self_min(arr[i][i+dist],arr[i][j-1]+arr[j][j]+val[i+dist]-val[i-1]);
            }
        }
    }
    cout<<arr[1][n];
}

Measured memory_bytes: 4920
n=int(input())


alphabet_count={}

alphabet="abcdefghijklmnopqrstuvwxyz"

for alpha in alphabet:
    alphabet_count[alpha]= 1000000000

mojis=[]
for i in range(n):
    mojis.append(input())

def get_count(moji):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    alphabet_count = {}
    for alpha in alphabet:
        alphabet_count[alpha] = 0
    for m in moji:
        alphabet_count[m]+=1
    return alphabet_count




for moji in mojis:
    each_count=get_count(moji)
    for alpha in alphabet:
        alphabet_count[alpha]=min(alphabet_count[alpha],each_count[alpha])

ans=""

for alpha in alphabet:
    for i in range(alphabet_count[alpha]):
        ans=ans+alpha
print(ans)






Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n,m; cin >> n >> m;
  vector<pair<int,int>> p;
  FOR(i,0,m-1){
    int a,b; cin >> a >> b;
    p.PB(MP(b,a));
  }
  SORT(p);

  int now = -1;
  int ans = 0;
  FOR(i,0,m-1){
    // cout << now << p[i].first << p[i].second << endl;
    if(now==-1){
      now = p[i].first;
      ++ans;
    } else {
      if(p[i].second<now) continue;
      else{
        now = p[i].first;
        ++ans;
      }
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 1400
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

N=int(input())
x=list(map(int,input().split()))

ans=1
first=1
cnt=0
id=0
for i in range(N):
    if cnt+1<=(x[i]-first+2)//2:
        cnt+=1
    else:
        cnt+=1
        ans*=g1[cnt]*cmb(i+1-cnt-id+cnt,cnt,mod)
        ans%=mod
        cnt=0
        first=x[i]+1
        id+=1


ans*=g1[cnt]*cmb(i+1-cnt-id+cnt,cnt,mod)
ans%=mod
print(ans)


Measured memory_bytes: 88248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;

ll f(ll x){
  if(x==1)return 1;
  return 1+2*f(x/2);
}

int main()
{
  ll h;cin>>h;
  cout<<f(h)<<endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
dp = [0 for _ in range(13)]
dp[0] = 1
c = 1000000007
m = 1
r13 = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
r10 = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
for i in range(len(s) - 1, -1, -1):
    ndp = [0 for _ in r13]
    if s[i] == "?":
        for j in r10:
            jm = j * m
            for k in r13:
                index = (jm + k) % 13
                ndp[index] = (ndp[index] + dp[k]) % c
    else:
        jm = int(s[i]) * m
        for k in r13:
            index = (jm + k) % 13
            ndp[index] = (ndp[index] + dp[k]) % c
    dp = ndp[:]
    m = m * 10 % 13
print(dp[5])


Measured memory_bytes: 43116
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;


int main() {
	int n,ans=0;
	cin >> n;
	int p[n+10];
	for(int i=0; i<n; i++) cin >> p[i];
	for(int i=1; i<n-1; i++){
		if(p[i-1]<=p[i] && p[i]<=p[i+1] || p[i-1]>=p[i] && p[i]>=p[i+1]){
		ans+=1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=15;
int n,m,vis1[N],vis2[N],ok1,ok2;
char s[N][N],t[N][N],r[N][N],v[N][N];
int pr[N];
void cpy()
{
//	for(int i=1;i<=n;i++)
//	  if(pr[i]) memcpy(v[])
}
bool judge(int x,int y)
{
	for(int k=1;k<=n;k++)
	  if(pr[k]&&s[k][x]!=s[pr[k]][y]) return 0;
	return 1;
}
void dfs2(int d)
{
	if(d==m/2+1||ok2) {ok2=1;return;}
	int l2=0;
	for(int i=1;i<=m;i++)
	  if(!vis2[i]) 
	    for(int j=i+1;j<=m;j++)
	    {
	    	if(!vis2[j]&&judge(i,j))
	      	{
	      		vis2[i]=vis2[j]=1,dfs2(d+1);
	      		vis2[i]=vis2[j]=0;
	      	}
	    }
	      
}
void dfs1(int d)
{
	if(ok2) return;
	if(d==n/2+1) {
		ok1=1;cpy();
		dfs2(1);
		return;
	}
	int l1=0;
	for(int i=1;i<=n;i++)
	  if(!vis1[i])
	    for(int j=i+1;j<=n;j++)
	    {
	    	if(!vis1[j]&&strcmp(t[j]+1,t[i]+1)==0)
	    	{
	    		vis1[i]=vis1[j]=1,pr[i]=j,pr[j]=i,dfs1(d+1);
	    		vis1[i]=vis1[j]=0; pr[i]=pr[j]=0;
	    	}
	          
	    }
	      
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		memcpy(t[i],s[i],sizeof(s[i]));
	}
	for(int i=1;i<=n;i++) sort(t[i]+1,t[i]+m+1);
//	cout<<endl;
//	for(int i=1;i<=n;i++) cout<<t[i]+1<<endl;  cout<<endl;
	dfs1(1);
//	if(!ok1) {puts("NO");return 0;}
//	for(int i=1;i<=n;i++)
//	  for(int j=1;j<=m;j++)
//	    r[j][i]=s[i][j];	
//	for(int i=1;i<=m;i++) sort(r[i]+1,r[i]+n+1);
//	for(int i=1;i<=m;i++) cout<<r[i]+1<<endl; cout<<endl;
//	dfs2(1);
//	cout<<ok1<<" "<<ok2<<endl;
	if(!ok1||!ok2) puts("NO");
	else puts("YES");
	return 0;
}



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

#define int long long

int cnt;
string s;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	for (char c : s)
		cnt += (c == 'o');
	cout << 700 + cnt * 100 << endl;
}

Measured memory_bytes: 256
n = int(input())
As = list(map(int, input().split()))

four = sum([1 for a in As if a%4 == 0])
odd = sum([1 for a in As if a%2 == 1])
two = sum([1 for a in As if a%2 == 0 and a%4 != 0])
if four < two%2 + odd - 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 14252
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main() {
	lint a;
	long double b;
	std::cin>>a>>b;
	b+=eps;
	b*=100;
	std::cout<<a*(lint)b/100<<std::endl;
	return 0;
}

Measured memory_bytes: 3700
#include<iostream>

using namespace std;

long long gcd(long long x, long long y){
    if(y > x) return gcd(y, x);
    if(x % y == 0) return y;
    return gcd(y, x % y);
}

int main(void){
    int N;
    cin >> N;
    long long ans;
    cin >> ans;
    for(int i = 1; i < N; i++){
        long long A;
        cin >> A;
        ans = gcd(A, ans);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}	
	vector <ll> vec;
	for(int i = 0; i < n; i++){
		ll curr = 0;
		for(int j = i; j < n; j++){
			curr += v[j];
			vec.push_back(curr);
		}
	}
	ll res = 0;
	for(int i = 63; i >= 0; i--){
		int cnt = 0;
		for(auto x : vec){
			if(x & (1LL << i)) cnt++;
		}
		if(cnt >= k){
			res += (1LL << i);
			vector <ll> next;
			for(auto x : vec){
				if(!(x & (1LL << i))) continue;
				next.push_back(x);
			}
			vec = next;
		}
	}
	cout << res;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI arccos(-1)
#define rep(i, N) for (int i = 0; i < (N); i++)
#define REP(i, a, N) for (int i = a; i < (N); i++)
#define rrep(i, N, k) for (int i = (N); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

struct UnionFind {
    vector<int> data;

    explicit UnionFind(int size) : data(size, -1)  {}

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(int idx) {
        if (data[idx] < 0) return idx;
        else return (data[idx] = find(data[idx]));
    }

    int size(int idx) {
        return (-data[find(idx)]);
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    auto data = UnionFind(N);

    ll temp = 0;
    vector<ll> ans(M, 0);
    for (int i = M - 1; i >= 0; i--) {
        ans[i] = N * (N - 1) / 2 - temp;
        if (data.find(A[i]) != data.find(B[i])) {
            temp += data.size(A[i]) * data.size(B[i]);
            data.unite(A[i], B[i]);
        }
    }
    for (auto now : ans) cout << now << endl;
}


Measured memory_bytes: 4096
package main

import (
	"fmt"
	"sort"
	"strings"
)

var S, T string

func main() {
	fmt.Scan(&S, &T)
	s := strings.Split(S, "")
	t := strings.Split(T, "")
	sort.Strings(s)
	sort.Sort(sort.Reverse(sort.StringSlice(t)))
	newS := ""
	newT := ""
	for _, tmp := range s {
		newS += tmp
	}
	for _, tmp := range t {
		newT += tmp
	}
	if newT > newS {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n+1) {
        if (i==0) continue;
        ll num = n/i;
        ans += ((num*(num+1))/2)*i;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include<stdlib.h>
int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
     return 2*i+1;
     }

int main(){
  int H[251];
  int i,j,k,Hsiz;
  scanf("%d",&Hsiz);
  for(i=1;i<=Hsiz;i++){
    scanf("%d",&H[i]);
  }

  for(i=1;i<=Hsiz;i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(parent(i)>=1 && parent(i)<=Hsiz){
      printf("parent key = %d, ",H[parent(i)]);
    }
if(left(i)>=1 && left(i)<=Hsiz){
  printf("left key = %d, ",H[left(i)]);
    }
 if(right(i)>=1 && right(i)<=Hsiz){
   printf("right key = %d, ",H[right(i)]);
    }
 printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int switches[n]={0};
	int current_state = 0;
	for(int i=0; i<m; i++){
		int connected;
		cin>>connected;
		while(connected--){
			int swt;
			cin>>swt;
			swt--;
			switches[swt]|=(1<<i);
		}
	}
	for(int i=0; i<m; i++){
		bool turned;
		cin>>turned;
		if(!turned) current_state|=(1<<i);
	}
	int ret = 0;
	for(int state=0; state<(1<<n); state++){
		int final_state = 0;
		for(int j=0; j<n; j++){
			if(state&(1<<j)) final_state^=switches[j];
		}
		final_state^=current_state;
		if(final_state==((1<<m)-1)){
			ret++;
		}
	}
	cout<<ret;
}

Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    cout << max(0ll, A - K) << " " << max(0ll, B - max(K - A, 0ll)) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int sum=0;
  rep(i, n) sum += a[i];
 int ans = 0;
  ans = sum - n;
  cout << ans << endl;
}


Measured memory_bytes: 256
d, n = gets.split(" ").map!{|p| p.to_i}
frag = false
i = 1
num = 0
while frag == false
  if d == 0
    if i % 100 != 0
      num += 1
    end
  elsif d == 1
    if i % 100 == 0 and i/100 % 100 != 0
      num += 1
    end
  else 
    if i % 100 == 0 and i/100 % 100 == 0 
      if  i/10000 % 100 != 0
        num += 1
      end
    end
  end
  if n == num
    puts i
    frag = true
  end
  i += 1
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    int inc=-1;
    ll s=1000,t=0;
    REP(i,n-1){
        if(inc==-1){
            if(a[i]<a[i+1]){
                inc=1;
                ll u=s/a[i];
                s=s-u*a[i];
                t+=u;
            }
            else if(a[i]==a[i+1]){
                continue;
            }
            else{
                inc=0;
            }
        }
        else if(inc==1){
            if(a[i]>a[i+1]){
                inc=0;
                s+=t*a[i];
                t=0;
            }
        }
        else{
            if(a[i]<a[i+1]){
                inc=1;
                ll u=s/a[i];
                s=s-u*a[i];
                t+=u;
            }
        }
    }
    cout << s+t*a[n-1] << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void) {

	char S[112];

    scanf("%s",S);
  
    for(int i = 0;i < 112;++i){
      if((i - 1) % 2 == 0 && S[i - 1] == 'L'){
        puts("No");
        return 0;
      }
      else if((i - 1) % 2 == 1 && S[i - 1] == 'R'){
        puts("No");
        return 0;
      }
    }
  
  puts("Yes");
    
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      cin >> a[i][j], a[i][j]--;
    }
  }
  int m = 0;
  vector<vector<int>> id(n, vector<int>(n));
  auto f = [&](int i, int j) { if (i > j) swap(i, j); return id[i][j]; };
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      id[i][j] = m++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      a[i][j] = f(i, a[i][j]);
    }
  }
  vector<int> deg(m, 0);
  vector<vector<int>> nxt(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 2; j++) {
      nxt[a[i][j]].push_back(a[i][j + 1]);
      deg[a[i][j + 1]]++;
    }
  }
  queue<int> q;
  vector<int> dp(m, -1);
  for (int i = 0; i < m; i++) {
    if (deg[i] == 0) {
      dp[i] = 1;
      q.push(i);
    }
  }
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    for (auto t : nxt[s]) {
      dp[t] = max(dp[t], dp[s] + 1);
      deg[t]--;
      if (deg[t] == 0) q.push(t);
    }
  }
  for (int i = 0; i < m; i++) {
    if (deg[i] > 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  int ans = *max_element(begin(dp), end(dp));
  cout << ans << endl;
}


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

#define Set(a, b) memset(a, b, sizeof (a))
#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
}

int a[100010];

inline int calc(int mn, int mx) {
	if (mx <= 0 && mn <= 0) return -mn;
	if (mx >= 0 && mn >= 0) return mx;
	return (abs(mx) + abs(mn)) * 2 - max(abs(mx), abs(mn));
}

int main() {

	int n = read(), k = read();
	For(i, 1, n) a[i] = read();

	int ans = INT_MAX;
	For(i, 1, n - k + 1) {
		ans = min(ans, calc(a[i], a[i + k - 1]));
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
#include<assert.h>
#include<queue>
#include<stack>

using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int  MOD = 998244353, OO = 2e9 + 100;
const int N = 1e5 + 10;
int n, m;
int par[N] , a[N] , finish[N];
int find(int i) {
	if (par[i] == i)
		return i;
	return par[i] = find(par[i]);
}
void merge(int a, int b, int c) {
	a = find(a);
	b = find(b);
	if (a == b) {
		finish[a] = 1;
		finish[b] = 1;
		return;
	}
	par[a] = b;
}
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		par[i] = i;
	while (m-- > 0) {
		int a, b, c;
		cin >> a >> b >> c;
		merge(a, b, c);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (find(i) == i) {
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(){
  int n, m, c;  scanf("%d%d%d", &n, &m, &c);
  int b[22];
  for(int i=0; i<m; i++) scanf("%d", &b[i]);
  int ans = 0;
  for(int i=0; i<n; i++){
    int sum = 0;
    for(int j=0; j<m; j++){
      int t;  scanf("%d", &t);
      sum = sum + t * b[j];
    }
    if(sum + c > 0) ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

a,b,c=nii()

if a%2==1 and b%2==1 and c%2==1:
  print(min(a*b,b*c,c*a))
else:
  print(0)

Measured memory_bytes: 9124
#include<iostream>
#include<string>
#include<algorithm>

int main()
{
	int K, S;
	std::cin >> K >> S;
	long long result{};
	for (int x = 0;x <= K;++x)
	{
		for (int y = 0;y <= K&&x + y <= S;++y)
		{
			if (S - (x + y) <= K)
				++result;
		}
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> vec(n);
    rep(i, n) {
        ll x, l;
        cin >> x >> l;
        vec[i] = {x + l, x - l};
    }
    sort(all(vec));

    int ans = n;
    ll now = -LINF;
    rep(i, n) {
        ll left, right;
        tie(right, left) = vec[i];
        if (left < now) {
            ans--;
            continue;
        }
        now = right;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
a.append(-1)
variation = []
target = a[0]
start = 0
for i in range(len(a)):
    if a[i] != target:
        variation.append(i-start)
        start = i
        target = a[i]
variation = sorted(variation)
cost = 0
for i in range(len(variation) - k):
    cost += variation[i]
print(cost)

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

#define rep(a,b) for(int a=0; a<b; ++a)

int main(void){
	map<int,int> mp; bool able=true;
	vector<int> v;
	rep(i,12){
		int e; cin>>e; ++mp[e];
	}
	switch((int)mp.size()){
		case 1 :
			cout<<"yes"<<endl;
			break;
		case 2 :
			for(auto &e:mp) v.emplace_back(e.second);
			if((v[0]==4&&v[1]==8)||(v[0]==8&&v[1]==4)) cout<<"yes"<<endl;
			else cout<<"no"<<endl;
			break;
		case 3 :
			for(auto &e:mp) able&=e.second==4;
			cout<<(able?"yes":"no")<<endl;
			break;
		default :
			cout<<"no"<<endl;
			break;
	}
}


Measured memory_bytes: 3144
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

// #define LOCAL_DEBUG

typedef long long LL;

const int maxn = 1e5+5;
LL a[maxn], b[maxn];
int n;
LL ans = 1LL<<61;

void solve_(LL tot) {
	LL x;
	
	for (int i=2; i<=n; ++i) {
		if (b[i-1] > 0) {
			x = b[i-1] + b[i];
			if (x >= 0) {
				tot += 1 + x;
				x = -1;
			}
		} else {
			x = b[i-1] + b[i];
			if (x <= 0) {
				tot += 1 - x;
				x = 1;
			}
		}
		b[i] = x;
	}
	
	ans = min(ans, tot);
	
	// #ifdef LOCAL_DEBUG
	// printf("%lld: ", tot);
	// for (int i=1; i<=n; ++i)
		// printf("%lld ", b[i]);
	// putchar('\n');
	// #endif
}

void solve() {
	LL tmp;
	
	tmp = 0;
	memcpy(b, a, sizeof(b));
	if (b[1] <= 0) {
		tmp = 1 - b[1];
		b[1] = 1;
	}
	solve_(tmp);
	
	tmp = 0;
	memcpy(b, a, sizeof(b));
	if (b[1] >= 0) {
		tmp = 1 + b[1];
		b[1] = -1;
	}
	solve_(tmp);
	
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifdef LOCAL_DEBUG
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	scanf("%d", &n);
	rep(i, 1, n+1)
		scanf("%lld", a+i);
	solve();
	
	// #ifdef LOCAL_DEBUG
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


Measured memory_bytes: 1792
n, m, l = gets.chomp.split(" ").map(&:to_i)

# get matrix A
a = []
for i in 1..n
    a << gets.chomp.split(" ").map(&:to_i)
end

# get matrix B
b = Array.new(l).map{Array.new(m, "0")}
for i in 0..m - 1
    input = gets.chomp.split(" ").map(&:to_i)

    for j in 0..l - 1
        b[j][i] = input[j]
    end
end

# calculate
for i in 0..n - 1       # a row
    for j in 0..l - 1   # b row
    
        sum = 0
        
        for k in 0..m - 1   # col
            sum += a[i][k] * b[j][k]
        end
        
        print sum
        
        if j != l- 1
            print " "
        end
    end
    puts ""
end


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

int main(){
    using namespace std;
    unsigned long N, A, B;
    cin >> N >> A >> B;
    if(A > B)return 0 & puts("0");
    auto D = B - A;
    if(N == 1)return 0 & puts(D ? "0" : "1");
    cout << (N - 2) * D + 1 << endl;
}

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

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


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**18


if __name__ == "__main__":
    l,r,d = map(int,input().split())
    ans = 0
    for i in range(l,r+1):
        if i%d == 0:
            ans+=1
    print(ans)

Measured memory_bytes: 9604
#include <iostream>
#include <vector>

int main(int argc, char** argv) {
  unsigned long H, N;
  std::cin >> H >> N;
  std::vector<unsigned long> A(N);
  for (auto& e : A) std::cin >> e;
  unsigned long sum {};
  for (const auto& e : A) {
    sum += e;
  }
  std::cout << ((sum < H)?"No":"Yes") << '\n';
}


Measured memory_bytes: 1024
#include <iostream>

#define MAX 100001
#define NIL -1

using namespace std;

struct Node { int parent, left, right; };


int degree(int n, Node nodes[]) {
  if (nodes[n].left != NIL && nodes[n].right != NIL) return 2;
  if (nodes[n].left == NIL && nodes[n].right == NIL) return 0;
  return 1;
}

int sibling(int n, Node nodes[]) {
  if (nodes[n].parent == NIL) return NIL;
  int p = nodes[n].parent;
  if (nodes[p].left == n) return nodes[p].right;
  return nodes[p].left;
}

void depth(int n, int d, Node nodes[], int ds[]) {
    ds[n] = d;
    if (nodes[n].right != NIL) depth(nodes[n].right, d+1, nodes, ds);
    if (nodes[n].left != NIL) depth(nodes[n].left, d+1, nodes, ds);
}

int height(int n, Node nodes[], int hs[]) {
    int left = 0; int right = 0;
    if (nodes[n].left != NIL) left = 1 + height(nodes[n].left, nodes, hs);
    if (nodes[n].right != NIL) right = 1 + height(nodes[n].right, nodes, hs);
    hs[n] = (left > right) ? left : right;
    return hs[n];
}

void print(int i, Node nodes[], int ds[], int hs[]) {
    cout << "node " << i << ": ";
    cout << "parent = " << nodes[i].parent;
    cout << ", sibling = " << sibling(i, nodes);
    cout << ", degree = " << degree(i, nodes);
    cout << ", depth = " << ds[i];
    cout << ", height = " << hs[i];
    cout << ", ";

    if (nodes[i].parent == NIL) cout << "root";
    else if (nodes[i].left == NIL && nodes[i].right == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}

int main() {
    int n, id, left, right, root, c;
    Node T[MAX];
    int D[MAX];
    int H[MAX];
    
    cin >> n;
    for (int i=0; i<n; i++) T[i].parent = NIL;
    
    for (int i=0; i<n; i++) {
        cin >> id >> left >> right;
        T[id].left = left;
        T[id].right = right;
        T[left].parent = id;
        T[right].parent = id;
    }
    
    for (int i=0; i<n; i++) {
        if (T[i].parent == NIL) {
            root = i;
            break;
        }
    }

    
    depth(root, 0, T, D);
    height(root, T, H);
    
    for (int i=0; i<n; i++) print(i, T, D, H);
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    rep(i, 0, n){
        cin >> a[i].second >> a[i].first;
    }
    sort(a.begin(), a.end());
    ll heap = 0;
    rep(i, 0, n){
        heap += a[i].second;
        if(heap > a[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; i++)

vector<int> v;

double cidadeX[15]; //x,y
double cidadeY[15]; //x,y

int main ()
{
    int n; cin >> n;
    for (int i = 1; i <= n; i++)
        v.push_back(i);

    double nfatorial = 1;

    for (int i = 1; i <= n; i++)
    {
        nfatorial *= (double)i;
        long double x, y; cin >> x >> y;
        cidadeX[i] = x;
        cidadeY[i] = y;
    }

    double total = 0;

    do {
        double d = 0;
        for (int j = 0; j < n-1; j++)
            d += sqrtl( (cidadeX[ v[j] ] - cidadeX[  v[j+1]  ]) * (cidadeX[ v[j] ] - cidadeX[ v[j+1] ]) + (cidadeY[  v[j]  ] - cidadeY[ v[j+1] ]) * (cidadeY[ v[j] ] - cidadeY[ v[j+1] ]) );
        total += d;

    } while(next_permutation(v.begin(), v.end()));

    total /= nfatorial;



    cout << setprecision(10) << fixed << total << endl;

    return 0;
}


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

using namespace std;
const int N=1E5+7;
vector<int>ve[N];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		ve[x].push_back(y);
	}
	for(int i=1;i<=m;i++){
		sort(ve[i].begin(),ve[i].end());
	}
	priority_queue<int >que;
	int ans=0;
	for(int i=1;i<=m;i++){
		for(int j=0;j<ve[i].size();j++){
			que.push(ve[i][j]);
		}
		if(que.size()){
				ans+=que.top();
				que.pop();
		}
//		cout<<i<<"---"<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 5632
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const int MAXN = 1234567;
int lfactor[MAXN], visit[MAXN];

int main() {
    for (int i = 2; i < MAXN; i++) {
        if (lfactor[i]) continue;
        for (int j = i; j < MAXN; j += i) {
            lfactor[j] = i;
        }
    }
    int N;
    scanf("%d", &N);
    bool OK = true;
    int g = 0;
    for (int i = 0; i < N; i++) {
        int A;
        scanf("%d", &A);
        g = __gcd(A, g);
        set<int> st;
        while (A > 1) {
            st.insert(lfactor[A]);
            A /= lfactor[A];
        }
        for (auto i : st) {
            if (visit[i]) OK = false;
            visit[i] = 1;
        }
    }
    if (g != 1) puts("not coprime");
    else if (OK) puts("pairwise coprime");
    else puts("setwise coprime");
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 12400
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
AM = A.pop(0)
xy = []
if AM > 0 and A[-1] >= 0:
    p = 1
elif AM <= 0 and A[-1] < 0:
    p = 2
else:
    p = 3
if p == 1:
    while(len(A)>1):
        x = A.pop(-1)
        y = A.pop(0)
        xy.append([x, y])
        A.append(x-y)
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 2:
    while(len(A)>1):
        x = AM
        y = A.pop(-1)
        xy.append([x, y])
        AM -= y
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 3:
    while(len(A)>1):
        y = A.pop(0)
        if y >= 0:
            x = A.pop(-1)
            xy.append([x, y])
            A.append(x-y)
        else:
            x = AM
            xy.append([x, y])
            AM -= y
    xy.append([AM, A[0]])
    ans = AM - A[0]
print(ans)
for out in xy:
    print(*out)

Measured memory_bytes: 21760
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
N = int(input())
import collections
import math
lst = prime_factorize(N)
c = collections.Counter(lst)
count = 0
for _, n in c.items():
    x = (-1+math.sqrt(1+8*n))//2
    count += x
print(int(count))

Measured memory_bytes: 68032
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace null_null {

void main_() {
  int a;
  std::string s;
  std::cin >> a >> s;
  if (a >= 3200) {
    std::cout << s << std::endl;
  } else {
    std::cout << "red" << std::endl;
  }
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 384
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INF (ll)1000000007
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];
    SORT(a);

    int l=-1, r=N, n=(l+r)/2;

    while(r-l > 1){
        int dp[N][K+1];
        REP(i,N)REP(j,K+1) dp[i][j] = 0;
        REP(i,N) dp[i][0] = 1;
        int k=1;
        REP(i,N){
            if(i == n) continue;
            FOR(j,1,K+1){
                if(j-a[i] >= 0) chmax(dp[k][j], dp[k-1][j-a[i]]);
                chmax(dp[k][j], dp[k-1][j]);
            }
            k++;
        }
        bool flag = false;
        for(ll i=max((ll)0, (ll)K-a[n]); i<K; i++) if(dp[N-1][i]){flag = true; break;}
        if(flag) r = n;
        else l = n;
        n = (l+r)/2;
    }

    cout << l+1 << endl;
    
    return 0;
}

Measured memory_bytes: 97920
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,X;
vector<int>S;
long mod=1e9+7,dp[222][1<<17];
main()
{
	cin>>N>>X;
	for(int i=0;i<N;i++)
	{
		int s;cin>>s;S.push_back(s);
	}
	sort(S.begin(),S.end());
	dp[0][X]=1;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<=X;j++)
		{
			if(dp[i][j]==0)continue;
			int k=0;
			for(;k<N;k++)
			{
				if(j<S[k])break;
				(dp[i+1][j%S[k]]+=dp[i][j])%=mod;
			}
			(dp[i+1][j]+=dp[i][j]*(N-k-i)%mod)%=mod;
		}
	}
	long ans=0;
	for(int i=0;i<=X;i++)(ans+=i*dp[N][i])%=mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 205312
import java.util.*;
import java.lang.Math;

public 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();
   	
  	if((a < c && c < b) || (a > c && c > b)) System.out.print("Yes");
    else System.out.println("No");

  }
}


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

const long long mod = 1e9+7;
const int N = 1e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

int a[N],m[N];
//vector<int> ;
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin>>n;
fr(i,0,n)
{
    cin>>a[i];
}
m[n-1]=(0);
m[n-2]=abs(a[n-2]-a[n-1]);
for(int j=(n-3);j>=0;j--)
{
    m[j]=min(m[j+1]+abs(a[j]-a[j+1]),m[j+2]+abs(a[j]-a[j+2]));
}
cout<<m[0]<<endl;
// Code Here

return 0;
}
/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x;
    while(y>0){
    if(y&1)ans=(x*ans);
    x=(x*x);
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


Measured memory_bytes: 1024
n,m = list(map(int, input().split()))
parents = [-1] * (n + 1)
def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]

def union(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    if parents[x] > parents[y]:
        x, y = y, x

    parents[x] += parents[y]
    parents[y] = x

def same(x, y):
    return find(x) == find(y)

for _ in range(m):
    a,b = list(map(int, input().split()))    
    union(a,b)

print(-min(parents[1:]))

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

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Integer.parseInt(in.next()),A[]=new int[n];
		for(int i=0;i<n;i++) A[i]=Integer.parseInt(in.next());
		
		int q=Integer.parseInt(in.next());
		for(int i=0;i<q;i++) {
			int b=Integer.parseInt(in.next()),
					e=Integer.parseInt(in.next()),
					k=Integer.parseInt(in.next());
			int cnt=0;
			for(int j=b;j<e;j++) {
				if(A[j]==k)cnt++;
			}
			out.println(cnt);
		}
		out.flush();
	}

}


Measured memory_bytes: 34536
#include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
    ll N, ans{};
    cin >> N;
    string S;
    unordered_map<string, ll> um;
    for (ll i{}; i < N; i++) {
        cin >> S;
        sort(S.begin(), S.end());
        if (um.find(S) == um.end()) um[S] = 1;
        else ans += um[S]++;    // nCr - n-1Cr = n-1Cr-1
    }
    cout << ans << endl;        // sum of um[S]C2
}

Measured memory_bytes: 10660