akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

long long comb(long long n, long long r) {
    long long r_new = (r <= n/2) ? r : n-r;
    if (r_new < 0) return 0;
    if (r_new == 0) return 1;
    else return (n-r_new+1) * comb(n, r_new-1) / r_new;
}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for (int i=0; i<n; ++i) {
        cin >> v.at(i);
    }

    sort(v.rbegin(), v.rend());
    double sum = 0.0;
    for (int i=0; i<a; ++i) sum += v.at(i);
    cout << sum / a << '\n';

    map<ll, int> mp;
    for (ll x : v) ++mp[x];
    int cnt = -1;
    for (int i=0; i<a; ++i) {
        if (v.at(i) == v.at(a-1)) {
            cnt = i;
            break;
        }
    }
    if (cnt == 0) {
        ll res = 0;
        int dif = b - a;
        int num = mp[v.at(a-1)];
        for (int i=0; i<dif+1; ++i) {
            res += comb(num, a+i);
        }
        cout << res << '\n';
    } else {
        int num = mp[v.at(a-1)];
        cout << comb(num, a-cnt) << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INT long long int
#define oo 987654321
#define MOD 1000000007
using namespace std;
INT n, cnt[26], ans = 1;
string s;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>s;
    for(int i = 0 ; i < n ; i++ )
        cnt[s[i]-'a']++;
    for(int i = 0 ; i < 26 ; i++ )
    {
        ans *= cnt[i]+1;
        ans %= MOD;
    }
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
const int M=2e5+10;
int n,m,v,P,ans,a[M];
LL s[M];
int main(){
	n=read(); m=read(); v=read(); P=read();
	F(i,1,n) a[i]=read();
	sort(a+1,a+n+1);
	F(i,1,n) s[i]=s[i-1]+a[i];
	F(i,1,n){
		int l=1,r=n+1,p=n+1;
		while (l<=r){
			int mid=(l+r>>1);
			if (a[mid]>a[i]+m){
				r=mid-1;
				p=mid;
			}
			
			else l=mid+1;
		}
		if (n-p+1<P){
			int num=v-(n-p+2);
			if (num<=0) ans++;
			else {
				if (num>=i) {
					num++;
					LL oo=1ll*(p-1-i)*(a[i]+m),o=s[p-1]-s[i];
					LL ret=oo-o;// cout<<ret<<'\n';
					ret=1ll*(num-i)*m-ret;
					l=i; r=p; int pos=p;
					while (l<=r){
						int mid=(l+r>>1);
						if ((s[p-1]-s[mid-1])-1ll*(p-mid)*a[i]>=ret){
							l=mid+1; pos=mid;
						}else r=mid-1;
					}
//					cout<<num<<" "<<pos<<" "<<p<<" "<<a[i]<<" "<<ret<<"\n";
					
					if (p-pos+(n-p+1)<P){
						
						ans++;
					}
				}
				else {
					ans++;
				}
//				if (num-i<=P-(n-p+1)) cout<<p<<" "<<num<<" "<<a[i]<<"\n",ans++;
				
			}
		}
	}
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,k,q;cin>>n>>k>>q;
    ll arr[n];mset(arr);
    for(int i=0;i<q;i++){
        ll d;cin>>d;d--;
        arr[d]++;
    }
    for(int i=0;i<n;i++){
        if(arr[i]+k>q)cout<<"Yes\n";
        else cout<<"No\n";
    }
}


Measured memory_bytes: 1408
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int a[3];
  scanf("%d%d%d", &a[0], &a[1], &a[2]);
  
  int m = 0;
  for(int i = 0; i < 3; i++){
    if(m < a[i]){
      m = a[i];
    }
  }
  
  int ans = 9 * m + a[0] + a[1] + a[2];
  
  printf("%d\n", ans);
  
  return 0;
}
         

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<int> d(n);
	RBF(i, d) {
		cin >> i;
	}

	int ans = 0;
	REP(i, n-1) {
		RNG(j, i+1, n) {
			ans += d[i] * d[j];
		}
	}
	col(ans);
	return 0;
}

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MAX = 410;
using pint = pair<int,int>;

