akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{

    int N,T[110]={},sum=0,M,P[110]={},X[110]={};

    cin>>N;

    for(int i=1;i<=N;i++){
        cin>>T[i];
        sum+=T[i];
    }

    cin>>M;

    for(int i=1;i<=M;i++){
        cin>>P[i]>>X[i];

        int temp = T[P[i]]-X[i];
        cout<<sum-temp<<endl;

    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    void calc()
    {
        int n = int.Parse(Console.ReadLine());
        long money = 100000;
        for (int i = 0; i < n; i++)
        {
            money *= 105;
            if (money % 100000 != 0) money += 100000 - money % 100000;
            money /= 100;
        }
        Console.WriteLine(money);
    }
}

Measured memory_bytes: 5596
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    #define rep(i, n) for(int i = 0; i < n; i++)
     
    int main(void){
        ll n;
        cin >> n;
     
        ll a[n];
        ll ma = 0;
        ll mi = 10000000000;
        rep(i, n){
            cin >> a[i];
            ma = max(a[i], ma);
            mi = min(a[i], mi);
        }
     
     
        cout << ma - mi << endl;
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;


int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,M,K,wrk;
	int ans = 0;
	int flg;

	cin >> N >> M;

	vector<vector<int>> foods(N, vector<int>(M + 1, 0));

	for (int i = 0; i < N ; i++) {
		cin >> K;
		for(int j=0;j<K;j++){
			cin >> wrk;
			foods[i][wrk]++;
		}
	}

	for(int j = 0; j < M + 1 ; j++){
		flg = 1;
		for(int i=0;i<N;i++){
			if(foods[i][j] == 0){
				flg = 0;
			}
		}
		if(flg){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;

}

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


typedef struct{
	int s;
	long long n = 0;
	int nextId = 0;
}Part;


int main(void){

	int n;
	std::cin >> n;

	Part **part = new Part*[3];
	for(int y = 0; y < 3; y++){
		part[y] = new Part[n];

		for(int x = 0; x < n; x++){
			std::cin >> part[y][x].s;
		}
	}

	for(int i = 0; i < 3; i++){
		std::sort(&part[i][0], &part[i][n], [](const Part& a, const Part& b){return a.s < b.s; });
	}


	// 2段目を検査
	int j;
	for(j = 0; j < n; j++){

		if(part[0][j].s >= part[1][0].s){ break; }
		part[1][0].n++;
	}
	part[1][0].nextId = j;

	for(int i = 1; i < n; i++){
		part[1][i].n = part[1][i - 1].n;

		for(j = part[1][i - 1].nextId; j < n; j++){
			if(part[0][j].s >= part[1][i].s){ break; }
			part[1][i].n++;
		}
		part[1][i].nextId = j;
	}


	// 3段目を検査
	long long sum = 0;
	for(j = 0; j < n; j++){

		if(part[1][j].s >= part[2][0].s){ break; }
		part[2][0].n += part[1][j].n;
	}
	part[2][0].nextId = j;
	sum += part[2][0].n;

	for(int i = 1; i < n; i++){
		part[2][i].n = part[2][i - 1].n;

		for(j = part[2][i - 1].nextId; j < n; j++){
			if(part[1][j].s >= part[2][i].s){ break; }
			part[2][i].n += part[1][j].n;
		}
		part[2][i].nextId = j;
		sum += part[2][i].n;
	}

	std::cout << sum << std::endl;

	/*
	std::cout << std::endl;
	for(int y = 0; y < 3; y++){
		for(int x = 0; x < n; x++){
			std::cout << part[y][x].s << " ";
		}
		std::cout << std::endl;
	}

	std::cout << std::endl;
	for(int y = 0; y < 3; y++){
		for(int x = 0; x < n; x++){
			std::cout << part[y][x].n << " ";
		}
		std::cout << std::endl;
	}
	*/

	for(int y = 0; y < 3; y++){
		delete[] part[y];
	}
	delete[] part;


	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;

const LL INF=1<<30;
const LL MOD=1000000007;






int main(){
    LL x,y,z;
    cin>>x>>y>>z;
    x-=z;
    y+=z;
    LL ans=x/y;
    cout<<ans<<endl;

}



Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n,i,t;
	long long sum=0;
	int min=1000001,max=-1000001;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&t);
		if(t<min){
			min=t;
		}if(t>max){
			max=t;
		}
		sum+=t;
	}
	printf("%d %d %ld\n",min,max,sum);

	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
const ll MAXN = 205;
pair<ll,ll> a[MAXN];
 
bool cmp(pair<ll,ll> a,pair<ll,ll> b){
    return atan2(a.second,a.first) < atan2(b.second,b.first);
}
 
void solve(){
    ll n; cin>>n;
 
   for(ll i=1;i<=n;++i) cin>>a[i].first>>a[i].second;
 
    sort(a+1,a+n+1,cmp);
 
    for(ll i=n+1;i<=2*n;++i) a[i] = a[i-n];
 
    ll ans = 0;
 
    for(ll i=1;i<=n;++i){
        ll x = 0,y = 0;
        for(ll j=i;j<=i+n-1;++j){
            x = x + a[j].first,y = y + a[j].second;
            ans = max(ans,x*x + y*y);
        }
    }
 
    ld ans1 = sqrtl(ans+.0);
 
    cout<<fixed<<setprecision(17)<<ans1<<endl;
} 
 
int main(){
 
   FastIO;    

        solve();
}

Measured memory_bytes: 256
x, y = 0, 0
rad = 0.0

while line = gets
  d, t = line.split(',').map(&:to_i)

  break if d.zero? && t.zero?

  x += d * Math.sin(rad * Math::PI / 180.0)
  y += d * Math.cos(rad * Math::PI / 180.0)

  rad += t
end

puts [x, y].map(&:truncate).join("\n")

Measured memory_bytes: 8776
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> num = new HashSet<>();
        for(int i=0; i<N; i++){
            int di = sc.nextInt();
            num.add(di);
        }
        System.out.println(num.size());
    }
}


