akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> AB(2 * M);
	vector<int> count(N);
	for (int i = 0; i < 2 * M; i++) {
		cin >> AB[i];
		count[AB[i] - 1]++;
	}
	for (int j = 0; j < N; j++) {
		cout << count[j] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val d = sc.nextInt()
    val c = (0 until 26).map { sc.next().toInt() }
    val s = (0 until d).map {
        (0 until 26).map { sc.next().toInt() }
    }
    println(problemintroduction_to_heuristics_contest(d, c, s))
}

fun problemintroduction_to_heuristics_contest(
    d: Int,
    c: List<Int>,
    s: List<List<Int>>
): String {
    val list = IntArray(26) { 0 }
    val ans = IntArray(d) { 1 }
    for (i in 0 until d) {
        ans[i] = i % 26 + 1
    }
    return ans.joinToString("\n")
}

Measured memory_bytes: 47616
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
string s, t;
set<string> S;
void Work(string s,string t)
{
    int lens = s.size(),lent = t.size();
    for(int i=0;i<lens;i++)
    {
        if(s[i] == '?' || s[i] == t[0])
        {
            string tmp = s;
            for(int j=0;j<i;j++)
                if(tmp[j] == '?') tmp[j] ='a';    
            bool can = false;
            for(int j=0;j<lent;j++)
            {
                if(tmp[i+j]!='?' && tmp[i+j]!=t[j])
                    break;
                tmp[i+j] = t[j];
                if(j == lent-1) can = true;
            }
            if(can)
			{
                for(int j=i+lent;j<lens;j++)
					if(tmp[j] == '?') tmp[j] = 'a';
                S.insert(tmp);
            }
        }
    }
    if(S.size()!=0) cout<<*S.begin();
    else cout<<"UNRESTORABLE";
}
int main()
{
    cin>>s>>t;
    Work(s,t);
    return 0;
}

Measured memory_bytes: 256
#from https://atcoder.jp/contests/abc087/submissions/4389032

class WeightedUnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
    @weight = Array.new(size, 0)
  end
 
  def unite(id_x, id_y, w)
    cw = w + weight(id_x) - weight(id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @weight[y_parent] = cw
      @parent[y_parent] = x_parent
    else
      @weight[x_parent] = -cw
      @parent[x_parent] = y_parent

      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def weight(idx)
    get_parent(idx)
    @weight[idx]
  end

  def weight_diff(x, y)
    weight(y)-weight(x)
  end

  def get_parent(id_x)
    if @parent[id_x] == id_x
      id_x
    else
      root = get_parent(@parent[id_x])
      @weight[id_x] += @weight[@parent[id_x]]
      @parent[id_x] = root
    end
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end


n, m = gets.strip.split.map(&:to_i)
lrd = readlines.map {|line| line.split.map(&:to_i) }

wuf = WeightedUnionFind.new(n+1)

lrd.each do |l, r, d|
  if wuf.same_parent?(l,r)
    if wuf.weight_diff(l, r) != d
      puts 'No'
      exit
    end
  else
    wuf.unite(l, r, d)
  end
end

puts'Yes'


Measured memory_bytes: 33788
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


if 2019 <= R-L:
    print(0)
else:
    x = L % MOD
    y = R % MOD
    if x < y:
        for i in range(x, y):
            for j in range(i+1, y+1):
                ans = min(ans, (i*j) % MOD)
            if ans == 0:
                break
        print(ans)
    else:
        print(0)

Measured memory_bytes: 3064
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
signed main(){
	int n, a, b;
	cin >> n >> a >> b;
	int ans = mod_pow(2, n, mod)-1;
	ans = (ans + 2 * mod - comb(n, a) - comb(n, b))%mod;
	cout << ans << endl;
}


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

using ll = long long;
using namespace std;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> f[i];
    }
    ll lb = -1;
    ll ub = 1e12;
    sort(a.begin(), a.end(), greater<int>());
    sort(f.begin(), f.end());
    while (ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        ll count = 0;
        for (int i = 0; i < n; i++) {
            ll p = a[i] * f[i];
            if (p > mid) {
                count += a[i] - mid / f[i];
            }
        }
        if (count > k) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << ub << endl;
    return 0;
}


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

#define MAX 1000
#define HALF_SIZE MAX * 2

