akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
using d = double;

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  int n;
  cin >> n;
  vector<mint> a(n);
  mint sum=0;
  rep(i,n){
    cin >> a[i];
  }
  vector<mint> b(n);
  rep(i,n) sum+=a[i];
  for(int i=0;i<n;++i){
    b[i]=sum;
    sum-=a[i];
  }

  mint ans=0;
  b.pop_back();
  rep(i,n){
    b[i]-=a[i];
    ans+=a[i]*b[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6428
I=lambda:[int(i)for i in input().split()]
F=1<<65
r=range
n,m=I()
X=set([0,F,-F])
Y=set(X)
R=[((-F,F),F),((-F,F),-F)]
H=[(F,(-F,F)),(-F,(-F,F))]
for i in r(n):a,b,c=I();R.append(((a,b),c));Y.add(c);X.add(a);X.add(b)
for i in r(m):a,b,c=I();H.append((a,(b,c)));X.add(a);Y.add(b);Y.add(c)
s=dict(enumerate(sorted(X)))
K=len(s)
t=dict(enumerate(sorted(Y)))
L=len(t)
h=dict(zip(s.values(),s.keys()))
w=dict(zip(t.values(),t.keys()))
V=[[0]*-~K for i in r(L+1)]
U=[i[:]for i in V]
v=[i[:]for i in V]
for (a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(L+1):
 for j in r(K):
  U[i][j+1]+=U[i][j]
for d,(e,f) in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for j in r(K+1):
 for i in r(L):
  V[i+1][j]+=V[i][j]
q=[(h[0],w[0])]
v[w[0]][h[0]]=1
a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  k=0;c=x+e;d=y+f
  if(0<=c<K)*(0<=d<L)*v[d][c]==0:k=U[-~f//2+y][x]==0if f!=0else V[y][-~e//2+x]==0
  if k:q.append((c,d));v[d][c]=1
if a>F:a='INF'
print(a)

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

using namespace std;

int main(int argc, char *argv []) {
	int n;
	int ch_count[26];

	for (int i = 0; i < 26; i++) ch_count[i] = 50 * 50 + 1;

	cin >> n;
	for (int i = 0; i < n; i++) {
		string S;
		cin >> S;

		int cnt[26] = {};
		for (char c : S) {
			cnt[c - 'a']++;
		}

		for (int j = 0; j < 26; j++) ch_count[j] = min(ch_count[j], cnt[j]);
	}

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < ch_count[i]; j++) {
			printf("%c", i + 'a');
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m, a[103];
long long ans = 2000000007;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i+=1)
		cin >> a[i];
	for (int i = 1; i <= 100; i+=1)
	{
		long long sum = 0;
		for (int j = 1; j <= n; j+=1)
		{
			sum += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
const int nax = 1e6 + 5;
int mp[nax];
bool check(int n)
 {
  if(n!=1 && mp[1]>0)
     return 0;
  if(n == 1 && mp[1] == 1)
     return 1;
  if(mp[n] > 1)
     return 0;
  for(int i=2;i*i<=n;i++)
     {
      if(n%i == 0)
         {
          if(mp[i]>0 || mp[n/i]>0)
             return 0;
         }
     }
   return 1;
 }
void solve()
  {
    int n;
    cin>>n;
    int ans = 0;
    memset(mp,0,sizeof mp);
    vector<int> v(n);
    loop(i,0,n)
      {
        cin>>v[i];
        mp[v[i]]++;
      }
    for(auto x : v)
          ans += check(x);
    cout<<ans;

   }

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

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 12704
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let ans = s
        .into_iter()
        .zip(t.into_iter())
        .filter(|(si, ti)| si != ti)
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 4040
using System;

namespace Math_Functions
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var a = double.Parse(x[0]);
            var b = double.Parse(x[1]);
            var c = double.Parse(x[2]);

            var t = c * Math.PI / 180;

            Console.Write("{0:F4}\n{1:F4}\n{2:F4}\n",
            a * b * Math.Sin(t) / 2,
            a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(t)),
            b * Math.Sin(t));
        }
    }
}

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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> snk(n, false);
  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      cin >> a;
      snk[--a] = true;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) if (!snk[i]) cnt++;
  cout << cnt << endl;
}


