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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()


const int MAX_AB = 10000;
int n, m;
vector<pll> ab;
ll ans = 0;
ll ileft = 0;
int main() {
    cin >> n >> m;

    ab.resize(n);
    REP(i,n) cin >> ab[i].first >> ab[i].second;


    sort(ab.begin(), ab.end());

    ileft = m;
    REP(i,n)
    {
        if (ileft <= 0) break;

        ans += ab[i].first * min(ab[i].second, ileft);

        ileft -= ab[i].second;
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> pii;



int main() {

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

	cout << (n+k-3)/(k-1) << endl;

}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 2e5 + 5;
const long long MOD = 1e9 + 7;


long long N, x, res;
priority_queue<long long> q;
priority_queue<pair<long long, int>> p;


int main() { speedhack()

	cin >> N;
	
	forn (i, N) {
		cin >> x;
		q.push(x);
	}

	res = q.top();
	q.pop();

	p.push({q.top(), 0});
	q.pop();

	while (!p.empty()) {
		if (!q.empty()) {
			pair<long long, int> cur = p.top();
			p.pop();
			res += cur.first;
			cur.second++;

			long long head = q.top();
			q.pop();
			p.push({head, 0});
		
			if (cur.second < 2)
				p.push(cur);
		} else p.pop();
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 7952
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;

    rep(i,a){
        if(s[i]=='-'){
            cout << "No";
            return 0;
        }
    }
    if(s[a]!='-'){
        cout << "No";
        return 0;
    }
    // cout << "Hello";
    for(int j=a+1;j<a+b+1;j++){
        if(s[j]=='-'){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

/* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0289 */

static int bitcount(int n)
{
    n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    n = (n & 0x0F0F0F0F) + ((n >> 4) & 0x0F0F0F0F);
    n = n + (n >> 8);
    n = (n + (n >> 16)) & 0x0000003F;
    return n;
}

static int msb(int n)
{
    n  = n | (n >> 1);
    n |= (n >> 2);
    n |= (n >> 4);
    n |= (n >> 8);
    n |= (n >> 16);
    n  = n ^ (n >> 1);
    return n;
}

static int cost(int s, int d)
{
    int t = 0;
    
    if (s < d){
        int m, tp;
        
        m = msb(d - s);
        tp = (m - s) & (m - 1);
        t += bitcount(tp);
        t += bitcount(d - s - tp);
    }
    return t;
}

int main(void) {
    int n;
    
    scanf("%d", &n);
    
    while (n--) {
        int s, d;

        scanf("%d%d", &s, &d);
        printf("%d\n", cost(s, d));
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void){
  int a,b,c, max = 0;
  scanf("%d%d%d",&a,&b,&c);
  
  if (a > max) max = a;
  if (b > max) max = b;
  if (c > max) max = c;
  printf("%d\n",a+b+c-max);
  return 0;
}

Measured memory_bytes: 128
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000009;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 5;
int n ;
bitset < 100500 > dp;
vector < int > v;
main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x;
	cin >> x;
	dp[0] = 1;
	for(int i = 100 ; i <= x ; i <<= 1)
		dp |= (dp << i);
	for(int i = 101 ; i <= x ; i <<= 1)
		dp |= (dp << i);
	for(int i = 102 ; i <= x ; i <<= 1)
		dp |= (dp << i);
	for(int i = 103 ; i <= x ; i <<= 1)
		dp |= (dp << i);
	for(int i = 104 ; i <= x ; i <<= 1)
		dp |= (dp << i);
	for(int i = 105 ; i <= x ; i <<= 1)
		dp |= (dp << i);
    ret(dp[x]);
}

Measured memory_bytes: 256
while True:
    N, R = map(int, input().split())
    if N == 0 and R == 0:
        break
    L = [i for i in range(N, 0, -1)]
    for i in range(R):
        p, c = map(int, input().split())
        p -= 1
        c = p + c
        tmp = L[p:c]
        tmp.extend(L[:p])
        tmp.extend(L[c:])
        L = tmp[:]
    print(L[0])


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

using namespace std;

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl

const int maxn = (int)3e5+5;
typedef long long ll;

int main()
{
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //cout << "Fi Amanillah" << endl;

    int n;
    cin >> n;

    vector < int > v(n);
    map < int , int > m;
    ll tot = 0LL;
    for(int i=0 ; i<n; i++){
         cin >> v[i];
         m[v[i]]++;
         tot +=v[i];
    }

    int q;
    cin >> q;

    while(q--){
      int B, C;
      cin >> B >> C;
      int sub = C-B, koyta=0;
      koyta = m[B];
      tot+=(sub * koyta * 1LL);

      cout << tot << endl;
      m[C] = m[C]+ m[B];
      m[B] = 0;
    }

    return 0;
}


Measured memory_bytes: 7900
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000005
#define INF 1000000005
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

signed main()
{
std::string sd;
std::string t;
std::cin >> sd >> t;
std::string s = sd;
int sdl = sd.length();
int tl = t.length();
int flag = INF;

for(int i = 0; i + tl <= sdl; i++){
    int tf = 1;
    for(int j = 0; j < tl; j++){
        if(sd[i + j] != t[j] && sd[i + j] != '?'){
            tf = 0;
        }
    }
    if(tf == 1){
        flag = i;
    }
}
if(flag == INF){
    std::cout << "UNRESTORABLE" << std::endl;
} else {
    for(int i = 0; i < flag; i++){
        if(s[i] == '?'){
            s[i] = 'a';
        }
    }
    for(int i = flag; i < flag + tl; i++){
        s[i] = t[i - flag];
    }
    for(int i = flag + tl; i < sdl; i++){
        if(s[i] == '?'){
            s[i] = 'a';
        }
    }

std::cout << s << std::endl;
}
return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i=0; i<n; i++)
    cin >> x.at(i);
  
  sort(x.begin(), x.end());
  reverse(x.begin(), x.end());
  
  int a = 0, b = 0;
  
  for (int i=0; i<n; i+=2)
    a += x.at(i);
  for (int i=1; i<n; i+=2)
    b += x.at(i);
  
  cout << a - b << endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// =========ここまでテンプレ============

int main()
{
    ll x;
    cin >> x;
    ll a = 100;
    ll count = 0;
    while (true)
    {
        ++count;
        a += a / 100;
        if (a >= x)
        {
            break;
        };
    }
    cout << count;
}

Measured memory_bytes: 3188
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
	"sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

type Unique struct {
	arr []int
	existsMap map[int]struct{}
}


type Item struct {
	value int
	weight int
	model string
	date int
	name string
}

func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)
	lines, _ := ReadLongLines(n)
	list := make([]Item, n)
	for i := range lines {
		args := strings.Split(lines[i], " ")
		value, _ := strconv.Atoi(args[0])
		weight, _ := strconv.Atoi(args[1])
		model := args[2]
		date, _ := strconv.Atoi(args[3])
		name := args[4]
		list[i] = Item{value, weight, model, date, name}
	}

	// sort
	sort.Slice(list, func(lhs, rhs int) bool {
		l := list[lhs]
		r := list[rhs]
		if l.value != r.value {
			return l.value < r.value
		}
		if l.weight != r.weight {
			return l.weight < r.weight
		}
		if l.model != r.model {
			return l.model < r.model
		}
		if l.date != r.date {
			return l.date < r.date
		}
		return l.name < r.name
	})


	// print
	for _, v := range list {
		con.Printf("%d %d %s %d %s\n", v.value, v.weight, v.model, v.date, v.name)
	}
}


Measured memory_bytes: 23712
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define S second
#define F first
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef pair<string,PP> SPP;
bool cmp(const SPP &p,const SPP &q){
  if(p.S.F.F != q.S.F.F)return p.S.F.F > q.S.F.F;
  else if(p.S.F.S != q.S.F.S)return p.S.F.S < q.S.F.S;
  else return p.S.S.S < q.S.S.S;
}


int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0)break;
    vector<SPP> info; string s;
    for(int i=0;i<n;i++){
      cin >> s;
      info.push_back(SPP(s,PP(P(0,0),P(0,i))));
      for(int j=0;j<n-1;j++)
	{ int a;
	  cin >> a;
	  if(a == 0)info[i].S.F.F++;
	  else if(a == 1)info[i].S.F.S++;
	  else info[i].S.S.F++;
	}
    }
     
      sort(info.begin(),info.end(),cmp);
     
      for(int i=0;i<info.size();i++){
		cout << info[i].F << endl;
      }
    

  }
  return 0;
}

Measured memory_bytes: 1208
def game(t, s)
  cnt = 0
  s.each_cons(2) do |l, r|
    l, r = r, l if t == 1
    if r % 3 == 1 && l % 3 != 1 || r % 3 == 2 && l % 3 == 0
      cnt += 1
    else t = 1 - t
    end
  end
  cnt
end

while s = gets.chomp
  break if s == '#'
  s = s.split('').map(&:to_i)
  p [game(0, s), game(1, s)].min
end

Measured memory_bytes: 16472
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    ll N;cin>>N;
    vector<ll> v;
    for(int i=0;i<N;i++){
      ll vv; cin>>vv; v.push_back(vv);
    }
    sort(v.begin(), v.end(), greater<ll>());
    ll w=0; ll h=0; ll past=-1; ll cnt=1; ll ans=0;
    for(int i=0;i<N;i++){
      ll a=v[i];
      if(a==past) cnt++;
      else cnt=1;

      if(cnt>=4) {
        ans=a*a; break;
      }
      if(cnt>=2 && w==0 && h==0){
        w=a;
      }else if(cnt>=2 && h==0 && w!=a){
        ans = w*a; break;
      }
      past = a;
      // cout<<i<<cnt<<w<<h<<endl;
    }

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


Measured memory_bytes: 1400
H, W = map( int, input().split())
N = int( input())
A = list( map( int, input().split()))
reverse = 0
ANS = [ [] for _ in range(H)]
gyou = 0
cnt = 0
for i in range(N):
    for j in range(A[i]):
        cnt += 1
        if reverse == 0:
            ANS[gyou].append(i+1)
        else:
            ANS[gyou].insert(0, i+1)
        if cnt == W:
            cnt = 0
            gyou += 1
            reverse = (reverse+1)%2
for i in range(H):
    for j in range(W-1):
        print( str(ANS[i][j]), end = ' ')
    print(ANS[i][W-1])

Measured memory_bytes: 3920
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int A[500010],H;
void MaxHeapify(int i)
{
	int t;
	int l=2*i;
	int largest;
	int r=2*i+1;
	if(l<=H && A[l]>A[i])
		largest=l;
	else
		largest=i;
	if(r<=H && A[r]>A[largest])
		largest=r;

	if(largest!=i)
	{
		t=A[i];
		A[i]=A[largest];
		A[largest]=t;

		MaxHeapify(largest);
	}
	return;
}
int main()
{
	int i;
	scanf("%d",&H);
	for(i=1;i<=H;i++)
		scanf("%d",&A[i]);

	for(i=H/2;i>=1;i--)
		MaxHeapify(i);

	for(i=1;i<=H;i++)
		printf(" %d",A[i]);
	printf("\n");

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
        q[p[i]] = i;
    }

    vector<int> dp(n,0);
    int ans = 1;
    int inc = 1;
    for(int i = 1; i < n; i++){
        if(q[i]-q[i-1]>0){inc++; ans = max(ans,inc);}
        else{inc = 1;}
    }
    cout << n - ans << endl;
    return 0;
}


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

