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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		map<int,int> f;
		{
			vi b=a;
			sort(all(b));
			rep(i,n) f[b[i]]=i<n/2?b[n/2]:b[n/2-1];
		}
		rep(i,n) cout<<f[a[i]]<<endl;
	}
}


Measured memory_bytes: 12156
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    if ((n & -n) == n) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for (int i = 1; 2 * i + 1 <= n; ++i) {
        cout << 2 * i << " " << 2 * i + 1 << "\n";
        cout << n + 2 * i << " " << n + 2 * i + 1 << "\n";
        cout << 1 << " " << 2 * i << "\n";
        cout << 1 << " " << n + 2 * i + 1 << "\n";
    }
    cout << 3 << " " << n + 1 << "\n";
    if (n % 2 == 0) {
        int h = 1 << (31 - __builtin_clz(n));
        cout << h << " " << n << "\n";
        cout << 2 * n - h + 1 << " " << 2 * n << "\n";
    }
    return 0;
}

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

int main () {
  vector<char> s(4);
  rep(i,4) cin >> s.at(i);
  sort(s.begin(),s.end());
  if(s.at(0) == s.at(1) && s.at(2) == s.at(3) &&s.at(1) !=s.at(2))
    cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 6;
char g[N][N];
int n,m,k;
int res;
bool calc(int x,int y)
{
    int cnt=0;
    
    for(int i=0;i<n;i++)    
        for(int j=0;j<m;j++)
            if(x>>i&1&&y>>j&1&&g[i][j]=='#') cnt++;
    return cnt==k;
}
int main()
{
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) cin>>g[i][j];
    for(int i=0;i<1<<n;i++) 
        for(int j=0;j<1<<m;j++)
            res+=calc(i,j);
            
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3588
use std::io;
use std::process;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let num: usize = buf.trim().parse().unwrap();
    let mut buf2 = String::new();
    stdin.read_line(&mut buf2).ok();

    if (num == 1) {
        println!("Yes");
        process::exit(0);
    }

    let mut previous: usize = 0;
    let mut result = "Yes";

    for (i, num_s) in buf2.split_whitespace().enumerate() {
        let num = usize::from_str(num_s).unwrap();

        if (i == 0) {
            previous = num;
            continue;
        }

        if (previous == num) {
            previous = num;
            continue;
        }

        if (previous <= (num - 1)) {
            previous = num - 1;
            continue;
        }

        result = "No";
        break;
    }

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


Measured memory_bytes: 6396
#include <stdio.h>
int main(){

  int n,a,b,c,i,blank;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    scanf("%d %d %d",&a,&b,&c);

    if(a > b){

      blank=a;
      a=b;
      b=blank;

    }

    if(b > c){

      blank=b;
      b=c;
      c=blank;

    }

    if(a > b){

      blank=a;
      a=b;
      b=blank;

    }

    if(c*c == a*a+b*b) printf("YES\n");
    else printf("NO\n");

  }

  return 0;

}

