akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Aoj.ALDS.Chapter9A
{
    class Heap<T> where T : IComparable<T>
    {
        private List<T> Values;

        public Heap()
        {
            Values = new List<T>();
        }

        public void Add(T value)
        {
            Values.Add(value);
        }

        public int Count()
        {
            return Values.Count();
        }

        public int ParentIndex(int index)
        {
            return index / 2;
        }

        public int LeftIndex(int index)
        {
            return index * 2;
        }

        public int RightIndex(int index)
        {
            return index * 2 + 1;
        }

        public bool Exists(int index)
        {
            return 1 <= index && index <= Count();
        }

        public T Value(int index)
        {
            if (Exists(index))
            {
                // ????????????1?§?????????§???????????????0?§???????????????§1????????????
                return Values[index - 1];
            }
            return default(T);
        }
    }

    class Program
    {
        public static void Solve()
        {
            var heap = new Heap<int>();

            int n = int.Parse(Console.ReadLine());

            int[] keys = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            foreach (var key in keys)
            {
                heap.Add(key);
            }

           for (int i = 1; i <= n; i++)
           {
                string output = string.Format("node {0}: ", i);

                output += string.Format("key = {0}, ", heap.Value(i));

                int parentI = heap.ParentIndex(i);
                if (heap.Exists(parentI))
                    output += string.Format("parent key = {0}, ", heap.Value(parentI));
                
                int leftI = heap.LeftIndex(i);
                if (heap.Exists(leftI))
                    output += string.Format("left key = {0}, ", heap.Value(leftI));

                int rightI = heap.RightIndex(i);
                if (heap.Exists(rightI))
                    output += string.Format("right key = {0}, ", heap.Value(rightI));

                Console.WriteLine(output);
           }
        }

        public static void Main()
        {
            //Console.SetIn(new System.IO.StreamReader("Aoj/AlgorithmsAndDataStructures/Input/09_Heap_A_01.txt"));
            //var sw = new Stopwatch();
            //sw.Start();
            Solve();
            //Console.WriteLine("{0}ms",sw.ElapsedMilliseconds);
        }
    }
}

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

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

  int cnt = a;
  while(cnt<=10000){
    if(cnt%b==c){
      cout << "YES" << endl;
      return 0;
    }
    cnt+=a;
  }
  cout << "NO" << endl;

}

Measured memory_bytes: 256
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');

var inputs = stdin.toString().trim();

var x = Number(inputs.split(' ')[0]);

var y = Number(inputs.split(' ')[1]);

var area = x * y;
var around = 2 * x + 2 * y;
console.log(area + ' ' + around);

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

int main() {
    int n, k;
    cin >> n >> k;
    double sol = 0;
    for(int i = 1; i <= n; i++) {
        int x = i;
        double val = 1;
        double c = 1.0 / n;
        while(x < k) {
            x *= 2;
            val /= 2;
        }
        //cout << c << ' ' << val << '\n';
        sol += c * val;
    }
    cout << fixed << setprecision(9) << sol;
    return 0;
}