int H, W;
vector<string> fi;

long long numb = 0, numw = 0;
bool seen[MAX][MAX];
void dfs(int x, int y) {
    seen[x][y] = true;
    if (fi[x][y] == '#') ++numb;
    else ++numw;
    
    for (int dir = 0; dir < 4; ++dir) {
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
        if (fi[x][y] == fi[nx][ny]) continue; // 隣接マスの色が同じだったら分断されている
        if (seen[nx][ny]) continue;
        dfs(nx, ny);
    }
}

int main() {
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];
    
    long long res = 0;
    for (int x = 0; x < H; ++x) {
        for (int y = 0; y < W; ++y) {
            if (fi[x][y] == '.') continue;
            if (seen[x][y]) continue;
            numb = numw = 0; // 黒マスと白マスの個数を 0 で初期化
            dfs(x, y);
            res += numb * numw;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 18176
def listToStr(list):
    return ''.join(list)

def getChar(h, w):
    h_parity = h % 2
    w_parity = w % 2
    total_parity = (h_parity + w_parity) % 2
    
    if total_parity == 0:
        return "#"
    else:
        return "."

def getMatrix(h, w):
    result = []
    for i in range(h):
        result.append([])
        for j in range(w):
            result[i].append(getChar(i, j))
    return result

def input_parse():
    inputs = []
    while True:
        input_HW = input().split(" ")
        (h, w) = (int(input_HW[0]),int(input_HW[1]))
        if h == 0 and w == 0:
            break
        inputs.append((h, w))
    return inputs

def output_matrix(matrix):
    for line in matrix:
        print(listToStr(line))
    print()

if __name__ == "__main__":
    inputs = input_parse()
    for input in inputs:
        matrix = getMatrix(input[0], input[1])
        output_matrix(matrix),0

Measured memory_bytes: 7900
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res%mod) * (a%mod))%mod;
      a = ((a%mod) * (a%mod))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("o.txt","w",stdout);
  #endif
}
///////////U L R D
int dx[4]={0,-1,1,0};
int dy[4]={1,0,0,-1};

template <typename T1, typename T2>
struct less_second {
    typedef pair<T1, T2> type;
    bool operator ()(type const& a, type const& b) const {
        return a.second > b.second;
    }
};

int solve(vi v)
{
  vi ans(v.size());
  ans[0]=0;
  ans[1]=abs(v[0]-v[1]);
  int fst=0,snd=1;

  for(int i=2;i<v.size();i++)
  {
    ans[i]=min(ans[fst]+abs(v[i]-v[fst]),ans[snd]+abs(v[i]-v[snd]));
    fst++;
    snd++;
    
  }
  return ans[v.size()-1];
}

int main()
{
  go();
  fast_io
  int n;cin>>n;
  vi v(n);
  for0(i,n)
  {
    cin>>v[i];
  }
  int ans=0;
  ans=solve(v);
  cout << ans <<"\n";
}



/*

arr : 0 20 min(30,50)

*/










Measured memory_bytes: 4524
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, M;
  std::cin >> N >> M;

  ll x = 1900 * M + 100 * (N - M);
  ll ans = x * std::pow(2, M);
  print(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);		
		int n = scan.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}

		String str = "";

		for (int i = n-1; i >= 0; i--) {
			str += a[i] + " ";
		}

		System.out.println(str.substring(0, str.length()-1));
		scan.close();
	}

}

Measured memory_bytes: 18312
#include<iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

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

    cout << (int)a/(int)b <<" "<< (int)a%(int)b<<" ";
    printf("%.5f\n",a/b);
    return 0;
}


