akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int n,m;cin>>n>>m;
	v h(n);in(h,n);
	vv gr(n);
	f(i,m)	
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		gr[a].pb(b);
		gr[b].pb(a);
	}
	int ans=0;
	f(i,n)
	{
		if(sz(gr)==0)
		{
			ans++;
			continue;
		}
		int mx=0;
		for(auto it:gr[i])
			mx=max(mx,h[it]);
		if(h[i]>mx)
			ans++;

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

Measured memory_bytes: 9772
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());

        int Alice = 0;
        int Bob = 0;
        for(int i=0;i<N; i+=2){
            Alice += a[i];
        }
        for(int i=1;i<N;i+=2){
            Bob += a[i];
        }
        System.out.println(Alice-Bob);
    }
}

Measured memory_bytes: 23632
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b&&a!=c||a==c&&b!=a||b==c&&a!=c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

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

int main(void) {
	int A, B, C;
	cin >> A >> B >> C;
	int max = A;
	int mid, min;
	if (max <= B) {
		mid = A;
		max = B;
	}
	else {
		mid = B;
	}
	if (max <= C) {
		min = mid;
		mid = max;
		max = C;
	}
	else if (mid <= C) {
		min = mid;
		mid = C;
	}
	else {
		min = C;
	}

	cout << 10 * max + mid + min << endl;
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

const int N = 1000005;

const int mod = 1000*1000*1000+7;

int n;
int f[N], g[N];

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

	cin >> n;

	int result = 0;

	f[0] = 1;

	for (int i = 1; i <= n; ++i) {
		g[i] = (g[i] + g[i - 1]) % mod;
		f[i] = (f[i] + f[i - 1]) % mod;
		f[i] = (f[i] + g[i]) % mod;
		if (i + 1 <= n) {
			result = (result + (1LL * (n - 1) * (n - 1) % mod) * f[i - 1]) % mod;
		}
		if (i + 2 <= n) {
			g[i + 2] = (g[i + 2] + f[i - 1]) % mod;
			result = (result + 1LL * f[i - 1] * i) % mod;
		} else {
			result = (result + 1LL * f[i - 1] * (n - 1)) % mod;
		}
		// for (int j = 2; j <= n; ++j) {
		// 	if (i + j <= n) {
		// 		f[i + j] = (f[i + j] + f[i]) % mod;
		// 	} else {
		// 		result = (result + f[i]) % mod;
		// 	}
		// }
	}

	result = (result + f[n]) % mod;

	cout << result << endl;

	return 0;
}

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

int main()
{

    int cartela[3][3];
    int numbers = 0;
    int count;
    int number;

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> cartela[i][j];
        }
    }

    cin >> count;

    for (int i = 0; i < count; i++)
    {
        cin >> number;

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                 if (number == cartela[i][j])
                    cartela[i][j] = 0;
            }
        }
    }

    if (cartela[0][0] == 0 && cartela[0][1] == 0 && cartela[0][2] == 0)
        cout << "Yes";
    else if (cartela[1][0] == 0 && cartela[1][1] == 0 && cartela[1][2] == 0)
        cout << "Yes";

    else if (cartela[2][0] == 0 && cartela[2][1] == 0 && cartela[2][2] == 0)
        cout << "Yes";

    else if (cartela[0][0] == 0 && cartela[1][0] == 0 && cartela[2][0] == 0)
        cout << "Yes";

    else if (cartela[0][1] = 0 && cartela[1][1] == 0 && cartela[2][1] == 0)
        cout << "Yes";

    else if (cartela[0][2] == 0 && cartela[1][2] == 0 && cartela[2][2] == 0)
        cout << "Yes";

    else if (cartela[0][0] == 0 && cartela[1][1] == 0 && cartela[2][2] == 0)
        cout << "Yes";

    else if (cartela[0][2] == 0 && cartela[1][1] == 0 && cartela[2][0] == 0)
        cout << "Yes";

    else
        cout << "No";
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  vector<vector<int>> A(N, vector<int>(N-1));
  REP(i, N) REP(j, N-1){
    cin >> A[i][j];
    A[i][j]--;
  }

  vector<int> cnt(N);
  vector<int> flag(N);
  vector<int> ok(N);
  vector<int> miru(N);
  REP(i, N) miru[i] = i;

  int ans = 0;

  while(true){
    fill(ALL(flag), 0);
    int change = 0;
    vector<int> add;
    for(int i : miru){
      int j = A[i][cnt[i]];
      if(ok[i] || flag[i]) continue;
      if(ok[j] || flag[j]) continue;

      if(i == A[j][cnt[j]]){
        add.push_back(i);
        add.push_back(j);
        change++;
        cnt[i]++; cnt[j]++;
        flag[i] = 1; flag[j] = 1;
        if(cnt[i] == N-1) ok[i] = 1;
        if(cnt[j] == N-1) ok[j] = 1;
      }
    }
    miru = add;
    if(change) ans++;
    else break;
  }

  REP(i, N) if(ok[i] == 0) ans = -1;
  cout << ans << endl;

  return 0;
}

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

