akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

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

	int n, ans = 0;
	for (int x = 1; x <= 9; x++) {
		for (int y = 0; y <= 9; y++) {
			for (int z = 0; z <= 9; z++) {
				n = 10001 * x + 1010 * y + 100 * z;
				if (n >= a && n <= b) {
					ans++;
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  int c1 = 0, c2 = 0;

  REP(i, n) {
    if ((i + 1) % k == 0) c1++;
  }
  if (k % 2 == 0) {
    REP(i, n) {
      if ((i + 1) % k == k / 2) c2++;
    }
  }
  ans += (ll)pow(c1, 3);
  ans += (ll)pow(c2, 3);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[100000]={},n,i,x=1,m;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    i=1;
    m=n;
    while(n--)
    {
        x=a[i];
        i=x;
        if(x==2)
            break;
    }
    if(n<=0)
        printf("-1\n");
    else
        printf("%d\n",m-n);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  ll a,b,c,e,f,g;
  cin >> a >> b >> c >> e >> f >> g;
  ll ans = INF,sugar = 0;
  ll A,B,C,D;
  for(int i = 0;(A = i * 100 * a) <= g;i++){
    for(int j = 0;(B = j * 100 * b) <= g - A;j++){
      for(int k = 0;(C = k * c) <= g - A - B;k++){
        for(int p = 0;(D = p * e) <= g - A - B - C;p++){
          // printf("%lld %lld %lld %lld\n",A,B,C,D);
          n = A + B + C + D;
          if(n > g)continue;
          if((i * a + j * b) * f < C + D)continue;
          if(n * sugar >= ans * (C + D))continue;
          ans = n;
          sugar = C + D;
        }
      }
    }
  }
  cout << ((ans == INF) ? 100 * a : ans) << " " << sugar << endl;
  return 0;
}

Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var one = nextStrArray();
  var s = one[0];
  var t = one[1];
  var output = "";
  for(var i = 0; i < N; i++){
    output += s[i] + t[i];
  }
  myout(output);
}


Measured memory_bytes: 29988
use proconio::marker::*;
use proconio::*;

type Link = Option<Box<Node>>;

const F: usize = 26;

#[derive(Default)]
struct Node {
    cnt: [u32; F],
    next: [Link; F],
}

impl Node {
    fn insert(&mut self, s: &[u8]) -> (usize, usize) {
        if s.is_empty() {
            return (0, 0);
        }
        let k = (s[0] - b'a') as usize;
        let (mut bit, mut ans) = self.next[k]
            .get_or_insert_with(|| Box::new(Node::default()))
            .insert(&s[1..]);
        if s.len() == 1 {
            ans += self.cnt[k] as usize;
        }
        bit |= 1 << k;
        for (i, c) in self.cnt.iter_mut().enumerate() {
            *c += (bit >> i & 1) as u32;
        }
        (bit, ans)
    }
}

fn run() {
    input! {
        n: usize,
        mut s: [Bytes; n],
    }
    let mut root = Box::new(Node::default());
    s.sort_by_key(|s| s.len());
    let mut ans = 0;
    for s in s.iter_mut().rev() {
        s.reverse();
        ans += root.insert(s).1;
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = (1 << 28) + (1 << 27);
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| run()).unwrap().join().unwrap();
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<bool> AC(N, false);
    vector<int> WA(N, 0);
    for (int i = 0; i < M; ++i) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (s == "AC") {
            if (!AC[p]) AC[p] = true;
        }
        else {
            if (!AC[p]) WA[p]++;
        }
    }
    int ac, wa;
    ac = wa = 0;
    for (int i = 0; i < N; ++i) ac += (AC[i] ? 1 : 0);
    for (int i = 0; i < N; ++i) wa += (AC[i] ? WA[i] : 0);
    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 640
#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;
	long long M;
	cin >> N >>M;
	vector<int> A(N);
	for (int n = 0;n < N;++n) {
		cin >> A[n];
	}
	sort(A.begin(), A.end());
	int l = 0;
	int r = 200005;
	vector<long long>S(N + 1);
	for (int n = 0;n<N;++n) {
		S[n + 1] = (long long)A[n] + S[n];
	}

	auto calc = [&](int x) {
		ll tot = 0, num = 0;
		rep(i, N) {
			int j = lower_bound(A.begin(), A.end(), x - A[i]) - A.begin();
			num += N - j;
			tot += S[N] - S[j];
			tot += A[i] * ll(N - j);
		}
		return make_pair(tot, num);
	};

	while (l + 1 < r) {
		long long num = 0;
		int c = (l+r) / 2;
		/*for (int n = 0;n < N;++n) {
			int j = lower_bound(A.begin(), A.end(), c - A[n]) - A.begin(); 
			num += (long long)(N - j);
		}
		if (num >= M) {
			l = c;
		}
		else {
			r = c;
		}*/
		if (calc(c).second >= M) l = c; else r = c;
	}
	long long ans = 0;
	long long num = 0; 
	for (int n = 0; n < N; ++n) {
		int j = lower_bound(A.begin(), A.end(), l - A[n]) - A.begin();
		num += (long long)(N - j);
		ans += (long long)(S[N] - S[j]);
		ans += (long long)(A[n]) * (long long)(N - j);
	}

	ans -= ((num-M)*(long long)l);
	cout << ans <<endl;
	/*auto p = calc(l);
	ll ans = p.first;
	ans -= (p.second - M)*l;
	cout << ans << endl;*/
	return 0;
}	

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

int main() {
  int N, p = 0;
  cin >> N;
  
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    p += (S == "Y");
  }
  
  if (p > 0) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

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

int main(){
    int n,x;

    while(1){
        int ans=0;

        cin>>n>>x;
        if(n==0&&x==0)break;

        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    //cout<<"I="<<i<<" "<<"J="<<j<<" "<<"K="<<k<<" ";
                    if(i+j+k==x)ans++;
                    //cout<<"ANS="<<ans<<endl;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];

    unordered_map<int,int> l,r;

    ll ans=0;

    rep(i,n){
        l[i+a[i]]++;
        r[i-a[i]]++;
        ans+=l[i-a[i]];
    }

    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 27328
n = int(input())
lis = list(map(str,input().split()))
li = lis[::2]
l = lis[1::2]

if n % 2 == 0:
  l = l[::-1]
  ans = l+li
  print(" ".join(ans))
else:
  li = li[::-1]
  ans = li+l
  print(" ".join(ans))


Measured memory_bytes: 27384
#include <algorithm>
#include <cstdio>
typedef long long lld;
const int MAXA = 1e9+5;
const int MAXN = 3005;
const lld INFN = 1LL * MAXA * MAXN;
lld dp[MAXN][MAXN];
int  A[MAXN];
int N;

void init() {
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      dp[i][j] = INFN;
    }
  }
}

// dp[l][r] = value of X - Y using elements A[l, r]

lld dfs(int l, int r) {
  if (l > r) return 0;
  if (dp[l][r] != INFN) {
    return dp[l][r];
  }
  return dp[l][r] = std::max(
    A[l] - dfs(l+1, r),
    A[r] - dfs(l, r-1)
  );
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
  }
  init();
  printf("%lld\n", dfs(1, N));
  return 0;
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll res=0;
    for(int bit=0; bit<(1<<(n-1)); ++bit){
        ll tmp=0;
        for(int i=0; i<n-1; ++i){
            tmp*=10;
            tmp+=s[i]-'0';
            if(bit&(1<<i))res+=tmp,tmp=0;
        }
        tmp*=10;
        tmp+=s.back()-'0';
        res+=tmp;
    }
    cout<<res<<endl;
    return 0;
}

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