Measured memory_bytes: 23380
n = input().split(" ")
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
for i in range(100):
    c += -b
    if c <= 0:
        print("Yes")
        break
    a += -d
    if a <= 0:
        print("No")
        break


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int sum, i;
    string N;
  
	i = 0;
    sum = 0;
    cin >> N;
    while (N[i] != '\0')
    {
      sum += N[i] - 48;
      ++i;
    }
	int change = stoi(N); 
    if (change % sum == 0)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
    return (0);
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

//#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

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

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)2e5 + 7;
const int MAXN = (int)4e5 + 7;
const int MOD = (int)998244353;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e15;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

void solve() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int X; cin>>X;
    int ans=1;
    for(int b=2;b<X;b++){
        int power=b*b;
        while(power<=X){
            ans=max(ans,power);
            power*=b;
        }
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
using namespace std;
vector<int> need;
char s[MAXN+5];
int main()
{
	int n;
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[n]=='1'||s[1]=='0')
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n-1;i++)
		if(s[i]!=s[n-i])
		{
			printf("-1\n");
			return 0;
		}
	for(int i=1;i<=n;i++)
		if(s[i]=='1')
			need.push_back(i);
	int idcnt=0;
	int prert=0;
	need.push_back(n);
	for(int i=0;i<(int)need.size();i++)
	{
		int rt=++idcnt;
		if(prert!=0)
		printf("%d %d\n",prert,rt);
		prert=rt;
		int cnt=0;
		if(i==0)
			cnt=need[i]-1;
		else
			cnt=need[i]-need[i-1]-1;
		while(cnt--)
			printf("%d %d\n",rt,++idcnt);
	}
	return 0;
}

Measured memory_bytes: 2040
#include <stdio.h>
int main()
{
	long N;
	scanf("%ld", &N);
	if (N <= 9)
		printf("%ld", N);
	else if (N <= 99)
		printf("9");
	else if (N <= 999)
		printf("%ld", 9 + (N + 1) - 100);
	else if (N <= 9999)
		printf("909");
	else if (N <= 99999)
		printf("%ld", 9 + 900 + (N + 1) - 10000);
	else
		printf("90909");
}

