akhauriyash/Code-Regression huggingface dataset:
<?php
$n = fgets(STDIN);
$a = explode(' ', fgets(STDIN));
rsort($a);
$p = 0;
for ($i = 0; $i < $n; $i++) {
    if ($i % 2 === 0) {
        $p += $a[$i];
    } else {
        $p -= $a[$i];
    }
}
echo $p;
?>

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

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


Measured memory_bytes: 3136
#include<stdio.h>

static int D[1000],C[1000],memo[1000][1000];

int f(int i,int j){
	if(i==-1&&j==-1)return 0;
	if(i==-1)return 0;
	if(j==-1)return 1000000000;
	if(memo[i][j]!=0)return memo[i][j];
	return memo[i][j]=((f(i-1,j-1)+D[i]*C[j]) < f(i,j-1) ? (f(i-1,j-1)+D[i]*C[j]) : f(i,j-1));
}

int main(){
	int N,M,i,j,k,l,score=0,dmax=0,min=1000000000;
	static int Min[1000];
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++)scanf("%d",&D[i]);
	for(i=0;i<M;i++)scanf("%d",&C[i]);
	for(i=0;N+i-1<=M-1;i++)Min[i]=f(N-1,N+i-1);
	for(i=0;N+i-1<=M-1;i++)if(min>Min[i])min=Min[i];
	printf("%d\n",min);
	
	return 0;
}

Measured memory_bytes: 4252
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値