Measured memory_bytes: 3756
#include <cstdio>
#include <algorithm>
using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
	int N, M, K;
	scanf("%d %d %d", &N, &M, &K);
	
	long long mod = 1000000007;	
	long long comb = 1;
	for(long long i = 1; i <= K-2; i++) {
		comb *= N * M - K + i;
		comb %= mod;
		comb *= modinv(i, mod);
		comb %= mod;
	}
	
	long long sum = 0;
	for(long long i = 1; i < N; i++) {
		sum += i * (N - i) * M * M;
		sum %= mod;
	}
	for(long long i = 1; i < M; i++) {
		sum += i * (M - i) * N * N;
		sum %= mod;
	}
	sum *= comb;
	sum %= mod;
	
	printf("%ld", sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;

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

    int N;
    cin>>N;
    vector<int> A(N), B(N), C(N);
    for (int n = 0; n < N; n++) cin>>A[n];
    for (int n = 0; n < N; n++) cin>>B[n];
    for (int n = 0; n < N; n++) cin>>C[n];
    
    sort(begin(A), end(A));
    sort(begin(B), end(B));
    sort(begin(C), end(C));

    vector<ll> dp(N+1);
    dp[N] = 0;
    for (int i = N-1; i >= 0; i--) {
        auto c = upper_bound(begin(C), end(C), B[i]);
        dp[i] = end(C) - c + dp[i+1];
    }

    ll ans = 0;
    for (int a : A) {
        auto b = upper_bound(begin(B), end(B), a);
        ans += dp[b-begin(B)];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> node[200005];
bool used[200005];
P d1(ll pos){
  P res=P(0,pos);
  for(int i=0;i<node[pos].size();i++){
    int to=node[pos][i];
    if(used[to]) continue;
    used[to]=true;
    P dans=d1(to);
    if(dans>res) res=dans;
  }
  res.first++;
  return res;
}
int main(){
  vector<ll> lsum,rsum,l;
  vector<P> r;
  ll n;
  cin>>n;
  vector<ll> in_l;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    in_l.push_back(b);
    r.push_back(P(a,i));
  }
  ll ls=0,rs=n;
  lsum.push_back(0);
  sort(r.begin(),r.end(),greater<P>());
  rsum.push_back(0);
  for(int i=0;i<r.size();i++) rsum.push_back(rsum[i]+r[i].first);
  priority_queue<ll,vector<ll>,greater<ll>> pque;
  ll ans=0;
  for(ll border=-100005;border<=100005;border++){
    if(rs>0){
      while(r[rs-1].first<border&&rs>0){
        pque.push(in_l[r[rs-1].second]);
        rs--;
        r.pop_back();
      }
    }
    while(!pque.empty()&&pque.top()<=border){
      l.push_back(pque.top());
      lsum.push_back(lsum[ls]+pque.top());
      pque.pop();
      ls++;
    }
    ll max_v=min(ls,rs)+1;
    ll kans=abs(border);
    ll lkb=min(ls,max_v),rkb=min(rs,max_v);
    if(border<0){
      if(lkb<=rkb) rkb=lkb-1;
    }
    if(border>0){
      if(lkb>=rkb) lkb=rkb-1;
    }
    if(lkb<0||rkb<0) continue;
    kans+=(-1*lsum[lkb]+border*lkb);
    kans+=rsum[rkb]-border*rkb;
    kans*=2;
    ans=max(ans,kans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11752
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = input.trim().split("\n");
  const info = input.shift().split(" ");
  const M = info[1]; // 提出回数

  let result = {};

  for (let i = 0; i < M; i++) {
    const obj = input[i].split(" ");
    if (!result[obj[0]]) {
      result[obj[0]] = [obj[1], obj[1] === "WA" ? 1 : 0];
    } else {
      if (obj[1] === "WA" && result[obj[0]][0] !== "AC") result[obj[0]][1] += 1;
      else result[obj[0]][0] = "AC";
    }
  }

  let ans = 0;
  let wrong = 0;

  Object.keys(result).forEach(function(key) {
    if (result[key][0] === "AC") {
      ans += 1;
      wrong += result[key][1];
    }
  });

  console.log(`${ans} ${wrong}`);
}


Measured memory_bytes: 55080
#include <iostream>
#include <string>
#include <deque>
using namespace std;
deque<char> dq;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string S;cin>>S;
	for(char c : S) dq.push_back(c);
	int Q;cin>>Q;
	int flag=0;
	while(Q--){
		int T;cin>>T;
		if(T==1) flag=!flag;
		else{
			int F;char C;
			cin>>F>>C;
			if(flag^(F-1)){
				dq.push_back(C);
			}
			else{
				dq.push_front(C);
			}
		}
	}
	if(flag) for(auto it = dq.rbegin();it!=dq.rend();++it) cout<<*it;
	else for(char c : dq) cout<<c;
}

Measured memory_bytes: 976
#include <iostream>
    #define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #include <algorithm>
    #include <bits/stdc++.h>
    #define MOD 1000000007
    #define ll long long
    #define mm(arr) memset(arr, 1, sizeof(arr))
    #define scanArray(a,n) for(ll i = 0; i < n; i++){cin >> a[i];}
    using namespace std;

    int main(){
        FAST
        int n; cin >> n;
        string s; cin >> s;
        for(int i=0; i<s.size(); i++){
                if(s[i]+n > 'Z'){
                    int ans = s[i]+n-'Z';
                        s[i] = 'A' -1 + ans;
                }
                else{
                    s[i]=s[i] + n ;
                }

        }
        cout << s << endl;


        return 0;
    }


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll cnt[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,res=0;
    cin>>n>>m;
    set<ll> s;
    for(ll i=0;i<m;i++){
        ll p;
        string st;
        cin>>p>>st;
        if(st=="AC"){
            if(s.find(p)==s.end())
            res+=cnt[p];
            s.insert(p);
        }
        else
        cnt[p]++;
    }
    cout<<s.size()<<" "<<res;
}


Measured memory_bytes: 4992
// lcs.rs --- LCS
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        s: chars,
        t: chars,
    };

    let (s_len, t_len) = (s.len(), t.len());
    let mut dp = vec![vec![0; t_len + 1]; s_len + 1];

    for i in 1..(s_len + 1) {
        for j in 1..(t_len + 1) {
            dp[i][j] = *[
                dp[i - 1][j - 1] + if s[i - 1] == t[j - 1] { 1 } else { 0 },
                dp[i - 1][j],
                dp[i][j - 1],
            ]
            .into_iter()
            .max()
            .unwrap()
        }
    }

    let (mut i, mut j) = (s_len, t_len);
    let mut ans = String::with_capacity(dp[s_len][t_len]);

    while i != 0 && j != 0 {
        if dp[i][j] == dp[i - 1][j] {
            i -= 1;
        } else if dp[i][j] == dp[i][j - 1] {
            j -= 1;
        } else if dp[i][j] == dp[i - 1][j - 1] + 1 {
            ans.push(s[i - 1]);
            i -= 1;
            j -= 1;
        }
    }

    ans = String::from_utf8(ans.into_bytes().into_iter().rev().collect::<Vec<_>>())
        .ok()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 90364
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int d;
    cin >> d;

    while(--d >= 0){
        int n, a, b;
        cin >> n >> a >> b;
        
        int sx, sy;
        cin >> sx >> sy;
        vector<int> x(n), y(n);
        for(int i=0; i<n; ++i)
            cin >> x[i] >> y[i];

        vector<vector<bool> > near(n, vector<bool>(n, false));
        for(int i=0; i<n; ++i){
            for(int j=0; j<i; ++j){
                int dx = x[i] - x[j];
                int dy = y[i] - y[j];
                if(dx * dx + dy * dy <= 50 * 50)
                    near[i][j] = near[j][i] = true;
            }
        }

        vector<bool> check(n, false);
        queue<int> q;
        for(int i=0; i<n; ++i){
            int dx = sx - x[i];
            int dy = sy - y[i];
            if(dx * dx + dy * dy <= 10 * 10){
                check[i] = true;
                q.push(i);
            }
        }

        if(a > b){
            bool loop = false;
            for(int i=0; i<n; ++i){
                for(int j=0; j<n; ++j){
                    if(check[i] && !check[j] && near[i][j])
                        loop = true;
                }
            }
            if(loop)
                cout << "You're always welcome!" << endl;
            else if(q.size() == 0)
                cout << 0 << endl;
            else
                cout << a << endl;
        }else{
            int ret = 0;
            while(!q.empty()){
                int m = q.size();
                while(--m >= 0){
                    int pos = q.front();
                    q.pop();
                    for(int i=0; i<n; ++i){
                        if(near[pos][i] && !check[i]){
                            check[i] = true;
                            q.push(i);
                        }
                    }
                }
                ret += a;
            }
            cout << ret << endl;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld",a)

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//bitset<32> bset1;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL
    //
    //scan(n);
    cin>>n;
    ll A[n];
    forr(i,n)
    {
        cin>>A[i];
        sum+=A[i];
        maxx= max(maxx, A[i]);
    }
    sum-=maxx;
    if(maxx<sum)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '0') {
        ans += "0";
      } else if(s.charAt(i) == '1') {
        ans += "1";
      } else {
        if(ans.length() > 1) {
          ans = ans.substring(0, ans.length() - 1);
        } else if(ans.length() == 1) {
          ans = "";
        }
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int main() {

	string n;
	cin >> n;

	if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}

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

bool OK(string s){
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='-'){
      if(i+1==s.size())return 0;
      if(s[i+1]=='+')return 0;
      if(s[i+1]=='*')return 0;
      if(i&&s[i-1]=='('&&s[i+1]==')')return 0;
      if(s[i+1]==')')return 0;
    }
    if(s[i]=='+'){
      if(i==0)return 0;
      if(i+1==s.size())return 0;
      if(s[i+1]=='+')return 0;
      //if(s[i+1]=='-')return 0;
      if(s[i+1]=='*')return 0;
      if(s[i+1]==')')return 0;
    }
     if(s[i]=='*'){
      if(i==0)return 0;
      if(i+1==s.size())return 0;
      if(s[i+1]=='+')return 0;
      //if(s[i+1]=='-')return 0;
      if(s[i+1]=='*')return 0;
      if(s[i+1]==')')return 0;
    }
    if(isdigit(s[i])){
      if(i&&s[i-1]==')')return 0;
      if(s[i]=='0'){
        if(i==0&&isdigit(s[i+1]))return 0;
        if(i&&i<s.size()&&!isdigit(s[i-1])&&isdigit(s[i+1]))return 0;
      }
      if(s[i+1]=='(')return 0;
    }
    if(s[i]=='('){
      cnt++;
      if(i==s.size())return 0;
      if(s[i+1]=='+')return 0;
      if(s[i+1]=='*')return 0;
      if(s[i+1]==')')return 0;
    }
    if(s[i]==')'){
      cnt--;
      if(cnt<0)return 0;
      if(!i)return 0;
      if(isdigit(s[i+1]))return 0;
      if(s[i+1]=='(')return 0;
    }
  }
  if(cnt)return 0;
  return 1;
}

string str,s;
set<char>st;

struct Parse{
    string s;
    int p;
    int g_A(){
        int r=0,x=1;
        if(s[p]=='-'){
          p++;
          return -g_A();
        }
        else if(s[p]=='(')p++,r=bnf1(),p++;
        else while(isdigit(s[p])) r=r*2+(s[p++]-'0');
        return r;
    }
    int bnf2(){
        int res=g_A();
        while(s[p]=='*'){
          int t=p++;
          if(s[t]=='*')res*=g_A();
        }
        return res;
    }
    int bnf1(){
        int res=bnf2();
        while(s[p]=='+'||s[p]=='-'){
            int t=p++;
            if(s[t]=='+')res+=bnf2();
            if(s[t]=='-')res-=bnf2();
        }
    return res;
    }
    int build(string t){
        p=0;
        s=t;
        return bnf1();
    }
};

int ans=0;
string t="01()+*-=";
map<char,int>M1;
int n;

signed main(){

  Parse p;

  cin>>s;
  r(i,s.size())if(isalpha(s[i]))st.insert(s[i]);
  n=st.size();
  int cc=0;
  for(set<char>::iterator it=st.begin();it!=st.end();it++){
    char c=*it;
    M1[c]=cc++;
  }
  set<string>S;
  vector<int>v;
  r(i,8)v.push_back(i);
  do{
    int sum=0,idx;
    string x=s;
    r(i,x.size()){
      if(isalpha(x[i])){
        int y=M1[x[i]];
        x[i]=t[v[y]];
      }
    }

    if(S.count(x))continue;
    r(i,x.size())if(x[i]=='=')sum++,idx=i;
    if(sum!=1)continue;
    if(idx==0||idx==x.size()-1)continue;

    string a=x.substr(0,idx);
    string b=x.substr(idx+1);

    if(!OK(a)||!OK(b))continue;

    int A=p.build(a);
    int B=p.build(b);
    if(A==B){

      S.insert(x);
      ans++;
    }
  }while(next_permutation(v.begin(),v.end()));
  cout<<ans<<endl;
}


Measured memory_bytes: 3248
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;
    ll H[N];
    REP(i, N) cin >> H[i];
    int A[M], B[M];
    REP(i, M) cin >> A[i] >> B[i];

    set<int> s[N];
    REP(i, M) {
        s[A[i] - 1].insert(B[i] - 1);
        s[B[i] - 1].insert(A[i] - 1);
    }

    bool f[N];
    REP(i, N) f[i] = true;
    REP(i, N) {
        if (f[i]) {
            bool ff = true;
            for (auto itr = s[i].begin(); itr != s[i].end(); ++itr) {
                if (H[i] == H[*itr]) {
                    ff = false;
                    f[*itr] = false;
                }
                else if (H[i] < H[*itr]) {
                    ff = false;
                }
                else {
                    f[*itr] = false;
                }
            }
            f[i] = ff;
        }
    }
    int ans = 0;
    REP(i, N) if (f[i]) ans++;
    cout << ans << endl;
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




ll n, k;
pair<ll,ll> a[maxn];

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

    cin>>n>>k;
    for (int i=0; i<n; i++) {
	cin>>a[i].first>>a[i].second;
    }
    sort(a,a+n);
    for (int i=1; i<n; i++) {
	a[i].second += a[i-1].second;
    }
    k--;

    for (int i=0; i<n; i++) {
	if (k>=a[i].second) continue;
	out(a[i].first);
    }

    assert(0);
  

    return 0;
}