int main()
{
    string s;
    int n,k;
    cin >> n >> k;
    cin >> s;
    s[k-1]+=32;
    for(int i=0;i<s.size();i++)
    {
            cout << s[i];
    }
    return 0;
}


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

int main(){
  int a[1000],b[1000];
  int p[1000000];
  int n,tmp,ans;

  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i] >> b[i];
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(b[i] > b[j]){
	swap(a[i],a[j]);
	swap(b[i],b[j]);
      }
    }
  }

  p[0] = 0;
  for(int i=1;i<=b[n-1];i++)p[i] = -1;

  for(int i=0;i<n;i++){
    for(int j=b[i]-a[i];j>=0;j--){
      if(p[j]>=0){
	if(p[j+a[i]]<p[j]+1)p[j+a[i]] = p[j]+1;
      } 
    }
  }

  ans = 0;
  for(int i=0;i<=b[n-1];i++){
    if(ans<p[i])ans = p[i];
  }

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

Measured memory_bytes: 0
function uniq(array) {
  const uniquedArray = [];
  for (var elem of array) {
    if (uniquedArray.indexOf(elem) < 0)
      uniquedArray.push(elem);
  }
  return uniquedArray;
}

function main(input){
  const lines = input.split('\n');
  const S = lines[0];
  const K = parseInt(lines[1]);

  var part_strings = [];
  for(var i=0;i<S.length;i++){
    for(var j=0;j<K;j++){
      part_strings.push(S.slice(i,i+j+1));
    }
  }
//  console.log(part_strings);
//  console.log(part_strings.length);

  part_strings = uniq(part_strings);

//  console.log(part_strings);
//  console.log(part_strings.length);


  var result_array = [];
  for(var i=0;i<K;i++){
    var current_min_str = '';
    for(var j=0;j<part_strings.length;j++){
      var current_str = part_strings[j];
      if(current_min_str=='' && (result_array.indexOf(current_str) < 0)){current_min_str = current_str;}

      if((current_str < current_min_str) && (result_array.indexOf(current_str) < 0)){
        current_min_str = current_str;
      }
    }
    result_array.push(current_min_str);
  }

//  console.log(result_array);
  console.log(result_array[result_array.length-1]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 10608
import math

while True:
    n = int(input())
    if n == 0: break;

    a = str(math.factorial(n))
    a = a[::-1]
    ans = 0

    for i in range(len(a)):
        if a[i] == '0':
            ans += 1
        else:
            break

    print(ans)

Measured memory_bytes: 7840
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        final long N = scan.nextLong();
        scan.close();

        System.out.println(BigInteger.valueOf(N - 1).multiply(BigInteger.valueOf(N)).divide(BigInteger.valueOf(2)).toString());
    }

}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            bool s_is_alphabet = Regex.IsMatch(s, @"^[a-z]+$");
            bool t_is_alphabet = Regex.IsMatch(t, @"^[a-z]+$");

            bool ans = false;
            if(s_is_alphabet && t_is_alphabet)
            {
                if(1 <= s.Length && s.Length <= 10 && t.Length == s.Length + 1)
                {
                    if (s == t.Substring(0, t.Length - 1))
                    {
                        ans = true;
                    }
                }
            }
            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 26804
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
c = 0
x = []
for i in range(2*(n+1)):
    if c%2==0:
        c+=1
        continue
    val = l[c]
    x.append(val)
    c+=1