Measured memory_bytes: 128
houkou={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
saikoro=input().split()
for i in input():
  saikoro=[saikoro[j]for j in houkou[i]]
  #print(saikoro)
print(saikoro[0])


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

int main(){
    long long N;
    long long h[100001];
    long long dp[100001];
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=N;i++){
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n , a[N] , b[N] , w;
long long dp[200][N] , INF = -2e12 - 1 ,ans = 0;
int main(){
    scanf("%d%d", &n , &w);
    for(int i = 1 ; i <= n ; i++){
        scanf("%d%d", &a[i] , &b[i]);
    }
    for(int i = 0 ; i < n ; i++)
        for(int j = 1 ; j <= w ; j++)
            dp[i][j] = INF;
    for(int i = 0 ; i <= w ; i++)
        dp[0][i] = 0;
    //dp[0][a[0]] = b[0];
    for(int i = 1; i <= n ; i++){
        for(int j = 0 ; j <= w ; j++){
            if(i > 0)
            dp[i][j] = dp[i - 1][j];
            if(a[i] <= j && i)
            dp[i][j] = max(dp[i][j] , dp[i - 1][j - a[i]] + b[i]);
            ans = max(dp[i][j] , ans);
        }
    }
    cout<<dp[n][w];
    return 0;
}

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

public class Main {

	public static void main(String[]  args)  {
		Scanner scanner = new Scanner(System.in);
		int counter = scanner.nextInt();
		int start = scanner.nextInt();
		int[] point = new int[counter];
		
		for(int i = 0;i<counter;i++) {
			point[i]= Math.abs(scanner.nextInt() - start); 
		}
		
		Arrays.sort(point);
		
		for(int i = counter -1;i>0;i--) {
			getGCD(point,i-1,i);
		}
		
		System.out.println(point[0]);
	}
	
	public static void getGCD(int[] a,int x,int y) {
		int tmp;
		while((tmp = a[y] % a[x]) != 0) {
			a[y]= a[x];
			a[x]= tmp; 
		}
	}
}

Measured memory_bytes: 52204
// // -*- coding:utf-8-unix -*-

// #[macro_use]
// extern crate lazy_static;
// extern crate num_bigint; // 0.2.2
// extern crate num_traits; // 0.2.8
// use num_bigint::BigInt;
// use num_traits::Pow;
// use petgraph::algo::dijkstra;
// use petgraph::Directed;

// // use proconio::derive_readable;
// use proconio::fastout;
// use proconio::input;
// // use std::convert::TryInto;
// use ascii::{AsciiChar, AsciiString};
// use itertools::concat;
// use lazy_static::lazy_static;
// use libm::*;
// use petgraph::Graph;
// use std::cmp::*;
// use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
// use std::io::*;
// use std::ops::Range;
// use std::str::FromStr;
// use std::sync::Mutex;
// use superslice::*;

// pub fn read<T: FromStr>() -> T {
//     let stdin = stdin();
//     let stdin = stdin.lock();
//     let token: String = stdin
//         .bytes()
//         .map(|c| c.expect("failed to read char") as char)
//         .skip_while(|c| c.is_whitespace())
//         .take_while(|c| !c.is_whitespace())
//         .collect();
//     token.parse().ok().expect("failed to parse token")
// }

// // lazy_static! {
// //     static ref H: Mutex<Vec<i32>> = Mutex::default();
// //     static ref W: Mutex<Vec<i32>> = Mutex::default();
// // }

// // let mut values = VALUES.lock().unwrap();
// // values.extend_from_slice(&[1, 2, 3, 4]);
// // assert_eq!(&*values, &[1, 2, 3, 4]);

use proconio::{input, marker::Chars};
use std::collections::HashMap;

// static ASCII_LOWER: [char; 26] = [
//     'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
//     't', 'u', 'v', 'w', 'x', 'y', 'z',
// ];

// abc172-D
fn main() {
    input! {
        n: usize,
    }

    let mut ans = 0;
    for i in 1..(n + 1) {
        let mut tmp = 1;
        while tmp * i <= n {
            // eprintln!("{},{},{}", i, tmp, tmp * i);
            ans += tmp * i;
            tmp += 1;
        }
    }

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


Measured memory_bytes: 2124
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <numeric> 
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
signed main(){
    int n,x[1001],k;
    int i,j,min,temp;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        min=i;
        for(j=i+1;j<n;j++){
            if(x[j]<x[min]){
                min=j;
            }
        }
        if(min!=i){
            temp=x[i];
            x[i]=x[min];
            x[min]=temp;
        }
    }
     int sum=0;
    for(i=0;i<k;i++){
        sum+=x[i];
    }
    printf("%d\n",sum);
    return(0);
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
#define ri(a,b,c) for(int a=(b);a<(c);++a)
#define ll long long
#define rll(a,b,c) for(ll a=(b);a<(c);++a)

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

    int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
cin>>a;
  cout<<(a/1000?"ABD":"ABC")<<endl;

















    return 0;
}


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


int main()
{
  long long N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> type_num(N, 0);
  for (long long i = 0; i < N; ++i)
  {
    long long a;
    cin >> a;
    A.at(i) = a - 1;
    type_num.at(a - 1) += 1;
  }
  long long all_ans = 0;
  for (long long i = 0; i < N; ++i)
  {
    if (type_num.at(i) < 2)
    {
      continue;
    }
    all_ans += type_num.at(i) * (type_num.at(i) - 1) / 2;
  }

  for (long long i = 0; i < N; ++i)
  {
    if (type_num.at(A.at(i)) >= 2)
    {
      cout << all_ans - type_num.at(A.at(i)) + 1 << endl;
    }
    else
    {
      cout << all_ans << endl;
    }
  }
}


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

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

  vector<ll> x(n, 0);
  ll tmp=0;
  for (int i=n-1; i>=0; i--) {
    a[i]+=tmp;
    if (a[i]%b[i]==0) continue;
    if (a[i]<b[i]) x[i]=b[i]-a[i];
    else {
      x[i]=b[i]-(a[i]%b[i]);
      x[i]%=b[i];
    }
    tmp+=x[i];
  }
  ll ans=0;
  rep(i, n) ans+=x[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#define N 100000

int A[N];

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void partition(int p, int r){
  int x = A[r];
  int i = p - 1, j;
  for(j=p;j<r;j++){
    if(A[j] <= x){
      i++;
      swap(&A[i], &A[j]);
    }
  }
  swap(&A[i+1], &A[r]);
  for(j=p;j<=r;j++){
    if(j!= p) printf(" ");
    if(j == i+1) printf("[%d]", A[j]);
    else printf("%d", A[j]);
  }
  printf("\n");
}

main(){
  int n, i;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &A[i]);
  partition(0, n-1);
  return 0;
}




Measured memory_bytes: 2192
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  string s;cin>>s;
  if(s[0]==s[1]&&s[1]==s[2]) p("No");
  else p("Yes");
  return 0;
}



Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
--import           Data.Vector.Algorithms.Search
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO



getvuil :: IO (VU.Vector Int)
getvuil = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readi :: BSC8.ByteString -> Int
readi = fst . fromJust . BSC8.readInt
readil :: BSC8.ByteString -> [Int]
readil = map readi . BSC8.words
geti :: IO Int
geti = readi <$> BSC8.getLine
getil :: IO [Int]
getil = readil <$> BSC8.getLine

getNis :: Int -> IO [(Int, BSC8.ByteString)]
getNis 0 = return []
getisl n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getisl (n - 1))
    return ((readi aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

modNum = 10 ^ 9 + 7
newtype Mint = M Int
instance Num Mint where
    (M a) + (M b) = M $ mod (a + b) modNum
    (M a) - (M b) = M (a - b)
    (M a) * (M b) = M $ mod (a * b) modNum
    fromInteger a = M $ mod (fromInteger a) modNum
    abs (M a) = M $ abs a
    signum (M a) = M $ signum a
instance Show Mint where
    show (M a) = show a

main :: IO ()
main = do
    aS <- getLine
    let sVI = VU.fromList $ map (\x -> if x == 'R' then 0 else 1) aS
    scan sVI (VU.length sVI - 1) 0 0 0 (-1)


scan :: VU.Vector Int -> Int -> Int -> Int -> Int -> Int -> IO ()
scan sVI l n cR cL pL
    | l < n = do
        mapM_ (\x -> putStr "0 ") [1 .. (cR - 1)]
        putStr
            (show ((div cR 2) + (div cL 2) + (if odd cR then 1 else 0)) ++ " ")
        putStr
            (show ((div cR 2) + (div cL 2) + (if odd cL then 1 else 0)) ++ " ")
        mapM_ (\x -> putStr "0 ") [1 .. (cL - 1)]
    | pL == -1 = if sVI VU.! n == 0
        then scan sVI l (n + 1) (cR + 1) cL pL
        else scan sVI l (n + 1) cR (cL + 1) n
    | otherwise = if sVI VU.! n == 0
        then do
            mapM_ (\x -> putStr "0 ") [1 .. (cR - 1)]
            putStr
                (  show ((div cR 2) + (div cL 2) + (if odd cR then 1 else 0))
                ++ " "
                )
            putStr
                (  show ((div cR 2) + (div cL 2) + (if odd cL then 1 else 0))
                ++ " "
                )
            mapM_ (\x -> putStr "0 ") [1 .. (cL - 1)]
            scan sVI l (n + 1) 1 0 (-1)
        else scan sVI l (n + 1) cR (cL + 1) pL





Measured memory_bytes: 11644
#include <iostream>
using namespace std;
int main()
{
    string s, t, u;
    cin >>s >> t;
    int a, b;
    cin >>a>>b>>u;
    if (u==s)
    {
       a--;
    }
    else 
    {
        b--;  
    }
    
    cout<<a<<" "<<b;
    
    
    
    
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	int N,X,inp,x;
	cin >> X >> N;
	vector<int> list(120);
	rep(i,120){
		list[i]=i-10;
	}
	rep(i,N){
		cin >> inp;
		rep(j,list.size()){
			if(list[j]==inp){
				list.erase(list.begin()+j);
			}
		}
	}

	list.push_back(X);
	sort(list.begin(),list.end());

	rep(i,list.size()){
		if(list[i]==X){
			x = i;
			break;
		}
	}
	if(x==0){
		cout << list[1];
	}
	else if(x==(list.size()-1)){
		cout << list[list.size()-2];
	}
	else if(list[x+1]-list[x] < list[x]-list[x-1])
		cout << list[x+1];
	else
		cout << list[x-1];

	cin >> N;

	
	return 0;	
}


Measured memory_bytes: 3636
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
A = iln()
total = sum(A)
cnt = 0
for a in A:
    if 4*M*a >= total:
        cnt += 1
print('Yes' if cnt >= M else 'No')




Measured memory_bytes: 5932
// Last Change: 06/22/2019 21:40:23.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

struct Data {
  ll A;
  ll B;
};

bool Comp(const Data &a, const Data &b) {
  return a.B < b.B;
}

int main() {
  ll N;
  cin >> N;
  vector<Data> task(N);

  for (ll i = 0; i < N; ++i) {
    cin >> task[i].A >> task[i].B;
  }

  sort(task.begin(), task.end(), Comp);

  ll time = 0;
  for (auto &&e : task) {
    time += e.A;
    if (time > e.B) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 3328
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n = I()

    return (n-2) * 180


print(main())



Measured memory_bytes: 5460
//https://beta.atcoder.jp/contests/abc102/tasks/abc102_b
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int a,b[110];
    int max=-1,min=1000000000;
    cin >> a;
    for(int i=0;i<a;i++) cin >> b[i];
    for(int i=0;i<a;i++){
        if(max<b[i]) max = b[i];
        if(min>b[i]) min = b[i];
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c,s;
  cin>>n>>m;
  priority_queue<int> q;
  for(int i=0;i<n;i++){
   cin>>c;
   q.push(c);
}
  for(int i=0;i<m;i++){
   s=q.top();
   s/=2;
   q.pop();
   q.push(s);
}
  int64_t ans=0;
  while(!q.empty()){
   ans+=q.top();
   q.pop();
}
  cout<<ans<<endl;
}

Measured memory_bytes: 892
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		
		// 結果の出力
		if (N % X == 0) {
			System.out.println((N / X ) * T);
		}
		else {
			System.out.println(((N / X) + 1) * T);
		}
		
		sc.close();
	}
}


Measured memory_bytes: 35780
a,b,c,d=map(int,input().split())
al=[]
bl=[]
for i in range(a,b+1):
    al.append(i)
for i in range(c,d+1):
    bl.append(i)
albl=set(al)&set(bl)
if len(albl)==0:
    print(0)
else:
    print(len(albl)-1)

Measured memory_bytes: 3064
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n-1]
    }

    let mut subords = vec![0; n + 1];

    for i in 0..n - 1 {
        subords[a[i]] += 1;
    }

    for i in 1..n + 1 {
        println!("{}", subords[i]);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main(){
    string S;
    cin >> S;

    string ans(S.length(), 'x');

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,c,i;
	c=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		if(0<i&&i<10){
			c++;
		}
		if(99<i&&i<1000){
			c++;
		}
		if(9999<i&&i<100000){
			c++;
		}
	
	}
	printf("%d",c);
		
	// your code goes here
	return 0;
}


