akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int solve(int index,int depth,int mode,string& s){
	int i;
	for(i = index;i <s.size();){
		if(mode == 0){//m
			if(s[i] != 'm')return INF;//else
			else i++,mode++;//m
		}else if(mode == 1){//e or X
			if(s[i] == 'm') {//X
				i += solve(i,depth+1,0,s) - i + 1;
			}else if(s[i] != 'e'){//else
				return INF;
			}else{//e
				i++;
				mode++;
			}
		}else if(mode == 2){//w or Y
			if(s[i] == 'm'){
				i += solve(i,depth+1,0,s) - i + 1;
			}else if(s[i] != 'w'){
				return INF;
			}else{
				return i;
			}
		}
	}
	return INF;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(solve(0,0,0,s) == s.size()-1)cout << "Cat" << endl;
	else cout << "Rabbit" << endl;
  return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];
string s;

int dp[200][5][3];

int get(int idx,int tot,int tight)
{
	if(tot>k)return 0;
	if(idx == -1)
	{
		if(tot!=k)return 0;
		return 1;
	}
	int&ans = dp[idx][tot][tight];
	if(ans!=-1)return ans;
	ans = 0;


	if(tight == 1)
	{
		int p = s[idx]-'0';
		if(p == 0)
		{
			ans = get(idx-1,tot,tight);
		}
		else
		{
			ans = get(idx-1,tot,0) + (p-1)*get(idx-1,tot+1,0) + get(idx-1,tot+1,1); 
		}
	}	
	else
	{
		int p = s[idx]-'0';
		ans = get(idx-1,tot,0)+9*get(idx-1,tot+1,0);

	}
	return ans;
}


void solve()
{
	st(dp,-1);
    cin>>s>>k;
    n = s.size();
    reverse(all(s));
    cout<<get(n-1,0,1);




}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

template<int MOD>
struct ModInt {
    using M = ModInt;
    long long val;
    ModInt(long long v = 0) {set_val(v%MOD+MOD);}
    M& set_val(unsigned int v) {
        val = v<MOD ? v : v - MOD;
        return *this;
    }
    M operator-() const {return M() - *this;}
    M operator+(const M& r) const {return M().set_val(val+r.val);}
    M operator-(const M& r) const {return M().set_val(val+MOD-r.val);}
    M operator*(const M& r) const {return M().set_val(val*r.val%MOD);}
    M operator/(const M& r) const {return *this * r.inverse();}
    M& operator+=(const M& r) {return *this = *this+r;}
    M& operator-=(const M& r) {return *this = *this-r;}
    M& operator*=(const M& r) {return *this = *this*r;}
    M& operator/=(const M& r) {return *this = *this/r;}
    bool operator==(const M& r) const {return val == r.val;}
    M pow(long long n) const {
        M x = *this, r = 1;
        while(n>0) {
            if(n & 1) r *= x;
            x *= x;
            n >> 1;
        }
        return r;
    }
    M inverse() const {
        int a = val, b = MOD, u = 1, v = 0, t;
        while(b>0) {
            t = a/b;
            swap(a-=t*b, b);
            swap(u-=t*v, v);
        }
        return ModInt(u);
    }
    friend istream& operator<<(istream& i, const M& r) {
        long long tmp; i >> tmp;
        r = M(i);
        return i;
    }
    friend ostream& operator<<(ostream& os, const M& r) {
        return os << r.val;
    }
};