Measured memory_bytes: 3268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int x = o[0];
            int y = o[1];
            string ans = GetGroupID(x) == GetGroupID(y) ? "Yes" : "No";
            Console.WriteLine(ans);
        }
        private static int GetGroupID(int n)
        {
            if( n == 2) { return 0; }
            else if( n == 4 || n == 6 || n == 9 || n == 11) { return 1; }
            else { return 2; }
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
ss = gets.chomp
tt = gets.chomp

cnt = 0
t = 0
while t<tt.length do
  s = ss.index(tt[t])
  if s.nil?
    puts -1
    exit
  end

  t += 1
  if t == tt.length
    cnt += s+1
    break
  end

  while true do
    s = ss.index(tt[t],s+1)
    if s.nil?
      cnt += ss.length
      break
    end

    t += 1
    if t == tt.length
      cnt += s+1
      break
    end
  end
end
puts cnt


Measured memory_bytes: 2172
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M;
	cin >> N >> M;
	VI check(N, -1);
	for (int m = 0; m < M; m++) {
		int s, c;
		cin >> s >> c;
		s--;
		if (check[s] != -1 && check[s] != c) {
			cout << -1 << "\n";
			return 0;
		}
		check[s] = c;
	}
	if (N != 1) {
		if (check[0] == 0) {
			cout << -1 << "\n";
			return 0;
		}
		if (check[0] == -1)check[0] = 1;
	}
	else {
		if (check[0] == -1)check[0] = 0;
	}
	for (int n = 1; n < N; n++) {
		if (check[n] == -1)check[n] = 0;
	}
	for (int n = 0; n < N; n++)cout << check[n];
	cout << "\n";
	return 0;
}


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

long long n, q, t1, t2, t3, t4, mb, t[200005], d[200005];

void apply(int p, int val) {
	t[p] += val;
	if (p < n) d[p] += val;
}

void build(int p) {
	while (p > 1) p >>= 1, t[p] = t[p << 1] + t[p << 1 | 1] + d[p];
}

void push(int p) {
	for (int s = mb; s > 0; --s) {
		int i = p >> s;
		if (d[i] != 0) {
			apply(i << 1, d[i] / 2);
			apply(i << 1 | 1, d[i] / 2);
			d[i] = 0;
		}
	}
}

void inc(int l, int r, int val) {
	l += n, r += n;
	int l0 = l, r0 = r;
	for (; l < r; l >>= 1, r >>= 1, val += val) {
		if (l & 1) apply(l++, val);
		if (r & 1) apply(--r, val);
	}
	build(l0);
	build(r0 - 1);
}

long long query(int l, int r) {
	l += n, r += n;
	push(l);
	push(r - 1);
	long long ans = 0;
	for (; l < r; l >>= 1, r >>= 1) {
		if (l & 1) ans += t[l++];
		if (r & 1) ans += t[--r];
	}
	return ans;
}

int main() {
	cin >> n >> q;
	t1 = 1;
	while (t1 < n) {
		t1 <<= 1, mb++;
	}
	for (int i = 0; i < q; i++) {
		cin >> t1;
		if (t1 == 0) {
			cin >> t2 >> t3 >> t4;
			inc(t2 - 1, t3, t4);
		}
		else {
			cin >> t2 >> t3;
			cout << query(t2 - 1, t3) << endl;
		}
	}
}



Measured memory_bytes: 5436
n = int(input())
s = [('', 0)]
cnt = 0
ans = []
while s:
    t, k = s.pop()
    if len(t) == n:
        ans.append(t)
    else:
        s.append((t + chr(k + 97), k + 1))
        for i in range(k - 1, -1, -1):
            s.append((t + chr(i + 97), k))
ans.sort()
for row in ans:
    print(row)


Measured memory_bytes: 12744
using System;
using System.Linq;

namespace b120C {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine().Select(c => c.ToString()).Select(byte.Parse).ToList();
            var red = 0;
            var blue = 0;

            foreach (var item in input) {
                if (item == 0) red++;
                else blue++;
            }
            
            Console.WriteLine(Math.Min(red,blue) * 2);
        }
    }
}