Measured memory_bytes: 128
N = int(input())
if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(N - 90)
elif N < 10000:
    print(909)
elif N < 100000:
    print(N - 9090)
else:
     print(90909)

Measured memory_bytes: 2940
import sys

N = int(input())

XY = []
for i in range(N):

    X,Y = map(int,input().split())
    XY.append([X,Y])

    if i > 0 and sum(XY[-2]) % 2 != (X+Y) % 2:
        print (-1)
        sys.exit()

d = [1]

while d[-1] <= 10 ** 9:
    d.append(d[-1] * 2)

d.reverse()
if sum(XY[0]) % 2 == 0:
    d.append(1)

print (len(d))
print (" ".join(map(str,d)))
for loop in range(N):

    ans = ""
    nx = 0
    ny = 0
    dx = XY[loop][0]
    dy = XY[loop][1]
    difx = 0
    dify = 0
    
    for i in range(len(d)):

        nmin = float("inf")
        pl = ""
        difx = 0
        dify = 0

        if abs(nx - d[i] - dx) + abs(ny - dy) < nmin:
            nmin = abs(nx - d[i] - dx) + abs(ny - dy)
            difx =  -1 * d[i]
            dify = 0
            pl = "L"

        if abs(nx + d[i] - dx) + abs(ny - dy) < nmin:
            nmin = abs(nx + d[i] - dx) + abs(ny - dy)
            difx = d[i]
            dify = 0
            pl = "R"

        if abs(nx - dx) + abs(ny - d[i] - dy) < nmin:
            nmin = abs(nx - dx) + abs(ny - d[i] - dy)
            difx = 0
            dify = -1 * d[i]
            pl = "D"

        if abs(nx - dx) + abs(ny + d[i] - dy) < nmin:
            nmin = abs(nx - dx) + abs(ny + d[i] - dy)
            difx = 0
            dify = d[i]
            pl = "U"

        ans += pl
        nx += difx
        ny += dify

    print (ans)