int main(void) {
	int table[HALF_SIZE + 1] = {};
	int n;
	int ans;
	
	for(int i = 0; i <= MAX; ++i) {
		for(int j = 0; j <= MAX; ++j) {
			++table[i + j];
		}
	}
	
	while(cin >> n) {
		ans = 0;
		if(n > HALF_SIZE) {
			for(int i = n - HALF_SIZE; i <= HALF_SIZE; ++i) {
				ans += table[i] * table[n - i];
			}
		} else {
			for(int i = 0; i <= n; ++i) {
				ans += table[i] * table[n - i];
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3124
import java.lang.reflect.Array;
import java.math.*;
import java.util.*;
public class Main
{
	static Scanner sc=new Scanner(System.in);
	static final int MAX=1000000+5;
	public static void main(String[] args)
	{
		int n=sc.nextInt();
		if(n==25)
			System.out.println("Christmas");
		else if(n==24)
			System.out.println("Christmas Eve");
		else if(n==23)
			System.out.println("Christmas Eve Eve");
		else if(n==22)
			System.out.println("Christmas Eve Eve Eve");
	}
}

Measured memory_bytes: 21204
n = int(input())
ans = 0
# 1桁目
for i in range(1, n+1):
    # 2桁目
    for j in range(1, n+1):
        # 3桁目
        for k in range(1, n+1):
            #print(i, j, k)
            ans += 1
print(ans)

Measured memory_bytes: 9108
n = gets.chomp.to_i
tmp = []
n.times do
  i = gets.chomp.split
  tmp.push(i)
  cnt = i
end

i = 0

deck = [["S", "1"],["S", "2"],["S", "3"],["S", "4"],["S", "5"],["S", "6"],["S", "7"],["S", "8"],["S", "9"],["S", "10"],["S", "11"],["S", "12"],["S", "13"],["H", "1"],["H", "2"],["H", "3"],["H", "4"],["H", "5"],["H", "6"],["H", "7"],["H", "8"],["H", "9"],["H", "10"],["H", "11"],["H", "12"],["H", "13"],["C", "1"],["C", "2"],["C", "3"],["C", "4"],["C", "5"],["C", "6"],["C", "7"],["C", "8"],["C", "9"],["C", "10"],["C", "11"],["C", "12"],["C", "13"],["D", "1"],["D", "2"],["D", "3"],["D", "4"],["D", "5"],["D", "6"],["D", "7"],["D", "8"],["D", "9"],["D", "10"],["D", "11"],["D", "12"],["D", "13"]]
n.times do
  deck.delete(tmp[i])
  i += 1
end

count = deck.length
i = 0

count.times do
  puts deck[i].join(' ')
  i += 1
end

Measured memory_bytes: 8652
open System

let isSubArray xs ys =
    let n, m = Array.length xs, Array.length ys
    let rec f i j =
        if i = n then true
        elif j = m then false
        elif xs.[i] = ys.[j] then f (i+1) (j+1)
        else f i (j+1)
    f 0 0

let n = stdin.ReadLine() |> int
let s = stdin.ReadLine().ToCharArray()

let mutable c = 0

for i in ['0'..'9'] do
    for j in ['0'..'9'] do
        for k in ['0'..'9'] do
            if isSubArray [| i; j; k |] s then
                c <- c + 1
 
printfn "%d" c

Measured memory_bytes: 21196
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,k;
  cin>>n>>k;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  int dp[n];
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    int m=INT_MAX;
    for(int j=i-1;j>=i-k && j>=0;j--)
      m=min(m,dp[j]+abs(h[i]-h[j]));
    dp[i]=m;
  }
  cout<<dp[n-1];
}


Measured memory_bytes: 1024
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let b = a.iter().map(|&a| -a).collect();
    let a = solve(a);
    let b = solve(b);
    println!("{}", cmp::min(a, b));
}

fn solve(mut a: Vec<i64>) -> usize {
    let n = a.len();
    let mut ans = 0;
    for i in 0..(n - 1) {
        if i % 2 == 1 {
            a[i] *= -1;
            a[i + 1] *= -1;
            if i + 2 < n {
                a[i + 2] *= -1;
            }
        }
        if a[i] > a[i + 1] {
            if i + 2 < n && a[i] < a[i + 2] {
                a.swap(i + 1, i + 2);
            } else {
                a.swap(i, i + 1);
            }
            ans += 1;
        }
        if i % 2 == 1 {
            a[i] *= -1;
            a[i + 1] *= -1;
            if i + 2 < n {
                a[i + 2] *= -1;
            }
        }
    }
    ans
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 7100
#include <iostream>

using namespace std;

int main()
{
    int t[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int a;
    cin>>a;
    cout<<t[a-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a;
  cin >> a;
  if(a=='A') cout << 'T';
  if(a=='T') cout << 'A';
  if(a=='G') cout << 'C';
  if(a=='C') cout << 'G';
return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  map<ll,ll> m;
  ll a;
  rep(i,n){
    cin>>a;
    m[a]++;
  }
  ll l1=0,l2=0;
  reps(x,m){
    if(l1<l2){
      swap(l1,l2);
    }
    if(x.se>3){
      l1=max(l1,x.fi);
      l2=max(l2,x.fi);
    }else if(x.se>1){
      l2=max(l2,x.fi);
    }
  }

  cout<<l1*l2<<endl;
  return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

ll memo[32];
ll rec(int n, int p)
{
	if(n < p) return 1;
	if(0 <= memo[p]) return memo[p];
	
	return memo[p] = rec(n, p + 1) + rec(n, p + 2) + rec(n, p + 3);
}

int main()
{
	for(int n; cin >> n && n;)
	{
		vector<vint> dp(n + 2, vint(n + 1));
		
		dp[0][0] = 1;
		rep(i, n + 1) rep(j, n)
		{
			dp[min(n + 1, i + 1)][j + 1] += dp[i][j];
			dp[min(n + 1, i + 2)][j + 1] += dp[i][j];
			dp[min(n + 1, i + 3)][j + 1] += dp[i][j];
		}
		
		cout << (accumulate(ALL(dp[n]), 0) + 3649) / 3650 << endl;
	}
}

Measured memory_bytes: 0
S = list(input())
Ski = S[0:len(S):2]
Sgu = S[1:len(S):2] 
p1 = Ski.count('1') + Sgu.count('0') 
p2 = Ski.count('0') + Sgu.count('1')
if p1>p2:
    print(p2)
else:
    print(p1)

Measured memory_bytes: 4652
n = gets.chomp.to_i

a, b, c = gets.chomp.split.map(&:to_i)
ka = [a]
kb = [b]
kc = [c]
0.upto(n-2).each do |i|
  a, b, c = gets.chomp.split.map(&:to_i)
  ka.push [kb[i], kc[i]].max + a
  kb.push [kc[i], ka[i]].max + b
  kc.push [ka[i], kb[i]].max + c
end

puts [ka.last, kb.last, kc.last].max


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll ans=0;
	string s;
	cin >> s;
	ll n=s.size();
	vll d(n+1);
	ll ten=1;
	map<ll,ll> m;
	m[0]++;
	for(ll i=n-1;i>=0;i--){
		ll a=(s[i]-'0')*ten%2019;
		d[i]=(d[i+1]+a)%2019;
		ten*=10;
		ten%=2019;
		ans+=m[d[i]];
		m[d[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5140
/**********************************************************************
   File abc163_a.cpp
   Author  harunaya
   Date   2020-05-11(Mon)
   note   
**********************************************************************/

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int r; cin >> r;
	cout << 2 * PI * r;
	return 0; 
}

Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
using namespace std;
int n;
int a[200005];
int b[200005];
vector <bool> vec[200005];
bool pattern[200005];
bool c[400005];
int fail[200005];

void build(bool c[],int n)
{
	int j=fail[0]=-1;
	for(int i=1;i<=n;i++)
	{
		while(j>=0 && c[i-1]!=c[j]) j=fail[j];
		fail[i]=++j;
	}
}

vector <pair<int,int> > solve(int bit)
{
	bit=1<<bit;
	for(int i=0;i<n;i++)
	{
		pattern[i]=b[i] & bit;
	}
	for(int i=0;i<n;i++)
	{
		c[i]=a[i] & bit;
	}
	for(int i=n;i<n+n;i++)
	{
		c[i]=c[i-n];
	}
	build(pattern,n);
	vector <pair<int,int> > res;
	for(int rev=0;rev<2;rev++)
	{
		for(int i=0,j=0;i<n+n;i++)
		{
			while(j>=0 && c[i]!=pattern[j]) j=fail[j];
			j++;
			if(j==n) res.push_back(mp(i-n+1,rev)),j=fail[j];
		}
		for(int i=0;i<n+n;i++)
		{
			c[i]=c[i]^1;
		}
	}
	return res;
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<30;i++)
	{
		for(auto x:solve(i))
		{
			vec[x.first].push_back(x.second);
		}
	}
	for(int i=0;i<n;i++)
	{
		if(vec[i].size()!=30) continue;
		int res=0;
		for(int j=0;j<30;j++)
		{
			res|=(vec[i][j]<<j);
		}
		cout<<i<<' '<<res<<endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}


int main() {
  ll x;cin >> x;
  ll y = x/500*1000;
  ll z =x%500;
  ll p= z/5*5;

  cout << y+p;
}

Measured memory_bytes: 764
n,a,b=map(int,input().split())
y=(b-a-1)//2
if (b-a)%2==0:
  print(int((b-a)//2))
else:
  if (a-1)<(n-b):
    print(int(y+a))
  else:
    print(int(y+1+n-b))



Measured memory_bytes: 2940
#pragma GCC optimize("O3")

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define VEC(v) vector<v >

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

int in() {int x;cin>>x;return x;}
ll llin() {unsigned long long x;cin>>x;return x;}

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

constexpr ll mod=998244353;
constexpr ll mod2=10e9+7;
const double PI = 3.1415926535897932384626433832795028841971; //acos(-1)

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

int main(){
  ios; cfs(15);
  INT(a);
  cout << a+(a*a)+(a*a*a) << endl;
  ret;
}

Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#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##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

ll power(ll n, int e) {
  const ll M = 1000000000+7;
  ll ans = 1;
  rep(i, e) {
    ans *= n;
    ans %= M;
  }
  return ans;
}

int main () {
  const ll M = 1000000000+7;
  ll n; cin >> n;
  ll ans = (power(10, n) + power(8, n) + (2*M)) - 2*power(9, n);
  ans %= M;
  cout << ans << endl;
}

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

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

}
  

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, M, X, Y = map(int, input().split())
    Xs = list(sorted(list(map(int, input().split()))))
    Ys = list(sorted(list(map(int, input().split()))))

    for z in range(-101, 101):
        if X < z <= Y:
            if Xs[-1] < z <= Ys[0]:
                print("No War")
                return
    print("War")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#木ではない
#非連結成分
#処理済みの判定、辺の距離はすべて1なので一度到達すればよい
from collections import deque

n = int(input())
V = [[] for _ in range(n+1)]
for _ in range(n):
    inpt = list(map(int,input().split( )))
    if len(inpt)>2:
        V[inpt[0]] = inpt[2:]

lrg = 10000
D = [lrg]*(n+1)
End = [0]*(n+1)

D[1] = 0
Deq = deque()

time = 1
Q = [1]
Deq.append(1)

while len(Deq) > 0:
    v = Deq.popleft()
    for i in V[v]:
        D[i] = min(D[i],D[v]+1)
        if End[i] == 0:
            Deq.append(i)
        End[i] = 1


for i in range(1,n+1):
    if D[i]<lrg-1:
        print(i,D[i])
    else:
        print(i,-1)



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

     public static void main(String []args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
        String line1 = br.readLine();
        String[] strs = line1.trim().split("\\s+");
        int x = Integer.parseInt(strs[0]);
        int a = Integer.parseInt(strs[1]);
        
        if(x<a) System.out.println(0);
        else System.out.println(10);
   
}  

}





Measured memory_bytes: 21076
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif
int t,rohan;
cin>>t>>rohan;
int count=0;
while(t>0){
    t-=rohan;
    count++;
}
cout<<count<<"\n";

return 0;
}

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

using namespace std;

#define LL long long

int main() {
    LL a, b;

    cin >> a >> b;
    a = a - 1;
    LL ans = 0;
    LL i=0;
    while ((b >> i) > 0) {
        LL bit = 0;


        if (i == 0) {
            if ((b % 4 == 1 || b % 4 == 2)) {
                bit++;
            }
        } else {
            if ((b >> i) & 1 == 1 && b % 2 == 0) {
                bit++;
            }
        }
        if (i == 0) {
            if ((a % 4 == 1 || a % 4 == 2) ) {
                bit++;
            }
        } else {
            if ((a >> i) & 1 == 1 && a % 2 == 0) {
                bit++;
            }
        }
        bit %= 2;

        ans += bit << i;
        i++;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
	
	int n,a,b,plano1=0;

	cin >> n >> a >> b;
	plano1 = n*a;
	
	if(plano1>b){
		cout << b << '\n';
	}
	else if(plano1<b){
		cout << plano1 << '\n';
	}
	else{
		cout << plano1 << '\n';
	}


	return 0;
}

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

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

    int ans = 0;
    for (auto i = 1; i <= n; i++) {
        int sum = 0, tmp = i;
        while(tmp > 0) {
            sum += tmp % 10;
            tmp /= 10;
        }
        if(sum >= a && sum <= b) ans += i;
    }

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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int q;
    cin >> q;
    rep(i, q)
    {
        int64_t a, b;
        cin >> a >> b;
        int64_t rab = (int64_t)ceil(sqrt(a * b));
        int64_t result = 2 * (rab - 1) - (rab * (rab - 1) >= a * b ? 1 : 0);
        if (a != b) {
            result--;
        }

        cout << result << endl;
    }

    return 0;
}

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

int main()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double s = double(w) * double(h) / 2;
	if(2*x==w&&2*y==h)
      cout << s << " " << 1 << endl;
  else
    cout << s << " " << 0 << endl;
}




Measured memory_bytes: 256
n=int(input())
model=[]
for i in range(n):
  model.append(i+1)
#print(model)
p=list(map(int,input().split()))
cnt=0
for j in range(n):
  if p[j] != model[j]:
    cnt+=1
if cnt<=2:
  print("YES")
else:
  print("NO")

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

int main(){
    double r;
    double s;
    double l;
    
    scanf("%lf", &r);
    
    s = r * r * M_PI;
    l = 2 * r * M_PI;
    printf("%.6lf %.6lf\n", s, l);
    
    return 0;
}


Measured memory_bytes: 2760
#include <algorithm>
#include <deque>
#include <iostream>
#include <vector>

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

string S;

int main() {
    cin >> S;
    REP(i, S.size()) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

using std::cin;
using std::cout;
using std::endl;

using std::set;

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

    set<int> s;
    for(int i = 0; i < n; i++){
        int v;
        cin >> v;
        if(s.count(v) == 0){
            s.insert(v);
        }else{
            s.erase(v);
        }
    }
    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {
  int64_t n, m;
  int64_t a, b, c;
  int64_t q;
  int64_t fs, fg;
  int64_t inf = 10000000000000;
  int64_t chunk_size = 512;
  cin >> n >> m;
  vector<unordered_map<int64_t, int64_t>> edges(n);
  for (int i = 0; i < m; ++i) {
    cin >> a >> b >> c;
    if (edges[a].find(b) != edges[a].end()) {
      if (c < edges[a][b]) {
        edges[a].erase(b);
        edges[b].erase(a);
      }
    }
    edges[a].emplace(b, c);
    edges[b].emplace(a, c);
  }
  vector<pair<int64_t, int64_t>> costs(n);
  for (int i = 0; i < n; ++i) {
    costs[i].first = inf;
    costs[i].second = -1;
  }
  priority_queue<pair<int64_t, int64_t>> pq;
  pq.emplace(0, 0);
  while (!pq.empty()) {
    int64_t cost = -pq.top().first;
    int64_t id = pq.top().second;
    pq.pop();
    if (costs[id].first != inf) {
      continue;
    }
    costs[id].first = cost;
    for (auto& edge : edges[id]) {
      if (costs[edge.first].first != inf) {
        continue;
      }
      pq.emplace(-(cost + edge.second), edge.first);
    }
  }
  pq.emplace(0, n - 1);
  while (!pq.empty()) {
    int64_t cost = -pq.top().first;
    int64_t id = pq.top().second;
    pq.pop();
    if (costs[id].second != -1) {
      continue;
    }
    costs[id].second = cost;
    for (auto& edge : edges[id]) {
      if (costs[edge.first].second != -1) {
        continue;
      }
      pq.emplace(-(cost + edge.second), edge.first);
    }
  }
  sort(costs.begin(), costs.end());
  vector<vector<int64_t>> chunked_cost;
  for (int i = 0; i < n; i += chunk_size) {
    vector<int64_t> chunk(chunk_size, -1);
    for (int j = i; j < min(i + chunk_size, n); ++j) {
      chunk[j - i] = costs[j].second;
    }
    sort(chunk.begin(), chunk.end());
    chunked_cost.push_back(chunk);
  }
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> fs >> fg;
    int cnt = 0;
    int nmin_fs = upper_bound(costs.begin(), costs.end(), pair<int64_t, int64_t> {fs, inf}) - costs.begin();
    for (int j = 0; j < nmin_fs / chunk_size; j++) {
      cnt += chunked_cost[j].end() - lower_bound(chunked_cost[j].begin(), chunked_cost[j].end(), fg);
    }
    for (int j = nmin_fs / chunk_size * chunk_size; j < nmin_fs; ++j) {
      if (costs[j].second >= fg) {
        ++cnt;
      }
    }
    cout << cnt << endl;
  }
}


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

double const pi = acos(-1);

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    cout << fixed << setprecision(10)
    << sqrt(a * a + b * b - 2 * a * b * cos(2 * pi * abs((h + m / 60) / 12.0 - m / 60.0))) << '\n';
}

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

using namespace std;

typedef long long ll;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }

}

Measured memory_bytes: 256
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int h[1000000];
int dp[1000000];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n, k;  
  cin >> n >> k;

  REP(i, n) {
    int tmp;
    cin >> tmp;
    h[i] = tmp;
  }
  REP(i, n) dp[i] = INT_MAX;
  
  dp[0] = 0;
  FOR(i, 1, k+1) dp[i] = abs(h[i]-h[0]);
  /*
  REP(j, n) cout << dp[j] << " ";
  cout << endl;
  */
  REP(i, n) {
    int tmp = INT_MAX;
    REP(j, k){
      dp[i+k] = min(dp[i+k], dp[i+j]+abs(h[i+j]-h[i+k]));      
    //dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]), dp[i+1]+abs(h[i+2]-h[i+1]));
    }
    /*
    REP(j, n) cout << dp[j] << " ";
    cout << endl;
    */
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > pii;
typedef long long LL;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
int readint(){
	char c=getchar();
	int ret=0;
	while(!(c>='0' && c<='9')) c=getchar();
	while(c>='0' && c<='9'){
		ret=ret*10+c-'0';
		c=getchar();
	}
	return ret;
}
void putint(int v){
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10) putint(v/10);
	putchar('0'+(v%10));
}
int n,m,ps[15],pre[15][15],pw3[15],tr3[32768];
int self[32768],inter[14348907];
#define MOD 1000000007ll
int powM(int V,int T=MOD-2){
	int R=1;
	while(T){
		if(T&1) R=(LL)R*(LL)V%MOD;
		T>>=1;
		V=(LL)V*(LL)V%MOD;
	}
	return R;
}
int dp[32768];
int main(){
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		--x;--y;
		x=n-1-x;y=n-1-y;
		pre[x][ps[x]++]=y;
	}
	int A=(1<<(n-1)),B=(1<<(n-2));
	pw3[0]=1;
	for(i=1;i<n;++i){
		pw3[i]=pw3[i-1]*3;
	}
	for(i=1;i<(1<<n);++i){
		for(j=0;j<n;++j){
			if(i&(1<<j))
				tr3[i]+=pw3[j];
		}
		if((!!(i&A))!=(!!(i&B)))
			self[i]=0;
		else{
			int cnt=0;
			for(j=0;j<n;++j){
				if(!(i&(1<<j))) continue;
				for(k=0;k<ps[j];++k){
					if(i&(1<<(pre[j][k])))
						++cnt;
				}
			}
			self[i]=powM(2,MOD-1-cnt);
		}
	}
	int prec[15];
	for(i=0;i<n;++i){
		prec[i]=(LL)((1<<i)-1)*(LL)powM(2,MOD-1-i)%MOD;
	}
	for(i=0;i<(1<<n);++i){
		inter[tr3[i]]=inter[tr3[i]*2]=1;
	}
	for(i=1;i<(1<<n);++i){
		int lf=(1<<n)-1-i,l;
		for(j=lf;j;j=((j-1)&lf)){
			if(!self[j] || (j&-j)<(i&-i)) continue;
			int &T=inter[tr3[i]+tr3[j]*2];
			T=1;
			for(k=0;k<n;++k){
				if(!(j&(1<<k))) continue;
				int cnt=0;
				for(l=0;l<ps[k];++l){
					if(i&(1<<pre[k][l])) ++cnt;
				}
				T=(LL)T*(LL)prec[cnt]%MOD;
			}
		}
	}
	dp[(1<<n)-1]=1;
	for(i=(1<<n)-2;i>=0;--i){
		int lf=(1<<n)-1-i,st=(lf&-lf);
		for(j=lf;j;j=(j-1)&lf){
			if(!(j&st)) continue;
			dp[i]+=(LL)dp[i|j]*(LL)self[j]%MOD*(LL)inter[tr3[lf]+tr3[lf^j]]%MOD;
			dp[i]%=MOD;
		}
	}
	printf("%lld\n",(LL)powM(2,m)*(LL)(MOD+1-dp[0])%MOD);
	return 0;
}
/*
 * 代码框架
 * 1. 计算预设答案：总答案。编号倒序。
 * 2. 预处理3的幂，预处理二进制转三进制
 * 3. 计算每个mask对应的内在损耗。只包含n,n-1中一个的，=0。
 * 4. 枚举在前的mask，预处理前缀和；枚举在后的mask，计算代价的系数
 * 5. dfs，枚举mask，每次-=(1<<(lb+1))。=0时跳过
 * 6. pre*(1-ans)
*/

Measured memory_bytes: 48512
n, m = map(int, input().split())

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

road = [[] for i in range(n)]

for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    road[u].append(v)
    road[v].append(u)

ans = 0

for i in range(n):
    flag = True
    for j in range(len(road[i])):
        if h[i] <= h[road[i][j]]:
            flag = False
            break
    if flag is True:
        ans += 1

print(ans)

Measured memory_bytes: 94588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef vector<vector<int>> matrix;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=5e5+123;
const int M=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll k,a,b;
    cin>>k>>a>>b;
    if(a>=b-1 || k<=a){
        cout<<k+1;
        return 0;
    }
    k-=a-1;
    cout<<(k/2)*b-(k/2-1)*a+(k&1);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define int long long
#define INTMAX 1e15+5
#define mp make_pair
#define N 1000005
#define pb push_back
#define pencho ios_base::sync_with_stdio(false);cin.tie(NULL);
#define s second
/*STL:
       (1) PRIORITY_QUEUE pq:
       -> priority_queue < int > pq; // max_heap
       -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap
       -> pq.top()   --> returns the maximum or minimum element
       -> pq.push()  --> push element into the queue
       -> pq.pop()   --> remove top most element
       -> pq.empty() --> checks whether queue is empty or not

       (2) set / multiset  ss;
       --> ss.insert(key); (insertion)
       --> ss.erase(ss.find(key)) .. (deletion)
       --> ss.find(key) != ss.end() ..existence check
       --> ss.lower_bound(x) -> smallest value which is greater than or equals to x
       --> ss.upper_bound(x) --> first value strictly greater than x
       --> multiset< data_type , greater<data_type> > ms; // for max ordering

       (3) common functions
       lower_bound(v.begin(),v.end(),x) - v.begin() --> smallest value greater than or equals to x
       upper_bound(v.begin(), v.end(),x)- v.begin() --> smallest value greater than x
       memset(dp , val , sizeof(dp)) -> sets the value of array dp to val

       (4)    Comparator for set
                     struct comp {
                            bool operator()(pair<int, int>a, pair<int, int>b) {
                     };
};
*/
int mod = 1000000007;
int bp(int x, int y) {int ans = 1; x %= mod; while (y) {if (y & 1) ans = ans * x % mod; x = x * x % mod; y >>= 1;} return ans;}
int mod_inverse(int x) {return bp(x, mod - 2); }
int gcd (int a, int b) { while (b) {a %= b; swap(a, b);} return a;}
int max(int a, int b) {     if (a < b)    swap(a, b);   return a;}
int min(int a, int b) { if (a > b) swap(a, b); return a;}
int countSetBits(int n) {int count = 0; while (n) {count += n & 1; n >>= 1;} return count;}



void solve() {
       int n; cin >> n;
       int a[n][3], dp[n][3] = {0};
       for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2], dp[i][0] = a[i][0], dp[i][1] = a[i][1], dp[i][2] = a[i][2];
       for (int i = 1; i < n; i++) {
              dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
              dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
              dp[i][2] += max(dp[i - 1][1], dp[i - 1][0]);
       }
       dp[n - 1][0] = max(dp[n - 1][0], dp[n - 1][1]);
       dp[n - 1][0] = max(dp[n - 1][0], dp[n - 1][2]);
       cout << dp[n - 1][0] << endl;
}