Measured memory_bytes: 15408
program kadai
    implicit none
integer  ::  n
integer,allocatable  ::  a(:,:)
integer,allocatable  ::  now(:)
integer,allocatable  ::  rest(:)
integer  ::  i,j,move,day,num,for

read(*,*) n
allocate(a(n,n-1))
allocate(now(n))
allocate(rest(n))

do i=1,n
    read(*,*) a(i,:)
end do

now=1
rest=0
move=0
num=0
day=1

do j=1,n*n
    do i=1,n
    if(now(i)<n) then
        for=a(i,now(i))

        if (now(for)>n-1) then
            write(*,*) -1
            stop
        end if

        if (a(for,now(for))==i .and. rest(for)==0 .and. rest(i)==0) then
            !write(*,*) i,"vs",for
            now(i)=now(i)+1
            now(for)=now(for)+1
            if (now(i)>n .or. now(for)>n) then
                write(*,*) -1
                !write(*,*) now,num
                stop
            end if
            move=1
            num=num+1
            rest(i)=1
            rest(for)=1
        end if
        if (num==n*(n-1)/2) then
            write(*,*) day
            stop
        end if
    end if
    end do
    if (move==0) then
        write(*,*) -1
        stop
    end if
    day=day+1
    rest=0
end do

write(*,*) -1


stop
contains

end program kadai


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <set>

using namespace  std;


int x[8];
int y[8];
double dist(int i, int j);

int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
	}
	vector<int> pathPoints;
	for (int i = 0; i < n; i++)
	{
		pathPoints.push_back(i);
	}

	int counter = 0;
	double length = 0;
	do
	{
		for (int i = 0; i < n - 1; i++)
		{
			length += dist(pathPoints[i], pathPoints[i + 1]);
		}
		counter++;
	} while (next_permutation(pathPoints.begin(), pathPoints.end()));
	cout << setprecision(10) << length / counter;
}

