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

using namespace std;

typedef long long ll;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

void build_primes(vector<bool>& bs, int n)
{
  bs.assign(n + 1, false);
  bs[0] = bs[1] = true;
  for (int i = 2; i * i <= n; i++){
    if (bs[i]) continue;
    for (int j = i * i; j <= n; j += i) bs[j] = true;
  }
}

int main()
{
  vector<bool> sieve;
  build_primes(sieve, 999999);
  vector<int> ps;
  for (int i = 0; i <= 999999; i++) if (!sieve[i]) ps.push_back(i);

  int n, p;
  while (n = in(), p = in(), ~p){
    int ui = ubnd(ps, n);
    vector<int> _v;
    for (int i = 0; i < 100; i++){
      for (int j = i; j < 100; j++){
        _v.push_back(ps[ui + i] + ps[ui + j]);
      }
    }
    sort(_v);
    printf("%d\n", _v[p - 1]);
  }
  return (0);
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void Dump(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

int main() {
    int n, p;
    cin >> n >> p;

    auto v = vc<priority_queue<int>>(n);

    REP(i, p) {
        int query, t;
        cin >> query >> t;

        if (query == 0) {
            int x;
            cin >> x;
            v[t].push(x);
        } else if (query == 1) {
            if (!v[t].empty()) cout << v[t].top() << endl;
        } else if (query == 2) {
            if (!v[t].empty()) v[t].pop();
        } else cout << "Error: query is not correct\n";
    }

    return 0;
}



Measured memory_bytes: 4008
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	long D, ans;
	long[] pow = new long[20];
	void Solve()
	{
		D = F();
		pow[0] = 1;
		for (var i = 1; i < 20; i++) pow[i] = pow[i - 1] * 10;
		WriteLine(Calc(D));
	}
	long Calc(long D)
	{
		if (D % 9 != 0) return 0;
		D /= 9;
		ans = 0;
		for (var n = 1; n <= 18; n++) DFS(new int[n / 2], n, D, 0);
		return ans;
	}
	void DFS(int[] a, int n, long d, int i)
	{
		if (i == n / 2)
		{
			if (d != 0) return;
			var p = a[0] >= 0 ? 9L - a[0] : 10 + a[0];
			for (var j = 1; j < n / 2; j++) p *= 10 - Abs(a[j]);
			//Console.WriteLine($"n = {n}, a = ({string.Join(", ", a)})");
			ans += (n % 2 == 0 ? 1 : 10) * p;
		}
		else
		{
			var c = (pow[n - i - 1] - pow[i]) / 9;
			var t = d / c;
			if (d < 0 && d % c != 0) t--;
			//foreach (var z in new HashSet<long> { t, t + 1, t - 1, 9, -9, t + 2, t - 2 })
			foreach (var z in new HashSet<long> { t, t + 1 })
				if (-9 <= z && z <= 9)
				{
					a[i] = (int)z;
					DFS(a, n, d - z * c, i + 1);
				}
		}
	}
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l;
int main()
{
  cin>>n>>k;
  a=1; i=2;
while(i<=k)
    {
      a+=2;
      i++;
    }
  //cout<<a<<" ";
  if(a<=n) cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>

typedef unsigned long long ll;

int main()
{
  ll ab = 0;
  ll ac = 0;
  ll bc = 0;
  ll sum = 0;
  ll a, b, c;
  std::cin >> a >> b >> c;
  ab = a + b;
  ac = a + c;
  bc = b + c;
  if (ab < ac) sum = ab;
  else sum = ac;
  if (sum > bc) sum = bc;
  std::cout << sum << std::endl;

  return 0;
}


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

int gcd(int, int);

int gcd(int p, int q){
    if(p % q) return gcd(q, p % q);
    else return q;
}

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

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long
#define INF (int)1e7
using namespace std;

struct S{
    int p,t,i;
};

bool cmp(const S &left, const S &right){
    return left.p == right.p ? left.t == right.t ? left.i > right.i : left.t < right.t : left.p > right.p;
}
bool eq(const S &l, const S &r){
    return l.p == r.p && l.t == r.t;
}


signed main(){
    while(true){
        int M,T,P,R; cin >> M >> T >> P >> R;
        if(M == 0)break;
        vector<S> s(T);
        vector<vector<int> > c(T,vector<int>(P,0));
        for(int i = 0; i < T; i++){
            S temp = {0, 0, i+1};
            s[i] = temp;
        }

        for(int i = 0; i < R; i++){
            int m,t,p,j;
            t--;
            cin >> m >> t >> p >> j;
            if(j == 0){
                if(c[t-1][p-1] != 1){
                    s[t-1].p++;
                    s[t-1].t += m+c[t-1][p-1];
                    c[t-1][p-1] = 1;
                }
            }
            else{
                c[t-1][p-1] += 20;
            }
        }
        sort(ALL(s),cmp);
        cout << s[0].i;// << ":" << s[0].p << ":" << s[0].t;
        for(int i = 1; i < T; i++){
            if(eq(s[i-1],s[i])){
                cout << "=";
            }
            else{
                cout << ",";
            }
            cout << s[i].i;// << ":" << s[i].p << ":" << s[i].t;
        }
        cout << endl;
    }
                


    return 0;
}




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




int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	int x = -1, y = -1;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i] == s[i - 1]) {
			x = i , y = i + 1;
			break;
		}
	}
	for (int i = 1; i < s.size() - 1; ++i) {
		if (s[i - 1] == s[i + 1]) {
			x = i, y = i + 2;
			break;
		}
	}
	cout << x << " " << y;
	

}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