x=x[:-1]
print(sum(x))

Measured memory_bytes: 42712
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var _S = cin.Read;
            var S = _S.ToCharArray();
            var left = 0;
            var right = 0;
            for(int i = 0; i < N; i++)
            {
                if(S[i] == '(')
                {
                    right++;
                }

                if(S[i] == ')')
                {
                    if(right > 0)
                    {
                        right--;
                    }
                    else
                    {
                        left++;
                    }
                }
            }
            for (int i = 0; i < left; i++) Write("(");
            Write(S);
            for (int i = 0; i < right; i++) Write(")");
            WriteLine("");
        }
        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
using namespace std;

int main(){

    int X;
    int res = 0;
    int tmp;
    cin >> X;
    
    tmp = X / 500;
    
    res += tmp*1000;
    X -= tmp*500;

    tmp = X/5;
    res += tmp*5;


    cout << res;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n)  cin >> vec[i];
  int i = 1; // 今現在どのボタンを押しているか
  int sum = 0; // ボタンを押した回数
  
  while (i != 2 && sum <= n) {
    sum++;
    i = vec[i-1];
  }
  if (i == 2)  cout << sum << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int N, K; cin >> N >> K;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  sort(H.begin(), H.end());
  long long ans = 0;
  for (int i = 0; i < N - K; i++) ans += H[i];

  cout << ans << endl;
}


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

int main(void) {
  ll x;
  cin >> x;
  ll cnt=0;
  cnt += x/11*2;
  x -= x/11*11;
  if(x > 6) cnt+=2;
  else if(x > 0) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
	using namespace std;
	#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
	#define ll long long int


	int main()
	{
		FAST;
		//ll testcase;
		//cin>>testcase;
		//for(ll t=0;t<testcase;t++)
		{
			//use long long
			//donot memeset other than 0 or 1 or -1
			//segmentation fault-> check for uninitialized global variable or out of bounds
			//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
			//dont rush to writing code think through the logic	
			char c;
			cin>>c;
			if((int)c>=97)
			{
				cout<<"a\n";
			}
			else
			{
				cout<<"A\n";
			}
			
			
			
			
			
			
		}
		return 0;
	}



































Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string pre;
  string suff="on";
  int rem=n%10;
  if(rem==2 or rem==4 or rem==5 or rem==7 or rem==9) pre="h";
  else if(rem==0 or rem==1 or rem==6 or rem==8) pre="p";
  else pre="b";
  cout<<pre+suff<<endl;
  
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>

using namespace std;

int n, a[100000];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n);
	if (n == 2) {
		printf("%d %d\n", a[1], a[0]);
		return 0;
	}
	int lo = 0, hi = n - 2;
	if (a[lo] >= (a[n - 1] + 1) / 2) {
		printf("%d %d\n", a[n - 1], a[lo]);
		return 0;
	}
	if (a[hi] <= (a[n - 1] + 1) / 2) {
		printf("%d %d\n", a[n - 1], a[hi]);
		return 0;
	}
	while (lo + 1 < hi) {
		int mid = (lo + hi) / 2;
		if (a[mid] <= (a[n - 1] + 1) / 2) lo = mid;
		else hi = mid;
	}
	if ((a[n - 1] + 1) / 2 - a[lo] > a[hi] - (a[n - 1] + 1) / 2) lo = hi;
	printf("%d %d\n", a[n - 1], a[lo]);
	return 0;
}

Measured memory_bytes: 512
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        string s;
        cin >> s;
        for(int i = 0;  i < s.size(); i++)
            cout << 'x' ;
        
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> matrix(H);
for (int i = 0; i < H; ++i) cin >> matrix[i];
string ans = ""; 

