akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;

}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }
    else u = u->right;
  }
  return u;

}

Node treeSuccessor(Node x){
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  Node y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL){
    Transplant(z,z->right);
  }
  else if(z->right == NIL){
    Transplant(z,z->left);
  }
  else{
    y = treeMinimum(z->right);
    if(y->parent != z){
      Transplant(y,y->right);
      y->right = z->right;
      y->right->parent =y;
    }
    Transplant(z,y);
    y->left = z->left;
    y->left->parent = y;
  }


}

void Transplant(Node u, Node v){
  if(u->parent == NIL){
    root = v;
  }
  else if(u == u->parent->left){
    u->parent->left = v;
  }
  else u->parent->right = v;
  if(v != NIL){
    v->parent = u->parent;
  }

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x; // set parent
    if(z->key < x->key){
      x = x->left; // shift to left child
    }
    else{
      x = x->right; // shift to right child
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z; // Tree is empty
  }
  else if(z->key < y->key){
    y->left = z; 
  }
  else{
    y->right = z;
  }

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

def bs(ok, ng, cond):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if cond(mid):
            ok = mid
        else:
            ng = mid
    return ok

ans = bs(n, 0, lambda x: x * 1.08 >= n)
if n == int(ans * 1.08):
    print(ans)
else:
    print(':(')


Measured memory_bytes: 61920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 4000007
#define mod 1000000007
int main()
{
    ll i,j,k,l,m,n,c;
    cin>>n;
    k=sqrt(n);
    cout<<k*k<<endl;
    return 0;
}


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

using int64 = long long;
using PII = pair<int64, int64>;

int64 CountInside(int64 x0, int64 y0, int64 x1, int64 y1, const vector<PII>& xys) {
  int64 res = 0;
  for (auto& xy : xys) {
    if (x0 <= xy.first && xy.first <= x1 &&
        y0 <= xy.second && xy.second <= y1)
      ++res;
  }
  return res;
}

int main() {
  int64 n, k;
  cin >> n >> k;
  vector<PII> xys(n);
  for (auto& xy : xys)
    cin >> xy.first >> xy.second;

  int64 res = 4e+18;
  for (int64 i0 = 0; i0 < n; ++i0) {
    auto& xy0 = xys[i0];
    for (int64 i1 = i0; i1 < n; ++i1) {
      auto& xy1 = xys[i1];
      for (int64 i2 = i1; i2 < n; ++i2) {
        auto& xy2 = xys[i2];
        for (int64 i3 = i2; i3 < n; ++i3) {
          auto& xy3 = xys[i3];
          int64 x0 = min(min(xy0.first, xy1.first), min(xy2.first, xy3.first));
          int64 x1 = max(max(xy0.first, xy1.first), max(xy2.first, xy3.first));
          int64 y0 = min(min(xy0.second, xy1.second), min(xy2.second, xy3.second));
          int64 y1 = max(max(xy0.second, xy1.second), max(xy2.second, xy3.second));
          int64 count = CountInside(x0, y0, x1, y1, xys);
          if (count < k)
            continue;
          int64 area = max<int64>(x1 - x0, 1) * max<int64>(y1 - y0, 1);
          res = min(res, area);
        }
      }
    }
  }
  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#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 rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b != 0){
    d = extgcd( b , a%b, y, x);
    y -= (a/b)*x;
  } else{
    x=1; y=0;
  }
  return d;
}

int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m) %m;
}

vector<ll> v;
ll N,K;
ll A[100000];
//ll B[300000];
bool b[100000];
ll m = 0xffffffff;
ll id=0;
int main()
{
  cin>>N>>K;
  rep(i,N) cin>>m;
  cout<<(N-2)/(K-1) + 1 <<endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int H = in.ni(), W = in.ni();
            int h = in.ni(), w = in.ni();
            out.println(H * W - h * W - w * H + w * h);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}



Measured memory_bytes: 22484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 10 * 10000 + 100;

typedef pair<int, int> pii;

int n;
pii s[MAXN];
vector<int> edg[MAXN];
int tot, N, pos[MAXN];
int dfn[MAXN], low[MAXN], bel[MAXN], totw;
bool inst[MAXN];
stack<int> sta;