int main(void) {
	int N, x = 0, max = 0;
	int i;
	char S[101];

	i_cin(N);
	s_cin(S);

	for (i = 0; i < N; i++) {
		if (S[i] == 'I') x++;
		else x--;
		if (x >max) max=x;
	}

	i_cout(max);
	return 0;
}

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a[102],k=0,l=0,cnt=0,x,n;
    map<int,int>m;
    string s,s1;
    cin>>s>>s1;
    if(s[0]==s1[0]){l++;}
      if(s[1]==s1[1]){l++;}
        if(s[2]==s1[2]){l++;}
        cout<<l<<endl;


}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	int n;
	cin >> n;
	int x = n;
	while (x % 10 == 0) {
		x /= 10; 
	}
	if (x == 1) {
		cout << 10 << endl;
		return 0;
	}
	x = n;
	int ans = 0;
	while (x) {
		ans += x % 10;
		x /= 10;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };
    let K: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = S.iter()
        .map(|&c| if c == S[K - 1] {
            c.to_string()
        } else {
            "*".to_string()
        })
        .collect::<String>();

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


Measured memory_bytes: 4352
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD 1e9+7
#define SIZE (int)1e5+5
#define all(x) x.begin(),x.end()

#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back

#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

int main()
{
  IOfast;
 
  int q=1;
  //cin>>q;
  //  memset(dp,-1,sizeof(dp));
  while(q--)
  {
    int n,k;
    cin>>n>>k;
    vector<int64_t> arr(n),value(n);
    
    for(auto &item:arr) cin>>item;
    
    for(auto &item:value) item = UINT_MAX;
    
    value[0] = 0;
    
    for(int i= 1;i<n;i++)
    {   
        for(int j=i-1 ; i-j <=k && j>=0 ;j--)
           value[i] = min(abs(arr[i] - arr[j]) + value[j] , value[i]);
    } 
    cout<<value[n-1];
  }
  
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

#define NIL -1
#define MAX 100000

typedef struct Node{
  int parent,lf,rg;
}node;

node ttt[MAX];

int k, ddd[MAX], hhh[MAX];

void Dep(int u, int p){
  if(u==NIL) return;
  ddd[u]=p;
  Dep(ttt[u].lf,p+1);
  Dep(ttt[u].rg,p+1);
}

int Height(int u){
  int p1=0,p2=0;
  if(ttt[u].lf !=NIL){
    p1=Height(ttt[u].lf)+1;
  }
  if(ttt[u].rg !=NIL){
    p2=Height(ttt[u].rg)+1;
  }

  if(p1<p2)hhh[u]=p2;
  else hhh[u]=p1;
  return hhh[u];
}

int Sibling(int u){
  if(ttt[u].parent==NIL)return NIL;
  if(ttt[ttt[u].parent].lf!=u && ttt[ttt[u].parent].lf!=NIL)
    return ttt[ttt[u].parent].lf;
  if(ttt[ttt[u].parent].rg!=u && ttt[ttt[u].parent].rg!=NIL)
    return ttt[ttt[u].parent].rg;
  return NIL;
}

void Prin(int u){
  int count=0;
  printf("node %d: ", u);
  printf("parent = %d, ", ttt[u].parent);
  printf("sibling = %d, ", Sibling(u));
  if(ttt[u].lf!=NIL)count++;
  if(ttt[u].rg!=NIL)count++;
  printf("degree = %d, ", count);
  printf("depth = %d, ", ddd[u]);
  printf("height = %d, ", hhh[u]);
  if(ttt[u].parent==NIL){
    printf("root\n");
  }else if(ttt[u].lf==NIL && ttt[u].rg==NIL){
    printf("leaf\n");
  }else {
    printf("internal node\n");
  }
}

int main(){
  int v, l, r, root=0, i,n;
  scanf("%d", &n);
  for(i=0 ; i<n ; i++)ttt[i].parent=NIL;
  for(i=0 ; i<n ; i++){
    scanf("%d%d%d",&v, &l, &r);
    ttt[v].lf=l;
    ttt[v].rg=r;
    if(l!=NIL)ttt[l].parent=v;
    if(r!=NIL)ttt[r].parent=v;
  }
  for(i=0 ; i<n ; i++) if(ttt[i].parent==NIL) root=i;
  Dep(root, 0);
  Height(root);
  for(i=0 ; i<n ; i++)Prin(i);
  return 0;
}



Measured memory_bytes: 2048
import math
n,m=map(int,input().split())
if n==m+1 or m==n+1:
  print((math.factorial(n)*math.factorial(m))%(10**9+7))
elif n==m:
  print(((math.factorial(n)*math.factorial(m))*2)%(10**9+7))
else:
  print(0)

Measured memory_bytes: 5192
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 105
using namespace std;
bool debug=false;

int main(){
  int n;
  int coin[6]={500,100,50,10,5,1};
  while(cin>>n){
    if(n==0)break;
    n=1000-n;
    int cnt=0;
    for(int i=0;i<6;){
      if(n>=coin[i]){
	n-=coin[i];
	cnt++;
	//cout<<coin[i]<<endl;
      }else{
	i++;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<double> v(n);
  REP(i, n) cin >> v[i];
  SORT(v);
  double ans;
  REP(i, n) {
    v[i + 1] = (v[i] + v[i + 1]) / 2;
  }
  cout << v[n - 1] << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n; cin >> n;
    map<int, int> odd, even;
    rep(i, n){
        int x; cin >> x;
        if(i % 2 == 0){
            odd[x]++;
        }
        else{
            even[x]++;
        }
    }
    vector<pair<int, int> > v_o, v_e;
    for(auto& m: odd){
        v_o.push_back(make_pair(m.second, m.first));
    }
    for(auto& m: even){
        v_e.push_back(make_pair(m.second, m.first));
    }
    sort(all(v_o), greater<pair<int, int> >());
    sort(all(v_e), greater<pair<int, int> >());

    int ans;
    if(v_o[0].second != v_e[0].second){
        ans = n - v_o[0].first - v_e[0].first;
    }
    else{
        if(v_o.size() == 1 && v_e.size() == 1){
            ans = n / 2;
        }
        else if(v_o.size() == 1){
            ans = n / 2 - v_e[1].first;
        }
        else if(v_e.size() == 1){
            ans = n / 2 - v_o[1].first;
        }
        else{
            ans = min(n - v_o[1].first - v_e[0].first, n - v_o[0].first - v_e[1].first);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6140
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String u, nl = System.getProperty("line.separator");
		StringBuilder 
			p = new StringBuilder(1000),
		  	d = (new StringBuilder(100)).append("."),
		  	s = (new StringBuilder(100)).append("#"),
		  	k = new StringBuilder(100);
		Scanner r = new Scanner(System.in);
		int h, w, ww = 0x10;
		while (0 != (ww >>= 1)) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while (0 != ((h = r.nextInt()) | (w = r.nextInt()))) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww = d.length();
			}
			p.append(u = s.substring(0, w)).append(nl);
			k.setLength(0);
			k.append(d.substring(0, w)).append(nl)
			.replace(0, 1, "#").replace(w - 1, w, "#");
			h -= 2;
			while (0 != h--) {
				p.append(k);
			}
			p.append(u).append(nl).append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18388
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=1e6+9;
ll dp[N][2],ls;
string s;
ll F(int i,int carry){
    if (i==ls)
        return carry;
    if (dp[i][carry]!=-1)
        return dp[i][carry];
    int val=s[i]-'0'+carry;
    ll mn=1e9;
    if (val<=9)
    mn=min(mn,F(i+1,0)+val);
    mn=min(mn,F(i+1,1)+10-val);
    return dp[i][carry]=mn;
}
int main()
{
    FASTINOUT;
    cin>>s;
    reverse(s.begin(),s.end());
    ls=s.length();
    memset(dp,-1,sizeof dp);
    cout<<F(0,0);
    return 0;
}


Measured memory_bytes: 63900
#include<stdio.h>
int main(){
  int A[1000],i,N,j,v,k;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  for(k=0;k<N-1;k++)
    printf("%d ",A[k]);
  printf("%d\n",A[N-1]);
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<N-1;k++)
      printf("%d ",A[k]);
    printf("%d\n",A[N-1]);
  }

  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;

int main(int argc, char** argv) {

        int N;
        int tmp;
        priority_queue<int> que;
        int maxl;
        int sum=0;

        cin >> N;
        for(int cnt0=0; cnt0 < N; cnt0++){
                cin >> tmp;
                que.push(tmp);
        }
/*
        while(que.size()){
                cout << que.top();
                que.pop();
        }
*/
        maxl = que.top();
        que.pop();

        while(que.size()){
                sum +=  que.top();
                que.pop();
        }
        if(maxl < sum) cout << "Yes";
        else cout << "No";
        return 0;

}

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

int main()
{
    char k[15];
    int len,c = 0;

    scanf("%s",k);

    len = strlen(k);
    for (int i = 0; i < len; i++)
    {
        if (k[i] == 'o')
        {
            c ++;
        }
    }
    if (c + 15 - len >= 8)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    
    
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
char a[11];
int main()
{
	int i;
	cin>>a;
	for(i=0;i<strlen(a)-1;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
} 

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 300005;

char s[N];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int cnt = 0;
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (s[i] == 'B') cnt ++;
		else {
			ans += cnt;
		}
	} 
	cout << ans;


	return 0;
}


Measured memory_bytes: 384
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  A = readint()

  prod = 1

  for a in A
    if a==0
      println(0)
      return
    end
  end
  for a in A
    
    if prod >=  10^18÷a + 1
      println(-1)
      return
    end
    prod = prod * a
  end
  println(prod)
end

main()

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

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N+2, 0);
    vector<ll> B(M+2, 0);
    rep(i, N) cin >> A[i+1];
    rep(i, M) cin >> B[i+1];
    A[0] = 0;
    B[0] = 0;
    A[N+1] = 1001001001;
    B[M+1] = 1001001001;

    ll ia = 1;
    ll ib = 1;
    ll cnt = 0;
    ll sum = 0;

    while(sum <= K){
        sum += A[ia];
        ia++;
        cnt++;
    }
    sum -= A[ia-1];
    ia = ia - 2;
    cnt--;

    // cout << cnt << endl;

    // if(cnt == N){
        while(sum <= K){
            sum += B[ib];
            ib++;
            cnt++;
        }
        sum -= B[ib-1];
        ib = ib - 2;
        cnt--;

        if (cnt == N + M){
            cout << cnt << endl;
            return 0;
        }
    // }

    // cout << cnt << ia << ib << endl;

    ll ans = cnt;
    // ll Asum = sum;
    // ll Bsum = 0;
    // ib = 1;

    // // cout << ans << " " << ia << " " << Asum << " " << Bsum << endl;


    for(ll j = ia; j >= 1; j--){
        // cout << "j="  << j << endl;
        sum -= A[j];
        cnt--;
        // cout << cnt << endl;

        ib++;
        while(sum <= K){
            sum += B[ib];
            ib++;
            cnt++;
        }
        sum -= B[ib-1];
        ib = ib - 2;
        cnt--;
        // cout << cnt << endl;

        // Asum -= A[j];
        // cnt--;
        // Bsum = 0;
        // ib = 0;
        // while(Asum + Bsum<= K){
        //     Bsum += B[ib];
        //     ib++;
        //     // cnt++;
        // }
        // sum -= B[ib-1];
        // ib = ib - 2;
        // cnt--;
        // cnt = j + ib;
        // cout << cnt << endl;
        if (cnt > ans){
            ans = cnt;
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6404
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int num;
    int win_point = 3;
    int draw_point = 1;
    int taro_point = 0;
    int hanako_point = 0;
    string card_taro, card_hanako;

    cin >> num;
    for (int i = 0; i < num; ++i)
    {
        cin >> card_taro >> card_hanako;
        if (card_taro > card_hanako){
            taro_point += win_point;
        }else if(card_taro < card_hanako){
            hanako_point += win_point;
        }
        else{
            taro_point += draw_point;
            hanako_point += draw_point;
        }
    }
    cout << taro_point << " " << hanako_point << endl;
}


Measured memory_bytes: 3204
fn main(){
  let mut v: Vec<Vec<u32>> = vec![vec![0;331];11];
  let mut usd: Vec<bool> = vec![false; 10];
  
  comb(&mut v, &mut usd, 1, 0);
  
  loop {
    let mut buf = String::new();
    match std::io::stdin().read_line(&mut buf) {
      Ok(l) => {
        if l == 0 { break; }
        else {
          let t: Vec<usize> = buf.split_whitespace().map(|e| e.parse().unwrap()).collect();
          let n = t[0];
          let s = t[1];

          println!("{}", if s > 330 { 0 } else { v[n][s] });
        }
      },
      Err(_) => { println!("failed to read"); },
    }
  }
}

fn comb(v: &mut Vec<Vec<u32>>, usd: &mut Vec<bool>, i: usize, sm: usize) {
  if i < 11 {
    for k in 0 .. 10 {
      if !usd[k] {
        usd[k] = true;
        let nsm = sm + i * k;
        v[i][nsm] += 1;
        comb(v, usd, i+1, nsm);
        usd[k] = false;
      }
    }
  }
}



Measured memory_bytes: 1084
N = int(input())

max_div_cnt = 0
result = 1
for n in range(N):
  tmp = n + 1
  div_cnt = 0
  while tmp > 0:
    if tmp % 2 == 0:
      div_cnt += 1
      tmp //= 2
    else:
      break
  if div_cnt > max_div_cnt:
    max_div_cnt = div_cnt
    result = n + 1
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  int R,G,B,n; cin >> R >> G >> B >> n;
  int ans = 0;
  rep(r,n/R+1) rep(g,n/G+1) {
    if((n-R*r-G*g)%B == 0 && n-R*r-G*g >= 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll x;
    cin>>x;

    x -= 400;
    x /= 200;
    cout<<8-x<<endl;
}

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

struct UnionFind {
	vector<int> par;
	
	UnionFind(int n) : par(n) {
		for (int i = 0; i < n; i++) par[i] = i;
	}
	
	int root(int x) {
		return par[x] == x ? x : par[x] = root(par[x]);
	}
	
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) par[x] = y;
	}
	
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

struct Edge {
	int from, to, cost;
	bool operator <(const Edge &e) { return cost < e.cost; }
};

int main() {
	int n;
	cin >> n;
	vector<pii> x(n), y(n);
	rep(i, n) {
		int tx, ty;
		cin >> tx >> ty;
		x[i] = {tx, i};
		y[i] = {ty, i};
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	vector<Edge> edges;
	rep(i, n - 1) {
		int dx = x[i + 1].first - x[i].first;
		int dy = y[i + 1].first - y[i].first;
		edges.push_back({x[i].second, x[i + 1].second, dx});
		edges.push_back({y[i].second, y[i + 1].second, dy}); 
	}
	sort(edges.begin(), edges.end());
	UnionFind uf(n);
	ll ans = 0;
	for (auto a : edges) {
		if (!uf.same(a.from, a.to)) {
			uf.unite(a.from, a.to);
			ans += a.cost;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
using Double = long double;
#define PUTS(x) cout << (x) << endl;
int main() {
    std::cout << std::fixed << std::setprecision(20);
    Double n, m, d;
    cin >> n >> m >> d;
    if(d==0){
        PUTS((m-1)/n);
    } else {
        PUTS(2 * (m - 1) * (n - d) / (n * n));
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int R(vector<long>&v, long x){
  //x<=v[i]となる最小のiを返す
  if(x<=v[0])return 0;
  long l=0,r=v.size();
  while(r-l!=1){
    long z=(r+l)/2;
    if(x<=v[z])r=z;
    else l=z;
  }
  return r;
}
int L(vector<long>&v, long x){
  //v[i]<=xとなる最大のiを返す
  if(v[v.size()-1]<=x)return v.size()-1;
  long l=0,r=v.size();
  while(r-l!=1){
    long z=(r+l)/2;
    if(v[z]<=x)l=z;
    else r=z;
  }
  return l;
}



int main(){
  long A,B,Q;cin>>A>>B>>Q;
  vector<long>S(A+2),T(B+2);S[0]=-1e10;T[0]=-1e10;
  for(int i=0;i<A;i++)cin>>S[i+1];
  for(int i=0;i<B;i++)cin>>T[i+1];
  S[A+1]=2e10;T[B+1]=2e10;
  for(int i=0;i<Q;i++){
    long x;cin>>x;
    long LS=L(S,x),LT=L(T,x),RS=R(S,x),RT=R(T,x);
    
    vector<long>v={abs(S[LS]-x)+abs(T[L(T,S[LS])]-S[LS]),
                   abs(S[LS]-x)+abs(T[R(T,S[LS])]-S[LS]),
                   abs(T[LT]-x)+abs(S[L(S,T[LT])]-T[LT]),
                   abs(T[LT]-x)+abs(S[R(S,T[LT])]-T[LT]),
                   abs(S[RS]-x)+abs(T[L(T,S[RS])]-S[RS]),
                   abs(S[RS]-x)+abs(T[R(T,S[RS])]-S[RS]),
                   abs(T[RT]-x)+abs(S[L(S,T[RT])]-T[RT]),
                   abs(T[RT]-x)+abs(S[R(S,T[RT])]-T[RT])
                  };
    cout<<*min_element(v.begin(),v.end())<<endl;
    
  }
}

Measured memory_bytes: 2944
#import sys
#input = sys.stdin.buffer.readline
import collections

def main():
    N = int(input())
    INF = 10**9+7
    h = []
    prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
    for _ in range(N):
        s = str(input())
        num = 1
        for i in range(10):
            num *= prime[ord(s[i])-97]
        h.append(num)
        
    c = collections.Counter(h)
    T = list(c.values())
    ans = 0
    for use in T:
        ans += (use*(use-1))//2
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 17348
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <climits>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main()
{
    int student_num, checkpoint_num;
    cin >> student_num >> checkpoint_num;

    struct Point
    {
        int x;
        int y;
    };

    std::vector<Point> students = {};
    std::vector<Point> checkpoints = {};

    for(int i = 0; i < student_num; i++) {    
        Point point;
        cin >> point.x >> point.y;
        students.push_back(point);
    }

    for(int i = 0; i < checkpoint_num; i++) {    
        Point point;
        cin >> point.x >> point.y;
        checkpoints.push_back(point);
    }


    for(int i = 0; i < student_num; i++) {
        Point student_pos = students.at(i);
        int min_distance = INT_MAX;
        int min_index = INT_MAX;

        for(int j = 0; j < checkpoint_num; j++) {
            Point checkpoint = checkpoints.at(j);
            int distance = abs(student_pos.x - checkpoint.x) + abs(student_pos.y - checkpoint.y);
            
            if(distance < min_distance) {
                min_distance = distance;
                min_index = j;
            }
        }
        cout << min_index + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int a,b;
  cin>>a>>b;
  cout<< (a-1) + (int)(b >= a)<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

int main() {
  int N, i; cin >> N;
  vector<int> a(N);
  rep (i, N) cin >> a.at(i);
  sort(a.begin(), a.end());
  bool flag = true;
  for (i = 1; i < N; i++) {
    if (a.at(i-1) == a.at(i)) {
      flag = false;
      break;
    }
  }
  if (flag)
    puts("YES");
  else
    puts("NO");
  return 0;
}


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


int main() {
string S;
string T;
  int Ans=0;
  cin >> S >> T;
  
  for(int i=0; i < S.size(); i++){
    if(S.at(i) != T.at(i)){
      Ans++;
    }
  }
  
  cout << Ans;

}

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

struct RMQ{
 UL N;
 vector<UL> V;
 const UL Z=(1u<<31)-1;
 void init(UL n){
  N=1; while(N<n) N*=2;
  V.assign(N*2,Z);
 }
 void upd(UL p,UL v){
  UL i=N+p;
  V[i]=v;
  while(i!=1){
   i>>=1;
   V[i]=min(V[i<<1],V[(i<<1)+1]);
  }
 }
 UL query(UL l,UL r){
  UL ans=Z;
  l+=N; r+=N;
  while(l<r){
   if(l&1) ans=min(ans,V[l++]);
   if(r&1) ans=min(ans,V[--r]);
   l>>=1; r>>=1;
  }
  return ans;
 }
};

int main() {
 UL N,Q; scanf("%u%u",&N,&Q);
 RMQ G; G.init(N);
 rep(i,Q){
  UL c,x,y; scanf("%u%u%u",&c,&x,&y);
  if(c==0) G.upd(x,y);
  else if(c==1) printf("%u\n",G.query(x,y+1));
 }
 return 0;
}



Measured memory_bytes: 3892
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int r = scan.nextInt();
	int c = scan.nextInt();
	int[][] sheet = new int[r+1][c+1];
	for (int i = 0; i < r; i++) {
	    for (int j = 0; j < c; j++) {
		sheet[i][j] = scan.nextInt();
	    }
	}
	for (int i = 0; i < r; i++) {
	    for (int j = 0; j < c; j++) {
		sheet[i][c] += sheet[i][j];
		sheet[r][j] += sheet[i][j];
	    }
	}
	for (int i = 0; i < c; i++) {
	    sheet[r][c] += sheet[r][i];
	}
	for (int i = 0; i < r + 1; i++) {
	    System.out.print(sheet[i][0]);
	    for (int j = 1; j < c + 1; j++) {
		System.out.print(" " + sheet[i][j]);
	    }
	    System.out.println();
	}
    }
}

Measured memory_bytes: 41940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(float i=0;i<=50000;i++){
        if(n==int(i*1.08)){
            cout<<i<<endl;
            break;
        }
        if(i==50000||n<int(i*1.08)){
            cout << ":(" <<endl;
            break;
        }
    }
    return 0;
}

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

int main()
{
	int m, r, f;
	char Grade;

	while (1){
		cin >> m >> r >> f;
		if (m == -1 && r == -1 && f == -1)break;
		else{
			if (m == -1 || r == -1)cout << 'F' << endl;
			else if (m + r >= 80)cout << 'A' << endl;
			else if (m + r >= 65)cout << 'B' << endl;
			else if (m + r >= 50)cout << 'C' << endl;
			else if (m + r >= 30){
				if (f >= 50)cout << 'C' << endl;
				else cout << 'D' << endl;
			}
			else cout << 'F' << endl;
		}
	}
	return 0;
}




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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll n,m,k;cin >> n >> m >> k;
    vector<ll> a(n);
    vector<ll> ra(n);
    ll temp = 0;
    rep(i,n)
    {
        cin >> a[i];
        temp += a[i];
        ra[i] = temp;
    }
    temp = 0;
    vector<ll> b(m);
    vector<ll> rb(m);
    rep(i, m)
    {
        cin >> b[i];
        temp += b[i];
        rb[i] = temp;
    }
    ll ans = upper_bound(all(rb), k) - rb.begin();

    rep(i,n)
    {
        if(k-ra[i]<0)
        {
            continue;
        }
        ll bi = upper_bound(all(rb), k-ra[i])-rb.begin();
        ans = max(ans, bi + (ll)i + (ll)1);
        
    }
    cout << ans << endl;

}

Measured memory_bytes: 9568
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n,m;
    cin >> n >> m;
    vector< vector< int > > field(n+1,vector<int>(m+1,0));
    rep(i,n){
        rep(j,m){
            cin >> field[i][j];
        }
    }
    rep(i,n){
        rep(j,m){
            field[i][m] += field[i][j];
        }
    }
    rep(i,m){
        rep(j,n){
            field[n][i] += field[j][i];
        }
    }
    rep(i,n){
        field[n][m] += field[i][m];
    }
    rep(i,n+1){
        rep(j,m+1){
            cout << field[i][j] << (j == m ? '\n' : ' ');
        }
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l, r;
    cin >> l >> r;
    if (r - l >= 2019) cout << 0 << endl;
    else {
        ll Min = INF;

        REP(i, l, r + 1) REP(j, i + 1, r + 1) {
            Min = min(Min, i * j % 2019);
        }
        cout << Min << endl;
    }
    return 0;
}


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

const lli mod = 1e9+7;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;

  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

int main(void){
    lli s;
    cin >> s;
    if(s < 3){
        cout << 0 << endl;
        return 0;
    }
    Combination<modint> comb(2020);
    modint ans = 0;
    for(int i = 1; i <= s/3; i++){
        ans += comb.C(s-2*i-1, i-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int L; scanf("%d", &L);
    int n = 0; while((1 << (n+1)) <= L) n++;
    int N = (1 << n) - 1; int U = L - N - 1;
    int l = L;
    int m = 2 * n + __builtin_popcount(U);
    printf("%d %d\n", n+1, m);
    for(int x = 0; x + 1 <= n; ++x) printf("%d %d 0\n%d %d %d\n", x+1, x+2, x+1, x+2, (1 << x));
    for(int d = n; d >= 0; --d) if((U >> d) & 1){
        l -= (1 << d);
        printf("%d %d %d\n", d+1, n+1, l);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define FB(i,a,b) for(ll i=a;i>=b;i--)
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SC second
#define FS first
using namespace std;

ll A[202];

 int main()
 {
	ll n,x;
	scanf("%lld%lld",&n,&x);
	F(i,1,n) scanf("%lld",&A[i]);
	sort(A+1,A+1+n);
	F(i,1,n)
	{
		x-=A[i];
		if(x<0)
		{
			printf("%lld\n",i-1);
			return 0;
		}
	}

	if(x==0) printf("%lld\n",n);
	else printf("%lld\n",n-1);
 }



Measured memory_bytes: 256
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = map(int, input().split())

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    long N;
    long min_num = 0;
    long num1, num2;

    cin >> N;
    min_num = 1 + N;
    int end_point = sqrt(N);
    for(int i = 2; i <= end_point; i++){
        if(N % i == 0){
            num1 = N / i;
            num2 = i;
            if(min_num > (num1 + num2)){
                min_num = num1 + num2;
            } 
        }
    }
    cout << min_num - 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,ans=0;
int main(){
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x) ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

int main()
{
	int n;
	cin >> n;
	double ans = 1.0 - (double)(n / 2) / (double)n;

	printf("%f", ans);

	return 0;
}




Measured memory_bytes: 256