Measured memory_bytes: 56812
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<LL,LL>
int N;
std::vector<PP> A;
LL sum[500010];
LL B,C=1;
LL ans;
int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0);
    std::cin>>N;
    for(int i=0;i<N;i++){
        LL tmp1,tmp2;
        std::cin>>tmp1>>tmp2;
        ans=std::max(ans,tmp2);
        A.emplace_back(PP{tmp1,tmp2});
    }
    std::sort(A.begin(),A.end());
    sum[1]=A[0].second;
    for(int i=2;i<=N;i++){
        sum[i]=sum[i-1]+A[i-1].second;
        LL val=sum[i]-sum[C-1]-(A[i-1].first-A[C-1].first);
        ans=std::max(ans,val);
        LL  score=A[i-1].first-A[0].first-sum[i-1];
       if(score>B){
           B=score;
           C=i;
       }
    }
    std::cout<<ans<<std::endl;
    return 0;
}


Measured memory_bytes: 14612
N,X,D=map(int,input().split())
r=N*(X!=0)+1
if D:
 f,c,r={},[0]*10**8,0
 for x,y,z in sorted(((N-k)*k*j+~-k*k//2+k*X//D,j,k*X%D)for k in range(N+1)for j in[0,1]):
  if c[z]+y<1:
   f[z]=x
  c[z]-=2*y-1
  if c[z]<y:
   r+=x-f[z]+1
print(r)

Measured memory_bytes: 887772
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int q = Integer.parseInt(sc.next());
        Deque<String> dq = new ArrayDeque<>();
        dq.add(s);
        boolean isR = false;
        for (int i = 0; i < q; i++) {
            int t = Integer.parseInt(sc.next());
            if (t == 1) {
                isR = !isR;
            } else {
                int f = Integer.parseInt(sc.next());
                String c = sc.next();
                if (f == 1) {
                    if (isR) {
                        dq.addLast(c);
                    } else {
                        dq.addFirst(c);
                    }
                } else {
                    if (isR) {
                        dq.addFirst(c);
                    } else {
                        dq.addLast(c);
                    }
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (String temp : dq) {
            sb.append(temp);
        }
        System.out.println(isR ? sb.reverse().toString() : sb.toString());
    }
}

Measured memory_bytes: 100856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main(){
    
    for(int n; cin >> n, n;){
        vector<P>v(n);
        for(int i = 0; i < n; i++){
            string s;
            cin >> s;
            char c = s[s.size() - 1];
            if(c == '+')v[i].first = -1;
            else if(c == '*')v[i].first = -2;
            else v[i].first = c - '0';
            v[i].second = s.size() - 1;
        }
        while(v.size() > 1){
            int idx = 0;
            for(int i = 0; i < v.size(); i++){
                if(v[i].first < 0)idx = i;
            }
            if(v[idx].first == -1){
                v[idx].first = 0;
                while(idx + 1 < v.size()){
                    if(v[idx].second + 1 == v[idx + 1].second){
                        v[idx].first += v[idx + 1].first;
                        v.erase(v.begin() + idx + 1);
                    }
                    else break;
                }
            }
            else{
                v[idx].first = 1;
                while(idx + 1 < v.size()){
                    if(v[idx].second + 1 == v[idx + 1].second){
                        v[idx].first *= v[idx + 1].first;
                        v.erase(v.begin() + idx + 1);
                    }
                    else break;
                }
            }
        }
        cout << v[0].first << endl;
    }

    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  vector<ll> a(87);
  a[0] = 2;
  a[1] = 1;
  rep(i, 85){
    a[i + 2] = a[i + 1] + a[i];
  }
  out(a[n]);
  memi;
}

Measured memory_bytes: 256
S_array = [int(c) for c in list(input())]
count = 0

if len(S_array) == 1:
  print(count)
  exit()

for i in range(len(S_array) - 1):
  if S_array[i] != S_array[i + 1]:
    continue
  elif S_array[i] == 0:
    S_array[i + 1] = 1
  else:
    S_array[i + 1] = 0
  count = count + 1

print(count)


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll l = 0, r = 1e+10;
    ll d = A-B;
    while(r-l > 1){
        ll mid = (l+r)/2;
        ll cnt = 0;
        rep(i, N){
            ll tmp = a[i]-B*mid;
            if(tmp > 0){
                cnt += (ll)ceil((double)tmp/d);
            }
        }
        if(cnt <= mid){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  vector<int> a(3);
  rep(i,3) cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[2]-a[0]<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int[] a;

    private void solve() {
        a = new int[3];
        for(int i = 0;i < 3;i++) {
            a[i] = nextInt();
        }

        int ans = (int)1e9 + 7;
        for(int i = 0;i < 3;i++) {
            for(int j = 0;j < 3;j++) {
                if (i == j) {
                    continue;
                }
                for(int k = 0;k < 3;k++) {
                    if (i == k || j == k) {
                        continue;
                    }
                    int sum = 0;
                    sum += Math.abs(a[j] - a[i]);
                    sum += Math.abs(a[k] - a[j]);

                    ans = Math.min(ans, sum);
                }
            }
        }

        out.println(ans);
    }

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

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

ll solve(ll x)
{
    if(x==1)
        return 1;
    return 2*solve(x/2)+1;
}

int main()
{
    ll n;
    inlld(n);
    printf("%lld\n", solve(n));
    return 0;
}

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

const ll MOD = 998244353LL;

class ModuloCombination {
private:
  vector<ll> fact, inv_fact;

  static ll modulo_power(ll a, ll n) {
    if(n == 0) return 1;
    if(n % 2 == 0) return modulo_power((a * a) % MOD, n / 2);
    return (a * modulo_power(a, n - 1)) % MOD;
  }

public:
  ModuloCombination(ll N): fact(N + 1), inv_fact(N + 1) {
    fact[0] = 1;
    REP(i, 1, N + 1) fact[i] = (i * fact[i - 1]) % MOD;
    REP(i, 0, N + 1) inv_fact[i] = modulo_power(fact[i], MOD - 2);
  }

  ll operator()(ll n, ll r) {
    return fact[n] * inv_fact[r] % MOD * inv_fact[n - r] % MOD;
  }
};

int main(void) {
  ll N, A, B, K;
  cin >> N >> A >> B >> K;

  ModuloCombination C(500000);
  ll ans = 0;

  REP(x, 0, N + 1) {
    if(K - x * A >= 0 && (K - x * A) % B == 0) {
      ll y = (K - x * A) / B;
      if(!(0 <= y && y <= N)) continue;

      // cerr << "x: " << x << ", y: " << y << endl;
      // ll w1 = max(x, y);
      // ll w2 = min(x + y, N) + 1;
      // REP(w, w1, w2) {
      //   ll t = N - w;
      //   ll g = x + y - w;
      //   ll r = x - g;
      //   ll b = y - g;
      //   cerr << "(r, g, b, t) = " << "(" << r << ", " << b << ", " << g << ", " << t << ")" << endl;
      // }

      ans = (ans + C(N, x) * C(N, y) % MOD) % MOD;
    }
  }

  cout << ans << endl;
}

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

vector<ll> enumDivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++){
        if(n % i != 0) continue;
        res.push_back(i);
        if(i * i != n)
            res.push_back(n / i);
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(auto x : enumDivisor(n)){
        if(x == 1) continue;
        if(n / (x-1) == n % (x-1))
            ans += x-1;
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 
bool hantei[3][3];
int suuji[3][3];

int main(){
    REP(i, 3) REP(j, 3) {
        cin >> suuji[i][j];
    }

    int n;
    cin >> n;
    REP(i, n) {
        int b;
        cin >> b;
        REP(i, 3) REP(j, 3) {
            if(suuji[i][j] == b) {
                hantei[i][j] = true;
            }
        }
    }

    REP(i, 3) {
        if(hantei[i][0] && hantei[i][1] && hantei[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    REP(i, 3) {
        if(hantei[0][i] && hantei[1][i] && hantei[2][i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(hantei[0][0] && hantei[1][1] && hantei[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }

    if(hantei[0][2] && hantei[1][1] && hantei[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256