for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
                int bomb = 0;
                for (int i = -1; i < 2; ++i) {
                        if (0 <= h - 1 and 0 <= w + i and w + i < W) {
                                if (matrix[h - 1][w + i] == '#') {
                                        ++bomb;
                                }   
                        }   
                        if (h + 1 < H and 0 <= w + i and w + i < W) {
                                if (matrix[h + 1][w + i] == '#') {
                                        ++bomb;
                                }   
                        }   
                }   
                for (int i = -1; i < 2; i += 2){ 
                        if (0 <= w + 1 and w + i < W) {
                                if (matrix[h][w + i] == '#') {
                                        ++bomb;
                                }   
                        }   
                }   

                if (matrix[h][w] == '#') {
                        ans += "#";
                } else {
                        ans += to_string(bomb);
                }   
                if (W - 1 > 0) {
                        if ( w % (W - 1) == 0 and w != 0) {
                                ans += "\n";
                        }   
                } else {
                                ans += "\n";
                }
        }
}
cout << ans << endl;
}

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


int main() {
const ll INF = 100100100100100100;

ll N,M,X, cost = 0,ans = INF;
ll A[12][12];
ll al[12];
ll C[12];
cin >> N >> M >> X;
rep(i,N) {
  cin >> C[i]; 
  rep(j,M) cin >> A[i][j];
}

rep(s,1<<N){
  rep(i,12) al[i] =0;
  cost = 0; 
  rep(i,N){
    if(s>>i&1){
      cost += C[i];
      rep(j,M) al[j] +=A[i][j];

    }

  }
  bool ok = true;
  rep(i,M) if(al[i]<X) ok = false;
  if(ok) ans = min(ans,cost);

} 
if(ans == INF) cout << -1 << endl;
else cout << ans << endl;
return 0;
}

Measured memory_bytes: 3636
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n; cin >> n;
  vector<ll> A(n);
  list<ll> B;
  loop(i,0,n) cin >> A[i];
  loop(i,0,n) {
    if (i%2==0) {
      B.push_back(A[i]);
    } else {
      B.push_front(A[i]);
    }
  }
  if (n%2==1) {
    reverse(B.begin(), B.end());
  }
  for (auto it = B.begin(); it != B.end(); it++) {
    cout << *it << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 11140
#include<bits/stdc++.h>
int n, h, ans, m;
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &h);
        if(m <= h){
            ans++; m = h;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string a, b;
  int INPUT_NUM;
  double CEIL_NUM;
  double FLOOR_NUM;
  cin >> a >> b;
  INPUT_NUM = stoi(a + b);
  //整数に切り捨て
  CEIL_NUM = ceil(sqrt(INPUT_NUM));
  //整数に切り上げ
  FLOOR_NUM = floor(sqrt(INPUT_NUM));
  
  
  // INPUT_NUMが平方数であればsqrt(INPUT_NUM)(平方根)が整数になる
  if(CEIL_NUM == FLOOR_NUM)
  {
    cout << "Yes" << endl;
  }
  else
  {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()

	cnt := 0
	for i := 1; i <= n; i++ {
		len := len(strconv.Itoa(i))
		if len%2 == 1 {
			cnt++
		}
	}

	fmt.Println(cnt)
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// tmp := 200001
	// sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, nn, i, j, k, MOD = 1000000007, x;
	cin >> n;
	vector<vector<bool>> v(n, vector<bool>(n));
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cin >> x;
			v[i][j] = (x == 1);
		}
	}

	vector<vector<int>> plist(n + 1);
	nn = 1 << n;
	for (i = 0; i < nn; i++) {
		// calculate pop count
		x = 0;
		for (j = 0; j < n; j++) {
			if ((1 << j) & i) x++;
		}
		plist[x].push_back(i);
	}

	vector<long long> dp(nn, 0);
	dp[0] = 1;
	for (i = 0; i < n; i++) {
		for (auto p : plist[i]) {
			for (k = 0; k < n; k++) {
				if (!((1 << k) & p) && (v[i][k])) dp[p + (1 << k)] = (dp[p + (1 << k)] + dp[p]) % MOD;
			}

		}
	}

	cout << dp[nn - 1] << "\n";

	return 0;
}





Measured memory_bytes: 26044
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll n;



    vector<pair<ll,ll>>p;
void fs(ll a){
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        p.emplace_back(i,cnt);
    }
    return;
}


ll di[]={1,0,-1,0};
ll dj[]={0,-1,0,1};
int main(){
   int n;
   cin>>n;
    long long int a[n],ans=0,i;
    int mod=1000000007;
    long long int sum=0;
 
    for( i = 0 ; i < n ; i++ ){
            cin>>a[i];
        sum = sum + a[i];
    }
    for( i = 0 ; i < n ; i++ ){
        sum = sum - a[i];
 
        ans+=(sum%mod * a[i]%mod)%mod;
    }
    cout<<ans%mod;
 
    return 0;
}
 