Measured memory_bytes: 1792
N = int(input())
S = []
ABcnt = 0
topABcnt = 0
topBbtmA = 0
topBbtmNO = 0
topNObtmA = 0
for _ in range(N):
  s = input()
  nowABcnt = s.count('AB')
  ABcnt += nowABcnt
  if s[0:2]=='AB':
    topABcnt += 1
  if s[0]=='B':
    if s[-1]=='A': topBbtmA += 1
    else: topBbtmNO += 1
  elif s[-1]=='A':
    topNObtmA += 1
  if nowABcnt!=0 or s[0]=='B' or s[-1]=='A': S.append(s)

ans = 0


ans += min(topBbtmNO, topNObtmA)
firstSurvivorCnt = max(topBbtmNO, topNObtmA) - ans

nikaisenGet = min(firstSurvivorCnt, topBbtmA)
ans += nikaisenGet

topBbtmA -= nikaisenGet
if ans == 0: ans += max(0, topBbtmA-1)
else: ans += topBbtmA #topBbtmAが生き残ってたら足す
#最後のtopBbtmAはペアを作れない

print(ans+ABcnt)

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

int main(){
  ll n, m, k;
  cin >> n >> m >> k;
  vl a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  
  //ーーーー累積和ーーーー//
  
  vl A(n), B(m);
  A[0] = a[0], B[0] = b[0];
  ll ans = 0;
  rep(i,n-1) A[i+1] = A[i] + a[i+1];
  rep(i,m-1) B[i+1] = B[i] + b[i+1];
  
  rep(i,m) if (B[i] <= k) ans = max(ans,i+1);
  
  //ーーーー二分探索ーーーー//
  //kからaのi番目までの累積和A[i]を引くことで残りの時間数keyが分かる。
  //keyがbの累積和Bではどこに当てはまるのかを二分探索で求める。
  //読んだ本の数は(i+1)と、二分探索で求めた(l+1)の和で与えられる。
  //これと、Bのみ貪欲に読んでいったときの本の数(ans)とで、大きい方を答にする。
  
  rep(i,n) {
    ll key = k - A[i];
    ll l = 0, r = m;
    if (key < 0) continue;
    if (key < A[0]) {
      ans = max(ans,i+1);
      continue;
    }
    while (r-l>1) {
      ll mid = (l+r)/2;
      if (key >= B[mid])
        l = mid;
      else r = mid;
    }
    
    ans = max(i+1+l+1,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VLL;
const int MOD=1000000007;

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

    int n, q;
    cin >> n >> q;
    VI v(q), w(q);
    REP(i, q){
        cin >> v[i] >> w[i];
    }

    REP(i, q){
        if(n == 1){
            if(v[i] < w[i]){
                cout << v[i] << endl;
            }else{
                cout << w[i] << endl;
            }
        }else{
            int vp = v[i];
            int wp = w[i];
            while(wp != vp){
                if(wp > vp){
                    wp = (wp + n - 2) / n;
                }else{
                vp = (vp + n - 2) / n;
                }
            }
            cout << vp << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2048
import java.util.Scanner;
import java.io.*;
class Main{
	public static void main(String[] args) {
		int[] A={0,0,0,0,0,0,0,0,0};
		int[] A2={0,0,0,0,0,0,0,0,0};
		Scanner scan = new Scanner(System.in);
		for(int i=0;i<9;i++){
			A[i]=scan.nextInt();
		}	
		int N;
		int b;
		N=scan.nextInt();
		for(int i=0;i<N;i++){
			b=scan.nextInt();
			for(int j=0;j<9;j++){
				if(b==A[j]){
					A2[j]=1;
				}	
			}
		}
		boolean flag=false;
		for(int i=0;i<3;i++){
			int c=1;
			for(int j=0;j<3;j++){
				c*=A2[i+3*j];
			}
			if(c!=0){
				flag=true;
			}
		}
		for(int i=0;i<3;i++){
			int c=1;
			for(int j=0;j<3;j++){
				c*=A2[3*i+j];
			}
			if(c!=0){
				flag=true;
			}
		}
		if(A2[0]*A2[4]*A2[8]!=0||A2[2]*A2[4]*A2[6]!=0){
			flag=true;
		}
		System.out.println(flag ? "Yes" : "No");
	}
}

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

using namespace std;

const int N = 302;
const int MOD = 998244353;

bitset<N>a[N];
int32_t main() {
    //ifstream cin("data.in");
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            int x;
            cin >> x;
            a[i][j] = x;
        }
    }


    // n ecuatii cu m necunoscute, rezultatul e 0
    for(int i = 0; i < n; ++i) {
        a[i][m] = 0;
    }
    int l = 0, c = 0, var_free = 0;
    while(l < n && c < m) {
        int poz = -1;
        for(int i = l; i < n && poz == -1; i++)
            if(a[i][c] == 1)
                poz = i;
        if(poz == -1) {
            // n-am putut gasi, e deja 0
            c++;
            continue;
        }
        swap(a[l], a[poz]);
        for(int i = l + 1; i < n; ++i)
            if(a[i][c] == 1)
                a[i] ^= a[l];
        l++;
        c++;
    }

    for(int i=0;i<n;++i)
    {
        bool any=0;
        for(int j=0;j<m;++j)
        {
            if(a[i][j]) any = 1;
        }
        if(!any)var_free++;
    }


    vector<long long>p2(n + m + 1);
    p2[0] = 1;
    for(int i = 1; i <= n + m; ++i)
        p2[i] = 2 * p2[i - 1] % MOD;
    int aux1, aux2;

    aux1 = (p2[n] - 1 + MOD) % MOD, aux2 = p2[m - 1];
    int answer = (1LL * aux1 * aux2) % MOD;

    aux1 = (p2[var_free] - 1 + MOD) % MOD, aux2 = p2[m - 1];
    int bad = (1LL * aux1 * aux2) % MOD;
    answer = (answer - bad + MOD) % MOD;

    cout << answer;




}


Measured memory_bytes: 384
#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<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

ll solve(ll X){
  if(X==1) return 1;
  return 1+2*solve(X/2);
}

int main(){
  ll N;
  cin>>N;
  cout<<solve(N)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main() {
  int a,b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b)) << endl;
  return 0;
}

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

int main() {
	int k, x;
	cin >> k >> x;
	if (500 * k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    h_l = list(map(int, input().split()))
    ans_set = set(range(1, n + 1))
    for _ in range(m):
        a, b = map(int, input().split())
        if h_l[a - 1] <= h_l[b - 1] and a in ans_set:
            ans_set.remove(a)
        if h_l[b - 1] <= h_l[a - 1] and b in ans_set:
            ans_set.remove(b)
    print(len(ans_set))


if __name__ == '__main__':
    main()


Measured memory_bytes: 22424
#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 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...); }

#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);
  STR(s);
  if(s[1]=='R') cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
  ret;
}


Measured memory_bytes: 3660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()
	cnt := 0
	for i := 1; i <= N; i++ {
		if i%2 == 1 && a[i-1]%2 == 1 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
  char a,b;
  cin >> a >> b;
  string sa,sb;
  for(int i=0;i<a-48;i++)
    sa+=b;
  for(int i=0;i<b-48;i++)
    sb+=a;
  cout << (sa>sb?sb:sa) << endl;
  return 0;
}

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


def solve(A: int, B: int, K: int):
    if (B - A + 1) <= 2*K:
        for i in range(A,B+1):
            print(i)
    else:
        for i in range(A,A+K):
            print(i)
        for i in range(B-K+1,B+1):
            print(i)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;

typedef complex<int> P;

int b[19][19];


int main(){
	
	string s;
	string ans="";
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'&&ans!="")
		ans.erase(ans.end()-1,ans.end());
		else if(s[i]=='0'||s[i]=='1')
			ans+=s[i];
	}
	cout<<ans<<endl;
	
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string S, T; cin >> S >> T;
  cout << T << S << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w,h,x,y,b=0;cin>>w>>h>>x>>y;
  double r=double(h)*double(w)/2.0;
  if(2*x==w&&2*y==h)b=1;
  printf("%.10lf %d",r,b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main (){
    int W;
    cin >> W >> W;
    string a , b(W + 2, '#');
    for (cout << b << endl; cin >> a; cout << '#' << a << "#\n");
    cout << b << endl;
}

Measured memory_bytes: 3616
fn main() {
    proconio::input! {
        a: usize,
        mut b: usize,
        mut c: usize,
        mut k: usize,
    }
    while a>=b && k>0 {
        b*=2;
        k-=1;
    }
    while b>=c && k>0 {
        c*=2;
        k-=1;
    }
    println!("{}",if a<b && b<c {"Yes"} else {"No"});
}

Measured memory_bytes: 2124
#include <iostream>
#include <string>
#include <unordered_map>


int main() {
	int N;
	std::unordered_map<std::string, int> prizes;

	std::cin >> N;

	for (int i = 0; i < N; i++) {
		std::string str;
		std::cin >> str;
		prizes[str]++;
	}


	std::cout << prizes.size() << std::endl;


}


Measured memory_bytes: 17084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
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 FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

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

int main(void){
	int a, b, c;
	int x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = a * x + b * y;
	ll res1 = c * 2 * x + b * max(0, y - x);
	ans = min(ans, res1);
	ll res2 = c * 2 * y + a * max(0, x - y);
	ans = min(ans, res2);
	ll res3 = c * 2 * (x-1) + b * max(0, y - x + 1) + a;
	ans = min(ans, res3);
	ll res4 = c * 2 * (y-1) + a * max(0, x - y + 1) + b;
	ans = min(ans, res4);
	cout << ans << endl;
}

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

constexpr int INF = 100000000;

int main() {
    int n;
    cin >> n;
    vector<int> dp(100010,INF);
    dp[0] = 0;
    for(int i = 1; i < 100010; i++) {
        int power = 1;
        while(power <= i) {
            dp[i] = min(dp[i],dp[i-power]+1);
            power *= 6;
        }
        power = 1;
        while(power <= i) {
            dp[i] = min(dp[i],dp[i-power]+1);
            power *= 9;
        }
    }
    cout << dp[n] << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>

int main(){
	int N;
	scanf("%d", &N);
	long int max_absolute_value = 0;
	int max_absolute_value_id = 1; 
	for (int i = 1; i <= N; ++i) {
		long int tmp;
		scanf("%ld", &tmp);
		if(tmp * tmp > max_absolute_value * max_absolute_value) {
			max_absolute_value = tmp;
			max_absolute_value_id = i;
		}
	}
	printf("%d\n", N * 2 - 2);
	for (int i = 1; i <= N; ++i) {
		if(i != max_absolute_value_id)
			printf("%d %d\n", max_absolute_value_id, i);
	}
	if(max_absolute_value >= 0) {
		for(int i = 1; i < N; ++i)
			printf("%d %d\n", i, i+1);
	} else {
		for(int i = N; i > 1; --i)
			printf("%d %d\n", i, i-1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 51
#define INF 1e9
using namespace std;
typedef long long ll;
int n,num[3];
ll G[N],rG[N];

ll mem[N][110],used[N][110];
ll dfs(int pos,int dep){
  if(dep==0) return (1LL<<pos);
  if(used[pos][dep]++) return mem[pos][dep];

  ll res=0;
  for(int i=0;i<n;i++)
    if(rG[pos]&(1LL<<i))res|=dfs(i,dep-1);
  return mem[pos][dep]=res;
}

  
int bfs(){
  vector<int> D(N,INF);
  int cnt[3][N]={};
  
  queue<int> Q;
  Q.push(n-1);
  D[n-1] = 0;
  
  while(!Q.empty()){
    int pos = Q.front();Q.pop();
    int cost = D[pos];
    
    if(pos==0) return cost;
    
    for(int k=0;k<3;k++){
      ll g = dfs(pos,num[k]);
      for(int i=0;i<n;i++) if((g>>i)&1) cnt[k][i] = 1;
    }

    for(int i=0;i<n;i++){
      int f = cnt[0][i]&cnt[1][i]&cnt[2][i];
      if(f==0||D[i]<=cost+1)continue;
      Q.push(i);
      D[i] = cost+1;
    }

  }
  return 0;  
}

int main(){
  int m;
  cin>>n>>m;
  for(int i=0;i<3;i++)cin>>num[i];
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    G[a-1]|=1LL<<(b-1);
    rG[b-1]|=1LL<<(a-1);
  }

  int ans = bfs();
  if(ans)cout<<ans<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string S, T;
  map<char, char> s, g;
  cin >> S >> T;
  for(int i = 0; i < S.size(); i++){
    if(s[S[i]] || g[T[i]]){
      if(s[S[i] != T[i]] || g[T[i]] != S[i]){
	cout << "No" << endl;
	return 0;
      }
    } else {
      s[S[i]] = T[i];
      g[T[i]] = S[i];
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
string s;
cin >> N >> s;
int ans = 1;
if (N == 1) cout << ans << endl;
 else { 
for (int i = 0; i < s.size()-1; i++) {
if(s[i] != s[i+1])  ans++;


if (i == s.size()-2) cout << ans << endl;
}
}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[100000],b[100000],c[100000];
ll aa[200000];
signed main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n)scanf("%d",&b[i]);
	rep(i,n)scanf("%d",&c[i]);
	
	sort(a,a+n);sort(b,b+n);sort(c,c+n);
	for(int i=n-1;i>=0;i--){
		aa[i]=aa[i+1]+n-(upper_bound(c,c+n,b[i])-c);
	}
	ll ans=0;
	rep(i,n){
		ans+=aa[upper_bound(b,b+n,a[i])-b];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2176
#![allow(unused)]

use std::{cell, cmp, collections, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let n = parse_line::<usize>();
    println!("{}", if n % 2 == 0 { n } else { 2 * n });
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rev(x) reverse(x.begin(),x.end())
#define al(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> G[101010];

void answer(bool flag){
	cout << (flag?"Yes":"No") << endl;
	exit(0);
}

vector<bool> visited(101010, false);

bool dfs(ll now, ll par, ll x, ll y){
	if(now == y) return false; 
	if(now == x && visited[now]) return true;
	if(visited[now]) return false;
	visited[now] = true;
	bool res = false;
	REP(i, G[now].size()){
		ll next = G[now][i];
		if(next == par) continue;
		res = (res || dfs(next, now, x, y)); 
	}
	return res;
}

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

    ll N, M;
    cin >> N >> M;
    REP(i, M){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }
    bool flag = true;
    REP(i, N){
    	if(G[i].size()%2 != 0) flag = false;
    }
    if(!flag){
    	answer(false);
    }
    
    vector<ll> four;
    REP(i, N){
    	if(G[i].size() > 5) answer(true);
    	if(G[i].size() == 4) four.push_back(i);
    }

    if(four.size() > 2) answer(true);
    if(four.size() < 2) answer(false);

    ll x = four[0];
    ll y = four[1];
    answer(dfs(x, -1, x, y));

    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int size = s.size();
	if (size % 2 != 0){
		cout << "No" << "\n";
	}else {
		bool OK = true;
		for (int ii = 0; ii < size / 2; ++ii){
			int idx1 = 2 *ii;
			int idx2 = 2 * ii + 1;
			if ((s[idx1] != 'h') || (s[idx2] != 'i') ){
				cout << "No" << "\n";
				OK = false;
				break;
			}
		}
		if (OK){
			cout << "Yes" << endl;
		}
	}


	return 0;
}


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

int main()
{
    ll n,d; cin >> n >> d;
    vector<ll> x(n);
    vector<ll> y(n);

    rep(i,n) cin >> x[i] >> y[i];
    ll ans= 0;
    rep(i,n) {
        double tmp;
        tmp = sqrt(x[i]*x[i] + y[i]*y[i]);
        if(tmp <= d) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6428