void init()
{
	tot = 2 * n;
	N = totw = 0;
	for(int i = 0; i < MAXN; i++)
		edg[i].clear();
	memset(dfn, 0, sizeof(dfn));
}

void add_edg(int x, int y)
{
	// cerr << "E" << x << ' ' << y << endl;
	edg[x].push_back(y);
}

void build()
{
	for(N = 1; N < 2 * n + 2; N <<= 1);
	// cerr << N << endl;
	for(int i = 1; i < N + N; i++)
		pos[i] = tot++;
	for(int i = 1; i < N; i++)
		add_edg(pos[i], pos[2 * i]), add_edg(pos[i], pos[2 * i + 1]);
	for(int i = 0; i < 2 * n; i++)
		add_edg(pos[N + i + 1], s[i].second ^ 1);
}

void link(int l, int r, int id) // index from zero
{
	if(l > r) return ;
	l += 1, r += 1;
	// cerr << l << ' ' << r << endl;
	for(l += N - 1, r += N + 1; (l ^ r) != 1; l >>= 1, r >>= 1)
	{
		if(~l & 1) add_edg(id, pos[l ^ 1]);
		if(r & 1) add_edg(id, pos[r ^ 1]);
	}
}

void tarjan(int x)
{
	dfn[x] = low[x] = ++totw;
	sta.push(x), inst[x] = true;
	for(int i = 0; i < edg[x].size(); i++)
	{
		int y = edg[x][i];
		if(!dfn[y])
			tarjan(y), low[x] = min(low[x], low[y]);
		else if(inst[y])
			low[x] = min(low[x], dfn[y]);
	}
	if(low[x] == dfn[x])
	{
		int y;
		do
		{
			y = sta.top();
			sta.pop(), inst[y] = false;
			bel[y] = x;
		}
		while(y != x);
	}
}

bool check(int k)
{
	init();
	build();
	int lp = 0, rp = 0;
	for(int i = 0; i < 2 * n; i++)
	{
		while(lp < 2 * n && s[lp].first <= s[i].first - k)
			lp++;
		while(rp < 2 * n && s[rp].first < s[i].first + k)
			rp++;
		// cerr << i << ' ' << lp << ' ' << rp << endl;
		link(lp, i - 1, s[i].second);
		link(i + 1, rp - 1, s[i].second);
	}
	for(int i = 0; i < tot; i++)
		if(!dfn[i])
			tarjan(i);
	// for(int i = 0; i < n; i++)
	// 	cerr << "!" << bel[2 * i] << ' ' << bel[2 * i + 1] << endl;
	for(int i = 0; i < n; i++)
		if(bel[2 * i] == bel[2 * i + 1])
			return false;
	return true;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

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

	// cerr << check(10) << endl;

	int l = 0, r = 1000000000;
	while(l < r)
	{
		int mid = (l + r + 1) / 2;
		if(check(mid))
			l = mid;
		else
			r = mid - 1;
	}
	cout << l << endl;


	return 0;
}


Measured memory_bytes: 12496
from sys import stdin

def main():
    n, k = [int(x) for x in stdin.readline().rstrip().split()]
    p = [int(x) for x in stdin.readline().rstrip().split()]
    p.sort()
    fee = 0
    for i in range(k):
        fee += p[i]

    print(fee)

if __name__ == "__main__":
    main()

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

int main() {
  int n,k;
  cin >> n >> k;
  
  vector<int> a(n);

  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  int ans = 0;
  
  for(int i = 0; i < k; i++){
    ans += a.at(i);
  }
  
  cout << ans << endl;
}

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