Measured memory_bytes: 5156
A = 3.times.map { gets.split.map(&:to_i) }
N = gets.to_i
b = N.times.map { gets.to_i }

# マーク配列
M = [[false,false,false],[false,false,false],[false,false,false]]

# マーキング
b.each do |i|
  (0..2).each do |j|
    (0..2).each do |k|
      if A[j][k] == i
        M[j][k] = true
      end
    end
  end
end

# ビンゴ判定
if (M[0][0] && M[0][1] && M[0][2]) ||
  (M[1][0] && M[1][1] && M[1][2]) ||
  (M[2][0] && M[2][1] && M[2][2]) ||
  (M[0][0] && M[1][0] && M[2][0]) ||
  (M[0][1] && M[1][1] && M[2][1]) ||
  (M[0][2] && M[1][2] && M[2][2]) ||
  (M[0][0] && M[1][1] && M[2][2]) ||
  (M[0][2] && M[1][1] && M[2][0])
  puts 'Yes'
else
  puts 'No'
end

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

int main()
{
	int n;
	int a[7] = { 1, 0, 0, 0, 0, 0, 0 };
	string s;

	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		int b, c, d, e, f, g, h;
		b = a[0];
		c = a[1];
		d = a[2];
		e = a[3];
		f = a[4];
		g = a[5];
		h = a[6];

		if (s[i] == 'J') {
			a[0] = (b + e + g + h) % 10007;
			a[1] = 0;
			a[2] = 0;
			a[3] = (b + c + e + f + g + h) % 10007;
			a[4] = 0;
			a[5] = (b + d + e + f + g + h) % 10007;
			a[6] = (b + c + d + e + f + g + h) % 10007;;
		}
		else if (s[i] == 'O') {
			a[0] = 0;
			a[1] = (c + e + f + h) % 10007;
			a[2] = 0;
			a[3] = (b + c + e + f + g + h) % 10007;
			a[4] = (c + d + e + f + g + h) % 10007;
			a[5] = 0;
			a[6] = (b + c + d + e + f + g + h) % 10007;;
		}
		else if (s[i] == 'I') {
			a[0] = 0;
			a[1] = 0;
			a[2] = (d + f + g + h) % 10007;
			a[3] = 0;
			a[4] = (c + d + e + f + g + h) % 10007;
			a[5] = (b + d + e + f + g + h) % 10007;
			a[6] = (b + c + d + e + f + g + h) % 10007;;
		}
	}

	int tt = 0;
	for (int i = 0; i < 7; i++)
		tt = (tt + a[i]) % 10007;

	cout << tt << endl;

	return 0;
}



Measured memory_bytes: 3232
v,e,r=map(int,input().split())
d=[float("INF")]*v
edges=[[] for i in range(v)]
for i in range(e):
    a,*s=map(int,input().split())
    edges[a].append(s)
d[r]=0
from collections import deque

#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
for i in range(v+2):
    f=False
    used=set()
    dq=deque([r])
    while dq:
        a=dq.popleft()
        for to,c in edges[a]:
            if d[to]>c+d[a]:
                f=True
                d[to]=c+d[a]
            if to not in used:dq.append(to);used.add(to)
    if i==v:print("NEGATIVE CYCLE");exit()
    if f:continue
    break
for i in d:
    print("INF" if i==float("INF") else i)


Measured memory_bytes: 6540
def main():
	maximum = 0
	global h, w
	h, w = map(int, input().split())
	street = [[None for i in range(w)] for j in range(h)]
	for y in range(h):
		line = input()
		for x, z in enumerate(line):
			street[y][x] = True if z=="." else False
	for y in range(h):
		for x in range(w):
			if get(x, y, street):
				r = bfs(x, y, [i[::] for i in street])
				# print(f"x: {x} and y: {y} and r: {r} and max: {maximum}")
				# print(street)
				maximum = max(maximum, r)
	print(maximum)
	return		

def get(x, y, l):
	return l[y][x]

def setter(x, y, z, l):
	l[y][x] = z

def bfs(x, y, visited):
	queue = [(x, y, 0)]
	maximum = 0
	setter(x, y, False, visited)
	for x, y, d in queue:
		if x>0 and get(x-1, y, visited):
			queue.append((x-1, y, d+1))
			setter(x-1, y, False, visited)
		if x<w-1 and get(x+1, y, visited):
			queue.append((x+1, y, d+1))
			setter(x+1, y, False, visited)
		if y>0 and get(x, y-1, visited):
			queue.append((x, y-1, d+1))
			setter(x, y-1, False, visited)
		if y<h-1 and get(x, y+1, visited):
			queue.append((x, y+1, d+1))
			setter(x, y+1, False, visited)
		maximum = max(maximum, d)
	return maximum