signed main()
{
#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("o.txt", "w", stdout);
#endif

       solve();
}

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

int main() {
  int n; cin >> n;
  string c; cin >> c;
  int l=0,r=c.size()-1;
  int ans = 0;
  while (true) {
    if (l>=r) break;
    if (c[l] == 'W') {
      while(c[r] != 'R' && r != l) r--;
      if (c[r] == 'R') {
        c[l] = 'R';
        c[r] = 'W';
        ans++;
      }
    }
    l++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <cstring>
char s[105];
int main()
{
	scanf("%s",s+1);
	int l=strlen(s+1);
	bool flag=0;
	for(int i=1;i<=l;i++)
	{
		if(s[i]=='F')
		{
			if(flag)
			{
				printf("Yes\n");
				return 0;
			}
		}else if(s[i]=='C')
		{
			flag=1;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

const int INF = 100000;
const int MAX_N = 100;
int N, X;
int m[MAX_N];

int main()
{
  cin >> N >> X;
  REP(i,0,N) cin >> m[i];
  // 金額 X

  int s = 0;                    // sum
  REP(i,0,N) s += m[i];

  // 残額 X - s

  // min
  // int m = min_element(m, m + N);
  // cout << m << endl;
  int mini = INF;
  // int mini_index = INF;         // null
  REP(i,0,N) {
    if (m[i] < mini) {
      mini = m[i];
      // mini_index = i;
    }
  }

  // mini_index を多く買う, k
  int k = (X - s) / mini;
  int ans = N + k;
  cout << ans << endl;

  return 0;
}


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

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

	long long a, b, k;
	cin >> a >> b >> k;
	if(a >= k)
		return cout << a - k << " " << b, 0;
	k -= a;
	a = 0;
	if(b >= k)
		return cout << a << " " << b - k, 0;
	cout << 0 << " " << 0;

	return 0;
}

Measured memory_bytes: 256
import Data.Maybe
import Data.List
import Data.List.Split
import qualified Data.IntSet as IS
import qualified Data.ByteString.Char8 as B
main = mapM_ (print . solve) . chunksOf 2 . map (map readInt . B.words) . B.lines =<< B.getContents
readInt = fst . fromJust . B.readInt
solve [[n],a] = fst . foldl f (0,IS.fromList [-1,n]) . sort $ zip a [0..] where
f (t,s) (v,i) = (t+v*l*r, IS.insert i s) where
  [l,r] = map (\f->abs $ (i-) $ fromJust $ f i s) [IS.lookupLT,IS.lookupGT]

Measured memory_bytes: 99964
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 1e6;

int a, b, c;
int aa, bb, cc;
int main()
{
	while(scanf("%d %d %d", &a, &b, &c) != EOF)
	{
		int cnt = 0;
		bool f = 1;
		while(true)
		{
			if((a & 1) || (b & 1) || (c & 1)) break;
			aa = (b + c) / 2;
			bb = (a + c) / 2;
			cc = (a + b) / 2;
			cnt++;
			if(cnt > MaxN)
			{
				f = 0;
				break;
			}
			a = aa;
			b = bb;
			c = cc;
		}
		if(f) printf("%d\n", cnt);
		else printf("-1\n");
	}
}

Measured memory_bytes: 128
n, m=map(int, input().split())
h=list(map(int,input().split()))
l = [[] for _ in range(n)]
#print(l)
#print(h)
for i in range(m):
  a, b=map(int, input().split())
  l[a-1].append(b)
  l[b-1].append(a)
ans=0
for x in range(n):
  for y in range(len(l[x])):
    if h[x]<=h[l[x][y]-1]:
      break
  else:
    ans+=1
    continue
print(ans)
  
    
    

  
                 
       

Measured memory_bytes: 29352