Measured memory_bytes: 3624
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for idx,val in enumerate(p):
    if idx == 0:
        continue
    elif idx == n - 1:
        break
    if val < max(p[idx - 1], p[idx + 1]) and val > min(p[idx - 1], p[idx + 1]):
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String str1 = br.readLine();
		String str2 = br.readLine();
		
		System.out.println(calcColorPattern(str1, str2, n));
	}
	
	public static int calcColorPattern(String str1, String str2, int n){
		char[] array1 = str1.toCharArray();
		char[] array2 = str2.toCharArray();
		long result = 1;
		
		final int V = 0;
		final int H = 1;
		int prevType = -1;
		
		for(int i = 0; i < n;){
			//縦
			if(array1[i] == array2[i]){
				if(i == 0){
					result *= 3;
				}
				else if(prevType == V){
					result *= 2;
				}
				
				prevType = V;
				i++;
			}
			//横
			else {
				if(i == 0){
					result *= 6;
				}
				else if(prevType == V){
					result *= 2;
				}
				else {
					result *= 3;
				}
				prevType = H;
				i += 2;
			}
			result %= 1000000007;
		}
		
		return (int) (result%1000000007);
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;

ll n,m,x[100001],y[100001];
ll xsum,ysum;
int main(void){
    cin>>n>>m;
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    rep(i,n){xsum=(xsum+i*x[i]-(n-1-i)*x[i])%mod;d(xsum)}
    rep(i,m){ysum=(ysum+i*y[i]-(m-1-i)*y[i])%mod;d(ysum)}
    p((xsum*ysum)%mod);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    if (K < A) ans += K;
    if (A <= K) ans += A;
    if (A + B <= K) ans -= K - (A + B);
    cout << ans << endl;
}


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

int main(){
	int m;
	int d, e, f;
	cin >> m >> d;
	int count = 0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			e = j / 10;
			f = j % 10;
			if(e>=2 && f>=2 && e*f == i){
				count++;
			}else{
				count = count;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
//Problem: ABC_169A
//Progress:
#include <iostream>
typedef long long int ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    cout << n*m;
    return 0;
}

Measured memory_bytes: 3604
# for c in '03210120123452101':
# 3 2 5 2
s = input()
lst = []
tmp = ''
cnt = 1
for c in s:
    if tmp == c:
        cnt += 1
    else :
        lst.append(cnt)
        cnt = 1
    tmp = c
lst.append(cnt)

ans = 0

if s[0] == '<':
    idx = 1
else:
    idx = 0
if (len(lst) - idx ) % 2 == 1:
    lst.append(1)
for i in range(idx,len(lst),2):
    if lst[i] > 1:
        if lst[i] <= lst[i+1]:
            lst[i] -= 1
        ans += lst[i] * (lst[i]+1) // 2
    if lst[i+1] > 1:
        if lst[i] > lst[i+1]:
            lst[i+1] -= 1
        ans += lst[i+1] * (lst[i+1]+1) // 2
    if lst[i] == 1 and lst[i+1] == 1:
        ans += 1
    # print(lst[i], lst[i+1])
print(ans)
# print(lst, idx)

Measured memory_bytes: 6300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define Q queue<ll>
#define DQ deque<ll> 
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define loop(x,y,z) for(ll i=x; i<=y; i+=z)
#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)
#define all(x) x.begin(), x.end()
#define sum(x) accumulate(all(x),0LL)
#define minE(x) *min_element(all(x))
#define maxE(x) *max_element(all(x))
#define watch(x) cout<<(#x)<<" is "<<x
#define endl "\n"

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

void display(vi &v,string c){
	for(auto x:v) cout<<x<<c;
}

int main(){
	IOS
	ll n;
	cin>>n;
	vi v(n-1,0),ans;
	loop(0,n-2,1) cin>>v[i];
	ans.pb(v[0]);
	ans.pb(v[0]);
	loop(1,n-2,1){
		if(v[i]>=ans.back()) ans.pb(v[i]);
		else{
			ans.popb();
			ans.pb(v[i]);
			ans.pb(v[i]);
		}
	}
	cout<<sum(ans);
	return 0;
}


Measured memory_bytes: 256
# -*- codong:utf-8 -*-
N=int(input())
A=list(map(int,input().split()))
ans1=0
ans2=0
for i in range(N):
    if A[i]%2==0:
        ans1=1
        if A[i]%3!=0 and A[i]%5!=0:
            ans2=1
if ans2!=1:
    print("APPROVED")
else:
    print("DENIED")

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

int main()
{
  int H, W;

  while(true){
      cin >> H >> W;
      if(H==0&W==0) break;
      else {
        for(int i=0; i<H; i++){
          for(int j=0; j<W; j++)cout << "#";
          cout << endl;
        }
        cout << endl;
      }
  }
}



Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int ans[200000];
vector<pair<int, ll>> to[200000];

void dfs(int v, int p, int c){
  ans[v] = c;
  for(auto u: to[v]){
    if(u.first == p) continue;
    if((u.second)%2) dfs(u.first, v, 1-c);
    else dfs(u.first, v, c);
  }
}

int main(){
  int N; cin >> N;
  rep(i, N-1){
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    to[u].push_back({v, w});
    to[v].push_back({u, w});
  }
  dfs(0, -1, 0);
  rep(i, N){
    cout << ans[i] << endl;
  }
  
}


Measured memory_bytes: 12928
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (x, y) = get!(usize, usize);
    let mut a = x;
    let mut count = 0;
    while a <= y {
        a *= 2;
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

	public static void main(String[] args) {
		while (true) {
			int X = sc.nextInt();
			if (X == 0) break;
			int Y = sc.nextInt();
			int S = sc.nextInt();
			int ans = 0;
			for (int i = 1; i < S; ++i) {
				int pa = i * (100 + X) / 100;
				for (int j = 1; j < S; ++j) {
					int pb = j * (100 + X) / 100;
					if (pa + pb != S) continue;
					int aa = i * (100 + Y) / 100;
					int ab = j * (100 + Y) / 100;
					ans = Math.max(ans, aa + ab);
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 19104
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)     for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
    
     ll a, b, c, d; cin >> a >> b >> c >> d;
     cout << max({a*c, b*d, a*d, b*c});

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    ll N, K;
    cin >> N >> K;
    ll kouho1 = N / K;
    ll kouho2 = kouho1 + 1;
    cout << min(abs(kouho1 * K - N), abs(kouho2 * K - N)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
long long H;

long long do_attack(long long X){
	if (X<=1)
	{
		X==0;
		return 1;
	}
	else
	{
		return 1 + 2 * do_attack(X/2);
	}
	
}
int main()
{
	scanf("%lld",&H);
	printf("%lld",do_attack(H));
	
}


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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(d / t + (d % t != 0) <= s)
        cout << "Yes";
    else
        cout << "No";
}



Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i, j, a, b, q;
	char str[1001], order[10], p[1001];
	
	scanf("%s",str);
	scanf("%d",&q);
	for (i=0; i<q; i++) {
		scanf("%s %d %d",order,&a,&b);
		
		if(strcmp(order,"print")==0) {
			for(j=a; j<=b; j++) {
				printf("%c",str[j]);
			}
			printf("\n");
		
		} else if(strcmp(order,"reverse")==0) {
			strcpy(p,str);
			for(j=a; j<=b; j++) {
				str[j] = p[a+b-j];
			}
		
		} else if(strcmp(order,"replace")==0) {
			scanf("%s",p);
			for(j=a; j<=b; j++) {
				str[j] = p[j-a];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007 
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
using namespace std;
vector<string> v;
void genrate(int count, string s, int x){
if(count == x ){
	//cout<<s;
	v.push_back(s); 
	return ;}
genrate(count+1,s+"0",x);
genrate(count+1,s+"1",x);

}


int main()
{
	int n,m;
	cin>>n>>m;
	genrate(0,"",n);
	vector<int> v1[m+1];
	for(int i = 1;i<=m;i++)
	{
		int x;
		cin>>x;
		for(int j = 0;j<x;j++){
			int y;
			cin>>y;
			v1[i].pb(y);
		}
	}
	int a[m+1];
	a[0] = -1;
	for(int i = 1;i<=m;i++)
		cin>>a[i];
	int ans =0;
	for(int p = 0;p<v.size();p++)
	{
		//string s = v[i];
		int temp = 0;
		for(int i = 1;i<=m;i++)
		{   int c = 0;
			for(int j = 0;j<v1[i].size();j++)
			{
				if(v[p][v1[i][j]-1] == '1')
					c++;
			}
			//if(v[p] == "10000")
			//	cout<<c<<" ";
			if(c%2 == a[i])
				temp++;
		}

		if(temp == m){
			//cout<<v[p]<<endl;
			ans++;
		}


	}
	cout<<ans;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
int n;
vec2int g;
vector<vecll> dp;
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
ll dfs(int a, int p, int c) {
  // c == 0: white, c == 1: black
  if (dp[a][c] != -1) return dp[a][c];
  ll res = 1;
  for (auto& i : g[a]) {
    if (i == p) continue;
    // cout << a << " " << i << " " << c << endl;
    if (c == 1) {
      res *= dfs(i, a, 0) % MOD;
    } else {
      res *= (dfs(i, a, 0) + dfs(i, a, 1)) % MOD;
    }
    res %= MOD;
  }
  dp[a][c] = res;
  // cout << res << endl;
  return res;
}
int main() {
  init();
  cin >> n;
  g = vector<vector<int>>(n);
  // REP(i, n) cout << g[i].empty() << endl;
  REP(i, n - 1) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    // cout << x << " " << y << endl;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  // REP(i, n) {<
  //   cout << i << ":";
  //   for (auto& e : g[i]) cout << e << " ";
  //   cout << endl;
  // }
  // cout << endl;
  dp = vector<vecll>(n, vecll(2, -1));
  dfs(0, -1, 0);
  dfs(0, -1, 1);
  cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}


Measured memory_bytes: 19584
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# UnionFind
class UnionFind():
    def __init__(self, n):
        self.nodes=[-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x]=self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x=self.get_root(x)
        root_y=self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root=root_x
                small_root=root_y
            else:
                small_root=root_x
                big_root=root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root]=big_root


def main():
    N,M=MI()
    A=LI()

    uf=UnionFind(N)
    get_root, unite, nodes=uf.get_root, uf.unite, uf.nodes
    for _ in range(M):
        x,y = MI()
        unite(x,y)
    
    need = N-1-M #N-1本の辺が必要で、今M本の辺がある
    need *= 2 #辺の2倍の点を使う
    if need > N:
        print("Impossible")
        return 
    if need == 0:
        print(0)
        return

    root = defaultdict(list)
    for i,a in enumerate(A):
        root[get_root(i)].append(a)

    ans = 0
    whole = []
    for list_ in root.values():
        list_.sort()
        ans += list_[0]
        whole.extend(list_[1:])
        need-=1
    whole.sort()
    ans += sum(whole[:need])
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 111508
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

vector<int> G[100'010];
vector<int> Gf[100'010];
vector<long long> dist(100'010, INF);
bool used[100'010];

int main(){
  
  int k;
  cin>>k;
  REP(i,k){
    G[i].push_back((i+1)%k);
    Gf[i].push_back((10*i)%k);
  }
  
  deque<int> d;
  d.push_back(1);
  dist[1] = 0;
  //used[1] = true;
  while(!d.empty()){
    int now = d.front();
    d.pop_front();
    for(int next_:Gf[now]){
      //if(used[next_])continue;
      if(dist[next_]>dist[now]){
        d.push_front(next_);
        dist[next_] = dist[now];
        //used[next_] = true;
      }
    }
    for(int next_:G[now]){
      //if(used[next_])continue;
      if(dist[next_]>dist[now]+1){
        d.push_back(next_);
        dist[next_] = dist[now]  + 1;
        //used[next_] = true;
      }
    }
  }
  
  long long ans = dist[0] + 1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];ll ans=0;
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll x=0;
    ll c[2];
    for(int i=45;i>=0;i--)
    {
        c[0]=0,c[1]=0;
        for(int j=0;j<n;j++)
        {
            if((a[j]>>i)&1LL)
            c[1]++;
            else
            c[0]++;
        }
        if((c[0]>c[1]) and x+(1LL<<i)<=k)
        {
            x+=(1LL<<i);
        }
    }
    for(int i=0;i<n;i++)
    {
        ans+=(a[i]^x);
    }
    cout<<ans<<endl;
    
}
int main()
{
    Imposter

    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 4384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray();

            var minusCount = 0;
            var zeroCount = 0;

            var sum = 0L;

            var min = long.MaxValue;

            for(int i = 0; i < n; i++) {
                if(a[i] < 0) {
                    minusCount++;
                } else if(a[i] == 0) {
                    zeroCount++;
                }

                var aa = Math.Abs(a[i]);

                min = Math.Min(aa, min);
                sum += aa;
            }

            var ans = 0L;

            if(minusCount % 2 == 0) {
                ans = sum;
            } else if(zeroCount > 0) {
                ans = sum;
            } else {
                ans = sum - min - min;
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 39356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const int mod = 1000000007;

int main(){
    int n,m; cin >> n >> m;
    vector<int> l(m),r(m); rep(i,m) cin >> l[i] >> r[i];
    
    int maxl=0, minr=n;
    rep(i,m) chmax(maxl, l[i]), chmin(minr, r[i]);
    if(minr>=maxl) cout << minr-maxl+1;
    else cout << 0;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n,k;
ll ans;
//string s;
signed main(){
	acc_io;
	cin>>n>>k;
	vector<pair<int,int>> ab(n);
	ll cnt=0;
	rep(i,0,n){
		cin>>ab[i].first>>ab[i].second;
	}
	sort(all(ab));
	rep(i,0,n){
		cnt+=ab[i].second;
		if(cnt>=k){
			ans=ab[i].first;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<stack>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define sd(n) scanf("%d",&n)
#define sf(n) scanf("%lf",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sld(n)  scanf("%lld",&n)
#define ss(str) scanf("%s",str)
#define pd(n) printf("%d",n)
#define pld(n) printf("%lld",n)
#define plf(n) printf("%lf",n)
#define mm(a,n) memset(a,n,sizeof(a))
#define tmp(x) std::cout<<"& "<<x<<" &\n"
using namespace std;
const int maxn=5e5+10;
char a[maxn];int b[maxn],c[maxn];
ll ans;
int main(){
    int cnt=0;
    while(~scanf("%c",&a[cnt])&&a[cnt]!='\n'){
        ++cnt;
    }
    int n=cnt;
    for(int i=0;i<n-1;++i){
        if(a[i]=='>'&&a[i+1]=='<') {
        	b[i+1]=c[i+1]=0;
        	int j=i;
        	while(j>=0&&a[j]=='>')b[j]=b[j+1]+1,--j;
        	j=i+1;
        	while(j<=n&&a[j]=='<')c[j+1]=c[j]+1,++j;
        }
    }
	if(ans==0){
		b[0]=0,c[0]=0;
		for(int i=0;i<n;++i){
			if(a[i]=='<')b[i+1]=b[i]+1;
		}
		for(int i=n-1;i >=0;--i){
			if(a[i]=='>')c[i]=c[i+1]+1;
		}
	}
	for(int i=0;i<=n;++i){
        if(b[i]&&c[i])ans+=max(b[i],c[i]);
        else ans+=max(b[i],c[i]);
    }
//    for(int i=0;i<=n;++i)cout<<b[i]<<" ";
//        cout<<endl;

//        for(int i=0;i<=n;++i)cout<<c[i]<<" ";
//    cout<<endl;
    cout<<ans<<endl;






    return 0;
}


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

bool chk[244140624];
int n;
string ins, s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    while (n--) {
        cin >> ins >> s;
        int h = 0;
        for (int i=0, l=s.size(); i<l; ++i) {
            h *= 5;
            if (s[i] == 'A')
                h += 1;
            else if (s[i] == 'C')
                h += 2;
            else if (s[i] == 'G')
                h += 3;
            else
                h += 4;
        }
        if (ins[0] == 'i') {
            chk[h] = true;
        } else {
            cout << (chk[h] ? "yes\n" : "no\n");
        }
    }
    return 0;
}

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

// --- SIEVE begin --- cut here ---

// sieve(upto) returns the list of prime numbers up to upto.
//   Size: upto(1e8).size() ... 5.7e6,  upto(1e9).size() ... 5.1e7
//   Performance: upto(1e8) ... 0.7sec,   upto(1e9) ... 9.2sec
vector<int> sieve(int upto) {
  vector<int> res;
  vector<bool> tbl(upto+1);
  ll lim = (int)(sqrt((double)upto)) + 1;
  for (int x = 2; x <= upto; x++) {
    if (tbl.at(x))  continue;
    res.push_back(x);
    if (x > lim)  continue;
    for (int y = x * 2; y <= upto; y += x) tbl.at(y) = true;
  }
  return res;
}

/*
  Prime Factorization
    Two versions:
      - prfac(n)
      - prfac(n, primes)
 */

vector<pair<ll, int>> prfac(ll n, const vector<int>& primes) {
  //      primes should contain prime numbers at least up to sqrt(n)
  vector<pair<ll, int>> res;
  ll x = n;
  for (ll p : primes) {
    if (x == 1)  break;
    if (p * p > x)  break;
    if (x % p != 0)  continue;
    int c = 1;
    x /= p;
    while (x % p == 0) {
      c += 1;
      x /= p;
    }
    res.push_back(make_pair(p, c));
  }
  if (x != 1)  res.push_back(make_pair(x, 1));
  return res;
}

vector<pair<ll, int>> prfac(ll n) {
  return prfac(n, sieve((int)(sqrt((double)n)) + 1));
}

/*
    List of divisors
      - getDivisors(n)
    Note: the results are NOT sorted
 */

// gdsub ... aux function used in getDivisors()
vector<ll> gdsub(int i, int n, auto fs) {
  if (i == n) { return vector<ll>({1}); }
  auto part = gdsub(i+1, n, fs);
  ll p  = fs.at(i).first;
  int r = fs.at(i).second;
  ll pp = p;    // pp = p^m, for m \in [1, r]
  int partOrigLen = part.size();
  for (int m = 1; m <= r; m++) {
    for (int j = 0; j < partOrigLen; j++) {
      part.push_back(pp * part.at(j));
    }
    pp *= p;
  }
  return part;
}

vector<ll> getDivisors(ll n) {
  auto fs = prfac(n);
  return gdsub(0, fs.size(), fs);
}

// --- SIEVE end --- cut here ---


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int X; cin >> X;

  for (int p : sieve(1e6)) {
    if (p >= X) {
      cout << p << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 1020
/*
	* ernestvw
	* C++
	* May 2020
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define veci vector<int>
#define vecs vector<string>
#define amax(x, v) x = max(x, (v))
#define amin(x, v) x = min(x, (v))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define nl '\n'

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

const int oo = 1e9; // INT_MAX
const long long OO = 1e18; // LLONG_MAX
const double eps = 1e-9;
const int p197 = 1000000007;
const int p998 = 998244353;
const int p103 = 1000003;

#define TEST_CASES 0

void solve(int test_case);

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

	int T = 1;
	if(TEST_CASES) cin >> T;
	for(int t = 1; t <= T; t++)
		solve(t);

	return 0;
}

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

int n;
vector<veci> adj;
veci a;
veci ans;
veci M;

void dfs(int u, int p, int maxi = 0) {
	ans[u] = maxi;
	int oldMaxi = maxi;
	for(int v : adj[u]) if(v != p) {
		maxi = oldMaxi;
		vector<pair<int, int>> chgs;
		if(a[v] < M[0]) {
			chgs.pb({0, M[0]});
			M[0] = a[v];
		}
		else if(a[v] > M[maxi-1]) {
			chgs.pb({maxi, M[maxi]});
			M[maxi] = a[v];
			maxi++;
		}
		else {
			int start = -1, end = maxi - 1, key = a[v];
			while(end - start > 1) {
				int mid = start + (end - start) / 2;
				if(M[mid] >= key) end = mid;
				else start = mid;
			}
			chgs.pb({end, M[end]});
			M[end] = a[v];
		}
		dfs(v, u, maxi);
		for(auto P : chgs) M[P.x] = P.y;
	}
}

void solve(int test_case) {
	cin >> n;
	a.resize(n);
	adj.resize(n);
	ans.resize(n);
	FOR(i, n)cin>>a[i];
	FOR(i, n-1){
		int u,v;
		cin >>u >> v;u--,v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	M.assign(n+2, +oo);
	M[0] = a[0];
	dfs(0, -1, 1);
	for(int i =0; i < n; i++) cout << ans[i] << nl;
}



















































Measured memory_bytes: 50372
#include<stdio.h>
#include<math.h>

typedef struct {
  double x, y;
} Point;

void print(Point p){
  printf("%.8f %.8f\n", p.x, p.y);
}

void koch(int n, Point p1, Point p2){
  Point s, t, u;
  double th = M_PI*60.0/180.0;
  if(n == 0)return;
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y ) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y ) * cos(th) + s.y;
  
  koch(n-1, p1, s);
  print(s);
  koch(n-1, s, u);
  print(u);
  koch(n-1, u, t);
  print(t);
  koch(n-1, t, p2);
}

int main(){
  Point p1, p2;
  int n;
  scanf("%d",&n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  koch(n, p1, p2);
  print(p2);

  return 0;
}



Measured memory_bytes: 2056
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,count2,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(a);
    Readln(b);
    count:=0;
    count2:=0;
    x:=0;
    y:=0;

    for i:=1 to (b-a) do
      x:=x+i;

    Writeln(x-b);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    ll a,b;
    cin>>a>>b;
    if((a*b)%2==0)cout<<"Even";
    else cout<<"Odd";
return 0;}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
  int N, M, X[100000], L[100000], sum;
  
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &X[i]);
  }
  if (N >= M) {
    printf("0\n");
    return 0;
  }
  sort(X, X + M);
  for (int i = 0; i < M - 1; i++) {
    L[i] = X[i+1] - X[i];
  }
  sort(L, L + M - 1, greater<int>());
  sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum += L[i];
  }
  printf("%d\n", X[M-1] - X[0] - sum);
  return 0;
}


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

int a[4] = {0}, n;

int main() {
  cin >> a[1] >> a[3] >> n;
  for(int i = 0; i < n; ++i) {
    int xy[2], na;
    cin >> xy[0] >> xy[1] >> na;
    if(na % 2 == 0)
      a[na - 1] = min(a[na - 1], xy[(na - 1) / 2]);
    else
      a[na - 1] = max(a[na - 1], xy[(na - 1) / 2]);
  }
  if(a[0] >= a[1] || a[2] >= a[3])
    cout << 0 << endl;
  else
    cout << (a[1] - a[0]) * (a[3] - a[2]) << endl;
  return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    int ans = 0;
    int min = MOD;
    rep(i, n) {
        if(p.at(i) <= min) {
            ans++;
            min = p.at(i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3992
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 
// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********
// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}
inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}
inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}
ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}
ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
ll modinv(ll n)
{
	return modexp(n,mod-2);
}
// ******** GLOBAL VARIABLES ********
// ******** GLOBAL VARIABLES ********
void solve(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	ll c1=0,c2=0;
	REP(i,n){
		cin>>a[i]>>b[i];
	}
	REP(i,n){
		if(a[i]==b[i])
			c1++; 
		else
			c1=0;
		c2=max(c2,c1);
	}
	if(c2>=3){
		cout<<"Yes";
	}
	else
		cout<<"No";
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-


def rli():
    return list(map(int, input().split()))


def check2(s):
    l = len(s) // 2
    if len(s) % 2 == 0:
        if s[:l] != s[:l-1:-1]:
            return False
    else:
        if s[:l] != s[:l:-1]:
            return False
    return True


def check(s):
    l = len(s) // 2
    if s[:l] != s[:l:-1]:
        return False
    if check2(s[:l]) and check2(s[l+1:]):
        return  True
    return False


def main():
    s = input()
    if check(s):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
A, B, C = map(int, input().split())
K = int(input())
while K > 0:
    if A >= B:
        B *= 2
        K -= 1

    if K <= 0:
        break

    if B >= C:
        C *= 2
        K -= 1

    if A < B < C:
        break

if A < B < C:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61912
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = sc.nextLong()
    val m = sc.nextLong()
    val ans = (n*(n-1)/2) + (m*(m-1)/2)
    println(ans)
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 31408
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vll v(n);
read(v);
ll count[2*MAXN]={0};
for(int i=0;i<n;i++)
{
    count[v[i]]++;
}
ll ans=0;
for(int i=0;i<2*MAXN;i++)
{
  ans+=(count[i]*(count[i]-1))/2;  
}
vll anss(n);
for(int i=0;i<n;i++)
{
    if(count[v[i]]==1)
    {
        anss[i]=ans;
        continue;
    }
    anss[i]=ans;
    anss[i]-=(count[v[i]]-1);
}
for(int i=0;i<n;i++)
{
    cout<<anss[i]<<' ';
}
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 7296
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static io;
public class CompetitiveProgramming
{
  public void Solve()
  {
    var N = Int1;
    var A = Ints;
    int ans = 0;

    for (int i = 0; i < N; ++i)
    {
      int min = i;
      for (int j = i; j < N; ++j)
      {
        if (A[min] > A[j])
        {
          min = j;
        }
      }
      if (i != min)
      {
        ++ans;
        int x = A[min];
        A[min] = A[i];
        A[i] = x;
      }
    }

    Write(A);
    Write(ans);
  }


}

class BIT
{

}



class Program
{
  static void Main(string[] args)
  {
    var CompetitiveProgramming = new CompetitiveProgramming();
    CompetitiveProgramming.Solve();
  }
}
public static class io
{
  public static string Str => Console.ReadLine();
  public static string[] Strs => Str.Split(' ');
  public static long[] Longs => Strs.Select(long.Parse).ToArray();
  public static int[] Ints => Strs.Select(int.Parse).ToArray();
  public static char[] Chars => Str.ToArray();
  public static double[] Doubles => Strs.Select(double.Parse).ToArray();
  public static long Long1 => Longs[0];
  public static int Int1 => Ints[0];
  public static char Char1 => Chars[0];
  public static double Double1 => Doubles[0];
  public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; }
  public static void Write(string a) => Console.WriteLine(a);
  public static void Write(params object[] i) => Write(string.Join(" ", i));
  public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
  public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); }
  public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); }
}



Measured memory_bytes: 18480
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  
  for (int i =0; i < N; i++) {
    int x;
    cin >> x;
    if (K - x > x) {
      sum += x * 2;
    }
    else {
      sum += (K -x) * 2;
    }
    
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
N, K = map(int, input().split())

num_exclude = list(map(int, input().split()))

dec_num = [i for i in range(0, 10)]

able_use_num_lis = list(map(str, set(dec_num) - set(num_exclude)))

num_len = len(str(N))

output_list = []

def dfs(cur, num, able_use_num_lis):
    if num != '':
        if int(num) >= N:
            output_list.append(int(num))
    if len(str(N)) + 1 == cur:
        return
    
    for add_num in able_use_num_lis:
        ret = dfs(cur + 1, num + add_num, able_use_num_lis)
    return output_list

print(min(dfs(0, '', able_use_num_lis)))

Measured memory_bytes: 5472