int main() {
	long long n, sum;
	cin>>n;
	sum=n;
	for(long long i=1;i*i<=n;i++) if(n%i==0) sum=(i-1)+(n/i-1);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, C;
    cin >> n >> C;

    vvl d(C, vl(C));  // d[x][y] : マスを色xから色yに塗り替えるときのコスト
    rep(i, C) {
        rep(j, C) {
            cin >> d[i][j];
        }
    }

    vvl c(n, vl(n));  // c[i][j] : マス(i,j)の色
    vvl v(C, vl(3));  // v[x][y] : 色xのマスのうち (i+j)%3 = y となるものの個数
    rep(i, n) {
        rep(j, n) {
            cin >> c[i][j];
            c[i][j]--;
            v[c[i][j]][(i+j)%3]++;
        }
    }
    
    ll ans = INF;
    rep(i, C) {  // (i+j)%3 = 0 のマスを色iで塗る
        rep(j, C) {  // (i+j)%3 = 1 のマスを色jで塗る
            rep(k, C) {  // (i+j)%3 = 2 のマスを色kで塗る
                if(i == j || j == k || k == i) {
                    continue;
                }
                ll now = 0;
                rep(x, C) {
                    now += d[x][i]*v[x][0];
                    now += d[x][j]*v[x][1];
                    now += d[x][k]*v[x][2];
                }
                chmin(ans, now);
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> A >> B;
	int ans = min(N * A, B);
	cout << ans << endl;
}

















Measured memory_bytes: 256
#include <stdio.h>
  
int main(void){
  
  int n;
  int a[100];
  register int i;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  for(i = (n - 1);i > 0;i--){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  return 0;
}

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

int main(){
    double x1,y1,x2,y2;
    double total_x,total_y;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%lf\n",hypot(x1-x2,y1-y2));
    return 0;
}



Measured memory_bytes: 2104
#include<iostream>

using namespace std;

#define int long long

int pos[123][42345];
int O=20000;

signed main(){
  int N,L,M,R;
  cin>>N>>L>>M>>R;
  pos[0][O]=1;
  bool can[123]={};
  for(int i=0;i<N;i++){
    int m;
    cin>>m;
    int mx=2*M;
    for(int j=-mx;j<=mx;j++){
      if(pos[i][j+O]){
	int lh=j-2*R*m;
	if(-mx<=lh){
	  pos[i+1][O+max(-mx,j-L*m)]++;
	  pos[i+1][O+lh+1]--;
	}
	int hl=j+2*R*m;
	if(hl<=mx){
	  pos[i+1][O+hl]++;
	  int hh=j+L*m;
	  if(hh+1<=mx){
	    pos[i+1][O+hh+1]--;
	  }
	}
      }
    }
    can[i+1]=pos[i+1][-mx+O];
    for(int j=-mx+1+O;j<=mx+O;j++){
      pos[i+1][j]+=pos[i+1][j-1];
      can[i+1]|=pos[i+1][j];
    }
  }
  cout<<(can[N]?"Yes":"No")<<endl;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

int N;
int arr[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    int res = 1;
    while (res * 2 <= N) res *= 2;cout << res << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int n,a,b,c;

scanf("%d",&n);

c=n%10;b=((n-c)/10)%10;a=(n-10*b-c)/100;

if(a==7||b==7||c==7){printf("Yes");}
else if(a!=7&&b!=7&&c!=7){printf("No");}

return 0;
}

Measured memory_bytes: 2152
#include <cstdio>
#include <string>
#include <set>
#include <cstring>

using namespace std;

char s[105];

int main()
{
  scanf("%s", s);

  set<char> S;
  S.insert('A');
  S.insert('T');
  S.insert('G');
  S.insert('C');

  int n = strlen(s), res = 0;
  for (int i = 0; i < n; ++i)
  {
    int j = i;
    while (j < n && S.find(s[j]) != S.end())
      j++;
    res = max(res, j - i);
  }

  printf("%d\n", res);
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

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

    int n;cin>>n;
    vector<int> p(n),q(n);
    for(int i=0;i<n;i++){
        cin>>p[i];p[i]--;
        q[p[i]]=i;
    }
    int res=0;
    int tmp=1,idx=q[0];
    for(int i=1;i<n;i++){
        if(q[i]>idx){
            tmp++;
            idx=q[i];
        }
        else{
            res=max(res,tmp);
            tmp=1;
            idx=q[i];
        }
    }
    res=max(res,tmp);
    cout<<n-res<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	long long a,b,c,s;
	cin>>a>>b>>c;
	for(long i=0;i<10;i++)
	{
		s=(a*c)-b;
		c=s;
		cout<<s<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>
#include <map>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc)
{
    for (auto e : vc)
        cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc)
{
    for (auto vc : vvc)
    {
        for (auto e : vc)
            cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp)
{
    for (auto pT : vp)
        cout << pT.first << " " << pT.second << endl;
}

int main() {
    int n;
    cin >> n;
    vi v(n);
    map<int, bool> t;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        t[a] = true;
    }
    cout << t.size() << endl;
    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
import os
from functools import reduce

import itertools
import sys
from math import gcd

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353

def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


def mod_invs(max, mod):
    """
    逆元 0, 1/1, 1/2, 1/3, ..., 1/max
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    invs[0] = 0
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def factorial_invs(max, mod):
    """
    階乗 0!, 1!, 2!, ..., max! の逆元
    :param int max:
    :param int mod:
    """
    ret = [1]
    r = 1
    for inv in mod_invs(max, mod)[1:]:
        r = r * inv % mod
        ret.append(r)
    return ret


class Combination:
    def __init__(self, max, mod):
        """
        :param int max:
        :param int mod: 3 以上の素数であること
        """
        self._factorials = get_factorials(max, mod)
        self._finvs = factorial_invs(max, mod)
        self._mod = mod

    def ncr(self, n, r):
        """
        :param int n:
        :param int r:
        :rtype: int
        """
        if n < r:
            return 0
        return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod


N, K = list(map(int, sys.stdin.buffer.readline().split()))


def test(N, K):
    s = 0
    counts = defaultdict(int)
    for nums in itertools.product(range(1, K + 1), repeat=N):
        s += reduce(gcd, nums)
        counts[reduce(gcd, nums)] += 1
    print(counts)
    print(s % MOD)


# test(N, K)


# comb = Combination(max=N + K, mod=MOD)


# @debug
def count_patterns(n):
    # gcd の約数が n となるように選ぶ方法の数
    return pow(K // n, N, MOD)


counts = [0] * (K + 1)
for n in range(1, K + 1):
    cnt = count_patterns(n)
    counts[n] = cnt
for n in reversed(range(1, K + 1)):
    i = n * 2
    while i <= K:
        counts[n] -= counts[i]
        i += n
# print(counts)

ans = 0
for n in range(1, K + 1):
    ans += n * counts[n] % MOD
    ans %= MOD
print(ans)


Measured memory_bytes: 69196
# Wrote in Mar 5, 2020 21:44 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=".to_i")
  t = []
  n.times do
    t.push(eval("gets.chomp#{datatype}"))
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end

#---------------

a,b = inp
if a>9||b>9
  puts "-1"
  exit
end
puts a*b


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

using namespace std;

int main() {
  //input
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }

  vector<int> c(n);
  for (int i = 0; i < n; i++){
    cin >> c[i];
  }


  //solve
  int ans = 0;
  for (int i=0; i < n; i++){
    if (v[i] > c[i]){
      ans += v[i] - c[i];
    }else{
      continue;
    }
  }

  //output
  cout << ans << endl;

  return 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(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int n, m;
    cin >> n >> m;

    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<vector<int>> G(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    rep(i, n){
        bool ok = true;
            for (auto& p : G[i]) {
                if(h[i] <= h[p]){
                    ok = false;
                }
            }
        ans += ok;
    }


    cout << ans << "\n";

    return 0;
}


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

using namespace std;

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

	vector<int> a(N);

	for (int i = 0; i < N; i++){
		cin >> a[i];
	}

	int right = 0;
	int sum = 0;
	long long cnt = 0;
	for (int left = 0; left < N; left++){
		while (right < N && ((sum ^ a[right]) == (sum + a[right]))){
			sum += a[right];
			right++;
		}
		cnt += right - left;

		if (right == left){
			right++;
		}
		else{
			sum -= a[left];
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
n,a,b,c = gets.split.map(&:to_i)
$xs = []
n.times do
  $xs << gets.to_i
end

$n = n
$h = {"a" => a, "b" => b, "c" => c}
$ans = Float::INFINITY
def calc(str)
  h = {}
  a = 0
  b = 0
  c = 0
  h["a"] ||= {count: 0, val: 0}
  h["b"] ||= {count: 0, val: 0}
  h["c"] ||= {count: 0, val: 0}
  str.chars.each.with_index do |ch,i|
    next if ch == "n"
    h[ch][:count] += 1
    h[ch][:val] += $xs[i]
  end

  if h["a"][:count] == 0 || h["b"][:count] == 0 || h["c"][:count] == 0
    return
  end

  cost = 0
  cost += ([h["a"][:count] - 1,0].max) * 10 
  cost += ([h["b"][:count] - 1,0].max) * 10
  cost += ([h["c"][:count] - 1,0].max) * 10

  cost += ($h["a"] - h["a"][:val]).abs
  cost += ($h["b"] - h["b"][:val]).abs
  cost += ($h["c"] - h["c"][:val]).abs

  # binding.pry if cost == 120

  $ans = [$ans, cost].min
end

def dfs(depth, str)
  if depth == $n
    calc(str)
    return if depth == $n
  else
    ["a","b","c","n"].each do |c|
      dfs(depth + 1, str + c)
    end
  end
end

dfs(0, "")
puts $ans


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

using namespace std;

int main(){
   //freopen("in.txt","r",stdin);
   int ans = 0;
   int tmp;
   int mmin = 10;
   int cnt = 0;
   for(int i = 0; i<5;i++){
      cin>>tmp;
      if(tmp % 10){
         cnt++;
      }
      if(tmp%10&&tmp%10<mmin){
         mmin = tmp%10;
      }
      ans += tmp/10 * 10;
      //cout<<ans<<endl;
   }
//   cout<<cnt<<endl;
   ans +=cnt*10 + mmin -10;
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int asc(const void *a, const void *b) {
  return *(char *)a - *(char *)b;
}
int ascs(const void *a, const void *b) {
  return strcmp((char *)a,(char *)b);
}
int main(){
   int n,i,k;
   long j,sum;
   char s[100000][11];   
   scanf("%d",&n);
   for (i=0;i<n;i++) {
      scanf("%s",s[i]);
      qsort(s[i],10,sizeof(char),asc);
   }
   qsort(s,n,sizeof(char)*11,ascs);
   for (sum=i=0;i<n;i++) {
      for (j=i+1;j<n;j++) 
         if (strcmp(s[i],s[j])!=0) break;
      sum+=(j-i-1)*(j-i)/2;
      i=j-1;
   }
   printf("%ld\n",sum);
   return 0;
}

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


int main()
{
  int n, x,count;
  cin >> n >> x;
  
  count = n;
  vector<int> m(n);
  for (int i = 0; i < n; i++)
  {
    cin >> m.at(i);
    x -= m.at(i);
  }

  sort(m.begin(), m.end());
  while (m.at(0) <= x)
  {
    
      x -= m.at(0);
      ++count;
    
  }
    cout << count << endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;

int main()
{
    int x=0,N,max=0;
    string S;
    cin >> N;
    cin >> S;
    for(int i = 0;i<N;i++){
        if(S[i]=='I'){
            x++;
            if(x>max){
                max=x;
            }
        }if(S[i]=='D'){
            x--;
        }
    }
    cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
gets
c=0
puts$<.map{|s|a=0
b=s.chop.bytes.map{|e|a+=81-e*2}.min
[-b,a-b]}.sort_by{|a,b|a<b ?a:2e9-b}.map{|a,b|b+c+=a-b}.max>0||c!=0?:No: :Yes

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

int main(){
	int N;
  cin>>N;
  vector<long> A(N);
  int count=0;
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  for(int i=0;i<30;i++){
    int X=pow(2,i+1);
  	for(int j=0;j<N;j++){
    	if(A.at(j)%X!=0){
          count++;
          break;
        }
    }
    if(count!=0){
     cout<<i<<endl;
      break;
    }
  }  
}

Measured memory_bytes: 512
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = sc.IntArray();

        int[] cnt = new int[1000001];
        foreach (int i in a)
        {
            cnt[i]++;
        }

        int ans = 0;

        for (int i = 1; i <= 1000000; i++)
        {
            if (cnt[i] > 0)
            {
                if (cnt[i] == 1) ans++;
                for (int j = i; j <= 1000000; j += i)
                {
                    cnt[j] = 0;
                }
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 47320
import java.util.Scanner;
public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int count = 0;
			int n = sc.nextInt();
			int x = sc.nextInt();
			if(n==0 && x==0) break;
			for(int i=1;i<=n;i++) {
				for(int j=i+1;j<=n;j++) {
					for(int k=j+1;k<=n;k++) {
						if(i+j+k==x) count++;
					}
				}
			}
			System.out.println(count);
		}	
	}
}


Measured memory_bytes: 26604
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);

int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> A(n);
  for (ll i = 0; i < n; ++i) {
    cin >> A[i];
  }
  vector<ll> B(m);
  for (ll i = 0; i < m; ++i) {
    cin >> B[i];
  }
  ll t = 0, na = 0, nb = 0;
  while (na < n && t+A[na] <= k) {
    t += A[na++];
  }
  while (nb < m && t+B[nb] <= k) {
    t += B[nb++];
  }


  ll ans = na + nb;
  while (na) {
    t -= A[--na];
    while (nb < m && t+B[nb] <= k) {
      t += B[nb++];
    }
    ans = max(ans,na+nb);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6364
#include<iostream>
using namespace std;
int main(){
  long long y,x,r;
  cin>>x;
  cin>>y;
  if(x<y)swap(x,y);
  r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  cout<<y<<endl;
    return(0);
}

    



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

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

    int N; cin >> N;
    vector<ll> T(N), A(N);
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> A[i];
    ll ans = 1;
    if (N == 1 && T[0] != A[0]) {
        cout << 0 << endl;
        return 0;
    }
    REP(i, 1, N) {
        if (T[i-1] < T[i]) {
            if (T[i] > A[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    for (int i = N-1; i > 0; i--) {
        if (A[i] < A[i-1]) {
            if (A[i] > T[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    REP(i, 1, N-1) {
        if (T[i-1] < T[i] || A[i+1] < A[i]) {
            continue;
        } else {
            ans = ans * min(T[i], A[i]);
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int selectionSort(int A[], int N) {
	int minj, sw = 0;

	for (int i = 0; i < N - 1; i++) {
		minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj]) minj = j;
		}
		swap(A[i], A[minj]);
		if (i != minj) sw++;
	}
	return sw;
}

int main(){
	int N, sw;
	int A[100];

	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	sw = selectionSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}


Measured memory_bytes: 3088
import java.util.HashMap;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer,Boolean> hm=new HashMap<Integer,Boolean>();
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			int buf=sc.nextInt();
			if(hm.containsKey(buf)){
				hm.remove(buf);
			}else{
				hm.put(buf,true);
			}
		}
		System.out.println(hm.size());
	}

}

Measured memory_bytes: 64892
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", std::max(0, std::min(b,d)-std::max(a,c)));
	return 0;
}



Measured memory_bytes: 256
N,K = map(int,input().split())
ans = 0
for p in range(1,min(N+1,K+1)):
    for q in range(1,K+10):
        if 2**(q-1) * p <= K - 1 and 2**q * p >= K:
            ans += (1/N)*(1/2)**q
            break
if N < K:
    ans = ans
else:
    ans += (N-(K-1))/N
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;

#define POS(i,j) (((i) & 1) * m + (j) % m)

int cond (i32 n) {
  i32 d[4];
  for (i32 i = 0; i < 4; ++i) {
    d[i] = n % 4;
    n /= 4;
  }
  for (i32 i = 0; i < 2; ++i) {
    if (d[i] ==0 && d[i + 1] == 1 && d[i + 2] ==2) {
      return 0;
    }
  }
  for (i32 j = 0; j < 3; ++j) {
    i32 swap = d[j];
    d[j] = d[j + 1];
    d[j + 1] = swap;
    for (i32 i = 0; i < 2; ++i) {
      if (d[i] ==0 && d[i + 1] == 1 && d[i + 2] ==2) {
	return 0;
      }
    }
    swap = d[j + 1];
    d[j + 1] = d[j];
    d[j] = swap;
  }
  return 1;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 m = 1 << 8;
  i32 *dp = (i32 *) calloc (2 * m, sizeof (i32));
  i32 *ok = (i32 *) calloc (m, sizeof (i32));
  for (i32 i = 0; i < m; ++i) {
    ok[i] = cond (i);
  }
  const i32 mod = 1000000007;
  dp[POS(0, m - 1)] = 1;
  for (i32 i = 1; i <= n; ++i) {
    memset (dp + POS(i,0), 0, m * sizeof (i32));
    for (i32 j = 0; j < m; ++j) {
      for (i32 k = 0; k < 4; ++k) {
	dp[POS(i, 4 * j + k)] += dp[POS(i - 1, j)];
	dp[POS(i, 4 * j + k)] %= mod;
      }
    }
    for (i32 j = 0; j < m; ++j) {
      dp[POS(i, j)] *= ok[j];
    }
  }
  i32 sum = 0;
  for (i32 i = 0; i < m; ++i) {
    sum = (sum + dp[POS(n, i)]) % mod;
  }
  printf("%" PRIi32 "\n", sum);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int res = 0;
        for (int a = 1; a <= n; ++a) {
            for (int b = a; b <= n; ++b) {
                if (a == b) continue;
                for (int c = b; c <= n; ++c) {
                    if (b == c) continue;
                    if (a + b + c == x) ++res;
                }
            } 
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
import sys
# sys.stdin = open('input.txt')

def createMatrix():
  matrix = [[i for i in map(int, input().split())] for i in range(n)]
  return matrix

def prim():
    d[0] = 0
    p[0] = -1

    while True:
        mincost = INFTY
        for i in range(n):
            if status[i] != VISITED and d[i] < mincost:
                mincost = d[i]
                u = i

        if mincost == INFTY:
            break

        status[u] = VISITED

        for v in range(n):
            if status[v] != VISITED and matrix[u][v] != -1:
                if matrix[u][v] < d[v]:
                    d[v] = matrix[u][v]
                    p[v] = u
                    status[v] = VISITING

n = int(input())
NOT_VISITED = 0 # WHITE
VISITING = 1 # GRAY
VISITED = 2 # BLACK
INFTY = 10**21

matrix = createMatrix()
status =  [NOT_VISITED] * n
d = [INFTY] * n
p = [-1] * n

prim()
print(sum(d))


Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }

// UnionFind
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}

    // ある要素がどの集合に属しているかを返す
    int find(int x) {
      if (d[x] < 0) return x;
      return d[x] = find(d[x]);
    }

    // 集合をマージする、すでに同じ集合ならfalseが返る
    bool unite(int x, int y) {
      x = find(x); y = find(y);
      if (x == y) return false;
      if (d[x] > d[y]) swap(x,y);
      d[x] += d[y];
      d[y] = x;
      return true;
    }

    // 2つの要素が同じ集合か判定する
    bool same(int x, int y) { return find(x) == find(y);}
  
    // ある集合の大きさを答える
    int size(int x) { return -d[find(x)];}
};

int n, m;

int main() {
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ufsize = 0;
    for(int i = 0; i < n; ++i) {
        int sss = uf.size(i);
        chmax(ufsize, sss);
    }

    cout << ufsize << endl;
}

Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

const int MAX=510000;
const int MOD=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,MAX){
    if(i>1){
      fac[i]=fac[i-1]*i%MOD;
      inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
      finv[i]=finv[i-1]*inv[i]%MOD;
    }
  }
}

ll COM(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  COMinit();
  int N,K;
  cin>>N>>K;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];
  ll ans=0;
  sort(all(A));
  rep(i,N) A[i]=(A[i]+MOD)%MOD;
  rep(i,N){
    if(i>=K-1) ans=(ans+COM(i,K-1)*A[i])%MOD;
    if(i<=N-K) ans=(ans-COM(N-i-1,K-1)*A[i])%MOD;
    if(ans<0) ans+=MOD;
  }
  if(K==1) cout<<0<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    set<int> S;
    for(int i = 0; i < N; i++){
        S.insert(A.at(i));
    }
    cout << S.size() << endl;
    return 0;
}

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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long ll;

ll INF = 100000000000000;
ll MOD = 1e9+7;


ll table[210][210];
ll L[210][210];
ll V,E,R;

void warshall_floyd(){
  for(int k = 0;k < V;k++){
    for(int i = 0;i < V;i++){
      for(int j = 0;j < V;j++){
        table[i][j] = min(table[i][j],table[i][k] + table[k][j]);
      }
    }
  }
}

int main(){
    cin >> V >> E >> R;
    vector<int> P(R);
    for(int i = 0;i < R;i++){
        cin >> P[i];
        P[i]--;
    }
    for(int i = 0;i < 210;i++){
        for(int j = 0;j < 210;j++){
            if(i == j){
                table[i][j] = 0;
            }else{
                table[i][j] = INF;
            }
        }
    }
    for(int i = 0;i < E;i++){
        ll a,b,c;cin >> a >> b >> c;
        a--;b--;
        table[a][b] = c;
        table[b][a] = c;
    }
    warshall_floyd();
    ll ans = INF;
    sort(P.begin(),P.end());
    do{
        ll cost = 0;
        for(int i = 0;i < R-1;i++){
            cost += table[P[i+1]][P[i]];
        }
       /*for(int i = 0;i < R;i++){
            cout << P[i] << ' ';
        }
        cout << '(' << cost << ')' << endl;*/
        ans = min(ans,cost);
    }while(next_permutation(P.begin(),P.end()));
    cout << ans << endl;
}



Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 505
#define maxm 150010
#define inf 1000000007
#define mod 1000000007
#define inv 500000005
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,int>pii;
typedef bitset<maxn> bit;
typedef long double ld;
ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m;
ll X,mn;
struct Edge{
    int u,v,w;
}e[2010];
bool cmp(Edge a,Edge b)
{
    return a.w<b.w;
}
int fa[1010];
int find(int x)
{
    if(fa[x]==x)  return x;
    return fa[x]=find(fa[x]);
}
void init_fa()
{
    for(int i=1;i<=n;i++) fa[i]=i;
}
ll get_MST()
{
    ll res=0;
    for(int i=1;i<=m;i++)
    {
        int u=find(e[i].u),v=find(e[i].v);
        if(u!=v)  fa[u]=v,res+=e[i].w;
    }
    return res;
}
ll f[2010];
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
int ans;
int main()
{
    n=read();m=read();X=read();
    for(int i=1;i<=m;i++)  e[i].u=read(),e[i].v=read(),e[i].w=read();
    sort(e+1,e+m+1,cmp);init_fa();mn=get_MST();
    for(int i=1;i<=m;i++)
      init_fa(),fa[e[i].u]=e[i].v,f[i]=get_MST()+e[i].w;
    if(mn==X)
    {
        int cnt=0;
        for(int i=1;i<=m;i++)
          if(f[i]==X)  cnt++;
        ans=1ll*(quick_pow(2,cnt)-2+mod)*quick_pow(2,m-cnt)%mod;
        cout<<ans<<endl;
        return 0;
    }
    int down=0,up=0;
    for(int i=1;i<=m;i++)
    {
        if(f[i]<X)  down++,up++;
        if(f[i]==X)  up++; 
    }
    for(int i=down+1;i<=up;i++)  ans=(ans+quick_pow(2,m-i))%mod;
    ans=(ans+ans)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n) rep(j, d) cin >> x[i][j];
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int dis = 0;
            int cnt = 1;
            for (int k = 0; k < d; k++)
            {
                dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            while (dis >= cnt * cnt)
            {
                if (dis == cnt * cnt)
                    ans++;
                cnt++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
# include <iostream>
# include <cstdio>
using namespace std;
const int N = 2e5 + 12;
const int inf = 0x3f3f3f3f;
int n,head[N],dt,du[N],bac[N],que[N],rt,a[N],tot,p;char str[N];bool w[N];
struct Edge{int to,nex;}edge[N << 1];
void Add(int u,int v){edge[++dt] = (Edge){v,head[u]};head[u] = dt;du[u]++;}
void Dfs(int u,int pre)
{
	if(str[u] == 'W')w[u] = true;
	for(int i = head[u];i;i = edge[i].nex)if(edge[i].to != pre)
	{
		Dfs(edge[i].to,u);
		if(!w[edge[i].to])du[u]--,du[edge[i].to]--;
		w[u] |= w[edge[i].to];
	}
	if(w[u])tot++;
}
void rebuild()
{
	for(int i = 1;i <= n;i++)if(str[i] == 'W')rt = i;
	Dfs(rt,-1);
	for(int i = 1;i <= n;i++)if(w[i])a[i] = (str[i] == 'B') ^ (du[i] & 1),p += !a[i];
}
int dp[N][2],f[N];
void dfs(int u,int pre)
{
	f[u] = (tot - 1) * 2 + p;
	dp[u][0] = a[u] ? -1 : 1;
	for(int i = head[u];i;i = edge[i].nex)if(edge[i].to != pre && w[edge[i].to])
	{
		dfs(edge[i].to,u);
		f[u] = min(f[u],f[edge[i].to]);
		f[u] = min(f[u],(tot - 1) * 2 + p - dp[u][0] - dp[edge[i].to][1] - 1);
		f[u] = min(f[u],(tot - 1) * 2 + p - dp[u][1] - dp[edge[i].to][0] - 1);
		dp[u][0] = max(dp[u][0],dp[edge[i].to][0] + 1 + (a[u] ? -1 : 1));
		dp[u][1] = max(dp[u][1],dp[edge[i].to][1] + 1 + (a[u] ? -1 : 1));
	}
}
int main()
{
	
	scanf("%d",&n);int x,y;
	for(int i = 1;i < n;i++)scanf("%d %d",&x,&y),Add(x,y),Add(y,x);
	scanf("%s",str + 1);rebuild();dfs(rt,-1);
	printf("%d\n",!tot ? tot : f[rt]);
}

Measured memory_bytes: 13056
#include<iostream>
#include<string>
#define LL long long
std::string s;
LL alpha[26];
LL ans;
int main() {
	std::cin >> s;
	for (auto u : s) {
		alpha[u - 'a']++;
	}
	LL size = s.size();
	ans = size * (size - 1) / 2;
	ans++;
	for (int i = 0; i < 26; i++) {
		ans -= alpha[i] * (alpha[i] - 1) / 2;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ll h,a;
cin>>h>>a;
cout<<(h+a-1)/a<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define  vi vector<int>
#define pb push_back
//#define int long long
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define pi pair<int,int>
#define F first
#define S second
using namespace std;

//int mod=(int)(1e9+7);

void solve()
{
 
 int n;
 cin>>n;
 vi v(n+1);
 for(int i=0;i<n-1;i++)
 { int t;
   cin>>t;
   v[t]++;
 }

 for(int i=1;i<=n;i++)
 cout<<v[i]<<endl;

}

signed main()
{ boost;
 //cout<<fixed<<setprecision(14 );
 // int t;cin>>t;
  //for(int i=1;i<=t;i++)
  solve();
 // cout<<"Case #"<<i<<": "<<solve()<<endl;

return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int dp[50010];

int main(){
    
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    REP(i,m)cin>>a[i];
    
    for(int i=1;i<=50005;i++)dp[i]=100000000;
    for(int j=0;j<m;j++){
        for(int i=1;i<=50005;i++){
            if(i-a[j]>=0)dp[i]=min(dp[i-a[j]]+1,dp[i]);
        }
    }
    
    cout<<dp[n]<<endl;
    
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007


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

   int N;
   cin>>N;
   vector<vector<int> >a(3,vector<int>(N+1,0));
   for(int i=0;i<N;i++)cin>>a[0][i]>>a[1][i]>>a[2][i];

   vector<vector<ll> >dp(N+1,vector<ll>(3,0));
   for(int i=1;i<=N;i++){
      for(int j=0;j<3;j++){
         for(int k=0;k<3;k++){
            if(j==k)continue;
            dp[i][j] = max(dp[i][j],dp[i-1][k]+a[j][i-1]);
         }
      }
   }

   cout<<*max_element(dp[N].begin(),dp[N].end())<<endl;
   return 0;
}


Measured memory_bytes: 6908
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const ll MOD=998244353;
const int MAXN=3010;
int N,S;
int A[MAXN];
ll dp[MAXN][MAXN];
void read()
{
    cin>>N>>S;
    for(int u=0;u<N;u++)cin>>A[u];
}
void solve()
{
    read();
    ll ans=0;
    for(int u=0;u<N;u++){
        memcpy(dp[u+1],dp[u],sizeof(dp[0]));
        dp[u+1][A[u]]=(dp[u+1][A[u]]+u+1)%MOD;
        for(int v=0;v+A[u]<=S;v++){
            dp[u+1][v+A[u]]=(dp[u+1][v+A[u]]+dp[u][v])%MOD;
        }
        ans=(ans+dp[u+1][S])%MOD;
    }
    cout<<ans<<"\n";
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 70912
n,m=map(int,input().split())
ans=0
e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
f=list(map(int,input().split()))
for i in range(2**n):
  l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
  for j in range(1,m+1):
    if len(e[j-1]&l)%2!=f[j-1]:break
  else:ans+=1
print(ans)

Measured memory_bytes: 3188