double dist(int i, int j)
{
	double xDiff = x[j] - x[i];
	double yDiff = y[j] - y[i];
	return sqrt(xDiff * xDiff + yDiff * yDiff);
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

void init()
{
}

void solve()
{
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int par = (b - a - 1) % 2;
    if(par == 0) cout << "Borys" << endl;
    else cout << "Alice" << endl;
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cout<<fixed<<setprecision(10);
	int n;
	cin>>n;
	ld a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ld s=a[0]+a[1];
	int l=1;
	for(int i=2;i<n;i++){
		s+=a[i]*pow(2,l);
		l++;
	}
	cout<<s/pow(2,n-1);
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int T;
map<ll,ll> ma;

ll rec(ll x,ll a,ll b,ll c,ll d){
    //cout << x << endl;
    if(x==0) return 0;
    if(x==1) return d;
    if(x==2) return min(2ll*d,d+a);
    if(ma[x]!=0) return ma[x];
    int r2=x%2ll,r3=x%3ll,r5=x%5ll;
    ll res=INF;
    if(INF/d>=x)res=min(res,x*d);
    res=min(res,a+d*(ll)r2+rec(x/2ll,a,b,c,d));
    res=min(res,a+d*(ll)(2-r2)+rec(x/2ll+1ll,a,b,c,d));
    res=min(res,b+d*(ll)r3+rec(x/3ll,a,b,c,d));
    res=min(res,b+d*(ll)(3-r3)+rec(x/3ll+1ll,a,b,c,d));
    res=min(res,c+d*(ll)r5+rec(x/5ll,a,b,c,d));
    res=min(res,c+d*(ll)(5-r5)+rec(x/5ll+1ll,a,b,c,d));
    ma[x]=res;
    //cout << x << " " << res << endl;
    return res;
}

void solve(){
    cin >> T;
    rep(i,T){
        ma.clear();
        ll n,a,b,c,d;cin >> n >> a >> b >> c >> d;
        cout << rec(n,a,b,c,d) << endl; 
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int main(){
    string s;
    cin >> s;
    bool flag=false;
    int ans;
    REP(i,26){
        if(s.find(moji[i]) == -1){
            flag=true;
            ans=i;
            break;
        }
    }
    if(flag) cout << moji[ans] << endl;
    else cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename S, typename T> inline void map_init(map<S, T> &m, S k, T v) { if(!m.count(k)) m[k] = v; }

// 二分探索（改）
// judge を満たすような下限を求める
// left:[X] 定義域の下限
// right:[X] 定義域の上限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X left, X right, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (right - left > eps) {
        X mid = (right + left) / 2;
        if (judge(mid) == lower) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return lower ? right : left;
}

int main() {
    int N;
    cin >> N;
    vector<i64> A(N), S(N), T(N);
    for(auto &x : A) cin >> x;
    for(int i = 0; i < N; i++) {
        S[i] = T[i] = A[i];
        if(i) {
            S[i] += S[i - 1];
            T[i] ^= T[i - 1];
        }
    }
    i64 ans = 0;
    for(int l = 0; l < N; l++) {
        int r = BinSearch<int>(l - 1, N, [&](int k) -> bool {
            i64 s, t;
            s = S[k] - (l ? S[l - 1] : 0);
            t = T[k] ^ (l ? T[l - 1] : 0);
            return s == t;
        }, false);
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    int a,b;
    IN a>>b;
    if(a>=b)
    {
        loop(i,0,a)
        {
            OUT b;
        }
    }
    else
    {
        loop(i,0,b)
        {
            OUT a;
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    long long a[3*n];
    priority_queue<long long,vector<long long>,greater<long long>> pq;
    long long A[n+1]={};
    for(int i=0;i<3*n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        pq.push(a[i]);
        A[0]+=a[i];
    }
    for(int i=n;i<2*n;i++){
        pq.push(a[i]);
        A[i-n+1]=A[i-n]+a[i]-pq.top();
        pq.pop();
    }

    priority_queue<long long,vector<long long>> pql;

    long long b[n+1]={};
    for(int i=0;i<n;i++){
        pql.push(a[i+2*n]);
        b[0]+=a[i+2*n];
    }
    //cerr<<b[0]<<endl;
    for(int i=0;i<n;i++){
        pql.push(a[n*2-1-i]);
        b[i+1]=b[i]+a[2*n-1-i]-pql.top();
        pql.pop();
        //cerr<<b[i+1]<<endl;
    }

    long long ans=-1e18;

    for(int i=0;i<=n;i++){
        ans=max(A[i]-b[n-i],ans);
        //cerr<<A[i]<<" "<<b[n-i]<<endl;
    }

    cout<<ans<<endl;

         
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}



int main() {
    while(true) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<int>s(90000,0);
        
        rep(i,n) {
            string start,arrived;
            cin >> start >> arrived;
            int hour = (start[0]-'0')*10+(start[1]-'0');
            hour *= 3600;
            int minute = (start[3]-'0')*10+(start[4]-'0');
            minute *= 60;
            int second = (start[6]-'0')*10+(start[7]-'0');
            s[hour+minute+second]++;
            
            hour = (arrived[0]-'0')*10+(arrived[1]-'0');
            hour *= 3600;
            minute = (arrived[3]-'0')*10+(arrived[4]-'0');
            minute *= 60;
            second = (arrived[6]-'0')*10+(arrived[7]-'0');
            s[hour+minute+second]--;
            
        }
        rep(i,87000) {
            s[i+1] += s[i];
        }
        
        int ans = 0;
        rep(i,87000) {
            ans = max(ans,s[i]);
        }
        cout << ans << endl;
    }
}




Measured memory_bytes: 3500
#include<stdio.h>

int main()
{
	int taro;
	int jiro;
	int sabu;
	int shiro;
	int hanako;
	int sum=0;
	
	scanf("%d",&taro);
	scanf("%d",&jiro);
	scanf("%d",&sabu);
	scanf("%d",&shiro);
	scanf("%d",&hanako);
	
	if(taro<40)sum+=40;
	else sum+=taro;
	if(jiro<40)sum+=40;
	else sum+=jiro;
	if(sabu<40)sum+=40;
	else sum+=sabu;
	if(shiro<40)sum+=40;
	else sum+=shiro;
	if(hanako<40)sum+=40;
	else sum+=hanako;
	
	printf("%d\n",sum/5);	
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a > b) swap(a,b);
  if(a == 1 && b == 2) cout << 3 << endl;
  if(a == 2 && b == 3) cout << 1 << endl;
  if(a == 1 && b == 3) cout << 2 << endl;
  return 0;
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
P = {}
for x in range(W):
    for y in range(H):
        P[A[y][x]] = (x, y)

# 倍数軸累積和
S = [0] * (H*W+1)
for n in range(1, H*W+1):
    if n + D > len(S) - 1:
        continue
    S[n + D] = abs(P[n][0] - P[n+D][0]) + abs(P[n][1] - P[n+D][1])

for n in range(1, H*W+1):
    if n + D > len(S) - 1:
        continue
    S[n + D] += S[n]

# クエリに答えていく
Q = int(input())
for q in range(Q):
    Li, Ri = map(int, input().split())
    print(S[Ri] - S[Li])


Measured memory_bytes: 25436
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin 
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let h : u64 = read();
    let n : u64 = read();
    let a : u64 = (0..n).map(|_| read::<u64>()).sum();

    if h <= a {
        println!("Yes");
    } else {
        println!("No");
    }
    
}


Measured memory_bytes: 4352
import sys

N, M = map(int,input().split())
An = [list(input()) for _ in range(N)]
Bn = [list(input()) for _ in range(M)]
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = True
        for ii in range(M):
            for jj in range(M):
                if An[j+jj][i+ii] != Bn[ii][jj]: flag = False
        if flag is True:
            print("Yes")
            sys.exit()
print("No")


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int x;
  cin >> x;
  
  if(x>=9900) {
  cout << 1 << endl;
  return 0;
  }
  
  rep(i,100){
    rep(j,(x-100*i)/101+1){
      rep(k,(x-100*i-101*j)/102+1){
        rep(l,(x-100*i-101*j-102*k)/103+1){
          rep(m,(x-100*i-101*j-102*k-103*l)/104+1){
            if((x-100*i-101*j-102*k-103*l-104*m)%105==0){
            cout << 1 << endl;
            return 0;
            }
          }
        }
      }
    }
    if(i==99) cout << 0 << endl;
  }
  
}

Measured memory_bytes: 256
//易知n%m==n/(m+1),且m+1为N的约数 
#include<bits/stdc++.h>
using namespace std;
#define go(i,a,b) for(int i=(a);i<=(b);++(i))
#define com(i,a,b) for(int i=(a);i>=(b);--(i))
#define mem(a,b) memset((a),(b),sizeof(a))
#define inf 0x3f3f3f3f
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
typedef unsigned long long ull;
typedef long long ll;

void read(ll &x){
    int f=1;char s=getchar();x=0;
    while(!isdigit(s)){
    	if(s=='-') f=-1;s=getchar();
    }
    while(isdigit(s)){
   		x=(x<<3)+(x<<1)+s-'0';s=getchar();
    }
    x*=f;
}//读入优化

int main()
{
	//fin;
	ll n;read(n);
	ll ans=0;
	for(ll i=1;i*i<=n;++i){
		if(n%i) continue;
		if(i!=1&&n/i==n%(i-1)) ans+=i-1;
		ll j=n/i;
		if(j!=1&&n/j==n%(j-1)) ans+=j-1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()

	points := make([]point, N)

	for i := 0; i < N; i++ {
		x := nextInt()
		y := nextInt()
		p := point{x - y, x + y}
		points[i] = p
	}

	d := 0
	sort.Slice(points, func(i, j int) bool {
		return points[i].x < points[j].x
	})
	d = max(d, abs(points[0].x-points[N-1].x))
	sort.Slice(points, func(i, j int) bool {
		return points[i].y < points[j].y
	})
	d = max(d, abs(points[0].y-points[N-1].y))

	fmt.Println(d)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

type point struct {
	x int
	y int
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args...)
}


Measured memory_bytes: 10516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll x[n];
    rep(0,i,n)cin>>x[i];
    sort(x,x+n);
    ll ans=1e9;
    rep(1,i,x[n-1]+1){
        ll sum=0;
        rep(0,j,n){
            sum+=(x[j]-i)*(x[j]-i);
        }
        ans=min(sum,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 19:31:10 2019
ABC118D
@author: maezawa
"""
import copy

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)

nmatch = [2,5,5,4,5,6,3,7,6]
rmatch = list(reversed(nmatch))
nmdic = dict([(i+1,nmatch[i]) for i in range(9)])
#nums = [[],[],[1],[7],[4],[2,3,5],[6,9],[8]]
nums = [[] for _ in range(10)]
for  i in a:
    nums[nmdic[i]].append(i)
        
#print(nmdic)
#print(nums)

dp = [[-1,[]] for _ in range(n+1)]
dp[0] = [0, []]
#print(dp)

for i in range(1, n+1):
    cnds = []
    for k in a:
        j = nmdic[k]
        if i-j < 0:
            continue
        if dp[i-j][0] == -1:
            continue
        cndo = dp[i-j][0]+1
        cndos = copy.copy(dp[i-j][1])
        cndos.append(max(nums[j]))
        cnds.append([cndo, cndos])
        #print(i, i-j, cnds, cndos)
    if cnds == []:
        continue
    dp[i] = max(cnds, key=lambda x: x[0])

ans = ''.join(map(str, sorted(dp[n][1], reverse=True)))
print(ans)



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int C,N;
    Scd2(C,N);
    int n = N/2;

    static char p[1111][1111];
    Rep(i,N){
        Scs(p[i]);
    }

    int sym = 0;
    int ans = 0;

    vector<vi> d(n,vi(n,0));
    Rep(i,n){
        Rep(j,n){
            d[i][j] |= ( p[i][j] == '1'     ) << 0;
            d[i][j] |= ( p[N-i-1][j] == '1'   ) << 1;
            d[i][j] |= ( p[i][N-j-1] == '1'   ) << 2;
            d[i][j] |= ( p[N-i-1][N-j-1] == '1' ) << 3;
            if( d[i][j] == 0 || d[i][j] == 15 ) sym++;
        }
    }
    if( sym == n*n ) ans++;

    C--;
    int D;
    int r,c;
    int sh;
    Rep(i,C){
        Scd(D);
        Rep(i,D){
            Scd2(r,c);
            r--,c--; sh = 0;
            if( r >= n ) sh+=1, r=N-r-1;
            if( c >= n ) sh+=2, c=N-c-1;
            if( d[r][c] == 0 || d[r][c] == 15 ) sym--;
            d[r][c] ^= 1 << sh;
            if( d[r][c] == 0 || d[r][c] == 15 ) sym++;
        }
        if( sym == n*n ) ans++;
    }

    printf ("%d\n", ans );

    return 0;
}





Measured memory_bytes: 4980
N = int(input())
A = sorted(list(map(int, input().split())))

a = [0]*(N+1)

for i in range(N):
    a[i+1] = a[i]+A[i]

A.reverse()
a.reverse()
# print(A)
# print(a)

ans = 1
for i in range(N):
    if A[i]/2 > a[i+1]:
        break
    ans += 1
print(ans)

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  
  for( int i = 0; i < S.size(); i++ ){
    if( i == A ){
      if( S.at(i) != '-' ){
        cout << "No" << endl;
        return 0;
      }
    }else if( S.at(i) == '-' ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_1_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str  = Console.ReadLine().Split(' ');

            int W = int.Parse(str[0]);
            int H = int.Parse(str[1]);

            int x = int.Parse(str[2]);
            int y = int.Parse(str[3]);
            int r = int.Parse(str[4]);

            if (x < 0 || y < 0 || x + r > W || y + r > H)
            {
                Console.WriteLine("No");
            }

            else
            {
                Console.WriteLine("Yes");
            }

        }
    }
}



Measured memory_bytes: 17912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k, d[10], a, t;
int main(){
	scanf("%d%d", &n, &k);
	rep(i,k){
		scanf("%d", &a);
		d[a] = 1;
	}
	for(;1;n++){
		for(t = n; t; t /= 10) if(d[t%10]) break;
		if(!t) break;
	}
	printf("%d\n", n);
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<pii,int> P;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
/*
10^3*50*100*
*/
int vis[55][11][(1<<7)+10];
void mainmain(){
	int n,m,L,K;
	while(cin>>n>>m>>L>>K,n){
		vint ball(n,-1);
		VV(pii) vv(n);
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			vv[a-1].PB(mkp(b-1,c));
			vv[b-1].PB(mkp(a-1,c));
		}
		int s,g;
		cin>>s>>g;
		s--;
		g--;
		int cnt=0;
		rep(i,L){
			int t;
			cin>>t;
			ball[t-1]=cnt++;
		}
		rep(i,55){
			rep(j,11){
				rep(k,(1<<7)+10){
					vis[i][j][k]=INF;
				}
			}
		}
		priority_queue<P> pq;
		pq.push(mkp(mkp(0,0),s));
		while(!pq.empty()){
			P top=pq.top();
			pq.pop();
			top.F.S*=-1;
			// cout<<-top.F.F<<" "<<top.F.S<<" "<<top.S+1<<endl;
			if(ball[top.S]!=-1) top.F.S|=1<<ball[top.S];
			bool f=false;
			int t=-top.F.F;
			rep(i,K){
				if(t<vis[top.S][i][top.F.S]){
					// cout<<"t "<<t<<endl;
					swap(vis[top.S][i][top.F.S],t);
					f=true;
				}
			}
			if(!f) continue;
			rep(i,vv[top.S].size()){
				P tmp=top;
				if(ball[vv[top.S][i].F]!=-1) tmp.F.S|=1<<ball[vv[top.S][i].F];
				if(vis[vv[top.S][i].F][K-1][tmp.F.S]<vv[top.S][i].S-tmp.F.F) continue;
				tmp.F.S*=-1;
				tmp.F.F-=vv[top.S][i].S;
				tmp.S=vv[top.S][i].F;
				pq.push(tmp);
			}
		}
		if(vis[g][K-1][(1<<L)-1]!=INF) cout<<vis[g][K-1][(1<<L)-1]<<endl;
		else cout<<"NA"<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 40084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int seq = 0;
        boolean yes = false;
        for(int i=0; i<n; i++) {
            int d1 = in.nextInt();
            int d2 = in.nextInt();
            if(d1==d2) {
                seq++;
                if(seq>=3) {
                    yes = true;
                }
            }
            else {
                seq = 0;
            }
        }
        System.out.println(yes ? "Yes" : "No");
    }
}


Measured memory_bytes: 36132
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
#define PI 3.14159265359
typedef long long ll;
using namespace std;
int main()
{
	string s,ans;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'&&ans.size()==0){
			continue;
		}
		else if(s[i]=='B'){
			ans.pop_back();
		}
		else if(s[i]=='1'){
			ans.push_back('1');
		}
		else if(s[i]=='0'){
			ans.push_back('0');
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define F first
#define S second
#define LL long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 1000000000000000000

using namespace std;

const int N = 2e5 + 10;


int main()
{
	LL ans = 0;
	string s, r;
	cin >> s >> r;

	for (int i = 0;i < s.size();i++)
		ans += s[i] != r[i];

	cout << ans << endl;
}


Measured memory_bytes: 3464