main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vi;
vi deg;
vi arr;
vector<vi> AdjList;
int n;
void dfs(int s, int p=-1) {
	int sum=0;
	int maxx=0;
	for(int u: AdjList[s]) {
		if(u==p) continue;
		if(u!=p) dfs(u,s);
		maxx=max(maxx,arr[u]);
		sum+=arr[u];
	}
	int able=min(sum/2,sum-maxx);
	if(deg[s]==1) return;
	if(arr[s]>sum) {
		cout<<"NO";
		exit(0);
	}
	if(sum-arr[s]>able&&deg[s]>1) {
		cout<<"NO";
		exit(0);
	}
	arr[s]=2*arr[s]-sum;
	if(arr[s]<0) {
		cout<<"NO";
		exit(0);
	}
} 
signed main() {
	cin>>n;
	deg.assign(n+1,0);
	arr.assign(n+1,0);
	AdjList.assign(n+1,vi());
	for(int i=1 ; i<=n ; i++) {
		cin>>arr[i];
	}
	if(n==2) {
		if(arr[1]!=arr[2]) {
			cout<<"NO";
			return 0;
		}
		else {
			cout<<"YES";
			return 0;
		}
	}
	for(int i=1 ; i<n ; i++) {
		int u,v;
		cin>>u>>v;
		AdjList[u].push_back(v);
		AdjList[v].push_back(u);
		deg[u]++; deg[v]++;
	}
	for(int i=1 ; i<=n ; i++) {
		if(deg[i]!=1) {
			dfs(i);
			if(arr[i]!=0) {
				cout<<"NO";
				return 0;
			}
			cout<<"YES";
			return 0;
		}
	}
}

Measured memory_bytes: 18124
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

A = sorted(ab[0] for ab in AB)
B = sorted(ab[1] for ab in AB)

N2 = N//2
if N%2 == 1:
    print(B[N2] - A[N2] +1)
else:
    print((B[N2] + B[N2-1]) - (A[N2] + A[N2-1])+1)




Measured memory_bytes: 39936
s = str(input())
  
if s == 'SAT':
    print('1')
elif s == 'SUN':
    print('7')
elif s == 'MON':
    print('6')
elif s == 'TUE':
    print('5')
elif s == 'WED':
    print('4')
elif s == 'THU':
    print('3')
elif s == 'FRI':
    print('2')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define INF (int)1e9+4
#define INFL (ll)1e18+4
#define md (int)1e9+7
#define mx 10000000  //use fixed<<setprecion
#define mk make_pair
#define pi pair<int,int>
#define ss second
#define ff first
#define pb emplace_back
#define onell(x) __builtin_popcountll(x)
#define one(x) __builtin_popcount(x)
#define maxi(a) *max_element(a.begin(),a.end());
#define mini(a) *min_element(a.begin(),a.end());
#define all(s) s.begin(),s.end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, a) for (auto& x: a)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sz(x) ((long long)x.size())
#define mez(s) memset(s,0,sizeof s)
#define mex(s) memset(s,-1,sizeof s)
#define metr(s) memset(s,true, sizeof s)
typedef vector<int> vi;
typedef vector<ll>vl;
typedef map<int,int> mp;
typedef queue<int> que;
typedef vector<pi> vp;
void solve(){
int n=0,x=0,y=0,z=0,m=0,k=0;ll ans=0;
cin>>x>>y>>z;
if(y*z>=x)cout<<"Yes\n";
else cout<<"No\n";
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
  	solve();
  }
  return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] li = new long[n];
        for(int i = 0; i < n; i++){
            li[i] = sc.nextLong();
            if(i != 0){
                li[i] += li[i-1];
            }
        }
        long ans = Long.MAX_VALUE;
        for(int i = 1; i < n; i++){
            ans = Math.min(ans,Math.abs(li[n-1]-li[i-1]-li[i-1]));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 67872
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define MOD 1000000007ll
using namespace __gnu_pbds;
using namespace std;

int n,sz[5010],g[5010],dp[5010][5010],f[5010];
vector<int> v[5010];

inline void dfs(int x,int pr)
{
	sz[x]=1;
	dp[x][1]=1ll;
	for(int i=0;i<v[x].size();i++) if(v[x][i]!=pr){
		int u=v[x][i];
		dfs(u,x);
		for(int j=1;j<=sz[x]+sz[u];j++) f[j]=0ll;
		for(int j=1;j<=sz[x];j++){
			for(int k=0;k<=sz[u];k++){
				f[j+k]=(f[j+k]+dp[x][j]*dp[u][k])%MOD;
			}
		}
		sz[x]+=sz[u];
		for(int j=1;j<=sz[x];j++) dp[x][j]=f[j];
	}
	for(int i=2;i<=sz[x];i++) dp[x][0]=(dp[x][0]+MOD-(dp[x][i]*g[i])%MOD)%MOD;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	g[0]=1ll;
	for(int i=2;i<=n;i+=2){
		g[i]=(g[i-2]*(i-1))%MOD;
	}
	dfs(1,-1);
	cout<<(MOD-dp[1][0])%MOD<<endl;
	return 0;
}

Measured memory_bytes: 194944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<string> d(k);
	for(int i=0;i<k;i++){
	    cin>>d[i];
	}
	string s_k;
	bool match=true;
	while(match){
	    match=false;
		s_k = to_string(n);
		for(int i=0;i<k;i++){
			if(s_k.find(d[i])!=std::string::npos){
				match=true;
				break;
			}
		}
		if(!match)break;
		n++;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
list_1=[]
list_2=[]
x=0
y=0

for i in range(10):
   a=int(input())
   list_1.append(a)
for j in range(10):
   b=int(input())
   list_2.append(b)

list_1.sort(reverse=True)
list_2.sort(reverse=True)

for m in range(3):
   x+=list_1[m]
   y+=list_2[m]

print(x,y)


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

signed main()
{
  int n,b[26]={0},c=0;
  cin>>n;
  string s;
  cin>>s;
  if(n&1)
  cout<<"No\n";
  else
  {
    for(int i=0;i<(n/2);i++)
    if(s[i]==s[i+(n/2)])
    c++;
    //cout<<c<<endl;
    if((2*c)==n)
    cout<<"Yes\n";
    else
    cout<<"No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
vector<int> vec;
vector<int> dp(100001,-1);
 
int back(int i,int k){
    for(int j=1;j<=k;j++){
        if(i+j==vec.size()-1) return abs(vec[i+j]-vec[i]);
    }
    // if(i+2==vec.size()-1) return abs(vec[i+2]-vec[i]);
    if(dp[i]!=-1) return dp[i];
    
    int ans=INT_MAX;
    for(int j=1;j<=k;j++){
        if(i+j<vec.size()){
            ans= min(ans, abs(vec[i+j]-vec[i]) + back(i+j,k));
        }
    }
 
    dp[i]=ans;
    return dp[i];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        vec.push_back(a);
    }
    cout<<back(0,k);
	return 0;
}

Measured memory_bytes: 9080
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i) >> b.at(i);
    }
    sort(b.begin(), b.end());
    const ll maxa = *max_element(a.begin(), a.end());
    ll ans = (h + maxa - 1) / maxa;
    for(int i = n - 1; i >= 0 && h > 0; --i){
        h = max(0LL, h - b.at(i));
        ans = min(
            ans,
            n - i + (h + maxa - 1) / maxa
        );
    }
    cout << ans << endl;
    return 0;
}


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