int main() {
    // 入力
    int N, K;
    while (cin >> N >> K) {
        if (N == 0) break;
        vector<long long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        
        // 累積和を前計算
        vector<int> s(N+1, 0);
        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
        
        // 答えを求める
        long long res = -INF; // 最初は無限小の値に初期化しておく
        for (int i = 0; i <= N-K; ++i) {
            long long val = s[K+i] - s[i];
            if (res < val) res = val;
        }
        cout << res << endl;
    }
}



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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  if (A % K == 0 || B % K == 0) cout << "OK" << endl;
  else if (B / K > A / K) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3636
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    a,b=map(int,input().split())
    x=(((b-1)//2)-(a-1)//2)%2
    if a%2==0:
        if b%2==0:print(x^b)
        else:print(x)
    else:
        if b%2==0:print(a^x^b)
        else:print(a^x)

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int a[102],i,x,n,max=0;
    for (i=0; i<102; i++) {
        a[i]=0;
    }
    while(1){
        x=scanf("%d",&n);
        if(x==EOF)
            break;
        a[n]++;
        if(a[n]>max)
            max=a[n];
    }
    for (i=0; i<100; i++) {
        if(a[i]==max)
            printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 596
import Control.Monad
import Data.List

solve = foldl' f (0, 0)
  where
    f (n, c) [a, b]
      | a < n
        = (n, c)
      | otherwise
        = (b, 1 + c)

readN = map read . words <$> getLine

main = do
  [n, m] <- readN
  rs <- replicateM m readN
  print . snd . solve . sortOn last $ rs


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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

  vector<int> A(1e6+2,0);
  ll total = 0;
  rep(i,N){
    int a; cin >> a;
    A[a]++;
    total += a;
  }

  int Q; cin >> Q;

  rep(i,Q){
    int B,C;
    cin >> B >> C;

    total += (C-B)*A[B];
    A[C] += A[B];
    A[B] = 0;

    cout << total << endl;
  }

}


Measured memory_bytes: 7216
# 2020/05/17
# AtCoder Beginner Contest 168 - D

# Input
n, m = map(int, input().split())

plist = [[] for k in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    plist[a].append(b)
    plist[b].append(a)

visited = [0] * (n+1)
visited[0] = 10 ** 9

beforeidx = [0] * (n+1)

# BFS
q = list()
q.append(1)

while(len(q) > 0):
    stidx = q.pop(0)
    for j in range(len(plist[stidx])):
        nextidx = plist[stidx][j]
        if visited[nextidx] == 0:
            q.append(nextidx)
            beforeidx[nextidx] = stidx
            visited[nextidx] = 1

if min(visited) > 0:
    print('Yes')
    for i in range(2, n+1):
        print(beforeidx[i])
else:
    print('No')


Measured memory_bytes: 34748
#include<cstdio>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
unordered_map<int,int>mp;
int a[201010];
int main()
{
	int n,i,j;int ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
		mp[a[i]]++; 
	for(i=n;i;i--)
	{
//			printf("%d %d\n",i,mp[a[i]]);
		if(mp[a[i]]==0)
			continue; 
		for(j=30;j>=0;j--)
		{
			if((1<<j)-a[i]<0) break; 
			if(!mp.count((1<<j)-a[i])) continue;
			if((mp[(1<<j)-a[i]]>0&&(1<<j)!=a[i]*2)||(mp[a[i]]>1&&(1<<j)==a[i]*2))
			{
//				printf("%d|\n",(1<<j));
				ans++,mp[a[i]]--,mp[(1<<j)-a[i]]--; 
				break;
			}
		}
	}
	printf("%d\n",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


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

int main() {
    int N, W;
    cin >> N >> W;
    vector<pair<ll, ll>> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    vector<vector<ll>> dp(W + 1, vector<ll>(N + 1, 0));
    for (int i = 1; i <= N; i++) {
        ll pw = p[i - 1].first;
        ll pv = p[i - 1].second;
        rep(w, W + 1) {
            if (w < pw) {
                dp[w][i] = dp[w][i - 1];
            } else {
                dp[w][i] = max(dp[w][i - 1], dp[w - pw][i - 1] + pv);
            }
        }
    }
    cout << dp[W][N] << endl;
}

Measured memory_bytes: 82304
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
  int *a;
  int N;
  scanf("%d",&N);
  a = (int*)malloc(sizeof(int)*N);
  int i,m1= 0,m2=0;
  for(i = 0; i<N;i++){
    scanf("%d",a+i);
    if(m1<a[i]){
      m2 = m1;
      m1 = a[i];
    }
    else if(m2 <a[i])
      m2 = a[i];
    
      
  }
  for(i = 0;i<N;i++){
    if(m1 != a[i]) printf("%d\n",m1);
    else  printf("%d\n",m2);
  }
  return 0;
} 

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i=1; i<a; i++) {
    for (int j=1; j<=31; j++) {
      if (i == j) ans++;
    }
  }
  for (int j=0; j<=b; j++) {
    if (j == a) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use itertools::Itertools as _;
use proconio::input;
use proconio::marker::Chars;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum RGB {
    R,
    G,
    B,
}

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let s = s
        .into_iter()
        .map(|ch| match ch {
            'R' => RGB::R,
            'G' => RGB::G,
            'B' => RGB::B,
            _ => panic!("parse error"),
        })
        .collect_vec();

    assert_eq!(s.len(), n);

    let mut rr = vec![0u64; n + 1];
    for i in (0..n).rev() {
        rr[i] = rr[i + 1] + if s[i] == RGB::R { 1 } else { 0 };
    }

    let mut rg = vec![0u64; n + 1];
    for i in (0..n).rev() {
        rg[i] = rg[i + 1] + if s[i] == RGB::G { 1 } else { 0 };
    }

    let mut rb = vec![0u64; n + 1];
    for i in (0..n).rev() {
        rb[i] = rb[i + 1] + if s[i] == RGB::B { 1 } else { 0 };
    }

    let mut res: u64 = 0;
    for i in 0..n {
        for j in i + 1..n {
            let (mut base, target) = match (s[i], s[j]) {
                (RGB::R, RGB::G) => (rb[j + 1], RGB::B),
                (RGB::R, RGB::B) => (rg[j + 1], RGB::G),
                (RGB::G, RGB::R) => (rb[j + 1], RGB::B),
                (RGB::G, RGB::B) => (rr[j + 1], RGB::R),
                (RGB::B, RGB::R) => (rg[j + 1], RGB::G),
                (RGB::B, RGB::G) => (rr[j + 1], RGB::R),
                (x, y) => {
                    assert_eq!(x, y);
                    continue;
                }
            };

            let k = (j - i) * 2 + i;
            assert_eq!(j - i, k - j);
            if k < n && s[k] == target {
                assert!(base > 0);
                base -= 1;
            }

            res += base;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	FOR(i,1,10){
		if(n%i == 0 && n/i<10){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
  return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<bool> aru(N,false);
  int d,A;
  char c = 's';
  for(int i=0; i<K; i++){
    cin >> d;
    do{
    scanf("%d",&A);
    scanf("%c",&c);
    aru[A-1] = true;
    }while(c != '\n');
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(aru[i] == false) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, K;
	in >> N >> K;
	std::vector<LL>a(N + 1);
	rep(i, N) in >> a[i + 1];

	std::vector<LL>bits;
	rep(i, N) a[i + 1] += a[i];
	rep(i, N)
	{
		for (int j = i; j < N; ++j)
		{
			LL sum = a[j + 1] - a[i];
			bits.push_back(sum);
		}
	}
	std::sort(bits.rbegin(), bits.rend());

	std::vector<LL>now = bits;
	for (LL b = 63; b >= 0; --b)
	{
		std::vector<LL>next;
		for (auto i : now)
		{
			if (i&(1LL << b)) next.push_back(i);
		}
		if (next.size() >= K) now = next;
	}

	LL ans = now[0];
	rep(i, K) ans &= now[i];

	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 9968
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n){
		cin >> a[i];
	}

	ll kane = 1000, kabu = 0;

	REP(i, n-1){
		if(a[i] <= a[i+1]){
			ll kosuu = kane / a[i];
			kabu += kosuu;
			kane -= kosuu * a[i];
		}else{
			kane += kabu * a[i];
			kabu = 0;
		}
	}
	kane += kabu * a[n-1];

	cout << kane << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}


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

	cout << (k+1) / 2 << endl;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x=0,cnt[105],val=-1000000;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I') x++;
		else x--;
		cnt[i]=x;
	}
	cnt[n]=0;
	for(int i=0;i<=n;i++) val=max(val,cnt[i]);
	cout<<val<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int main(){
    int n,m;cin>>n>>m;
    if(n<6){
        cout<<0<<endl;
    }
    else if(n<13){
        cout<<m/2<<endl;
    }
    else{
        cout<<m<<endl;        
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        char[] t = br.readLine().toCharArray();
        
        boolean[] s_existing = new boolean[26];
        boolean[] t_existing = new boolean[26];
        
        char[] st_corresponding = new char[26];
        char[] ts_corresponding = new char[26];
        
        //System.out.println((int)'a');
        
        boolean flag = true;
        for (int i = 0; i < s.length; i++) {
            if (s_existing[(int)s[i]-97]) {
                if (t[i] != st_corresponding[(int)s[i]-97]) {
                    flag = false;
                    break;
                }
            }
            if (t_existing[(int)t[i]-97]) {
                if (s[i] != ts_corresponding[(int)t[i]-97]) {
                    flag = false;
                    break;
                }
            }
            if (!s_existing[(int)s[i]-97] && !t_existing[(int)t[i]-97]) {
                s_existing[(int)s[i]-97] = true;
                t_existing[(int)t[i]-97] = true;
                
                st_corresponding[(int)s[i]-97] = t[i];
                ts_corresponding[(int)t[i]-97] = s[i];
                
            }
        }
        
        
        if (flag) System.out.println("Yes");
        else System.out.println("No");
        
        
        
    }
}


Measured memory_bytes: 27220
#include <iostream>

int main(void) {
  int A, B = 0;
  
  std::cin >> A;
  std::cin >> B;
  
  if(A >= 13) {
    std::cout << B;
  }else if( (A >= 6) && (A <=12) ) {
    std::cout << (B / 2);
  }
  else {
    std::cout << 0;
  }
  
  return 0;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N,X,Y;
    cin >> N >> X >> Y;
    X--;
    Y--;

    vector<ll> ans(N-1,0);
    queue<int> bfs;
    queue<int> tmp;

    rep(i,N-1)
    {
        // start: i
        swap(bfs, tmp);
        bfs.push(i);

        vector<int> dist(N, -1);
        dist[i] = 0;

        while(!bfs.empty())
        {
            int v = bfs.front();
            bfs.pop();
                
            // 左側
            if( v-1 > -1 && dist[v-1] == -1)
            {
                dist[v-1] = dist[v]+1;
                bfs.push(v-1);
            }
            // 右側
            if( v+1 < N && dist[v+1] == -1 )
            {
                dist[v+1] = dist[v] + 1;
                bfs.push(v+1);
            }
            // 今の場所がXの時
            if( v == X && dist[Y] == -1 )
            {
                dist[Y] = dist[v]+1;
                bfs.push(Y);
            }
            // 今の場所がYの時
            if( v == Y && dist[X] == -1 )
            {
                dist[X] = dist[v]+1;
                bfs.push(X);
            }
        }
        REP(j, i,dist.size())
        {
            if( dist[j] > 0 ) ans[dist[j]-1]++;
        }
    }
    rep(i,ans.size()) cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;
  
  vi q(N);
  vi wa(N);
  
  int acn = 0;
  rep(i, M) {
    int p; string S;
    cin >> p >> S;
    --p;
    if(S == "AC") {
      if(!q[p]) {
        q[p] = 1;
        acn ++;
      }
    } else {
      if(!q[p]) {
        wa[p]++;
      }
    }
  }
  
  int wan = 0;
  rep(i, N) {
    if(q[i]) wan+=wa[i];
  }
  
  cout << acn << " " << wan << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    int x, n; cin >> x >> n;
    vector<int> v(n);
    map<int, int> m;
    bool x_not_in = true;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        if (x == v[i]) x_not_in = false;
        m[v[i]] = 1;
    }
    if (x_not_in) {
        cout << x << endl;
        return 0;
    }
    // find lower
    int lower = x - 1;
    while (m.count(lower) > 0) lower--;
    int upper = x + 1;
    while (m.count(upper) > 0) upper++;
    if (abs(x - lower) <= abs(x - upper)) {
        cout << lower << endl;
    }
    else {
        cout << upper << endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> d(n);
  REP(i,n) cin>>d[i];

  int ans=0;
  REP(i,n){
    REP2(j,i+1,n){
      ans+=d[i]*d[j];
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
apple_ary = Array.new(n)
first_win = false
n.times do |i|
    apple_ary[i] = gets.chomp.to_i
    first_win = true if apple_ary[i] % 2 == 1
end

puts first_win ? 'first' : 'second'


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

int main(){
  long long n;
  cin >> n;
  long long lucas_i2=2,lucas_i1=1,lucas_i=0;
  for(int i=0;i<=n;i++){
    if(i==0){
      lucas_i=lucas_i2;
    }else if(i==1){
      lucas_i=lucas_i1;
    }else{
      lucas_i = lucas_i2 + lucas_i1;
      lucas_i2 = lucas_i1;
      lucas_i1 = lucas_i;
    }
  }
  cout << lucas_i << endl;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
 
	if a*b >= c*d {
		fmt.Println(a * b)
	} else {
		fmt.Println(c * d)
	}
}

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

int main() {
  int x, y;
  cin >> x >> y;
  bool flag = false;
  for (int i = 0; i <= x; i++) {
    int sum = i * 2 + (x - i) * 4;
    if (sum == y) {
      flag = true;
      break;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3636
def f(e):
 a=list(tuple(map(int,input().split())) for _ in range(int(e)))
 s,t=a[0]
 b={tuple(map(int,input().split())) for _ in range(int(input()))}
 for x,y in b:
  for u,v in a[1:]:
   if(x+u-s,y+v-t)not in b:break
  else:return print(x-s,y-t)
for e in iter(input,'0'):f(e)


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

int h, w, ch, cw, dh, dw, dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}, dist[1005][1005];
char grid[1005][1005];
bool vis[1005][1005];
typedef pair<int, int> ii;
deque<ii> bfs;
#define INF 1023456789

int main(){
    scanf("%d%d%d%d%d%d", &h, &w, &ch, &cw, &dh, &dw);
    --ch; --cw; --dh; --dw;
    for (int i = 0; i < h; ++i){
        for (int j = 0; j < w; ++j){
            dist[i][j] = INF;
            vis[i][j] = false;
            scanf(" %c", &grid[i][j]);
        }
    }
    bfs.push_front(ii(ch, cw));
    dist[ch][cw] = 0;
    while (!bfs.empty()){
        int x, y; tie(x, y) = bfs.front(); bfs.pop_front();
        //printf("%d %d\n", x, y);
        if (vis[x][y]) continue;
        vis[x][y] = true;
        if (x == dh && y == dw) break;
        for (int i = 0; i < 4; ++i){
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (grid[nx][ny] == '#') continue;
            if (dist[x][y] < dist[nx][ny]){
                dist[nx][ny] = dist[x][y];
                bfs.push_front(ii(nx, ny));
            }
        }
        for (int i = -2; i <= 2; ++i){
            for (int j = -2; j <= 2; ++j){
                int nx = x + i, ny = y + j;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (grid[nx][ny] == '#') continue;
                if (dist[x][y] + 1 < dist[nx][ny]){
                    dist[nx][ny] = dist[x][y] + 1;
                    bfs.push_back(ii(nx, ny));
                }
            }
        }
    }
    if (dist[dh][dw] == INF) printf("-1\n");
    else printf("%d\n", dist[dh][dw]);
}


Measured memory_bytes: 9752
/*
	watch me go
*/

#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/
#define int long long
//#define d long double
#define pii pair<int,int>
#define bitcount(a) __builtin_popcountll(a)
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */

int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}

signed main() 
{ 
    haha
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    
    int dp[n];
    init(dp,0);
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        int x=inf;
        for(int j=i-1;j>=max(0ll,i-k);j--)
        {
        int t=dp[j]+abs(arr[i]-arr[j]);
        x=min(x,t);
        }
        dp[i]=x;
    }
  
    cout<<dp[n-1];
    
   
   
} 


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> H(n);
    rep(i, n) cin >> H[i];
    sort(ALL(H));
    int minv = INF;
    rep(i, n - k + 1) {
        int value = H[i + k - 1] - H[i];
        minv = min(value, minv);
    }
    cout << minv << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 3;
const int N = 1e2 + 10, M = 1e7 + 10;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)

int main()
{
    int n;
    ll d;
    cin >> n >> d;
    int cnt = 0;
    d *= d;
    while (n--)
    {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        ll sum = x * x + y * y;
        if (sum <= d)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define lb lower_bound
#define maxn 100005
#define lowbit(x) (x)&(-x)
#define forup(i,a,b) for(int i=(a);i<=(b);i++)
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)
#define int ll
typedef long long  ll;
typedef unsigned long long ull;
template<class T> inline
void read(T &num)
{num=0; bool f=true; char ch=getchar();
 while(ch<'0'||ch>'9') {if(ch=='-')  f=false;  ch=getchar();}
 while(ch>='0'&&ch<='9') {num=num*10+ch-'0';ch=getchar();}
 num=f?num:-num;
}
int out[100];
template<class T> inline
void  write(T x,char ch)
{if(x==0) {putchar('0');putchar(ch);return;}
 if(x<0) {putchar('-'); x=-x;}
 int num=0;
 while(x){out[num++]=(x%10);x=x/10;}
 fordown(i,num-1,0) putchar(out[i]+'0');
 putchar(ch);
}
string s;
int n;
struct P
{string A,B;
 bool operator <(const P &y) const
  {if(A<y.A) return 1; if(A>y.A) return false;
   if(A==y.A) return B<y.B; 
   
  } 
};
map<P,ll> mp;
int ans=0ll; 
int a[20];
void dfs1(int x)
{if(x>n) 
{string A="",B="";
 forup(i,1,n) if(a[i]==1){A=A+s[i-1];}else B=s[i-1]+B;
 P tmp; tmp.A=A;tmp.B=B;
 mp[tmp]=mp[tmp]+1; 
 return;
}
 a[x]=0;
 dfs1(x+1);
 a[x]=1;
 dfs1(x+1); 
}
void dfs2(int x)
{if(x>n)
 {string A="",B="";
  forup(i,1,n) if(a[i]==1) A=A+s[n+i-1]; else B=s[n+i-1]+B; 
  P tmp; tmp.A=B;tmp.B=A; 
  if(mp.find(tmp)!=mp.end())ans+=mp[tmp];	
  return;
 }
  a[x]=0;
  dfs2(x+1);
  a[x]=1;
  dfs2(x+1);	
}
signed main()
{ cin>>n;
  cin>>s;
  dfs1(1);
  
  dfs2(1);	
  cout<<ans<<endl;
return 0;
 } 

Measured memory_bytes: 42624
import collections

N = int(input())
s = [0] * N
for i in range(N):
    s[i] = list(input())
    s[i].sort()
    s[i] = ''.join(s[i])

c = collections.Counter(s)
l = list(c.values())
#print(l)

ans = 0
for i in range(len(l)):
    tmp = (l[i] * (l[i] - 1)) // 2
    ans += tmp

print(ans)

Measured memory_bytes: 19720
import bisect, itertools

n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

c_num = [0]*n
for i in range(n):
    c_num[i] = n - bisect.bisect_right(C, B[i])
c_accum = [0] + list(itertools.accumulate(c_num))

ans = 0
for i in range(n):
    b_index = bisect.bisect_right(B, A[i])
    ans += (c_accum[-1] - c_accum[b_index])
print(ans)

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

    for(ll len = n-2; len >= 2; len -= 2) {
        string t = s.substr(0, len);
        bool ok = true;
        rep(i, len/2) {
            if(t[i] != t[i+len/2]) {
                ok = false;
            }
        }
        if(ok) {
            out(len);
            re0;
        }
    }
    
    re0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

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

using namespace std;

//===================================== template =========================================================

int main()
{
    int N, M; cin >> N >> M;
    priority_queue<double> pq; REP(i, N) { ll tmp; cin >> tmp; pq.push(tmp); }
    REP(i, M) {
        double t = pq.top(); pq.pop();
        t = t/2.;
        pq.push(t);
    }
    ll sum = 0;
    while (pq.size()) {
        ll t = (ll)pq.top(); pq.pop();
        sum += t;
    }
    cout << sum << endl;
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 1; i <= n; i++) {
      a[i] = sc.nextInt();
      b[a[i]] = i;
    }

    for (int i = 1; i <= n; i++) {
      System.out.print(b[i]);
      if (i != n) System.out.print(" ");
    }
    
    System.out.println();
  }
}

Measured memory_bytes: 63684
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		abc155_a();

	}

	static void abc155_a() {

		Scanner sc = new Scanner(System.in);
		// 数値
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int n3 = sc.nextInt();

		if ((n1 == n2 && n2 == n3) || (n1 != n2 && n1 != n3 && n2 != n3)) {

			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm> //lower_bound,upper_bound,sort
#include<iterator>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  long long cnt=0;
  for(int i=0;i<n;i++){
    long long aa=distance(a.begin(),lower_bound(a.begin(),a.end(),b[i]));
    long long cc=distance(upper_bound(c.begin(),c.end(),b[i]),c.end());
    cnt += aa*cc;
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 1408
//ABC125 D - Flipping Signs
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int64_t> atbl(n);
    int64_t fnum=0;
    int64_t min_val=INT64_MAX;
    int64_t idx=0;
    int i=0;
    for(auto&a:atbl){
		cin >> a;
        if(a<0) ++fnum;
        if (min_val > abs(a)) {
            min_val = abs(a);
            idx=i;
        }
        ++i;
	}
    int64_t sum=0;

    if (fnum%2) { //odd
        for(int i=0;i<atbl.size();++i){
            if (i==idx) {
                sum -= abs(atbl[i]);
            } else {
				sum += abs(atbl[i]);
			}
        }
	} else {
        //even
        for(auto&a:atbl){
			sum += abs(a);
		}
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=2005;

struct node{
	int w,id;
	node(){}
	node(int w,int id):w(w),id(id){}
}b[N];
int n,ans,k,Q;
int a[N],sz[N],fa[N],vis[N];

int find(int k){
	if (fa[k]!=k) fa[k]=find(fa[k]);
	return fa[k];
}

void merge(int x,int y){
	x=find(x); y=find(y);
	if (x!=y){
		fa[x]=y;
		sz[y]+=sz[x];
	}
}

bool cmp(node a,node b){
	return a.w<b.w;
}

void work(int w){
	int i,cnt=0,x;
	memset(vis,0,sizeof(vis));
	for (i=1;i<=n;i++)
		if (a[i]<w) vis[i]=1;
	for (i=1;i<=n;i++) fa[i]=i,sz[i]=1;
	for (i=1;i<n;i++)
		if (a[i]>=w&&a[i+1]>=w) merge(i,i+1);
	for (i=1;i<=n;i++) if (b[i].w>=w){
		x=find(b[i].id);
		if (sz[x]>=k){
			cnt++;
			sz[x]--;
		}
		if (cnt==Q){
			ans=min(ans,b[i].w-w);
			return;
		}
	}
}

int main(){
	int i,j;
	scanf("%d%d%d",&n,&k,&Q);
	for (i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=node(a[i],i);
	}
	sort(b+1,b+1+n,cmp);
	ans=b[n].w-b[1].w;
	for (i=1;i<=n;i++) work(a[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


int main(){
	base();
	int arr[MAX];
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);
	cout<<arr[0]+arr[1]<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int solve(int, int,int *,int);

int main()
{
  int i,n,q;
  int A[2000],M[2000];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }

  for(i=0;i<q;i++){
    if(solve(0,M[i],A,n)){
      printf("yes\n");
    }
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m,int *A,int n)
{
  int S=0;
  if(m==0)return 1;
  if(i>=n)return 0;
  else{
  S+=solve(i+1,m,A,n);
  S+=solve(i+1,m-A[i],A,n);
  }
  return S;
}



Measured memory_bytes: 2140
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int n;
vector<int> e[111111];


bool used[111111];
int bo[111111];
int dfs1(int x,int y){
  used[x] = true;
  int ret = 1;
  for(int i = 0; i < (int)e[x].size(); i++){
    if(used[e[x][i]]) continue;
    if(bo[e[x][i]] == y) continue;
    ret += dfs1(e[x][i],y);
  }
  return ret;
}

int dfs2(int x){
  if(x == 0) return 0;
  used[x] = true;

  for(int i = 0; i < (int)e[x].size(); i++){
    if(used[e[x][i]]) continue;
    int ret = dfs2(e[x][i]);
    if(ret >= 0){
      bo[x] = 3;
      return ret+1;
    }
  }
  return -1; 
}

int main(void){
  scanf("%d",&n);
  for(int i = 0; i < n-1; i++){
    int a,b;
    scanf("%d%d", &a, &b);
    a--;b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  memset(used,false,sizeof(used));
  int fs = dfs2(n-1);
  fs--;

  bo[0] = 3;
  bo[n-1] = 2;
  int x = n-1;
  for(int j = 0; x != 0; j++){
    for(int i = 0; i < (int)e[x].size(); i++){
      int y = e[x][i];
      if(bo[y] == 3){
	bo[y] = (fs/2 > j)?2:1;
	x = y;
	break;
      }
    }
  }
  bo[0] = 1;
  bo[n-1] = 2;

  memset(used,false,sizeof(used));
  int f = dfs1(0,2);
  memset(used,false,sizeof(used));
  int s = dfs1(n-1,1);
  f--;s--;

  //printf("%d %d %d\n", f,s,fs);

  if(f > s){
    puts("Fennec");
  }else{
    puts("Snuke");
  }
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  string s;
  cin >> N >> s;
  int r = 0, b = 0;
  REP(i,N) {
    if(s[i] == 'R') ++r;
    if(s[i] == 'B') ++b;
  }
  if(r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
var
p:boolean;
a,b,c,d,n:longint;
begin
read(n);
if n>=1000 then
 begin 
 a:=n div 1000;b:=n mod 1000 div 100;c:=n mod 100 div 10;d:=n mod 10;
 if (a=b) and (b=c) then p:=true
 else if (b=c) and (c=d) then p:=true;
 end;
 if n>=100 then
 begin 
 a:=n div 100;b:=n mod 100 div 10;c:=n mod 10;
 if (a=b) and (b=c) then p:=true;
 end;
 if p then writeln('Yes')
 else writeln('No');
 end.

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	if (s.size() != 6) {
		cout << "No" << endl;
		return 0;
	}
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}









Measured memory_bytes: 256
N,x = map(int, input().split())
a= [int(i) for i in input().split()]

a_s = sorted(a)

count=0
if sum(a) < x:
  count = -1
for i in range(N):
  if a_s[i] <= x:
    count += 1
    x -= a_s[i]
  else:
    break
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      String s = sc.next();
      if (s.equals("0")) break;
      int sum = 0;
      for (int i = 0; i < s.length(); i++) {
        int n = s.charAt(i) - '0';
        sum += n;
      }
      System.out.println(sum);
    }
  }
}



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

int main(){
  int N;
  cin >> N;
  vector<int> arr(N + 1);

  for(int i=0;i<N+1;i++){
    cin >> arr[i];
  }
    
  long sum = 0;
  for(int i=0;i<N;i++){
    int v;
    cin >> v;
    sum += min(arr[i], v);
    v -= arr[i];
    if(v > 0){
      sum += min(arr[i + 1], v);
      arr[i+1] -= v;
      if(arr[i+1] < 0) arr[i+1] = 0;
    }
  }

  cout << sum << endl;
  return 0;

 } 


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Pattern;

public class Main {
    public void solve(Stdin stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = stdin.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = stdin.nextLong();
        }

        int[] c = new int[61];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 61L; j++) {
                if ((a[i] & (1L << j)) != 0) {
                    c[j]++;
                }
            }
        }

        long ans = 0;
        long d = 1;
        for (int i = 0; i < 61; i++) {
            ans += mul(mul(c[i], n - c[i]), d);
            ans %= mod;
            d *= 2L;
        }
        stdout.println(ans);
    }

    private long mul(long x, long y) {
        return ((x % mod) * (y % mod)) % mod;
    }

    private long mod = 1000000007L;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Stdin stdin = new Stdin();
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }

    public static class Stdin {
        private Deque<String> queue;
        private BufferedReader stdin;
        private Pattern delimiter;

        public Stdin() {
            queue = new ArrayDeque<>();
            stdin = new BufferedReader(new InputStreamReader(System.in));
            delimiter = Pattern.compile(" ");
        }

        public String next() throws IOException {
            if (queue.isEmpty()) {
                delimiter.splitAsStream(stdin.readLine()).forEach(queue::addLast);
            }
            return queue.removeFirst();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 94792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

signed main(){
  lint N; cin >> N;
  vector<lint> a(N);
  lint sum = 0;
  map<lint, lint> MAP;
  MAP[0]++;
  for(lint i = 0; i < N; i++) cin >> a[i], sum += a[i], MAP[sum]++;
  lint ans = 0;
  for(auto value : MAP){
    ans += (value.second - 1) * value.second / 2;
  }
  cout << ans << endl;
}

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif

int main() {
    LL n, m, d;
    cin >> n >> m >> d;
    
    double ans = 0;
    if(d == 0){
        ans = ((double)(m-1))/n;
    }else{
        ans = 2 * (double)(n-d)*(m-1) / (n * n);
    }
    cout.precision(10);
    cout << fixed << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
// C++ program to print all prime factors  
#include <bits/stdc++.h> 
using namespace std; 
  
// A function to print all prime  
// factors of a given number n  
 #define ll long long 
 ll a,b;ll ans;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    if(n%2==0&&b%2==0){ans++;}
    while (n % 2 == 0)  
    {  
       
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i*i <= n; i = i + 2)  
    {  
        // While i divides n, print i and divide n  
          if(n%i==0&&b%i==0){ans++;}
        while (n % i == 0)  
        {  
          
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2&&b%n==0)  
       ans++;
       
       //return ans;
}  
  

int main()  
{  
 cin>>a>>b; 
    primeFactors(a);  
    cout<<ans+1;  
}  
  

Measured memory_bytes: 256
#include<stdio.h>
#define MAX(a,b) ((a)>(b) ?(a) : (b))
#define MIN(a,b) ((a)<(b) ?(a) : (b))
#define ABS(a) ((a)>0 ?(a) : (-a))
int main(void){
  long long int a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  //printf("%lld-%lld-%lld-%lld\n",b*d,a*c,a*d,b*c);
  printf("%lld\n",MAX(MAX(b*d,a*c),MAX(a*d,b*c)));
  return 0;
}


Measured memory_bytes: 1728