int main()
{
    ll a, b, c; cin >> a >> b >> c;
    set<ll> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    int m = max({a,b,c});
    if(2*m==a+b+c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i)
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
eni(!=) { cerr << boolalpha << i; ris; }
eni(==) { ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << &", " [ 2 * (it == d.b)] << *it;
  ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...) "" << #__VA_ARGS__ " = " << (__VA_ARGS__) << ""
#define arr array

const int INF = 1e9 + 5;
const int N = 1e5 + 5;


//dp[curr_idx][weight_till_curr_idx]

int main() {
	int n,W;
	cin >> n >> W;
	vector<int> w(n),v(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	
	vector<vector<long long>> dp(100,vector<long long>(W + 1,0));

	for(int index = 0; index < n; index++) {
		for(int weight = 0; weight <= W; weight++) {
			if(index == 0) {
				if(weight == 0) {
					dp[index][weight] = 0;
				}else {
					dp[index][w[index]] = v[index];
				}
			}else {
				//discard the current item
				dp[index][weight] = dp[index - 1][weight];
				//pick the current item
				if(w[index] <= weight) {
					dp[index][weight] = max(dp[index][weight],v[index] + dp[index-1][weight-w[index]]);
				}
			}
		}
	}
	
	long long ans = -INF;
	for(int i = 0; i <= W; i++) {
		ans = max(ans,dp[n-1][i]);
	}
	
	cout << ans << "\n";

    return 0;
}




Measured memory_bytes: 82320
// AOJ Volume 0 Problem 0060

#include <stdio.h>
#include <string.h>

int main(void)
{
    int c1, c2, c3;
	int card[11];
	int i;
	int n;
	
	while (scanf("%d%d%d", &c1, &c2, &c3) != EOF){
		memset(card, 0, sizeof(card));

		card[c1] = card[c2] = card[c3] = 1;

		n = 0;
		for (i = 1; i <= 10; i++){
			if (card[i] == 0){
				if (c1 + c2 + i <= 20){
					n++;
				}
			}
		}

		if (n >= 4){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n;
  cin>>n;
  ll ans = 0;

  for(ll x = 1;x <= (ll)sqrt(n);x++){
    if(n%x==0){

      ll y = n/x-1;
      if(x<y){
        ans += y;
       //cout<<y<<endl;
      }
    }
  }
  cout<<ans<<endl;


 

  return 0;
}

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

typedef long long ll;

int R, G, B, N;

int main() {
	scanf("%d%d%d%d", &R, &G, &B, &N);

	ll tot = 0;
	for (int i = 0; i <= 3005; ++i) for (int j = 0; j <= 3005; ++j) {
		if (N - R*i - G*j >= 0 && (N - R*i - G*j) % B == 0) tot++;
	}

	printf("%lld\n", tot);
}


Measured memory_bytes: 256
mod = 10**9+7

def count(L, R):
    res = 0
    for j in range(70):
        res = (res + subcount(j, L, R)) % mod
    return res

def subcount(j, L, R):
    if j >= L.bit_length():
        return 0
    dp = [[0]*4 for _ in range(70)]
    
    cnt = 0
    if R.bit_length() != j+1:
        cnt += 1
    if L.bit_length() != j+1:
        cnt += 2
    dp[j][cnt] = 1
    
    for i in range(j, 0, -1):
        yf = R & (1<<(i-1))
        xf = L & (1<<(i-1))
        
        d0 = dp[i][0]
        if yf and xf:
            dp[i-1][0] += d0
            dp[i-1][2] += d0
            dp[i-1][3] += d0
        elif yf:
            dp[i-1][0] += d0
            dp[i-1][1] += d0
        elif xf:
            dp[i-1][2] += d0
        else:
            dp[i-1][0] += d0
        
        d1 = dp[i][1]
        if xf:
            dp[i-1][1] += d1
            dp[i-1][3] += 2*d1
        else:
            dp[i-1][1] += 2*d1
        
        d2 = dp[i][2]
        if yf:
            dp[i-1][2] += 2*d2
            dp[i-1][3] += d2
        else:
            dp[i-1][2] += d2
        
        d3 = dp[i][3]
        dp[i-1][3] += 3*d3
        
        dp[i-1][0] %= mod
        dp[i-1][1] %= mod        
        dp[i-1][2] %= mod
        dp[i-1][3] %= mod
        
    return sum(dp[0][i] for i in range(4))

L, R = map(int, input().split())
print((count(R, R) - count(L-1, R))%mod)


Measured memory_bytes: 41200
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<set>
#define pa pair<int,int>
#define mp make_pair
#define ll long long
#define inf 20021225
#define fs first
#define se second
using namespace std;

multiset<pa> a,b;
int ra[100010],rb[100010];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&ra[i],&rb[i]),
		a.insert(mp(ra[i]+rb[i],ra[i])),b.insert(mp(ra[i]+rb[i],rb[i]));
	ll aans=0,bans=0;
	for(int i=1;i<=n;i++)
	{
		pa ta=*a.rbegin(),tb=*b.rbegin();
		if(i&1)
		{
			a.erase(a.find(ta));
			b.erase(b.find(mp(ta.fs,ta.fs-ta.se)));
			aans+=ta.se;
		}
		else
		{
			a.erase(a.find(mp(tb.fs,tb.fs-tb.se)));
			b.erase(b.find(tb));
			bans+=tb.se;
		}
	}
	printf("%lld\n",aans-bans);
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
int main(){
    int n;
    std::cin >> n;
    std::vector<std::pair<std::pair<std::string,int>,int>> v;
    for(int i=1;i<=n;i++){
        std::string s;
        int p;
        std::cin >> s >> p;
        v.push_back({{s,100-p},i});
    }
    std::sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        std::cout << v[i].second << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll h,w,a,b;cin>>h>>w>>a>>b;
    char arr[h][w];
    for(ll i=0;i<b;i++)for(ll j=0;j<a;j++)arr[i][j]='0';
    for(ll i=b;i<h;i++)for(ll j=0;j<a;j++)arr[i][j]='1';
    for(ll i=0;i<b;i++)for(ll j=a;j<w;j++)arr[i][j]='1';
    for(ll i=b;i<h;i++)for(ll j=a;j<w;j++)arr[i][j]='0';
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++)cout<<arr[i][j];
        cout<<"\n";
    }
}

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

int main() {
  int N,M,ans=0;
  cin>>N>>M;
  vector<vector<int>> a(M,vector<int>(0));
  vector<int> p(M);
  for(int i=0;i<M;i++){
    int K;
    cin>>K;
    for(int j=0;j<K;j++){
      int s;
      cin>>s;
      a.at(i).push_back(s);
    }
  }
  for(int i=0;i<M;i++){
    cin>>p.at(i);
  }
  for(int i=0;i<(1<<N);i++){
    bitset<10> s(i);
    for(int j=0;j<M;j++){
      int c=0;
      for(int k=0;k<a.at(j).size();k++){
        if(s.test(a.at(j).at(k)-1)){
          c++;
        }
      }
      if(p.at(j)!=c%2){
        break;
      }
      else if(j==M-1){
        ans++;
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define sc scanf
using namespace std;
char c;
int main(){
    c=getchar();
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel\n";
    else cout<<"consonant\n";
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int a;

int main() {


	scanf("%d", &a);

	if (a < 1200) {
		printf("ABC\n");
	}
	else if (a < 2800) {
		printf("ARC\n");
	}
	else {
		printf("AGC\n");
	}



	return 0;

}

Measured memory_bytes: 888
#include<cstdio>
using namespace std;
int a[100050];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=2;i<=n;i++)
	if (a[i]>a[i-1]) a[i]--;else
	if (a[i]<a[i-1]) return printf("No\n"),0;
	printf("Yes\n");
	return 0;
}

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

using namespace std;

string str;

int dfs()
{
  stack<priority_queue<int, vector<int>, greater<int> > > pqs;
  int num = 0;
  int x;
  for(int i = 0; i < str.size(); i++) {
    if(str[i] == '[') {
      pqs.push(priority_queue<int, vector<int>, greater<int> >());
      num = 0;
      x = max<int>(x, pqs.size());
    }
    else if (str[i] == ']') {
      if (num) {
        pqs.top().push(num);
        num = 0;
      }
      int r = 0, size = pqs.top().size();
      for (int j = 0; j * 2 < size; j++) {
        r += pqs.top().top();
        if (x == pqs.size()) r -= pqs.top().top() / 2;
        pqs.top().pop();
      }
      pqs.pop();
      if (pqs.empty()) return r;
      pqs.top().push(r);
    }
    else {
      num *= 10;
      num += str[i] - '0';
    }
  }
}

static void solve()
{
  int n;
  cin >> n;
  while(n--) {
    cin >> str;
    cout << dfs() << "\n";
  }
}

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

Measured memory_bytes: 3236
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

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

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (par[x] > par[y])
      swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { return -par[root(x)]; }
};


int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}


signed main() {
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<map<int, ll>> a(n);
  REP(i, n) a[i][i] = 0;
  UnionFind tree(n);
  REP(i, m) {
    ll l, r, d;
    cin >> l >> r >> d;
    l--;r--;
    if(tree.same(l, r)) {
      int root = tree.root(l);
      if(a[root][r] - a[root][l] != d) {
        // cout << l << ":" << r << endl;
        cout << "No" << endl;
        // cout << "a[root][r]:" << a[root][r] << endl;
        // cout << "a[root][l]:" << a[root][l] << endl;
        // REP(i, n) cout << a[root][i] << " "; cout << endl;
        return 0;
      }
      continue;
    }
    if(tree.size(l) < tree.size(r)) {
      swap(l, r);
      d = -d;
    }
    int root_l = tree.root(l);
    ll base = a[tree.root(l)][l] - a[tree.root(r)][r] + d;
    for(const auto value: a[tree.root(r)]) {
      a[tree.root(l)][value.first] = value.second + base;
    }
    tree.unite(l, r);
    if(root_l != tree.root(l)) {
      a[l] = a[root_l];
    }
  }
  cout << "Yes" << endl;
  // REP(i, n) cout << a[0][i] << " "; cout << endl;
  return 0;
}


Measured memory_bytes: 48256
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
// #define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

#define N 10000005

void test_case(){
    int x;
    cin>>x;
    for(int i=-150;i<=150;++i){
        for(int j=-150;j<=150;++j){
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<" "<<j;
                goto label;
            }
        }
    }
    label:{
        
    }
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
		return 0;
    }
}

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