int anum[100005];

int main(void){
    int N, a;
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> a;
        anum[a]++;
    }
    
    int ans=0;
    for(int i=1; i<100004; i++){
        ans = max(ans, anum[i-1]+anum[i]+anum[i+1]);
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, K; 
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> F(N);
  REP(i, N) cin >> F[i];

  sort(ALL(A));
  sort(ALL(F), greater<>());

  int ok = INF;
  int ng = -1;
  while(ok-ng > 1){
    int mid = (ok+ng)/2;
    int cnt = 0;
    REP(i, N){
      cnt += max(0ll, A[i]-mid/F[i]);
    }

    if(cnt <= K) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;

  return 0;
}

Measured memory_bytes: 3328
n =int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, len(p) - 1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        ans += 1

print(ans)


Measured memory_bytes: 38384
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

answer = 0
for b_i in range(len(B)):
    value = B[b_i]
    """Aについて"""
    right = len(A)
    left = -1
    while right - left > 1:
        center = (right + left) // 2
        if A[center] >= value:
            right = center
        else:
            left = center
    a_num = left + 1
    
    """Cについて"""
    right = len(C)
    left = -1
    while right - left > 1:
        center = (right + left) // 2
        if C[center] <= value:
            left = center
        else:
            right = center
    c_num = len(C) - right

    answer += a_num*c_num

print(answer)

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


class dice {
public:
	dice(int* a) {
		set(a[0], a[1], a[2], a[3], a[4], a[5]);
	}
	dice(int& a, int& b, int& c, int& d, int &e, int& f) {
		set(a, b, c, d, e, f);
	}
	void turn(int n) {
		if (n < 4)
		{
			turndice(n);
			return;
		}
		switch (n)
		{
		case 'N':
			turndice(0);
			break;
		case 'E':
			turndice(1);
			break;
		case 'S':
			turndice(2);
			break;
		case 'W':
			turndice(3);
			break;
		}

	}

	void turn(const char* str)
	{
		for (size_t i = 0; str[i] != '\0' ; i++)
		{
			turn(str[i]);
		}
	}

	int getcurrent(int n = 0) { return label[n]; }

private:

	int label[6];

	void set(int& a, int& b, int& c, int& d, int &e, int& f) {
		label[0] = a; 
		label[1] = b; 
		label[2] = c; 
		label[3] = d; 
		label[4] = e; 
		label[5] = f; 
	}
	void turndice(int n)
	{
		int m = (n > 1) ? n - 2 : n + 2;
		int f[] = { 1, 3, 4, 2 };
		int tmp;

		tmp = label[0];
		label[0] = label[f[n]];
		label[f[n]] = label[5];
		label[5] = label[f[m]];
		label[f[m]] = tmp;
	}

};

#define A

#ifdef B

#endif // B



#ifdef A
int main(void)
{
	int in[6];
	for (auto &a :in)
	{
		cin >> a;
	}
	dice d(in);
	string oder;
	cin >> oder;
	d.turn(oder.c_str());

	cout << d.getcurrent() << endl;


	return 0;
}
#endif // A

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

const int MAX_V = 110;
const int INF = (1<<29);

int n, m, s, g1, g2;
int cost[MAX_V][MAX_V];

void init(){
  for(int i = 0 ; i < MAX_V ; i++)
    for(int j = 0 ; j < MAX_V ; j++) cost[i][j] = INF;
  
  for(int i = 0 ; i < MAX_V ; i++) cost[i][i] = 0;
}


void wf(){
  for(int k = 0 ; k < n ; k++){
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
	cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }    
}

int main(){
  while(cin >> n >> m >> s >> g1 >> g2, n|m|s|g1|g2){
    init();
    s--, g1--, g2--;
    int from, to, C;
    for(int i = 0 ; i < m ; i++){
      cin >> from >> to >> C;
      cost[from-1][to-1] = C;
    }
    
    wf();
        
    int ans = INF;
    for(int i = 0 ; i < n ; i++){
      ans = min(ans, cost[s][i] + cost[i][g1] + cost[i][g2]);
    }
    cout << ans << endl;    
  }
  return 0;
}

Measured memory_bytes: 1208
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,q=map(int,input().split())
tate=[n]*(n+1)
yoko=[n]*(n+1)
black=(n-2)*(n-2)
h=n
w=n
for i in range(q):
    ty,x=map(int,input().split())
    if ty==1:
        if x<=w:
            black-=h-2
            for j in range(w-1,x,-1):
                tate[j]=h   
            w=x
            tate[x]=0
        else:
            black-=tate[x]-2
    else:
        if x<=h:
            black-=w-2
            for j in range(h-1,x,-1):
                yoko[j]=w
            h=x
            yoko[x]=0
        else:
            black-=yoko[x]-2
print(black)

Measured memory_bytes: 78132
#include<cstdio>

int A[100001],n,q;

int binarySearch(int key){
	int l = 0;
	int r = n;
	int mid;
	int sum = 0;
	while(r-l>1){
		mid =(l+r)/2;
		if(A[mid]>key) r=mid;
		else l=mid;
	}
	return A[l]==key?1:0;
}

int main(void){
	int k,sum=0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for(int i=0; i<q; i++){
		scanf("%d", &k);
		sum += binarySearch(k);
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 3000
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] chars = S.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            char ch = chars[i];
            if ((i + 1) % 2 == 0) {
                if (ch == 'R') {
                    System.out.print("No");
                    return;
                }
            }
            else {
                if (ch == 'L') {
                    System.out.print("No");
                    return;
                }
            }
        }
        System.out.print("Yes");
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner scan = new Scanner(System.in);
		int i, j, m;
		
		while(true){
			int n = scan.nextInt();
			int x = scan.nextInt();
			int count=0;
			
			if(n==0 && x==0) break;
			
			for(i=1; i<=n; i++){
				for(j=i+1; j<=n; j++){
					for(m=j+1; m<=n; m++){
						if(i + j + m == x){
							count++;
						}
					}
				}
			}
			
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 19588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <ios>
#include <iomanip>
#define ll long long
using namespace std;
typedef pair<ll,int> P;

int main(){
    int n,m;
    cin>>n>>m;
    vector<P> city;
    vector<int> pref(m);
    for(int i=0;i<m;i++){
        int y;
        cin>>pref[i]>>y;
        city.emplace_back(y,i);
    }
    sort(city.begin(),city.end());
    vector<int> chkpref(100005);
    vector<P> citynum;
    for(int i=0;i<m;i++){        
        chkpref[pref[city[i].second]]++;
        citynum.emplace_back(city[i].second,chkpref[pref[city[i].second]]);
    }
    sort(citynum.begin(),citynum.end());
    for(int i=0;i<m;i++){
        cout<<setfill('0')<<right<<setw(6)<<pref[citynum[i].first];
        cout<<setfill('0')<<right<<setw(6)<<citynum[i].second;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 5616
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    long ans =0 ;
    vector < int> d(n);
    for(int i = 0 ; i < n ; i++){
        cin >> d[i];
    }
    for(int i = 0 ; i < n-1 ; i++){
        for(int j = i+1 ; j < n ; j++){
            ans += d[i] * d[j];
        }
    }

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

Measured memory_bytes: 256