int main(){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;

  string s = "Yes";
  if(x-r < 0){
    s = "No";
  }
  if(y-r < 0){
    s = "No";
  }
  if(x+r > w){
    s = "No";
  }
  if(y+r > h){
    s = "No";
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 3216
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- sort <$> getIntList
    let s = sum . map (pred . length) $ group as
    print $ if even s then n - s else n - s - 1

Measured memory_bytes: 16764
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)

#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <list>
#include <stack>
#include <bitset>
#include <ctime>
using namespace std;

typedef long double ld;
typedef long long int lli;
#define pb(x) push_back(x)
#define recout(x) return cout << (x), 0
#define fr first
#define sc second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
const lli N = 1e6, N2 = 5e3, delta = 46639, mod = 1e9 + 7, oo = 1e16;
const ld PI = 3.141592653589793;

lli dp[N], a[N];

int main(){
	lli n;
	cin >> n;
	for (lli i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0)
			dp[i] = 0;
		else if (i == 1)
			dp[1] = abs (a[1] - a[0]);
		else
			dp[i] = min (dp[i - 1] + abs (a[i] - a[i - 1]), dp[i - 2] + abs (a[i] - a[i - 2]));
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 5120
import numpy as np
from itertools import combinations
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


h, w, k = LI()
c = [list(S()) for _ in range(h)]
c = np.array(c)
# print(c)
hl = list(range(h))
wl = list(range(w))
ans = 0
for i in range(h + 1):  # i 個の行を選ぶ
    for j in range(w + 1):  # j 個の列を選ぶ
        # print(list(combinations(hl, i)))
        for choice_line in combinations(hl, i):
            for choice_col in combinations(wl, j):
                tmp_c = np.copy(c)
                # print('i', choice_line)
                # print('j', choice_col)
                for line in choice_line:
                    tmp_c[line] = 'r'
                for col in choice_col:
                    tmp_c[:, col] = 'r'
                # print(tmp_c)
                if np.sum(tmp_c == '#') == k:
                    ans += 1
print(ans)


Measured memory_bytes: 26744
def fac0(a):
    r = 0
    while a > 0:
        r += a//5
        a = a//5
        #print("r=",r)
        #print("a=",a)
    return(r)

N = int(input())
#print("a=",N//2)
#for i in range(999999999999999900,1000000000000000001):
#    N = i
#    print("i=",i)
    
if N % 2 == 0:
    print(fac0(N//2))
else:
    print(0)


Measured memory_bytes: 2940
import math
from functools import reduce
K = int(input())
CNT= 0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for i in range(1,K+1):
    for j in range(1,K+1):
        GCD = gcd(i,j)
        if GCD == 1:
            CNT += K
        else:
            for k in range(1, K+1):
                if gcd(GCD,k) != 1:
                    CNT += gcd(GCD,k)
                else:
                    CNT += 1
print(CNT)

Measured memory_bytes: 9660
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

# print(is_prime(53))    
# print(is_prime(84))


M, D = map(int, input().split())

counter = 0





if D >= 22:
	for i in range(M):
		if not is_prime(i+1):
			for j in range(22,D+1):
			# 11~Dまでを見る
				j_0 = j%10
				j_1 = j//10

				if i+1 == j_0*j_1 and j_0 >= 2:
					counter += 1

print(counter)				

Measured memory_bytes: 38512
#include<iostream>
#include<queue>
#include<deque>
#include<vector>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
#include<unordered_set>
#include<unordered_map>
 
#define pi 3.141592653
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt","w",stdout);
#define ii pair<int,int> 
#define fast_io cin.tie(0), cin.sync_with_stdio(false);
#define inf 0x3f3f3f3f
#define sup_inf 1e18
#define f first
#define s second
#define eps 1e-9

#define nl ( no << 1)
#define nr ( no << 1)|1
#define mid l+(( r-l)>>1)
 
using namespace std;
typedef long long ll;	
typedef long double ld;
typedef unsigned long long ull;
typedef  pair< long long , pair< int,int> > iii;

const int maxn = 2e5 + 100; 
const int MAX = 1010;
const int mod = 1e9 + 7;
const int MAXLV = 16;
 

using namespace std;

int n ;


int gcd (int a, int b ){
  while ( b ) {
    int aux = b;
    b = a % b;
    a = aux;
  }
  return a;
}

int main () {
  //~ in
  fast_io
  
  cin >> n;
  
  bool parwise = true;
  int aux = 0;
  
  set <int> st;
  
  for(int i = 0 ;i < n;i++) {
    int x;
    cin >> x;
    
    if ( aux == 0 ){
      aux = x;
    }else {
      aux = gcd ( aux, x );
    }
    
    int N = x;
    for(int j = 2;j * j <= N && parwise ;j++) {
      
      if ( x % j == 0 ) {
        if (st.count ( j )) {
          parwise = 0;
        }
        st.insert ( j );
        while ( x % j == 0  && parwise){
          x/=j;
        }
      }
    }
    
    if ( x != 1 ){
      if (st.count ( x ) ) {
        parwise = false;
      }
      
      st.insert ( x);
    }
    
  }
  
  if ( parwise ) {
    cout << "pairwise coprime\n";
  }else if ( aux == 1  ){
    cout << "setwise coprime\n";
  }else  { 
    cout << "not coprime\n";
  }

    
  
  
  return 0;
}


Measured memory_bytes: 49872
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> a(n), ims(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ims[i + 1] = ims[i] + a[i];
    }
    vector<long long> subs;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < i; ++j) {
            subs.push_back(ims[i] - ims[j]);
        }
    }
    long long ans = 0;
    for (int i = 42; i >= 0; --i) {
        vector<long long> nex;
        for (auto& j : subs) {
            if ((j >> i) & 1) {
                nex.push_back(j);
            }
        }
        if (nex.size() >= k) {
            ans |= 1LL << i;
            subs = nex;
        }
    }
    cout << ans << "\n";
    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

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

    if (s[0] == 'W' || s[n * 2 - 1] == 'W') {
        cout << 0 << endl;
        return 0;
    }

    vector<int> v(n * 2, 1);

    REP1(i, n * 2 - 1) {
        if (s[i] == s[i - 1]) {
            if (v[i - 1] == 1) {
                v[i] = -1;
            } 
        } else {
            if (v[i - 1] == -1) {
                v[i] = -1;
            }
        }
    }

    ll t = 1;
    ll c = 1;
    REP1(i, n * 2 - 2) {
        if (v[i] == -1) t = (t * c) % MOD;
        c += v[i];
        if (c < 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    c += v[n * 2 - 1];
    if (c != 0) {
        cout << 0 << endl;
        return 0;
    }

    REP1(i, n) {
        t = t * i % MOD;
    }
    cout << t << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

ll mod=1e9+7;

vector <ll> factorials, inv_factorials;

ll modExp(ll x, ll n)
{
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}

ll modInv(ll a)
{
    return modExp(a, mod-2);
}

void calculate(ll N)
{
    factorials.resize(N+1);
    inv_factorials.resize(N+1);
    factorials[0]=1;
    for (int i=1; i<=N; ++i) factorials[i]=(factorials[i-1]*i)%mod;
    inv_factorials[N]=modInv(factorials[N]);
    for (int i=N-1; i>=0; --i) inv_factorials[i]=((i+1)*inv_factorials[i+1])%mod;
}

ll choose(ll N, ll K)
{
    if (N<0 || K<0) return 0;
    if (K>N) return 0;
    return (((factorials[N]*inv_factorials[N-K])%mod)*inv_factorials[K])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll S;
    cin >> S;
    calculate(S+1);
    ll ans=0;
    for (int i=1; i<=S; ++i)
    {
        ans=(ans+choose(S-2*i-1,i-1))%mod;
    }
    cout << (ans+mod)%mod << "\n";
    return 0;
}

Measured memory_bytes: 3664
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    while(true){
        int m,mi,ma;
        cin>>m>>mi>>ma;
        if(m==0&&mi==0&&ma==0) break;
        V<int> p(m);
        cinf(m,p);
        int cnt=0;
        int ans;
        for(int i=mi;i<=ma;i++){
            if(p[i-1]-p[i]>=cnt){
                cnt=p[i-1]-p[i];
                ans=i;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3020
function Main(input) {
  input = input.split(' ');
  const sheeps = parseInt(input[0]);
  const wolves = parseInt(input[1]);
  console.log('%s', sheeps > wolves ? 'safe' : 'unsafe');
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29624
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 int A,B,K;
 cin>>A>>B>>K;
 map<int,int>x;
 for(int i=A;i<min(B+1,A+K);i++){
     x[i]++;
     cout<<i<<endl;
 }
 for(int i=max(A,B-K+1);i<=B;i++){
     if(x[i]>0){continue;}
     cout<<i<<endl;
 }

 return 0;}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int R, C, K;
int V[3300][3300];
int dp[3300][3300][4];
signed main() {
    cin >> R >> C >> K;
    rep(i, K) {
        int r, c, v;
        cin >> r >> c >> v, r--, c--;
        V[r][c] = v;
    }
    dp[0][0][1] = V[0][0];
    rep(i, R) {
        rep(j, C) {
            rep(k, 4) {
                if (V[i + 1][j] > 0) {
                    chmax(dp[i + 1][j][1], dp[i][j][k] + V[i + 1][j]);
                    chmax(dp[i + 1][j][0], dp[i][j][k]);
                } else {
                    chmax(dp[i + 1][j][0], dp[i][j][k]);
                }
                if (V[i][j + 1] > 0) {
                    if (k < 3) { chmax(dp[i][j + 1][k + 1], dp[i][j][k] + V[i][j + 1]); }
                    chmax(dp[i][j + 1][k], dp[i][j][k]);
                } else {
                    chmax(dp[i][j + 1][k], dp[i][j][k]);
                }
            }
        }
    }
    R--, C--;
    cout << max({dp[R][C][0], dp[R][C][1], dp[R][C][2], dp[R][C][3]}) << endl;

}

Measured memory_bytes: 373832
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
const ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll w, h;
  cin >> w >> h;
  vp cost;
  cost.reserve(w+h);
  vll p(w);
  rep(i, w){
    cin >> p[i];
    cost.emplace_back(p[i], 0);
  }
  vll q(h);
  rep(i, h){
    cin >> q[i];
    cost.emplace_back(q[i], 1);
  }
  sort(ALL(cost));
  ll cntw = w+1, cnth = h+1;
  ll ans = 0;
  rep(i, w+h){
    if(cost[i].second){
      //q
      ans += cost[i].first*cntw;
      dump(cost[i].first, cntw);
      cnth--;
    }else{
      //p
      ans += cost[i].first*cnth;
      dump(cost[i].first, cnth);
      cntw--;
    }
  }
  print(ans);
}


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

namespace _20180502_pra
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            List<String> S = new List<String>();

            for (int i = 0; i < input[0]; i++)
            {
                S.Add(Console.ReadLine());
            }

            S.Sort();
            StringBuilder sb = new StringBuilder();

            foreach (var item in S)
            {
                sb.Append(item); 
            }

            Console.WriteLine(sb.ToString());
        }
    }
}

Measured memory_bytes: 13536
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
	int i;

	double a,b;
	cin >> a >> b;
	double c=a*b/(a+b);
	printf("%.12f\n",c);


	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`



		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	a, b, n := nextFloat64(), nextFloat64(), nextInt()

	x := 0.0
	if float64(n) < b {
		x = float64(n)
	} else {
		x = b - 1
	}
	ans := math.Floor(a*x/b) - a*math.Floor(x/b)

	//fmt.Fprintln(out, "[DEBUG]", d)
	fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 1760
import sys
N=int(input())
alist=list(map(int,input().split()))

s1=[]
s2=[]
s4=[]

for a in alist:
  if a%2==1:
    s1.append(a)
  elif a%4==0:
    s4.append(a)
  else:
    s2.append(a)
#print(s1,s2,s4)

answer_list=[]
last=4
for i in range(N):
  if last==4:
    if s1:
      answer_list.append(s1.pop())
      last=1
    elif s2:
      answer_list.append(s2.pop())
      last=2
    else:
      answer_list.append(s4.pop())
      last=4
  elif last==2:
    if s2:
      answer_list.append(s2.pop())
      last=2
    elif s4:
      answer_list.append(s4.pop())
      last=4
    else:
      print("No")
      sys.exit(0)
  elif last==1:
    if s4:
      answer_list.append(s4.pop())
      last=4
    else:
      print("No")
      sys.exit(0)
      
#print(answer_list)
print("Yes")

Measured memory_bytes: 14480
N = int(input())
S = input()
answer = 0

for i in range(10):
    idx1 = S.find(str(i))
    if idx1 == -1:
        continue
    for j in range(10):
        idx2 = S.find(str(j), idx1 + 1)
        if idx2 == -1:
            continue
        for k in range(10):
            idx3 = S.find(str(k), idx2 + 1)
            if idx3 == -1:
                continue
            answer += 1

print(answer)

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

r , g, b = S.count("R"), S.count("G"), S.count("B")
ans = r * g * b

for i in range(N-2):
    for d in range(1,N//2+1):
        j = i + d
        k = j + d
        if k >= N:break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9108
#include <stdio.h>
int main (void)
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);
	if (a < b ){
		if (b < c){
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}	

	}
	else{
		printf("No\n");
	}

	return 0;

}


Measured memory_bytes: 2044
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 1000;

char a[MAXN], b[MAXN];
int n;

int main() {
	scanf("%d", &n);
	scanf("%s %s", a + 1, b + 1);
	rep(i, 1, n) {
		printf("%c%c", a[i], b[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
///////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

#define pb push_back

void intin(int &a)
{
        cin >> a;
}

void intinl1(auto &v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a;
                cin >> a;
                v.push_back(a);
        }
}

void intinl2(auto &v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a, b;
                cin >> a >> b;
                v.push_back({a, b});
        }
}

void intinl3(auto &v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a, b, c;
                cin >> a >> b >> c;
                v.push_back({a, b, c});
        }
}

void intina(auto &v, int count)
{
        intinl1(v, count);
}

///////////////////////////////////////////////////////////////////////////////

int main()
{
        vector<int> nlist;
        intina(nlist, 5);

        int minx = 100;
        for (auto n : nlist) {
                if (n % 10) {
                        minx = min(minx, n % 10);
                }
        }

        int ans = 0;
        for (auto n : nlist) {
                if (n % 10) n += 10 - n % 10;
                ans += n;
        }

        if (minx < 50) {
                ans -= 10;
                ans += minx;
        }

        cout << ans;

        return 0;
}

///////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int temp, a[31];
int main(){
  for(int i = 0; i < 28; i++){
    cin >> temp;
    a[temp]++;
  }
  for(int i = 1; i < 31; i++){
    if(!a[i]){
      cout << i << endl;
    }
  }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int n;
  cin>>n;

  vector<int> L(n);
  for(int i=0;i<n;i++){
    cin>>L.at(i);
  }

  int cnt=0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        bool flg1 = (L.at(i)!=L.at(j) && L.at(j)!=L.at(k) && L.at(k)!=L.at(i));
        bool flg2 = L.at(i)+L.at(j)>L.at(k) && L.at(j)+L.at(k) >L.at(i) && L.at(k)+L.at(i)>L.at(j);
        if(flg1 && flg2)
          cnt++;
      }
    }
  }

  cout<<cnt<<endl;

	return 0;
}



Measured memory_bytes: 3620
N, A, B, K = map(int, input().split(" "))
mod = 998244353
ncr = [1] * (N + 1)
v = 1

for i in range(N):
    v = (v * ((N - i) % mod) * pow((i + 1), mod - 2, mod)) % mod
    ncr[i + 1] = v % mod

pat = 0
for a in range(N + 1):
    if (K - (a * A) < 0):
        break
    if (K - (a * A)) % B == 0 and ((K - (a * A)) // B) <= N:
        pat += ncr[a] * ncr[(K - (a * A)) // B]
        pat %= mod

print(pat % mod)

Measured memory_bytes: 14836
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;



int main(){
	int N,K;
	cin >> N >> K;
	vector<P> a(N);
	vector<ll> f(N + 1,0);
	for(int i = 0; i < N; i++) {
		ll t,d;cin>>t>>d;
		a[i] = mp(d,t);
	}
	sort(RALL(a));
	priority_queue<ll,vector<ll>,greater<ll>> que1;
	vector<bool> used(N + 1,false);//一個使ってるか
	ll sum = 0;
	int kind = 0;
	ll res = 0;
	for(int i = 0; i < N; i++) {
		if (i < K){
			if (!used[a[i].sc]){
				sum += a[i].fs;
				kind ++;
				used[a[i].sc] = true;
			}
			else{
				sum += a[i].fs;
				que1.push(a[i].fs);
			}
			f[kind] = sum;
			res = max(res,sum + kind * kind);
		}
		else{
			if (que1.empty())break;
			if (!used[a[i].sc]){
				sum -= que1.top();
				sum += a[i].fs;
				kind++;
				used[a[i].sc] = true;
				que1.pop();
				f[kind] = sum;
				res = max(res,sum + kind * kind);
			} 
		}
	}
	ll ans = 0;
	for(ll i = 0; i <= N; i++) {
		if (f[i] != 0){
			ans = max(ans,f[i] + i * i);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int N;

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return i * 2;
}

int right(int i) {
    return i * 2 + 1;
}

void maxHeapify(vector<int> &A, int i) {
    int l = left(i);
    int r = right(i);

    int largest;
    // select largest node
    if (l <= N && A.at(l) > A.at(i)) {
        largest = l;
    }
    else
    {
        largest = i;
    }

    if (r <= N && A.at(r) > A.at(largest)) {
        largest = r;
    }

    if (largest != i)
    {
        swap(A.at(i), A.at(largest));
        maxHeapify(A, largest);
    }
}


int main() {
    cin >> N;

    vector<int> A(N+1); // 1 origin vector

    for (int i = 1; i <=  N; i++)
    {
        cin >> A.at(i);
    }

    for (int i = N/2; i >= 1; i--)
    {
        maxHeapify(A, i);
    }

    for (int i = 1; i <= N; i++)
    {
        cout << " " << A.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 4584
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
	static void Main(string[] args)
	{
		var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		var answer = 0;
		for (int i = 0; i < 2; i++)
		{
			if (array[0] > array[1])
			{
				answer += array[0];
				array[0]--;
			}
			else
			{
				answer += array[1];
				array[1]--;
			}
		}
		Console.WriteLine(answer);
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
long out = 0;

void dfs(const string& s, long sum) {
  if(s.size() == 1) {
     out += stol(s) + sum;
     return;
  }
  out += stol(s);
  for (int i = 1; i < s.size(); ++i ) {
    sum += stol(s.substr(0,i));
    dfs(s.substr(i, s.size() - i), sum);
  }
  return;
}


int main() {
	string s; cin >> s;
  dfs(s, 0);
	cout << out << endl;
	return 0;
}


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

ll n, ans, sum;

int main() {
  cin >> n;
  vector<int> x(n);
  rep (i, n) {
    cin >> x[i];
  }
  ans = pow(10,8);
  rep (i, 99) {
    sum = 0;
    rep (j, n) {
      sum += pow(x[j] - i - 1, 2);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    using namespace std;
     
    signed main () {
      vector <int> a;
      for (char c; cin >> c;) {
        a.push_back(c);
      }
      if ( a[1] == a[2] ) {
        if ( a[0] == a[1] || a[2] == a[3]) cout << "Yes";
        else cout << "No";
      }
      else cout << "No";
    }

Measured memory_bytes: 256
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int n;cin>>n;
  string s;cin>>s;
  int r=0;
  int b=0;
  rep(i, sz(s)){
    dump(s[i]);
    if (s[i]=='R') r++;
    else b++;
  }

  dump(r, b);
  if (r>b) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
string S;

bool C(int x){
    int cur=0,cnt=0;
    while(cur<N&&cnt<x){
        if(S[cur]=='I')cnt++;
        cur++;
    }
    if(cnt!=x)return false;
    int J=0,O=0,I=0;
    rep(_,x){
        while(I<N&&S[I]!='I')I++;
        I++;
        chmax(O,I);
        while(O<N&&S[O]!='O')O++;
        if(O==N)return false;
        O++;
        chmax(J,O);
        while(J<N&&(S[J]=='O'||(S[J]=='I'&&J<cur)))J++;
        if(J==N)return false;
        J++;
    }
    return true;
}

signed main(){
    cin>>N>>S;
    reverse(all(S));
    int lb=0,ub=N;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(C(mid))lb=mid;
        else ub=mid;
    }
    cout<<lb<<endl;
    return 0;
}

Measured memory_bytes: 2068
import math
dice,point=map(int,input().split())
percent = 0.0
power = 0
for i in range(1,dice+1):
    for j in range(20):
        if (point <= i *(2 **j)):
            power = j
            break


    current = (1 / dice) * (1/2) ** power
    percent = percent + current


print(percent)


Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize, d: usize,
        xy_vec: [(isize, isize); n]
    }

    let mut ans = 0;

    for (x, y) in xy_vec.into_iter() {
        if x.pow(2) + y.pow(2) <= d.pow(2) as isize {
            ans += 1;
        }
    }

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

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 7820
n,a,b,c=map(int,input().split())
s=[input()for _ in range(n)]
if (a+b+c)==0:
  print("No")
if (a+b+c)==1 or (a+b+c)>=3:
  ans=[]
  for i in s:
    if i=="AB":
      if a<b:ans.append("A");a+=1;b+=-1;c+=0
      else:ans.append("B");a+=-1;b+=1;c+=0
    if i=="BC":
      if b<c:ans.append("B");a+=0;b+=1;c+=-1
      else:ans.append("C");a+=0;b+=-1;c+=1
    if i=="AC":
      if a<c:ans.append("A");a+=1;b+=0;c+=-1
      else:ans.append("C");a+=-1;b+=0;c+=1
    if min(a,b,c)<0:
      exit(print("No"))
  print("Yes")
  for i in ans:print(i)
if (a+b+c)==2:
  ans=[]
  for i in range(n-1):
    if s[i]=="AB":
      if a==b:
        if s[i+1]=="AC":ans.append("A");a+=1;b+=-1;c+=0
        else:ans.append("B");a+=-1;b+=1;c+=0
      elif a<b:ans.append("A");a+=1;b+=-1;c+=0
      else:ans.append("B");a+=-1;b+=1;c+=0
    if s[i]=="BC":
      if b==c:
        if s[i+1]=="AC":ans.append("C");a+=0;b+=-1;c+=1
        else:ans.append("B");a+=0;b+=1;c+=-1
      elif b<c:ans.append("B");a+=0;b+=1;c+=-1
      else:ans.append("C");a+=0;b+=-1;c+=1
    if s[i]=="AC":
      if a==c:
        if s[i+1]=="BC":ans.append("C");a+=-1;b+=0;c+=1
        else:ans.append("A");a+=1;b+=0;c+=-1
      elif a<c:ans.append("A");a+=1;b+=0;c+=-1
      else:ans.append("C");a+=-1;b+=0;c+=1
    if min(a,b,c)<0:
      exit(print("No"))
  for i in s[n-1:]:
    if i=="AB":
      if a<b:ans.append("A");a+=1;b+=-1;c+=0
      else:ans.append("B");a+=-1;b+=1;c+=0
    if i=="BC":
      if b<c:ans.append("B");a+=0;b+=1;c+=-1
      else:ans.append("C");a+=0;b+=-1;c+=1
    if i=="AC":
      if a<c:ans.append("A");a+=1;b+=0;c+=-1
      else:ans.append("C");a+=-1;b+=0;c+=1
    if min(a,b,c)<0:
      exit(print("No"))
  print("Yes")
  for i in ans:print(i)

Measured memory_bytes: 17040
from itertools import accumulate
import sys
input = sys.stdin.readline

N = int(input())
P = list(accumulate(list(map(int, input().split()))))
l, r = 0, 2
ans = P[N - 1]
for i in range(1, N - 2):
    while l < i and abs(P[i] - 2 * P[l]) > abs(P[i] - 2 * P[l + 1]):
        l += 1
    while r < N - 1 and abs(P[N - 1] - 2 * P[r] + P[i]) > abs(P[N - 1] - 2 * P[r + 1] + P[i]):
        r += 1
    minn = min(abs(P[i] - P[l]), P[l], abs(P[N - 1] - P[r]), abs(P[r] - P[i]))
    maxn = max(abs(P[i] - P[l]), P[l], abs(P[N - 1] - P[r]), abs(P[r] - P[i]))
    ans = min(ans, maxn - minn)
print(ans)


Measured memory_bytes: 24348
from itertools import accumulate
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
count = [[0] * (N+1) for _ in range(N+1)]
for _ in range(M):
    L, R = map(lambda x: int(x)-1, input().split())
    count[0][R] += 1
    count[L+1][R] -= 1
for i in range(N+1):
    count[i] = list(accumulate(count[i]))
for i in range(1, N+1):
    for j in range(N+1):
        count[i][j] += count[i-1][j]
for _ in range(Q):
    p, q = map(lambda x: int(x)-1, input().split())
    print(count[p][q])


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, mx, sum = 0;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.rbegin(), p.rend());
    mx = p[0];
    for (int i = 1; i < n; ++i) {
        sum += p[i];
    }
    cout << mx / 2 + sum << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <time.h>

int main(void)
{ 
	int a[3];
	int i,j,m;
	for(i=0;i<3;i++) scanf("%d",&a[i]);
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				m=a[i];
				a[i]=a[j];
				a[j]=m;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	return 0;
}


Measured memory_bytes: 2612