int main(int argc, char const *argv[]){
    string S,T;
    cin>>S>>T;
    int cnt = 0;
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i]){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3896
#include<stdio.h>
#include<stdlib.h>

int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H,W;
    cin>>H>>W;
    char px[100][100];
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>px[i][j];
            
        }   
        
    }
    
    for(int i=-1;i<=H;i++){
        for(int j=-1;j<=W;j++){
            if(i<0||i>=H||j<0||j>=W){
                cout<<"#";
            }else{
                cout<<px[i][j];
            }
            
            
        }   
        cout<<endl;
        
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen(".testcase", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string S;
  cin >> S;
  vector<int> left(S.size() + 1, 0);
  for (unsigned int i = 0; i < S.size(); i++) {
    if (S[i] == '<')
      left[i+1] = left[i] + 1;
  }
  vector<int> right(S.size() + 1, 0);
  for (int i = S.size() - 1; i >= 0; i--) {
    if (S[i] == '>')
      right[i] = right[i+1] + 1;
  }
  ll ans = 0;
  for (unsigned i = 0; i < left.size(); i++) {
    ans += max(left[i], right[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

vector<int>solve(int N,int L,int R){
	if(N==1)return {L,R};
	int dif=(L^R)&-(L^R);
	vector<int>l,r;
	int ldif=(L&dif-1)+(L/dif/2*dif);
	int rdif=(R&dif-1)+(R/dif/2*dif);
	l=solve(N-1,ldif,ldif^1);
	r=solve(N-1,ldif^1,rdif);
	for(int &i:l){
		i=(i&dif-1)+(i/dif*dif<<1)+dif*(bool)(L&dif);
	}
	for(int &i:r){
		i=(i&dif-1)+(i/dif*dif<<1)+dif*(bool)(R&dif);
	}
	l.insert(l.end(),all(r));
	return l;
}
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,A,B;cin>>N>>A>>B;
	if(__builtin_popcount(A^B)%2==0)puts("NO");
	else {
		cout<<"YES"<<endl;
		for(int i:solve(N,A,B))cout<<i<<" ";
		cout<<endl;
	}
}


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

int N,M;
int K[11],S[11][11];
int P[11];
int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> K[i];
        for(int j=0;j<K[i];j++){
            cin >> S[i][j];
            S[i][j]--;
        }
    }
    for(int i=0;i<M;i++) cin >> P[i];
    int ans = 0;
    for(int T=0;T<(1<<N);T++){
        bool ok = true;
        for(int i=0;i<M;i++){
            int cnt = 0;
            for(int k=0;k<K[i];k++){
                if(T&(1<<S[i][k])) cnt++;
            }
            if(cnt%2!=P[i]) ok = false;
        }
        ans += ok;
    }
    cout << ans << endl;
}

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

#define SQ(X) ((X)*(X))

int main(){
    double x1, x2, y1, y2;
    double dx, dy;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    dx = x1-x2;
    dy = y1-y2;
    printf("%f\n", sqrt(SQ(dx)+SQ(dy)));

    return 0;
}

Measured memory_bytes: 1080
N,A,B = map(int, input().split())
total = 0
for i in range(N + 1):
    count = 0
    n = str(i)
    length = len(n)
    
    for j in range(length):
        count += int(n[j])

    if count >= A and count <= B:
        total += i

print(total)

Measured memory_bytes: 3060
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    double n;
    cin>>n;
    double ans=2*acos(-1)*n;
    printf("%.12lf\n",ans);
}






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

int main() {
  int N,K;
  cin >> N >> K;
  double ans = 0;
  for (int i = 1; i <= N; i++) {
    int score = i;
    double kakuritu = 1.0/N;
    while (score < K) {
      score *= 2;
      kakuritu /= 2;
    }
    ans += kakuritu;
  }
  cout << setprecision(15) << ans << endl;
 // printf("%.12f\n",ans);    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-6)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
typedef double FP;
typedef complex<FP> pt;
typedef pt P;
typedef pair<pt,pt> line;
FP dot(P a,P b){return (conj(a)*b).real();}
FP crs(P a,P b){return (conj(a)*b).imag();}
P crspt(P a,P b,P c,P d){b-=a,d-=c;return a+b*crs(d,c-a)/crs(d,b);}
bool onl(P a1,P a2,P b){return abs(b-a1)+abs(b-a2)<abs(a1-a2)+EPS;}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
/*
enum{TOP,BTM,LFT,RGT,FRT,BCK};
int dxdy2ce[]={RGT,FRT,LFT,BCK};
template<class T> T shift(T a,int b,int c,int d,int e){
  __typeof(a[0])t=a[b];
  a[b]=a[c];a[c]=a[d];a[d]=a[e];a[e]=t;return a;}
template<class T> T rgtin(T a){return shift(a,TOP,LFT,BTM,RGT);}
template<class T> T lftin(T a){return shift(a,TOP,RGT,BTM,LFT);}
template<class T> T frtin(T a){return shift(a,TOP,BCK,BTM,FRT);}
template<class T> T bckin(T a){return shift(a,TOP,FRT,BTM,BCK);}
*/

int n;
int hx,hy,mx,my;
int cx[20],cy[20];
map<PI,double> cost;

bool dfs(int cv,int vis,double cc){
  if(cost.count(mp(cv,vis)) &&
     cost[mp(cv,vis)]<=cc+EPS) return false;
  if(vis==(1<<n)-1) return true;
  //cout << cv << ' ' << vis << ' ' << cc << endl;
  cost[mp(cv,vis)] = cc;
  rep(i,n){
    if((vis>>i)&1) continue;
    if(cc+abs(pt(cx[i],cy[i])-pt(cx[cv],cy[cv]))+EPS>
       abs(pt(cx[i],cy[i])-pt(mx,my))) return false;
  }
  
  rep(i,n){
    if((vis>>i)&1) continue;
    if(dfs(i,vis|1<<i,cc+abs(P(cx[cv],cy[cv])-P(cx[i],cy[i]))))
      return true;
  }
    
  return false;
}

void solve(){
  cin >> hx >> hy >> mx >> my;
  rep(i,n) cin >> cx[i] >> cy[i];
  //rep(i,n)rep(j,(1<<n)) cost[i][j] = 1<<20;
  cost.clear();
  rep(i,n){
    if(abs(P(mx,my)-P(cx[i],cy[i]))>
       abs(P(cx[i],cy[i])-P(hx,hy))+EPS &&
       dfs(i,1<<i,abs(P(cx[i],cy[i])-P(hx,hy)))){
      cout << "YES" << endl;
      return;
    }
  }
  cout << "NO" << endl;
}

int main(int argc, char *argv[]){
  while(cin >> n && n) solve();
}

Measured memory_bytes: 53284
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 1005
using namespace std;
typedef long long ll;

int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if((b-a)%2==1) printf("Borys\n");
    else printf("Alice\n");
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf=1000001000;
ll INF=100000000000000000;
ll MOD=1000000007;
//g++ code.cpp   ./a.out 
 
int main() {
    ll h;
    cin >> h;
    ll ans=0,cnt=0;
    while(h>0){
       h/=2;
       ans+=pow(2,cnt);
       cnt++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[100010];
int main()
{
	int n, k;
	cin >> n;
	k = n / 2-1;
		for (int i = 0; i < n; i++)
			cin >> a[i];
	sort(a, a + n);
	cout << a[k + 1] - a[k];


}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n;
    cin >> n;
    int res[n+1];
    memset(res, 0, sizeof res);
    for(int i=1;i<=sqrt(n);i++)
        for(int j=1;j<=sqrt(n);j++)
            for(int k=1;k<=sqrt(n);k++) {
                ll val = i*i+j*j+k*k+i*j+i*k+j*k;
                if(val<=n) res[val]++;
            }
    for(int i=1;i<=n;i++) cout << res[i] << "\n";
}


Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
 int a;
 int b;
 int ans;
 char op;
 for(;;)
 {
  scanf("%d %c %d", &a, &op, &b);
  if(op == '+')
  ans = a + b;
  else if(op == '-')
  ans = a - b;
  else if(op == '*')
  ans = a * b;
  else if(op == '/')
  ans = a / b;
  else if(op == '?')break;
  printf("%d\n", ans);
 }
 return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<algorithm>
using namespace std;
int n,k,ans,x,a[200001];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		cin>>x;
		++a[x];
	}
	sort(a+1,a+n+1);
	for(int i=n;i>n-k;--i)
		ans+=a[i];
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = input()

ans = float('inf')
sum_E = [0]
sum_W = [0]
cnt_e = 0
cnt_w = 0

for i in range(N):
	if S[i] == 'E':
		cnt_e += 1
	else:
		cnt_w += 1
	sum_E.append(cnt_e)
	sum_W.append(cnt_w)

for i in range(N):
	ans = min(ans, sum_W[i] + sum_E[-1] - sum_E[i+1])

print(ans)

Measured memory_bytes: 17644
#include <iostream>
#include <vector>
#include <sstream>
#include <cstring>
using namespace std;

struct P {
	int id;
	char name;
};

P newP(int id, char name){
	P *v = new P;
	v->id = id; v->name = name;
	return *v;
}

void swap(P& a, P& b){
	P h = newP(a.id, a.name);
	a = b;
	b = h;
}

bool check(vector<P>& A, vector<P> a){
	int *ar1, *ar2;
	int n = A.size();
	ar1 = new int[n]; ar2 = new int[n];
	memset(ar1, 0, n*sizeof(int));
	memset(ar2, 0, n*sizeof(int));
	for(int i=0;i<n;i++){
		if(ar1[i] == 0){
			int rank = 1;
			ar1[i] = rank;
			for(int j=i+1;j<n;j++){
				if(A[i].id == A[j].id){
					rank++;
					ar1[j] = rank;
				}
			}
		}
		if(ar2[i] == 0){
			int rank = 1;
			ar2[i] = rank;
			for(int j=i+1;j<n;j++){
				if(a[i].id == a[j].id){
					rank++;
					ar2[j] = rank;
				}
			}
		}
	}
	bool ans = true;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(A[i].name == a[j].name && A[i].id == a[j].id){
				if(ar1[i] != ar2[j]) ans = false;
			}
		}
	}
	return ans;
}