Measured memory_bytes: 2588
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray().groupBy { it }.map { it.value.size }.sorted()
    val t = readLine()!!.toCharArray().groupBy { it }.map { it.value.size }.sorted()


    for (i in s.indices) {
        if (s[i] != t[i]) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 39760
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, tmp, max, count;
    cin >> N;
    cin >> max;
    count = 1;
    for(int i=1;i<N;i++){
        cin >> tmp;
        if(tmp >= max){
            count++;
            max = tmp;
        }
    }

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


Measured memory_bytes: 256
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <utility>

namespace n91 {

template <class T> constexpr T gcd(T m, T n) noexcept {
  while (n != static_cast<T>(0)) {
    m %= n;
    std::swap(m, n);
  }
  return m;
}

template <class T> constexpr T lcm(const T &m, const T &n) noexcept {
  return m / gcd(m, n) * n;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u64 a = scan<u64>();
  const u64 b = scan<u64>();
  std::cout << lcm(a, b) << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

hi = 10**18
lo = 0

while hi - lo > 1:
    mid = (hi + lo) // 2
    cut = 0
    for i in range(N):
        cut += (A[i] + mid - 1) // mid - 1
    if cut <= K:
        hi = mid
    else:
        lo = mid

print(hi)

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

int main(int argc, const char * argv[]) {
    int w, a, b;
    int ans;
    
    cin >> w >> a >> b;
    
    if(a<b){
        ans = b - (a+w);
    }else{
        ans = a - (b+w);
    }
    if(ans<0){
        ans = 0;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int s[3];
    for(int i=0;i<3;i++){
    cin>>s[i];
    if(s[i]!=7&&s[i]!=5){
        return 0;
    }
    }
    if(s[0]+s[1]+s[2]==17){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* ex_9_1
   seira3 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 11

typedef struct{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

void initialize_stack(stack *stk);
void push(stack *stk, char chara);
int empty(stack *stk);
char pop(stack *stk);
void print_stack(stack *stk);

int main(void){
    char str[SIZE], *ptr;
    stack stk;
    scanf("%s",str);
    initialize_stack(&stk);
    ptr = str;
    while(*(ptr)!='\0'){
        if(*(ptr)=='B' && empty(&stk)==0){
            pop(&stk);
        }
        else if(*(ptr)=='0' || *(ptr)=='1'){
            push(&stk,*(ptr));
        }
        ptr++;
    }
    print_stack(&stk);
    return 0;
}

void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[0]);
}

void push(stack *stk, char chara){
    if(stk->count >= stk->size){
        printf("Error: stack overflow. (chara=%c)\n", chara);
        exit(1);
    }
    else{
        stk->top++;
        *(stk->top) = chara;
        stk->count++;
    }
}

int empty(stack *stk){
    if(stk->count == 0){
        return 1;
    }
    if(stk->count < 0){
        return -1;
    }
    else{
        return 0;
    }
}

char pop(stack *stk){
    char chara;
    if(stk->count <= 0){
        printf("Error: stack underflow.\n");
        exit(1);
    }
    else{
        chara = *(stk->top);
        stk->top--;
        stk->count--;
        return chara;
    }
}

void print_stack(stack *stk){
    int i;
    char *ptr;
    ptr = &(stk->data[1]);
    for(i=0;i<stk->count;i++){
        printf("%c",*ptr++);
    }
    printf("\n");
}

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

string bd[12];

void del(int y, int x) {
	if (0 <= y && y < 12 && 0 <= x && x < 12 && bd[y][x] == '1') {
		bd[y][x] = '0';
		del(y-1, x);
		del(y+1, x);
		del(y, x-1);
		del(y, x+1);
	}
}

int main() {
	while (cin >> bd[0]) {
		for (int i=1; i<12; ++i) cin >> bd[i];
		int ans = 0;
		for (int i=0; i<12; ++i) {
			for (int j=0; j<12; ++j) {
				if (bd[i][j] == '1') {
					del(i, j);
					++ ans;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
 
int main(){
	int a, b, i, ans = 0;
	while(scanf("%d", &a) != 0){
		if(a == 0) break;
		a = 1000 - a;
		ans += a / 500;
		a = a % 500;
		ans += a / 100;
		a = a % 100;
		ans += a / 50;
		a = a % 50;
		ans += a / 10;
		a = a % 10;
		ans += a / 5;
		ans += a % 5;
		printf("%d\n", ans);
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 300

int main(){
    int H; cin >> H;
    int  b[MAX];
    for(int i = 1; i <= H; i++){
        cin >> b[i];
    }
    for(int i = 1; i <= H; i++){
        cout << "node " << i << ": key = " << b[i] << ", ";
        if(i/2 >= 1) cout << "parent key = " << b[i/2] << ", ";
        if(i*2 <= H) cout << "left key = " << b[i*2] << ", ";
        if(i*2+1 <= H) cout << "right key = " << b[i*2+1] << ", ";
        cout << endl;;
    }
    return 0;
}


Measured memory_bytes: 3096
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

#define all(x) x.begin(), x.end()
#define all_r(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, n) for(int i = n; i >= 0; --i)
#define f first
#define s second

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a[5];
	FOR(i, 5) cin >> a[i];
	cout << 1 + (find(a, a + 5, 0) - a) << '\n';
 	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    char S[11];
    char *p;
    int64_t ans = 0, tmp = 0;

    gets(S);
    p = S;

    while (*p) {
        if ((*p == 'A') || (*p == 'C') || (*p == 'G') || (*p == 'T')) {
            tmp++;
        } else {
            tmp = 0;
        }
        if (tmp > ans) ans = tmp;
        p++;
    }

    printf("%"PRId64"\n", ans);
}


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

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

  vector<double> v(N);

  for (int i = 0; i < N; i++)
    cin >> v.at(i);

  while (v.size() != 1)
  {
    // 小さい順に
    sort(v.begin(), v.end());

    // (1番小さい具材 + 2番目に小さい具材) / 2 を先頭に追加
    v.insert(v.begin(), (v.at(0) + v.at(1)) / 2);

    // 鍋に入れた具材を削除
    v.erase(v.begin() + 1);
    v.erase(v.begin() + 1);
  }

  cout << fixed << setprecision(5) << v.at(0) << endl;
}


Measured memory_bytes: 3820
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int i = 0;
	while (y * i + z * (i + 1) < x) {
		i++;
	}
	if (y * i + z * (i + 1) > x) {
		i--;
	}
	cout << i << endl;
	return 0;
}



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

vector<int> v;
int A[200010], B[100010];

int main() {
	v.push_back(3);
	A[3]=2; A[5]=1;
	bool P;
	for(int i=5; i<100000; i += 2){
	    P=true;
	    for(int j=0; j<v.size(); ++j){
	        if(i%v[j]<1){
	            P=false;
	            break;
	        }
	    }
	        if(P){
	            v.push_back(i);
	            ++A[i];
	            ++A[i*2-1];
	        }
	}
	for(int i=1; i<100000; ++i){
	    if(A[i]==2) B[i]=B[i-1]+1;
	    else B[i]=B[i-1];
	}
	int Q, l, r, ans; cin >> Q;
	for(int i=0; i<Q; ++i){
	    cin >> l >> r;
	    cout << B[r]-B[l-1] << endl;
	}
	return 0;
}


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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <typename T, typename U>
vector<U> make_vector(T&& n, U&& val) {
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
decltype(auto) make_vector(T&& n, Args&&... args) {
  return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...));
}

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

void solve() {
  int n;
  cin >> n;
  for (int i = 1000; i <= 10000; i += 1000) {
    if (i >= n) {
      cout << i - n << endl;
      return;
    }
  }
}


Measured memory_bytes: 3636
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class Edge
  attr_accessor:to,:from,:c
  def initialize(from,to,cost)
    @from=from
    @to=to
    @c=cost
  end
end
V,E,r=get_i

edges=array(E,1)
E.times do|i|
  s,t,d=get_i
  edges[i]=Edge.new(from=s,to=t,cost=d)
end
INF=Float::INFINITY
d=array(V,1,INF)
d[r]=0
flag=false
V.times do|i|
  E.times do|j|
    e=edges[j]
    if d[e.to]>d[e.from]+e.c
      d[e.to]=d[e.from]+e.c
      if i==V-1
        flag=true
        break
      end
    end
  end
end
if flag
  puts "NEGATIVE CYCLE"
else
  V.times do|i|
    if d[i]==INF
      puts "INF"
    else
      puts d[i]
    end
  end
end


Measured memory_bytes: 6896
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=1e5+5,mod=1e9+7;
typedef long long ll;
string s;
int cnt,n;
int main()
{
    Elhabashy
    input();
    cin>>n>>s;

    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')cnt++;

    }
    int ans=0;
    for(int i=0;i<cnt;i++)
    {
        if(s[i]=='R')continue;
        ans++;
    }
    cout<<ans<<endl;

}


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

int main(){
  int k,i,n,d,x,a[100],sum=0;
  cin>>n;
  cin>>d>>x;
  for(i=0; i<n; i++){
    cin>>a[i];
  }
  for(k=1; k<=d; k++){
    for(i=0; i<n; i++){
      if(a[i]==1 || k%a[i]==1) sum++;
    }
  }
  cout<<x+sum<<endl;
  return 0;
}

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

int main(void) {
  int i;
  char o[60], e[60];
  scanf("%s%s", o, e);
  for(i = 0; i < strlen(e); ++i) printf("%c%c", o[i], e[i]);
  if(strlen(e) != strlen(o)) printf("%c", o[strlen(e)]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // 全ての帽子の排他的論理和が0、3種類の数が1/3ずつか、2種類以下か
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> cnt;
  rep(i, N) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  if (cnt[0] == N) {
    puts("Yes");
    return 0;
  }
  if (N % 3 != 0) {
    puts("No");
    return 0;
  }
  vector<int> all;
  for (auto p : cnt) {
    for (int i = 0; i < p.second / (N/3); i++) {
      all.push_back(p.first);
    }
  }
  //show(all);
  if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 7184
N = input()
cards = list(map(int, input().split()))

apoint = 0
bpoint = 0
while True:
	apoint += max(cards)
	cards.remove(max(cards), )

	if len(cards) == 0:
		break

	bpoint += max(cards)
	cards.remove(max(cards))

	if len(cards) == 0:
		break

dif = apoint - bpoint
print(dif)

Measured memory_bytes: 3064
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 2000010
using namespace std;
char s[N],t[N]; int s1,s2,h,w,n;
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	scanf("%d%d",&s1,&s2);
	scanf("%s",s+1);scanf("%s",t+1);// printf("%s",t+1);
	int su=s1,sd=s1,sl=s2,sr=s2,i;
	for(i=1;i<=n;i++)
	{
		if(s[i]=='U')	su--;
		if(s[i]=='D')	sd++;
		if(s[i]=='L')	sl--;
		if(s[i]=='R')	sr++;
	//	printf("%d %d %d %d\n",su,sd,sl,sr);
		if(su==0)	break;
		if(sd>h)	break;
		if(sl==0)	break;
		if(sr>w)	break;
	//	printf("%d %c\n",t[i]);
		if(t[i]=='U' && sd>1)	sd--;
		if(t[i]=='D' && su<h)	su++;
		if(t[i]=='L' && sr>1)	sr--;
		if(t[i]=='R' && sl<w)	sl++;
	}
	if(i<=n)	printf("NO\n");
	else	printf("YES\n");
	return 0;
}


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

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    vector<bool> correct(N, false);
    vector<int> penalty(N, 0);

    for (int i = 0; i < M; i++) {
        int p;
        string S;
        cin >> p >> S;
        p--;

        if (S == "AC") {
            if (!correct[p]) {
                correct[p] = true;
            }
        } else if (S == "WA") {
            if (!correct[p]) {
                penalty[p]++;
            }
        }
    }

    int penalty_num = 0;
    int correct_num = 0;
    for (int i = 0; i < N; i++) {
        if (correct[i]) {
            correct_num++;
            penalty_num += penalty[i];
        }
    }

    cout << correct_num << " " << penalty_num << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[100010] = {}, f[100010];
double syo = 0, su = 0;
long long   mur = 0, kmr = 0, yju = 0, counto[5003], counto1[5003];
char fir, sec = 'z', mado[52][52], homu[52][52];
string rik, mrsm[55], tok[25003];
bool mazi[110], gi[110], zi, manji;
pair<int, int>n[110];
vector<int> aa[50] = {}, cc;
vector<char> bb, dd;
map<char, int>zis, uuu;
int gcd(int a, int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int main()
{
	cin >> rik;
	for (int i = 0; i < (1 << ((int)rik.size()-1));i++) {
		a = rik[0] - '0';
		for (int j = 0; j < ((int)rik.size() - 1); j++) {
			if (i&(1 << j)) {
				a += rik[j + 1]-'0';
				bb.push_back('+');
			}
			else {
				a -= rik[j + 1] - '0';
				bb.push_back('-');
			}
		}
		if (a == 7) {
			cout << rik[0] << bb[0] << rik[1] << bb[1] << rik[2] << bb[2] << rik[3]<<"=7"<<endl;
			return 0;
		}
		else {
			bb.clear();
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n;i++)
typedef long long ll;
using namespace std;

int main(void){
    // Your code here!
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int pizza = 0;
    if(C*2 <= A){
        if(C*2 <= B){
            pizza = 0;
        }
        else{
            pizza = 1;
        }
    }
    else if(C*2 <= B){
        pizza = 2;
    }
    else if(C*2 <= A+B){
        pizza = 3;
    }
    else{
        pizza = 4;
    }
    int ans  = 0;
    if (pizza == 0){
        if(X>Y){
            ans = 2*X*C;
        }
        else{
            ans = 2*Y*C;
        }
    }
    else if(pizza == 1){
        if(X>=Y){
            ans = 2*X*C;
        }
        else{
            ans = 2*X*C + (Y-X)*B;
        }
        
    }
    else if(pizza == 2){
        if(Y>=X){
            ans = 2*Y*C;
        }
        else{
            ans = 2*Y*C + (X-Y)*A;
        }
    }
    else if(pizza == 3){
        if(X>=Y){
            ans = 2*Y*C + (X-Y)*A;
        }
        else{
            ans = 2*X*C + (Y-X)*B;
        }
    }
    else if(pizza == 4){
        ans = A*X + B*Y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 22:14:02 2019

@author: Yamazaki Kenichi
"""

N, K = map(int,input().split())
mod = 10**9+7

r = int(pow(N,1/2))

const = []
if N // r == r:
    s = r - 1
else:
    s = r

for i in range(1,r+1):
    const.append(N//i - N//(i+1))
#if r == int(pow(N,1/2)) :
#    const += [1]
const.reverse()
const = [1 for i in range(s)] + const

dp = [[]]
for c in const:
    try:
        dp[0].append(dp[0][-1] +c)
    except:
        dp[0].append(c)
dp += [[0 for i in range(len(const))] for k in range(K-1)]

for k in range(1,K):
    for i in range(len(const)):
        dp[k][i] = (dp[k][i-1] + dp[k-1][len(const)-i-1]%mod
                      * const[i])%mod
print(dp[-1][-1]%mod)


Measured memory_bytes: 121020
#include<iostream>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

  vector<int> a(n), b(n), c(n-1);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  for(int i = 0; i < n; i++)
    cin >> b[i];
  for(int i = 0; i < n-1; i++)
    cin >> c[i];

  int sat = b[a[0] - 1];
  for(int i = 1; i < n; i++){
    sat += b[a[i] - 1];
    if(a[i] - a[i-1] == 1)
      sat += c[a[i] - 2];
  }

  cout << sat << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

int N,M;
P a[SIZE];

int main(){
  cin >> N >> M;
  rep(i,0,N){
    cin >> a[i].first >> a[i].second;
  }

  sort(a,a+N);
  int L=0;
  ll cost = 0;

  for(int i=0;i<N;i++){
    int u = min(a[i].second,M-L);
    L += u;
    cost += (ll)u * a[i].first;
    if(L == M)break;
  }

  cout << cost << endl;

  return 0;
}


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int len = s.length();
  
  vector<char> cube;
  for(int i=0; i<len; i++){
    //cout << s[i] << endl;
    if(cube.empty() || cube.back()==s[i])
      cube.push_back(s[i]);
    else
      cube.pop_back();
    //for(auto itr: cube)
    //  printf("%c", itr);
    //printf("  : %d\n", i);
  }
  
  cout << len - cube.size() << endl; 
    
  return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y == 0)return x;
  return gcd(y, x % y);
}


int main(){
  int n,x; cin >> n >> x;
  int t = 0;
  for(int i = 0; i < n; ++i){
    int y; cin >> y; y = abs(y - x);
    if(i)t = gcd(t,y);
    else t = y;
  }
  cout << t << endl;
}


Measured memory_bytes: 3600
def check(P):
    global w, k
    t=1
    wt=0
    for wi in w:
        if wt+wi>P:
            wt=wi
            t+=1
        else:
            wt+=wi
        if t>k:
            return False
    return True

def search(l, r):
    if r-l==1:
        return r
    else:
        m=(l+r)//2
        if not check(m):
            return search(m,r)
        else:
            return search(l,m)

n,k=map(int,input().split())
w=[]
for i in range(n):
    w.append(int(input()))
S=sum(w);M=max(w)
#print(S,M)
P0=M-1
#print(P0)

print(search(M-1,S))


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

using namespace std;

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

  int c, t;
  
  int minCost = 1001;
  for (int i = 0; i < N; ++i) {
    cin >> c >> t;
    if (t <= T) {
      minCost = min(c, minCost);
    }
  }
  if (minCost > 1000) {
    cout << "TLE" << endl;
  }
  else {
    cout << minCost << endl;
  }
  return 0;
}



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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);
  cout << a[n-1] - a[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   string s;
   cin >> s;
   int n = s.length();

   FOR(i, 0, n / 2)
   {
      if (s[i] != s[n - i - 1])
      {
         cout << "No" << endl;
         return 0;
      }
   }

   FOR(i, 0, (n - 1) / 4)
   {
      if (s[i] != s[(n - 1) / 2 - 1 - i])
      {
         cout << "No" << endl;
         return 0;
      }
   }
   FOR(i, (n + 3) / 2, n / 4)
   {
      if (s[i] != s[n - i - 1 + (n + 3) / 2])
      {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){

    int n,m,c;
    while(cin>>m>>c>>n&&!(m==0&&c==0&&n==0)){
        vector<vector<int> > orders;
        vector<int> idxs;
        for(int i = 0; i < n; i++) idxs.push_back(0);
        queue<int> waiter;
        for(int i = 0; i < n; i++) waiter.push(i);
        for(int i = 0; i < n; i++){
            int k;
            cin>>k;
            vector<int> v;
            for(int j = 0; j < k; j++){
                int b;
                cin>>b;
                v.push_back(b);
            }
            orders.push_back(v);
        }
        vector<vector<int> > tableAndShelf;
        for(int i = 0; i < m; i++)tableAndShelf.push_back(vector<int>());
        vector<int> shelf;
        for(int i = 0; i < 101; i++)
            shelf.push_back(i);
        tableAndShelf.push_back(shelf);
        int sumCost=0;
        while(waiter.size()){
            int member=waiter.front();
            int bookid=orders[member][idxs[member]];
            waiter.pop();
            for(int i = 0; i < tableAndShelf.size(); i++){
                vector<int>::iterator it=find(tableAndShelf[i].begin(),tableAndShelf[i].end(),bookid);
                if(it!=tableAndShelf[i].end()){
                    tableAndShelf[i].erase(it);
                    sumCost+=i+1;
                    break;
                }
            }
            if(tableAndShelf[0].size()<c){
                tableAndShelf[0].push_back(bookid);
                sumCost+=1;
            }
            else{
                pair<int,int> tmp;
                for(int i = 0; i < tableAndShelf.size(); i++){
                    if(tableAndShelf[i].size()<c||i==tableAndShelf.size()-1){
                        tableAndShelf[i].push_back(bookid);
                        sumCost+=i+1;
                        tmp.first=i;
                        tmp.second=tableAndShelf[i].size()-1;
                        break;
                    }
                }
                int old=tableAndShelf[0][0];
                tableAndShelf[0].erase(tableAndShelf[0].begin());
                sumCost++;
                for(int i = 1; i < tableAndShelf.size(); i++){
                    if(tableAndShelf[i].size()<c||i==tableAndShelf.size()-1){
                        tableAndShelf[i].push_back(old);
                        sumCost+=i+1;
                        break;
                    }
                }
                tableAndShelf[tmp.first].erase(tableAndShelf[tmp.first].begin()+tmp.second);
                sumCost+=tmp.first+1;
                tableAndShelf[0].push_back(bookid);
                sumCost++;
            }
            idxs[member]++;
            if(idxs[member]!=orders[member].size())
                waiter.push(member);
        }
        cout<<sumCost<<endl;
    }
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int ne[7][7]={
{4,3,5,0,2,6,1},
{0,2,6,1,8,18,7},
{3,10,0,2,9,1,8},
{12,11,4,3,10,0,2},
{13,12,14,4,3,5,0},
{14,4,15,5,0,16,6},
{5,0,16,6,1,17,18},
};

int c[128];

int change(int &s){
    int t=0;
    rep(i,7){
        int b=0;
        for(int j=6;j>=0;j--){
            b=(b<<1)+(s>>ne[i][j]&1);
        }
        t|=c[b]<<i;
    }
    int ret=t&1;
    s>>=7;s<<=7;s|=t;
    return ret;
}

void solve(){
    rep(i,1<<19){
        int t=i;
        int a=change(t);
        int b=change(t);
        if(a!=b){
            cout<<"no"<<endl;
            return;
        }
    }
    cout<<"yes"<<endl;
}

signed main(){
    string s;

    while(cin>>s,s!="#"){
        rep(i,128)c[i]=s[i]-'0';
        solve();
    }
    return 0;
}

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int main(){
	ll d, m, n;
	cin >> n >> m >> d;
	cout << fixed << setprecision(7);
	if (d > 0) {
		cout << (ll)2 * (n - d)*(m - 1) / (ld)(n*n) << endl;
	}
	else {
		cout << (m-1)/(ld)n << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b) ; }
template<typename T> T power(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}

void read(vt<int> &a) {
    rep(i,0,a.size()) 
        cin >> a[i] ; 
}
void read(vt<ld> &a) {
    rep(i,0,a.size()) 
    cin >> a[i] ; 
}

bool prime(ll t) {
    for(ll i  =2 ; i*i <= t ; ++i) {
        if(t%i==0) 
            return 0 ; 
    }
    return 1 ; 
}
bool cmp(pii &a , pii &b) {
    if(a.ss == b.ss) 
        return a.ff > b.ff ; 
    return a.ss < b.ss ; 
}

// ==========Start Here==============
const int N = 1e6 + 1 ; 
int store[N] ; 
vt<bool>  vis(N) ; 
vt<int> primes  ; 



int main() 
{ 
    int n ; 
    cin >> n ; 
    vt<int> a(n) ; 
    vt<int> cnt(N+5) ; 
    rep(i,0,n)  {
        cin >> a[i] ;  
        ++cnt[a[i]] ; 
    }

    int g = 0 ; 
    rep(i,0,n) {
        g = gcd(g,a[i]) ; 
    }
    if(g>1) {
      cout << "not coprime"; 
      return 0 ; 
    }
    for(int i = 2 ; i < N ; ++i) {
        int tmp =0 ; 
        for(int j = i ; j < N ; j += i ) 
            tmp += cnt[j] ; 
        if(tmp > 1) {
            cout << "setwise coprime" ; 
            return 0 ; 
        }
    }
    cout << "pairwise coprime" ; 
    

    return 0; 
} 


Measured memory_bytes: 11108
import java.util.Scanner;
class Main{
 public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
System.out.println();
System.out.println((a*b*c)%175==0 ? "YES" : "NO");
 }
  }


Measured memory_bytes: 22612
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: u32 = read();

  let mut ans = 0;
  for _ in 0..n {
    let lr: Vec<u32> = read_vec();
    ans += lr[1] - lr[0] + 1;
  }

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


Measured memory_bytes: 4352
//WA RE TLE MLE 10 pts
//Always look up the code afeter programming
//Keep Calm
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i, j, k) for(ll i = j; i <= k; ++i)
#define D(i, j, k) for(ll i = j; i >= k; --i)
#define pp pair<ll, ll>
#define mp make_pair
const ll maxn = 2e5+5;
ll n, m, x, y, z;
ll a, b, c, d, e, f;
double update(double x, double y) {
    if(x + y == 0) return 0;
    return (100 * y) / (x + y);
}
//by GengChen================
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f);
    ll ans1, ans2;
    double perf = 0;
    F(i, 0, 70) F(j, 0, 70) {
	ll tmpp = a * 100 * i + b * 100 * j;
	if(tmpp > f) continue;
	ll tmp = min((i * a + j * b) * e, f - tmpp);
	ll X = 0;
	F(A, 0, 3001) {
	    F(B, 0, 3001) {
		if(A * c + B * d <= tmp) X = max(X, A*c+B*d);
	    }
	}
	double aa = update(tmpp, X);
	if(aa >= perf) {
	    ans1 = tmpp;
	    ans2 = X;
	    perf = aa;
	}
    }
    printf("%lld %lld\n", ans1 + ans2, ans2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
double a[102];
double ans;
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
		ans += 1.0/a[i];
	}
	cout << 1.0/ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

int X;

int main() {
    cin >> X;
    ll res = X/500 * 1000;
    X %= 500;
    res += X/5 * 5;
    cout << res << endl;
}


Measured memory_bytes: 3472
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int i = 1;
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s;
        while (true) {
            try {
                s = bf.readLine();
                if (s.equals("0")) {
                    break;
                } else {
                    System.out.printf("Case %d: %s\n", i++, s);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}



Measured memory_bytes: 61880
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  string s;
  cin>>s;
  int ans=0;
  for(char i='0';i<='9';i++){
  for(char j='0';j<='9';j++){
  for(char k='0';k<='9';k++){
  for(int a=0;a<N-2;a++){
     if(s.at(a)==i){
     for(int b=a+1;b<N-1;b++){
       if(s.at(b)==j){
       for(int c=b+1;c<N;c++){
       if(s.at(c)==k){
        ans++; break;
       }
       } break;
       } 
     } break;
     }
    
    }
    
  }
  }
  }cout<<ans<<endl;
    
   return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N,K;
	cin >> N >> K;
	vec(A);
	fx(N) {
		vecp(A);
	}

	sorts(A)
		ll ans = 0;
	fx(N-K) {
		ans += A[x];
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 1400
/*
	@author: cheerioskun
*/
#pragma GCC target("popcnt")
#include "bits/stdc++.h"
#define f first
#define sc second
#define pb push_back
#define MOD 1000000007L
#define inf 0x3f3f3f3f
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
using namespace std;

ll h[100005], dp[100005];

int main(){
	fast_io
	int N, K;
	cin>>N>>K;
	for(int i = 0;i < N; ++i){
		dp[i] = 1e12;
		cin>>h[i];
	}
	dp[0] = 0;
	for(int i = 1;i < N; ++i){
		for(int k = 1;k <= K && i - k >= 0; ++k){
			dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]));
		}
	}
	cout<<dp[N - 1]<<endl;
	
	
	
	#ifndef ONLINE_JUDGE
    	cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}



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

int K,R,L;
double P,E,T;
const double EPS = 1e-10;
double solve(double a,double b,double l,double r,int k){
  if( r+EPS < a || b < l-EPS ) return 0.0;
  else if( a+EPS < l && r < b-EPS ) return 1.0;
  double h = (l+r)/2.0;
  if( k == K ){
    if( a-EPS < h && h < b+EPS ) return 1.0;
    return 0.0;
  }
  double vl = solve( a, b, (l+r)/2.0, r, k+1 ) * ( h > T-EPS ? P : 1.0-P );
  double vr = solve( a, b, l, (l+r)/2.0, k+1 ) * ( h > T-EPS ? 1.0-P : P );
  return vl+vr;
}

int main(){
  cin >> K >> R >> L;
  cin >> P >> E >> T;
  printf("%.10lf\n", solve(T-E,T+E,R,L,0) );
}

Measured memory_bytes: 1248
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static long median(long array[]){
		int N = array.length;
		if(N % 2 == 0){
			return (array[N / 2] + array[N / 2 - 1]) ;			
		}else{
			return array[N / 2];
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		long B[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}
		Arrays.sort(A);
		Arrays.sort(B);
		if(N % 2 == 1){
			long ret = median(B) - median(A) + 1;
			System.out.println(ret);			
		}else{
			long ret = median(B) - median(A) + 1;
			System.out.println(ret);			
		}
	}
}


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


int main() {
    const ll MOD_NUM = 1e9 + 7;
    ll N, M;
    cin >> N >> M;
    ll X[N], Y[M];
    rep(i, N) {
        cin >> X[i];
    }
    rep(i, M) {
        cin >> Y[i];
    }

    ll xSum = 0;
    {
        ll rate = N - 1;
        ll rateDiff = N - 3;
        rep(idx, N - 1) {
            ll diff = X[idx + 1] - X[idx];
            ll area = diff * rate % MOD_NUM;
            xSum = (xSum + area) % MOD_NUM;
            rate += rateDiff;
            rateDiff -= 2;
        }
    }
    ll ySum = 0;
    {
        ll rate = M - 1;
        ll rateDiff = M - 3;
        rep(idx, M - 1) {
            ll diff = Y[idx + 1] - Y[idx];
            ll area = diff * rate % MOD_NUM;
            ySum = (ySum + area) % MOD_NUM;
            rate += rateDiff;
            rateDiff -= 2;
        }
    }
    ll total = (xSum * ySum) % MOD_NUM;
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 1792