const unsigned int MOD = 1000000007;
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    mint dp[n+1][4][4][4];
    dp[0][3][3][3] = 1;
    REP(i,n) REP(w,4) REP(x,4) REP(y,4) REP(z,4) {
        if(z==2 && y==1 && x==0) continue;
        if(z==1 && y==2 && x==0) continue;
        if(z==2 && y==0 && x==1) continue;
        if(z==2 && x==1 && w==0) continue;
        if(z==2 && y==1 && w==0) continue;
        dp[i+1][x][y][z] += dp[i][w][x][y];
    }
    mint ans = 0;
    REP(x,4) REP(y,4) REP(z,4) {
        ans += dp[n][x][y][z];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int count=0, i;
    char S[4];
    scanf("%s", &S);
    for(i=0; i<strlen(S); i++)
    {
        if(S[i]=='o')
        {
            count++;
        }
    }
    printf("%d\n", 700+count*100);
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    cin >> a >> b;
    if(a==1) a=14;
    if(b==1) b=14;
    //処理
    //出力
    if(a>b) cout << "Alice" << ENT;
    else if(a==b) cout << "Draw" << ENT;
    else cout << "Bob" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[20];

void insert(int a[])
    {
        int i,j,key;
        for(j=2;j<=10;j++)
        {
            key=a[j];
            i=j-1;
            while(i>0&&a[i]>key)
            {
                a[i+1]=a[i];
                i=i-1;
            }
            a[i+1]=key;
        }
    }
int main()
{
    int i;
    for(i=1;i<=10;i++)
    {
        cin>>a[i];
    }
    insert(a);
    for(i=10;i>=8;i--)
    {
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PR pair<int, int>
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
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;}
void Yes(bool b){cout << (b? "Yes" : "No") << endl;}
void YES(bool b){cout << (b? "YES" : "NO") << endl;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//
int ary[] = {105,3*5*11,3*5*13,3*3*3*5,3*3*3*7};
signed main()
{
  ios();
  int N;
  cin >> N;
  switch(N % 4)
  {
    case 0:
      Yes(1);
      break;
    case 1:
      Yes(N>=21);
      break;
    case 2:
      Yes(N >= 14);
     break;
    case 3:
      Yes(N >= 7);
     break;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main(void){
	int n;

	cin >> n;

	vector<int> c(n), s(n), f(n), a(n, 0);

	for (int i = 0; i < n - 1; i++)
		cin >> c[i] >> s[i] >> f[i];


	for (int i = 0; i < n - 1; i++){
		int ans = 0;
		for (int j = i; j < n - 1; j++){
			if (j == i){
				ans += c[i] + s[i];
			}
			else {
				if (ans >= s[j]){
					int k = 0;
					while (s[j] + k*f[j] < ans){
						k++;
					}
					ans += s[j] + k*f[j] - ans + c[j];
				}
				else {
					ans = s[j] + c[j];
				}
			}
		}
		cout << ans << endl;
	}

	cout << 0 << endl;

	return 0;
}

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

int main() {
    long long H, W;
    cin >> H >> W;
    long long ans = (H*W + 1)/2;
    if (H == 1 || W == 1) ans = 1;
    cout << ans << endl;
    return 0;
}

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

const int N = 4e5 + 9;

int n, x[N], y[N], a[N][2], sid[N];
vector<int> g[N], gt[N];
int get_id(int i, int j, int k) {
	int z = a[i][j];
	if (k == 0) return z;
	else return z + 2 * n;
}
int get_segtree_id(int x) {
	return sid[x];
}
void add_edge(int u, int v) {
	g[u].push_back(v);
	gt[v].push_back(u);
}
void build(int cur, int b, int e) {
	if (b == e) {
		sid[cur] = b;
		return;
	}
	sid[cur] = 4 * n + cur;
	build(cur << 1, b, b + e >> 1);
	add_edge(sid[cur], sid[cur << 1]);
	if ((b + e >> 1) + 1 <= e) {
		build(cur << 1 | 1, (b + e >> 1) + 1, e);
		add_edge(sid[cur], sid[cur << 1 | 1]);
	}
}
void add(int n, int b, int e, int l, int r, int u) {
	if (b > r || e < l) return;
	if (b >= l && e <= r) {
		add_edge(u, get_segtree_id(n));
		return;
	}
	add(n << 1, b, b + e >> 1, l, r, u);
	add(n << 1 | 1, (b + e >> 1) + 1, e, l, r, u);
}
stack<int> ts;
bool vis[N];
int comp[N];
void dfs1(int u) {
	vis[u] = true;
	for (int v : g[u]) if (!vis[v]) dfs1(v);
	ts.push(u);
}
void dfs2(int u, int c) {
	comp[u] = c;
	for (int v : gt[u]) if (comp[v] == -1) dfs2(v, c);
}
vector<pair<int, int>> v;
bool yo(int d) {
	for (int i = 1; i < N; i++) {
		g[i].clear();
		gt[i].clear();
	}
	build(1, 1, 2 * n);
	for (int i = 1; i <= n; i++) {
		add_edge(get_id(i, 0, 0), get_id(i, 1, 1));
		add_edge(get_id(i, 1, 0), get_id(i, 0, 1));

		int l = upper_bound(v.begin(), v.end(), make_pair(x[i] - d, N)) - v.begin() + 1;
		int cur = get_id(i, 0, 0);
		if (l < cur) add(1, 1, 2 * n, l, cur - 1, get_id(i, 0, 1));	
		int r = upper_bound(v.begin(), v.end(), make_pair(x[i] + d, -1)) - v.begin() + 1;
		r--;
		if (cur < r) add(1, 1, 2 * n, cur + 1, r, get_id(i, 0, 1));	

		l = upper_bound(v.begin(), v.end(), make_pair(y[i] - d, N)) - v.begin() + 1;
		cur = get_id(i, 1, 0);
		if (l < cur) add(1, 1, 2 * n, l, cur - 1, get_id(i, 1, 1));	
		r = upper_bound(v.begin(), v.end(), make_pair(y[i] + d, -1)) - v.begin() + 1;
		r--;
		if (cur < r) add(1, 1, 2 * n, cur + 1, r, get_id(i, 1, 1));
	}
	memset(vis, 0, sizeof vis);
	ts = stack<int>();
	for (int i = 1; i < N; i++) if(!vis[i]) dfs1(i);
	int scc = 0;
	memset(comp, -1, sizeof comp);
	while (!ts.empty()) {
		int u = ts.top();
		ts.pop();
		if (comp[u] == -1) dfs2(u, scc++);
	}
	for (int i = 1; i <= 2 * n; i ++) {
		if (comp[i] == comp[i + 2 * n]) return false;
	}
	return true;
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
		v.push_back({x[i], i});
		v.push_back({y[i], i + n});
	}
	sort(v.begin(), v.end());
	for (int i = 1; i <= 2 * n; i++) {
		auto x = v[i - 1];
		if (x.second <= n) {
			a[x.second][0] = i;
		}
		else {
			a[x.second - n][1] = i;
		}
	}
	int l = 1, r = 1e9, ans = 0;
	while (l <= r) {
		int mid = l + r >> 1;
		if (yo(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 43324
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    vector<vector<bool>> G(n, vector<bool>(m,false));
    vector<int> light(m,0);

    rep(i,m){
        int k; cin >> k;
        rep(j,k){
            int s; cin >> s; s--;
            G[s][i] = true;
        }
    }

    vector<int> p(m); rep(i,m) cin >> p[i];
    ll ans = 0;

    for(int bit = 0; bit < (1 << n); bit++){
        vector<int> q(m,0);
        rep(i,n){
            if(bit & (1 << i)){
                rep(j,m){
                    if(G[i][j]) q[j] ^=1;
                }
            }
        }

        bool jud = true;
        rep(i,m) if(p[i] != q[i]) jud = false;

        if(jud) ans++;
        
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, M: int, x: "List[int]", y: "List[int]", z: "List[int]"):
    res = 0
    for mp in itertools.product([-1,1],repeat=3):
        xyz = [sum([p*q for p,q in zip(xyz,mp)]) for xyz in zip(x,y,z)]
        res = max(res, sum(sorted(xyz,reverse=True)[0:M]))
    print(res)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    z = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        z[i] = int(next(tokens))
    solve(N, M, x, y, z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

w = a[0..k-1].inject(:+)
prev = w

for i in (k..n-1)
  prev = prev + a[i] - a[i-k]
  w = [w, prev].max
end

puts 1.0 * (k + w)/2


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

#define MOD 1000000007ll
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define for0(i,n) for(__typeof(n) i = 0; i < n ; i++) 
#define forab(i,a,b) for(__typeof(a) i = a ; i < b ; i++) 
#define forba(i,b,a) for(__typeof(a) i = b ; i > a ; i--) 
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define pb     push_back
#define mp     make_pair
#define MAX 100005

int a , b , c , d;

int main(int argc, char const *argv[])
{
   scanf("%d %d %d %d" , &a , &b , &c , &d);

  printf("%d" , max(a*b , c*d));

  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
ll Power(ll x, ll y) {
	ll res = 1;
	rep(i, y) {
		res *= x;
	}
	return res;
}
vector<P<ll>> prime_fact(ll x) {
	vector<P<ll>> factor;
	for (ll i = 2; i * i <= x; i++) {
		if (x % i != 0) continue;
		ll res = 0;
		while (x % i == 0) {
			res++;
			x /= i;
		}
		factor.push_back(P<ll>(i, res));
	}
	if (x != 1) factor.push_back(P<ll>(x, 1));
	return factor;
}
int main() {
	/*
	ull a;
	cin >> a;
	double b;
	cin >> b;
	b *= 100;
	ll c = b;
	string s = to_string(a);
	string t = to_string(c);
	int n = s.size();
	int m = t.size();
	reverse(all(s));
	reverse(all(t));
	ll ans = 0;
	rep(i, m) {
		int d1 = t[i] - '0';
		ll mul1 = Power(10, i);
		rep(j, n) {
			ll d2 = s[j] - '0';
			ll mul2 = Power(10, j);
			ll tmp = d1 * d2 * mul1 * mul2;
			ans += tmp;
		}
	}
	cout << ans / 100 << endl;
	*/
	ll x;
	cin >> x;
	vector<P<ll>> fac = prime_fact(x);
	ll ans = 0;
	rep(i, fac.size()) {
		int cnt = fac[i].second;
		ll sum = 0;
		rep1(j, 1010101) {
			sum += j;
			if (sum > cnt) {
				ans += j - 1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using ll=long long;
using ld=long double;

bool pres[102];

void solve(){
	int x,n;
	cin>>x>>n;
	if(n==0){
		cout<<x<<"\n";
		return;
	}else{
		for(int i=0;i<=10;i++){
			pres[i]=false;
		}
		int a[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
			pres[a[i]]=true;
		}
		int val=101;
		int ans;
		bool flag=0;
		for(int i=0; i<=101; i++){
			if(pres[i]==false && abs(x-i)<val){
				flag=1;
				val=min(val,abs(x-i));
				ans=i;
			}
		}
		cout<<ans<<"\n";	
	}
	
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3652
url = "https://atcoder.jp//contests/abc093/tasks/arc094_a"

def main():
    t = list(map(int, input().split()))
    ind = t.index(max(t))
    count = 0
    for i in range(len(t)):
        if ind == i:
            continue
        while t[i] < t[ind] - 1:
            t[i] += 2
            count += 1
    tmp = set(t)
    if len(tmp) == 1:
        print(count)
    elif len(tmp) == 2:
        if t.count(max(tmp)) == 2:
            print(count + 2)
        else:
            print(count + 1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//g++ test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;

int a1,a2,a3;

int main(){
	cin >> a1 >> a2 >> a3;

	if(a1+a2+a3>=22){
		cout << "bust";
		return 0;
	}
	cout << "win";
	return 0;
}

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

int main() {
  
  int N; cin >> N; int64_t sum = 0; int count = 1;
  
  vector<int64_t> vec(N), sortedVec(N), countMemo(N + 1);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sortedVec = vec;
  
  sort(sortedVec.begin(), sortedVec.end());
  
  for (int i = 0; i < N - 1; i++) {
    
    int64_t tmp = sortedVec[i], next = sortedVec[i + 1];
    
    if (tmp == next) count++;
    
    else {
      countMemo[tmp] = count;
      count = 1;
    }
    
    if (i == N - 2) countMemo[next] = count;
    
  }
  
  for (int64_t x : countMemo) {
    
    if (x < 2) continue;
    
    sum += x * (x - 1) / 2;
    
  }
  
  for (int x : vec) {
    
    int64_t tmp = countMemo[x];
    
    if (tmp < 2) cout << sum << endl;
    
    else cout << sum - tmp + 1 << endl;
    
  }
  
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
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; }

vl dp(500010,-1);
vl dp2(500010,-1);

long dfs(long,long);
long dfs2(long,long);

int main(){
  long n,m;
  cin >> n >> m;
  long d = 1;
  rep(i,n){
    d *= m - i;
    d %= MOD;
  }
  cout << d*dfs(n, m-n)%MOD << endl;
}

long dfs(long n, long j){
  if(dp.at(n) != -1) return dp.at(n);
  if(n == 1) return dp.at(n) = j;
  long res = (j)*dfs(n-1, j) % MOD;
  res += (n-1)*dfs2(n-1,j+1) % MOD;
  res %= MOD;
  return dp.at(n) = res;
}

long dfs2(long n, long j){
  if(dp2.at(n) != -1) return dp2.at(n);
  if(n == 1) return dp2.at(n) = j;
  long res = (n-1)*dfs2(n-1,j) % MOD;
  res += (j)*dfs(n-1,j+1) % MOD;
  res %= MOD;
  return dp2.at(n) = res;
}

Measured memory_bytes: 42172
#include<iostream>
#include<cstring>
using namespace std;
string str[12345];
int main()
{
	int n,flag=0,flag1=0,flag2=0,flag3=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>str[i];
	for(int i=0;i<n;i++)
	{
		int len=str[i].length();
		for(int j=0;j<len-1;j++)
		{
			if(str[i][j]=='A'&&str[i][j+1]=='B')
				flag++;
		}
		if(str[i][len-1]=='A'&&str[i][0]!='B')
		{
			flag1++;
		}
		if(str[i][0]=='B'&&str[i][len-1]!='A')
		{
			flag2++;
		}
		if(str[i][len-1]=='A'&&str[i][0]=='B')
			flag3++;
	}
	if(flag1!=flag2)
		flag+=flag3+min(flag1,flag2);
	else
	{
		if(flag3!=0&&flag1==0)
		{
			flag+=flag3-1;
		}
		else if(flag3!=0&&flag1!=0)
		{
			flag+=flag3+flag1;
		}
		else 
			flag+=flag1;
	}
	cout<<flag<<endl;
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    int x;
    cin >> x;
    if (x < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin>>n;
    vector<int> V;
    vector<int> C;
    vector<int> R;
    for(int i=0;i<n;i++){
        int m;cin>>m;
        V.push_back(m);
    }
    for(int i=0;i<n;i++){
        int m;cin>>m;
        C.push_back(m);
    }
    for(int i=0;i<n;i++){
        int m;m=V[i]-C[i];;
        R.push_back(m);
    }
    int S=0;
    for(int i=0;i<n;i++){
        if(R[i]>=0){S+=R[i];}
    }
    cout<<S;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int w,q,id,wid;
  char c;
  while(cin>>wid>>q, wid|q) {
    vector<int> wall(wid,-100);
    while(q--) {
      cin>>c;
      if(c == 's') {
        cin>>id>>w;
        for(int i=0; i+w<=wid; ++i)
          if(wall[i] == -100)
            for(int j=0; j<w; ++j) {
              if(wall[i+j] != -100) break;
              if(j == w-1) {
                for(int k=0; k<w; ++k)
                  wall[i+k] = id;
                cout<<i<<endl;
                goto NEXT;
              }
            }
        cout<<"impossible"<<endl;
      NEXT:
        ;
      }else if(c == 'w') {
        cin>>id;
        for(int i=0; i<wid; ++i)
          if(wall[i] == id) wall[i] = -100;
      }
    }
    cout<<"END"<<endl;
  }
}

Measured memory_bytes: 0
l, r = [int(i) for i in input().split()]
lmod = l % 2019
rmod = r % 2019
dif = r - l
if dif >= 2019:
	print(0)
else:
	if lmod >= rmod:
		print(0)
	else:
		cand = [i for i in range(lmod, rmod + 1)]
		nc = len(cand)
		prd = []
		for i in range(nc):
			for j in range(i):
				prd.append((cand[i] * cand[j]) % 2019)
		print(min(prd))


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

int calc(int N) //0^1^...^N
{
    if(N%4==0) return N;
    if(N%4==1) return 1;
    if(N%4==2) return N+1;
    if(N%4==3) return 0;
}

signed main()
{
    int A,B; cin>>A>>B;
    if(A==0) cout<<calc(B)<<endl;
    else cout<<(calc(B)^calc(A-1))<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int n,i,sm,bi;
int main(void){
    cin>>n;
    int x[n],y[n];
    for(i=-1;++i-n;){
        cin>>x[i];
        y[i]=x[i];
    }
    sort(x,x+n);
    sm=x[n/2-1];
    bi=x[n/2];
    for(i=-1;++i-n;){
        if(y[i]>sm)cout<<sm<<endl;
        else cout<<bi<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count;
		int[] ice = new int[10];
		while ((count = Integer.parseInt(br.readLine())) > 0) {
			Arrays.fill(ice, 0);
			while (count-- > 0) {
				ice[Integer.parseInt(br.readLine())]++;
			}
			for (int b : ice) {
				if (b != 0) {
					char[] c = new char[b];
					Arrays.fill(c, '*');
					System.out.println(c);
				} else {
					System.out.println('-');
				}
			}
		}
	}
}

Measured memory_bytes: 25388
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define inf 100000000
#define _GLIBCXX_DEBUG
typedef vector<int> VI;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<int,int> PII;
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 mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(){
    int n,g;
    cin>>n;
    g=gcd(n,2);
    int ans=n*2/g;
    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;

using namespace std;
typedef pair<long,long> pr;
bool pairCompare(const pr& firstElof, const pr& secondElof)
{
    return (firstElof.first < secondElof.first || ((firstElof.first == secondElof.first) && (firstElof.second < secondElof.second)));
}

class Lowlink {
private:
	vector<vector<long>> E;
	vector<long> ord;
	vector<long> low;
	vector<long> prev;
	size_t V;
public:
	Lowlink() : V(0){ }
	Lowlink(size_t v) : 
		V(v),E(v,vector<long>(0)),ord(v,-1),low(v,2147483647),prev(v,-1) {}

	size_t size() {return V;}

	void add_edge_directed(long from,long to){
		E[from].push_back(to);
	}

	void add_edge_undirected(long from,long to){ 
		E[from].push_back(to);
		E[to].push_back(from);
	}

	void dfs(long node,long parent,long order){
		long child = 1;
		prev[node] = parent;
		low[node] =  ord[node] = order;

		REP(i,(long)E[node].size()){
			long to = E[node][i];
			if (to == parent) continue;
			if (ord[to] == -1) { // 子ノードへの辺
				dfs(to,node,order + child);
				child++;
				low[node] = min(low[node],low[to]);
			}
			low[node]=min(low[node],ord[to]);
		}
	}

	vector<pr> find_bridge(void){
		vector<pr> bridge;
		REP(i,V){
			if (ord[i] == (-1)) dfs(i,-1,1);
		}

		REP(i,V){
			if (ord[i] == low[i]) {
				if (prev[i] == (-1)) continue;
				bridge.push_back(pr(min(i,prev[i]),max(i,prev[i])));
			}
		}

		sort(bridge.begin(),bridge.end(),pairCompare);
		return bridge;
	}

	vector<long> find_articulation_point(void){
		vector<long> point;
		vector<char> root(V,0);

		REP(i,V){
			if (ord[i] == (-1)) {
				dfs(i,-1,1);
				root[i] = 1;
			}
		}

		REP(i,V){
			if (prev[i] == (-1)) continue;
			if (root[prev[i]]) root[prev[i]]++;
			else {
				if (ord[prev[i]] <= low[i]) point.push_back(prev[i]);
			}
		}
		
		REP(i,V) if (root[i] >= 3) point.push_back(i);

		sort((point).begin(),(point).end());
		point.erase(unique(point.begin(),point.end()),point.end());

		return point;
	}
};

int main(void){
	long V,E;
	long u,v;
	cin >> V >> E;
	Lowlink ll(V);
	REP(i,E){
		cin >> u >> v;
		ll.add_edge_undirected(u,v);
	}

	vector<pr> ans = ll.find_bridge();
	REP(i,ans.size()) cout << ans[i].first << " " << ans[i].second << endl;

	return 0;
}


Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 A, B, C;
  __int128 a, b, c;
  cin >> A >> B >> C;
  a = __int128(A);
  b = __int128(B);
  c = __int128(C);

  __int128 d = __int128(c - a - b) * __int128(c - a - b);
  if(c - a - b >= 0 && __int128(a) * __int128(b) < (d + 3) / 4) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int t=0, a,i=4;
	while (i--)
		fscanf(stdin, "%d", &a), t += a;
	fprintf(stdout, "%d\n%d\n", t / 60, t % 60);
		return 0;
}

Measured memory_bytes: 600
s=list(input())
k=int(input())

count=0
end=True
first_count=1

if k==1:
  for i in range(1,len(s)):
    if s[i-1]==s[i]:
      s[i]=1
      count+=1
  print(count)
else:
  is_same_all=True
  for i in range(1,len(s)):
    if s[i]!=s[i-1]:
      is_same_all=False
  if is_same_all:
    print((len(s)*k)//2)
    exit()
  if s[0]==s[-1]:
    for i in range(1,len(s)):
      if s[i-1]==s[i]:
        first_count+=1
      else:
        break     
  
  for i in range(1,len(s)):
    if s[i-1]==s[i]:
      s[i]=1
      count+=1
      if i==len(s)-1:
        end=False

  if end and s[0]==s[-1]:
    if first_count%2 != 0:
    	count+=1
    	print(k*count-1)
    else:
      print(k*count)
  else:
    print(k*count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)

int main() {
	int n, k;
	cin>>n>>k;
	int B[n];
	for(int i = 0; i < n; i++) {
		cin>>B[i];
	}
	sort(B, B + n);
	char A[k + 1];
	A[0] = 'b';
	for(int i = 1; i <= k; i++) {
		int index = 0, t = 0;
		while(index < n && B[index] <= i) {
			if(A[i - B[index]] == 'b') {
				t = 1;
				break;
			}
			index++;
		}
		if(t) {
			A[i] = 'a';
		}
		else {
			A[i] = 'b';
		}
	}
	if(A[k] == 'a')
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {

    char a[8];
    char b[4];

    scanf("%s %s", a, b);
    //文字列連結
    strcat(a, b);

    int num = atoi(a);

    double ans = pow(num, 1.0 / 2.0);

    if (ans == (int) ans) {
        printf("Yes");
    } else {
        printf("No");
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
    int a, b;
    cin >> a >> b;
    vector<int> c;
    c.resize(a);
    REP(i, a) {
        cin >> c[i];
    }
    int index = distance(c.begin(), find(ALL(c), 1));
    int perA = index % (b - 1);
    int perB = (a - index - 1) % (b - 1);
    int ans = index / (b - 1) + (a - index - 1) / (b - 1);
    if (perA > 0) ans++;
    if (perB > 0) ans++;
    if (perA != 0 && perB != 0 && perA + perB <= b) ans--;
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;
int ans[100005];

int main(void){
	cin >> s;
	int n=s.size();
	int cnt[2]={0,0};
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			cnt[i%2]++;
		}else{
			ans[i]+=cnt[i%2];
			ans[i-1]+=cnt[(i+1)%2];
			cnt[0]=0;
			cnt[1]=0;
		}
	}
	cnt[0]=0;
	cnt[1]=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='L'){
			cnt[i%2]++;
		}else{
			ans[i]+=cnt[i%2];
			ans[i+1]+=cnt[(i+1)%2];
			cnt[0]=0;
			cnt[1]=0;
		}
	}
	for(int i=0;i<n;i++){
		printf("%d%c",ans[i],i+1==n?'\n':' ');
	}
	return 0;
}


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

int main () {
  long long a, b, k;
  cin >> a >> b >>k;
  if (a - k > 0) {
    cout << a - k << ' ' << b << endl;
  } else if ((a + b) - k > 0) {
    cout << 0 << ' ' << a + b - k << endl;
  } else {
    cout << 0 << ' ' << 0;
  }
}
  


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

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

int n,m;
double p[20][3];
double d[20][20];
int perm[20];

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

    cin>>n>>m;
    REP(i,n) cin>>p[i][0]>>p[i][1]>>p[i][2];
    REP(i,n) REP(j,n){
        d[i][j]=(p[i][0]-p[j][0])*(p[i][0]-p[j][0])+
                (p[i][1]-p[j][1])*(p[i][1]-p[j][1])+
                (p[i][2]-p[j][2])*(p[i][2]-p[j][2]);
    }

    REP(i,m) perm[n-1-i]=1;
    double ret=0;
    do{
        double sum=0;
        REP(i,n-1) for(int j=i+1;j<n;j++){
            if(perm[i] && perm[j]) sum+=d[i][j];
        }
        ret=max(ret,sum);
    }while(next_permutation(perm,perm+n));

    printf("%.20lf\n",ret);
}



Measured memory_bytes: 3316
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():

    def fur(n,r):
        p,q = 1,1
        for i in range(r):
            p = p*(n-i)%mod
            q = q*(i+1)%mod
        return p * pow(q,mod-2,mod) % mod

    x, y = nm()

    if (x + y) % 3 != 0:
        print(0)
        exit()
    
    n = (2*y - x) // 3 # (X, Y) -> (X+1, Y+2) 
    m = (2*x - y) // 3 # (X, Y) -> (X+2, Y+1) 

    if n < 0 or m < 0:
        print(0)
        exit()

    print(fur(n+m, n))

if __name__ == '__main__':
    main()

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s; cin >> s;
	for (int i = 0; i < (int)s.size(); ++i) {
		if (i%2) continue;
		cout << s[i];
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 592
import itertools

n = sorted([x+1 for x in range(int(input()))])
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
count = 0
pv = 0
qv = 0
for i in itertools.permutations(n,len(n)):
  count += 1
  if i == p:
    pv = count
  if i == q:
    qv = count
print(abs(pv-qv))

Measured memory_bytes: 9208
#include<iostream>
#include<string>

using namespace std;

int win[8][3]={
	{1,2,3},
	{4,5,6},
	{7,8,9},
	{1,4,7},
	{2,5,8},
	{3,6,9},
	{1,5,9},
	{3,5,7}
};

int main(void)
{
	for(int i=0;i<8;i++)
	{
		for(int j=0;j<3;j++)
		{
			win[i][j]--;
		}
	}
	while(1)
	{
		string s;
		cin>>s;
		if(cin.eof())break;
		char c='d';
		for(int i=0;i<8;i++)
		{
			if(s[win[i][0]]!='s'&&s[win[i][0]]==s[win[i][1]]&&s[win[i][1]]==s[win[i][2]])
			{
				c=s[win[i][0]];
			}
		}
		cout<<c<<endl;
	}
}

Measured memory_bytes: 1176
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

#define int ll

vector<int> mae[200],gyaku[200];
long double percentage[200];
int visited[200];
long double colorP[200];
stack<int> tmp;
void Fdfs(int now) {
    for (auto x : mae[now]) {
        if (visited[x] == 1) continue;
        visited[x] = 1;
        Fdfs(x);
    }
    tmp.push(now);
}
void Sdfs(int now) {
    colorP[visited[now]] *= percentage[now];
    for (auto x : gyaku[now]) {
        if (visited[x] != 0) {
            if (visited[x] < visited[now]) {
                colorP[visited[now]] = 0.0L;
            }
            continue;
        }
        visited[x] = visited[now];
        Sdfs(x);
    }
}
void solve(){
    while (true) {
        int n;
        cin >> n;
        if (n == 0) return;
        REP(i, n) {
            mae[i].clear();
            gyaku[i].clear();
            visited[i] = 0;
        }
        REP(i, n) {
            cin >> percentage[i];
            int m;
            cin >> m;
            REP(q, m) {
                int a;
                cin >> a;
                a--;
                mae[i].push_back(a);
                gyaku[a].push_back(i);
            }
        }
        for (int i = 0; i < n; ++i) {
            if (visited[i] == 0) {
                visited[i] = 1;
                Fdfs(i);
            }
        }
        REP(i, n+1) {
            visited[i] = 0;
            colorP[i] = 0;
        }
        REP(hoge, n){
            int i = tmp.top();
            tmp.pop();
            if (visited[i] == 0) {
                colorP[hoge+1] = 1.0L;
                visited[i] = hoge + 1;
                Sdfs(i);
            }
        }
        long double ans = 1.0L;
        for (int q = 0; q < n + 1; ++q) {
            ans *= 1.0L - colorP[q];
        }
        cout << ans << endl;
    }
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi dep,par;
vvi g;
void dfs(int i,int p,int d){
    par[i]=p;
    dep[i]=d;
    for(ll x:g[i])if(x!=p)dfs(x,i,d+1);
}
int main(){
    ll n;cin>>n;
    if(n==2)dame("Second");
    g=vvi(n);
    dep=vi(n);
    par=vi(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    //outvv(g);
    int s=0;
    while(g[s].size()==1)s++;
    dfs(s,-1,0);
    vi color(n),cnt(n);
    vp v(n);
    rep(i,n)v[i]=P(dep[i],i);
    sort(all(v));reverse(all(v));
    //outvp(v);
    rep(i,n){
        if(color[v[i].se]){
            if(cnt[v[i].se]>1)dame("First");
        }
        else if(par[v[i].se]!=-1){
            color[par[v[i].se]]=1;
            cnt[par[v[i].se]]++;
        }
        else dame("First");
    }
    dame("Second");
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while (true) {
        string s;
        getline(cin, s);
        // cout << "********************" + s << endl;
        if (s==".") break;

        stack<char> st;
        bool ok = true;
        for (const auto c: s) {
            if (c=='(' || c=='[') st.push(c);
            if (c==')') {
                if (!st.empty() && st.top()=='(') st.pop();
                else {ok = false; break;}
            }
            if (c==']') {
                if (!st.empty() && st.top()=='[') st.pop();
                else {ok = false; break;}
            }
        }
        if (!st.empty()) ok = false;

        if (ok) puts("yes");
        else puts("no");
    }
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

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

	int ans = 0;
	for (int i = 1; i < n; i++) {
		int cnt = 0;

		for (char c = 'a'; c <= 'z'; c++) {
			bool left = false, right = false;

			for (int j = 0; j < i; j++) {
				if (s[j] == c) left = true;
			}

			for (int j = i; j < n; j++) {
				if (s[j] == c) right = true;
			}

			if (left && right) cnt++;
		}
	
		if (ans < cnt) ans = cnt;
	}

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

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


string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}


string toNegativeBase(long long int n, int negBase)
{

    if (n == 0)
        return "0";

    string converted = "";
    while (n != 0)
    {

        int remainder = n % negBase;
        n /= negBase;


        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }

        // convert remainder to string add into the result
        converted = toString(remainder) + converted;
    }

    return converted;
}

//  Driver code to test above methods
int main()
{
   long long int n;
    int negBase = -2;
  cin>>n;
    cout << toNegativeBase(n, negBase)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  lvector v(n),c(n);rep(i,n) cin>>v[i];rep(i,n) cin>>c[i];
  rep(i,n) if(v[i]-c[i]>0) ans+=v[i]-c[i];
  print(ans);
  return 0;
}

Measured memory_bytes: 3608