void BubbleSort(vector<P>& A){
	for(int i = 0;i<A.size();i++){
		for(int j = A.size()-1; j>i; j--){
			if(A[j].id < A[j-1].id){
				swap(A[j], A[j-1]);
			}
		}
	}
}
int SelectionSort(vector<P>& A){
	for(int i = 0; i< A.size(); i++){
		int mini = i;
		for(int j = i; j < A.size(); j++){
			if(A[j].id < A[mini].id){
				mini = j;
			}
		}
		if(i != mini){
			swap(A[i], A[mini]);
		}
	}
}

int main(){
	int n;
	string h;
	vector<P> v,a,b;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> h;
		v.push_back(newP( h[1]-'0', h[0]));
		a.push_back(newP(h[1]-'0', h[0]));
		b.push_back(newP(h[1]-'0', h[0]));
	}
	SelectionSort(a);
	BubbleSort(b); 
	cout << b[0].name << b[0].id;
	for(int i=1;i<n;i++){
		cout << " " << b[i].name << b[i].id;
	}
	cout << endl;
	if(check(v,b)){
		cout << "Stable"<<endl;
	} else {
		cout <<"Not stable"<<endl;
	}
	cout << a[0].name << a[0].id;
	for(int i=1;i<n;i++){
		cout << " " << a[i].name << a[i].id;
	}
	cout << endl;
	if(check(v,a)){
		cout << "Stable"<<endl;
	} else {
		cout <<"Not stable"<<endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<int,int> d;
  int m;
  rep(i,n) {cin >> m; d[m] += 1;}
  cout << d.size() << endl;
}

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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] input = br.readLine().split(" ");
		int n = Integer.parseInt(input[0]);
		int m = Integer.parseInt(input[1]);
		int l = Integer.parseInt(input[2]);
		long[][] a = new long[n][m];
		long[][] b = new long[m][l];

		for (int i = 0; i < n; i++) {
			input = br.readLine().split(" ");
			for (int j = 0; j < m; j++) {
				a[i][j] = Integer.parseInt(input[j]);
			}
		}
		for (int i = 0; i < m; i++) {
			input = br.readLine().split(" ");
			for (int j = 0; j < l; j++) {
				b[i][j] = Integer.parseInt(input[j]);
			}
		}

		StringBuffer sb = new StringBuffer();
		String space = " ";
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				long sum = 0;
				for (int k = 0; k < m; k++) {
					sum += a[i][k] * b[k][j];
				}
				if (j != l -1) {
					sb.append(sum + space);
				} else {
					sb.append(sum + "\n");
				}
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 34524