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

int main() {
    int N,count = 0;
    int max = 0;
    int h = 0;
    cin  >> N;
    
    vector<string> vec(N);
    for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    }
    vector<string> hozon(200001);
    sort(vec.begin(), vec.end());
    for (int i = 0; i < N - 1; i++) {
        if (vec.at(i) == vec.at(i + 1)) {
            count++;
            if (i == N - 2){
                if (count > max){
                    max = count;
                    h = 0;
                    hozon.at(h) = vec.at(i);
                }
                else if (count == max) {
                    h++;
                    hozon.at(h) = vec.at(i);
                }
            }
        }
        else {
            if (count > max) {
                max = count;
                h = 0;
                hozon.at(h) = vec.at(i);
            }
            else if (count == max) {
                h++;
                hozon.at(h) = vec.at(i);
            }
            if (i == N - 2 && max == 0) {
                h++;
                hozon.at(h) = vec.at(N - 1);
            }
            count = 0;
          }
    }
    
    for (int i = 0; i <= h; i++) {        
    cout << hozon.at(i) <<endl;
    }
            
}

Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;
using ll = long long;


int main() {
    int n, m;
    cin >> n >> m;
    cout << string(m + 2, '#') << endl;
    for (int i = 1; i <= n; ++i) {
        string s; cin >> s;
        cout << "#" << s << "#" << endl;
    }
    cout << string(m + 2, '#') << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int digit = String.valueOf(n).length();

		int sum = 0;

		sum += calc(n, 0, digit, true).size();

		System.out.println(sum);

	}

	public static Set<Long> calc(long n, long v, int digit, boolean isTop){
		long value = (long)Math.pow(10, digit);
		long sum = 0;
		Set<Long> resultSet = new HashSet<>();

		if(digit < 0){
			if(v >n)
				return new HashSet<>();
			Set<Character> set = new HashSet<>();
			for(char c : String.valueOf(v).toCharArray())
				set.add(Character.valueOf(c));
			if(set.size() == 3) {
				resultSet.add(v);
				return resultSet;
			}else
				return new HashSet<>();
		}

		if(isTop)
			resultSet.addAll(calc(n, 0, digit-1, true));

		resultSet.addAll(calc(n, v + value * 3, digit-1, false));
		resultSet.addAll(calc(n, v + value * 5, digit-1, false));
		resultSet.addAll(calc(n, v + value * 7, digit-1, false));

		return resultSet;
	}


}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 47932
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  ll n,sum=0;
  string a,b,c;
  cin >> n >> a >> b >> c;
  for(int i=0;i<n;i++) {
    ll count=0;
    if(a[i]!=b[i]) {
      count++;
    }
    if(b[i]!=c[i]) {
      count++;
    }
    if(a[i]!=c[i]) {
      count++;
    }
    if(count==3) {
      sum+=2;
    }else if(count==2) {
      sum+=1;
    }else if(count==1) {
      sum+=1;
    }
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll N,ans=INF;
  cin>>N;
  ll A[N];
  REP(i,N) cin>>A[i];
  
  for(int i=-100; i<=100; ++i){
    ll cnt=0;
    for(int j=0; j<N; ++j){
      cnt+=abs(i-A[j])*abs(i-A[j]);
    }
    ans=min(ans,cnt);
  }
  
  cout<<ans<<endl;
  return 0;
}

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

const int mxN = 410;
const ll INF = 1e18;
int N, a[mxN];
ll dp[mxN][mxN], pref[mxN];

ll rec(int l, int r) {
	if (l == r) {
		return 0;
	}
	if (dp[l][r] != -1) {
		return dp[l][r];
	}
	dp[l][r] = INF;
	for (int i = l; i < r; i++) {
		dp[l][r] = min(dp[l][r], rec(l, i) + rec(i + 1, r));
	}
	dp[l][r] += (pref[r] - pref[l - 1]);
	return dp[l][r];
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}
	memset(dp, -1, sizeof(dp));
	ll answer = rec(1, N);
	cout << answer;

	return 0;
}

Measured memory_bytes: 4972
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>

using namespace std;

int main()
{
	int a,b,c,x;
	int vis;
	while(cin >> a)
	{
		vis = 0;
		scanf("%d",&b);
		scanf("%d",&c);
		scanf("%d",&x);
		for(int i = 0; i <= a; i++)
			for(int j = 0; j <= b; j++)
				for(int k = 0; k <= c; k++)
				{
					if(x == 500 * i + 100 * j + 50 * k) vis++;
				}
		printf("%d\n",vis);
	}
	return 0;
}


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

int attack(int H, int cnt);

int main(){
    int A1,A2,A3;
    cin >>A1>>A2>>A3;
    
    if(A1+A2+A3>=22)
      cout<<"bust";
  	else
      cout<<"win";
                 
  	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Tree int h,int l,int r,int L,int R
#define left 2*h,l,(l+r)/2,L,R
#define right 2*h+1,(l+r)/2+1,r,L,R
#define F first
#define S second
#define Pb push_back
using namespace std;
long long n,a,b;
main ()
{
	cin>>n;
	
	if (n==1)
	{
		cout<<"Hello World"<<endl;
		return 0;
	}
		else
	{
		cin>>a>>b;
		
		cout<<a+b<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    int sum=0;
    cin>>s;
    for(int i=0; i<s.length(); i++)
    {
        sum+=(s[i]-'0');
    }
    if(sum%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  
  long sumH = 0;
  for (int i = k; i < n; i++) { // 体力の降順にソートしてk番目までとばし、体力の総和をとる
    sumH += h.at(i);
  }
  
  cout << sumH << endl;
}

Measured memory_bytes: 4008
#include<cstdio>

int k,s;

int main(void){
	register int i,j,cnt=0;
	scanf("%d%d",&k,&s);
	for(i=0;i<=k;++i)
		for(j=0;j<=k;++j)
			if(s-i-j>=0&&s-i-j<=k)
				++cnt;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <utility>
using namespace std;
#define MP make_pair
#define F first
#define S second
#define PB push_back
const int N=100 + 10;
int main(){
    int n,k,val[N],now,q,temp;
    bitset<N>b;
    bool f,c;
    string s;
    unordered_map<string,int> m;
    vector<vector<int>>graph[N];
    vector<int> emp;
    while(true){
        cin>>n;
        if(n==0)return 0;
        b.reset();
        m.clear();
        for(int i=0;i<n;i++){
            cin>>s>>k;
            m.insert(MP(s,i));
            val[i]=k;
        }
        cin>>q;
        for(int i=0;i<q;i++){
            cin>>s>>k;
            now=m[s];
            b[now]=true;
            graph[now].PB(emp);
            while(k--){
                cin>>s;
                graph[now].back().PB(m[s]);
            }
        }
        while(q){
            for(int i=0;i<n;i++)if(!graph[i].empty()){
                f=true;
                for(int j=0;j<graph[i].size();j++)if(!graph[i][j].empty()){
                    f=false;
                    c=true;
                    temp=0;
                    for(int r=0;r<graph[i][j].size();r++){
                        if(b[graph[i][j][r]]){
                            c=false;
                            break;
                        }
                        else temp+=val[graph[i][j][r]];
                    }
                    if(c){
                        val[i]=min(val[i],temp);
                        graph[i][j].clear();
                        q--;
                    }
                }
                if(f){
                    graph[i].clear();
                    b[i]=false;
                }
            }
        }
        cin>>s;
        cout<<val[m[s]]<<endl;
    }
    
}


Measured memory_bytes: 3012
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int a[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>a[i];

    int res=0;
    rep(i,N){
        res^=a[i];
    }

    if(res==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 640
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n, p = map(int, input().split())
x = 1
for k, v in factorint(p).items():
    x *= k ** (v//n)
print(x)

Measured memory_bytes: 9200
import math

k = int(input())
ans = 0
chk_list = []
for i in range(1, k+1):
    for j in range(1, k+1):
        chk = math.gcd(i, j)
        chk_list.append(chk)

for l in range(1, k+1):
    for h in chk_list:
        ans += math.gcd(l, h)

print(ans)

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

int main(){
  int a,b;
  cin>>a>>b; 
  
  if(a>b) cout<<"a > b"<<endl;
  if(a<b) cout<<"a < b"<<endl;
  if(a==b) cout<<"a == b"<<endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	std::vector<int> v;
	for (int i = 0; i < N; ++i)
	{
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	long long prev = -1;
	bool b = false;
	int sum = 0;
	for (int i = 0; i < N; ++i)
	{
		if(prev == v[i]){
			if(b){
				sum--;
			}else{
				sum++;
			}
			b = !b;
		}else{
			sum++;
			b = true;
		}
		prev = v[i];
	}
	cout << sum << endl;
}

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

long long int n, a, b;
int main(void){
  cin >> n >> a >> b;
  long long int ans = (n-2) * (b-a) + 1;
  if (a > b) ans = 0;
  else if (n==1 && a<b) ans = 0;
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 256
INTEGER M,K
INTEGER,ALLOCATABLE,DIMENSION(:)::L
INTEGER ANSWER
READ*,M,K
ALLOCATE(L(M))
READ*,L
CALL HEAPSORT(M,L)
ANSWER=0
DO I=0,K-1
  ANSWER=ANSWER+L(M-I)
ENDDO
PRINT"(I0)",ANSWER

CONTAINS

subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  
  integer ::i,k,j,l
  integer :: t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return
 
  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
 
  return
end subroutine heapsort
END

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

namespace AtCoder.Abc
{
    class A_162_Lucky7
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string N = Console.ReadLine();
            List<string> list = new List<string>();

            for (int i = 0; i < N.Length; i++)
            {
                list.Add(N.Substring(i, 1));
            }

            if (list.Contains("7"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26076
#include <stdio.h>

#define N 1000000

int main(void)
{
    int p[N];
    int i, j;
    int n;

    for (i = 0; i < N; i++){
        p[i] = 1;
    }

    p[0] = p[1] = 0;
    for (i = 2; i * i < N; i++){
        if (p[i] == 1){
            for (j = i * i; j < N; j += i){
                p[j] = 0;
             }
         }
     }

    for (i = 1; i < N - 1; i++){
        p[i + 1] += p[i];
    }

    while (scanf("%d", &n) != EOF){
        printf("%d\n", p[n]);
    }

    return (0);
}

Measured memory_bytes: 4500
#include<stdio.h>
int main()
{
	long long int a,b,x;
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a%x==0) printf("%lld",b/x-a/x+1);
	else printf("%lld",b/x-a/x);
	return 0;
}


Measured memory_bytes: 1724
import itertools
def main():
    N = int(input())
    if N < 357:
        print(0)
    else:
        digit = 1
        n = N
        while N//10 != 0:
            N //= 10
            digit += 1
        ans = 0
        for i in range(3,digit+1):
            ls = list(itertools.product([3,5,7],repeat=i))
            for j in ls:
                if 3 in j and 5 in j and 7 in j:
                    tmp = 0
                    for k in range(1,len(j)+1):
                        tmp += j[-k]*10**(k-1)
                    if tmp <= n:
                        ans += 1
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, y;
    cin >> x >> y;
    if (x == y) {
        cout << 0 << endl;
        return 0;
    }
    if (x == - y) {
        cout << 1 << endl;
        return 0;
    }
    if (x == 0) {
        if (y >= 0) cout << y - x << endl;
        else cout << -y + 1 << endl;
        return 0;
    }
    if (y == 0) {
        if (x <= 0) cout << -x << endl;
        else cout << x + 1 << endl;
        return 0;
    }
    int ans = abs(abs(x) - abs(y));
    if ((x > 0 && y < 0) || (x < 0 && y > 0)) ans++;
    if (x > 0 && y > 0 && x > y) ans += 2;
    if (x < 0 && y < 0 && x > y) ans += 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();

		long mina = 0;
		long minb = Long.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			long a = nl();
			long b = nl();

			if (b <= minb) {
				minb = b;
				mina = a;
			}
		}

		out(mina + minb);
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] val = Console.ReadLine().Split(' ');
            int X = int.Parse(val[0]);
            int A = int.Parse(val[1]);
 

            Console.WriteLine(X<A?0:10);

        }
    } 
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int ans = n;
    int current = 1;
    for (int i = 0; i < n; i++) {
        if (v[i] == current) {
            current++;
            ans--;
        }
    }
    if (ans == n) {
        cout << -1 << "\n";
    } else {
        cout << ans << "\n";
    }
}

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

typedef long long ll;

int phi(int n) {
	int result=n;
	for (int i=2; i*i<=n; i++) {
		if(n%i==0) result-=result/i;
		while(n%i==0) n/=i;
	}
	if(n>1) result-=result/n;
	return result;
}

// (a^b)%m
ll exp(ll a, ll b, ll m) {
	ll r=1;
	while(b) {
		if(b%2) r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

// a^-1 %m, any m
ll inv(ll a, ll m) {
	return exp(a, phi(m)-1, m);
}

// a^-1 %m, prime m
ll invp(ll a, ll m) {
	return exp(a, m-2, m);
}

// (a*b)%m
ll mul(ll a, ll b, ll m) {
	ll x=0, y=a%m;
	while(b>0) {
		if(b%2) x=(x+y)%m;
		y=(y*2)%m;
		b/=2;
	}
  return x%m;
}

// (a+b)%m
ll add(ll a, ll b, ll m) {
	return (a+b)%m;
}

const int mx=1e6+5;
const int mod=1e9+7;

ll fact[mx];

ll combi(int n, int x, ll m) {
	ll p=fact[n], q=fact[x], r=fact[n-x];
	ll ret=p;
	ret=(ret*invp(q,m))%m;
	ret=(ret*invp(r,m))%m;
	return ret;
}

bool isprime(int n) {
	if(n==1) return false;
	for (int i=2; i*i<=n; i++)
		if(n%i==0) return false;
	return true;
}

int gcd(int a, int b) {
	if(!b) return a;
	else return gcd(b,a%b);
}

int main() {
	int N,K; cin>>N>>K;
	fact[0]=1;
	for (int i=1; i<=N; i++)
		fact[i]=(fact[i-1]*i)%mod;

	vector<ll> A(N);
	for (int i=0; i<N; i++)
		cin>>A[i];
	if(K==1) {
		cout<<0<<"\n";
		return 0;
	}
	sort(A.begin(),A.end());
	vector<ll> pre(N,0), suf(N,0);
	pre[0]=A[0];
	for (int i=1; i<N; i++)
		pre[i]=(pre[i-1]+A[i])%mod;
	suf[0]=A[N-1];
	for (int i=1; i<N; i++)
		suf[i]=(suf[i-1]+A[N-1-i])%mod;
	ll ret=0;
	for (int i=N-K; i>=0; i--)
		ret=(ret+(suf[i]-pre[i])*combi(N-i-2,K-2,mod))%mod;
	cout<<ret<<endl;
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d" , &n);

    ll ans = 0;
    for(int i = 1 ; i <= n ; i ++){
            for(int j = 1 ; j <= n ; j ++){
                    for(int k = 1 ; k <= n ; k ++){
                            ans += 1ll * __gcd(i , __gcd(j , k));
                    }
            }
    }

    printf("%lld\n" , ans);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

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

    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans1, ans2, ans3, ans4;
  ans1=a*c;
  ans2=a*d;
  ans3=b*c;
  ans4=b*d;
  cout << max(ans1,max(ans2,max(ans3,ans4))) << endl;
  return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 8000 + 10;
int x, y;
char S[MAXN];

int len, n, m, a[MAXN], b[MAXN];
int dp[2][MAXN * 2];

int Compute(int a[], int n, int target) {
    const int OFFSET = 8000;
    for (int i = -OFFSET; i <= OFFSET; ++i) dp[0][i + OFFSET] = 0;
    dp[0][0 + OFFSET] = 1;
    int cur = 1, nxt = 0;
    for (int i = 1; i <= n; ++i) {
        cur ^= 1;
        nxt ^= 1;
        for (int j = -OFFSET; j <= OFFSET; ++j) dp[nxt][j + OFFSET] = 0;
        for (int j = -OFFSET; j <= OFFSET; ++j) {
            if (dp[cur][j + OFFSET] == 0) continue;
            if (j - a[i] >= -OFFSET) dp[nxt][j - a[i] + OFFSET] = 1;
            if (j + a[i] <=  OFFSET) dp[nxt][j + a[i] + OFFSET] = 1;
        }
    }
    if (target < -OFFSET || target > OFFSET) return 0;
    return dp[nxt][target + OFFSET];
}

int main() {
    scanf("%s", S + 1); len = strlen(S + 1);
    scanf("%d%d", &x, &y);

    int p = 0;
    while (p < len && S[p + 1] == 'F') p++;
    x -= p;

    n = 0;
    m = 0;
    for (int i = p + 1, dir = 0; i <= len; ++i) {
        if (S[i] == 'T') {
            dir ^= 1;
            continue;
        }
        int j = i;
        while (j < len && S[j + 1] == 'F') j++;
        if (dir == 0) a[++n] = j - i + 1;
        else b[++m] = j - i + 1;
        i = j;
    }

    puts((Compute(a, n, x) && Compute(b, m, y)) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 512
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 2200000 

//double alCards[MAXCARDS];
char sInput[MAX_STRING];

int main() {

	char* psInput;
	long long l=0;
	double  lLoopEnd=0.0;
	double  lTemp=0.0;
/*	double  lAllSum=0.0;
	double  lLeftSum=0.0;
	double  lRightSum=0.0;
	double  lTempMin=0.0;
	double  lMin=0.0; */
	double  lCardsNumber =0.0;
	double  lEven = 0.0;
	double  l2Multi = 0.0;
	double  l4Multi = 0.0;
	int     nBefore=1; /*1,2,4*/
	int	    nGoal=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (l=0;l<lCardsNumber;l++){
		lTemp=atol(psInput);
		if (fmod(lTemp,4.0)==0.0){
			l4Multi++;
		} else if (fmod(lTemp,2.0)==0.0){
			l2Multi++;
		} else {
			lEven++;
		}
		psInput = strtok(NULL," ");
	}
	
	if (lEven==0){
		if (l2Multi>0){
			nBefore=2;
		} else {
			nBefore=4;
			nGoal=1;
		}
	} else {
		nBefore=1;
	}


	while(nGoal==0){
		switch (nBefore){
		case 1:
			if(l4Multi>0){
				lEven--;
				l4Multi--;
				nBefore=4;
			} else {
				nGoal=-1;
			}
			break;
		case 2:
			if(l2Multi>0){
				l2Multi--;
				nBefore=2;
			} else if(l4Multi>0)  {
				l4Multi--;
				nBefore=4;
			} else {
				nGoal=-1;
			}
			break;
		case 4:
			if (lEven>0&&l4Multi>0){
				lEven--;
				l4Multi--;
				nBefore=4;
			} else if (lEven>0){
				lEven--;
				nBefore=1;
			} else if (l2Multi>0){
				l2Multi--;
				nBefore=2;
			} else {
				nGoal=1;
			}
			break;
		}
		if (lEven==0&&(l2Multi==0&&l4Multi==0))
		{
			nGoal=1;
		}
	}

	if (nGoal>0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

    return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}







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

  ll cnt = 0;
  rep (i,x+1){
    cnt+=i;
    if (cnt >= x) {
      cout << i << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template<typename X>
class Graph {
private:
  int n;
  int m;
  vector<vector<pair<int,X>>> edge;
  
  vector<X> d;
  const X inf = 1e+9;

  set<int> node;
  vector<vector<int>> rev;
  vector<bool> visit;
  bool f;
public:
  Graph(int _n, int _m, vector<int> a, vector<int> b, vector<X> c) {
    n = _n;
    m = _m;
    edge.resize(n);
    rev.resize(n);
    rep(i, m) {
      add_edge(a[i], b[i], c[i]);
      add_rev(b[i], a[i]);
    }
  }

  void add_rev( int from, int to) {
    rev[from].push_back(to);
  }  
  
  void add_edge( int from, int to, X cost ) {
    edge[from].push_back( { to, cost } );
  }

  //ベルマンフォード法。頂点sから全頂点への最短距離。負閉路を見つけるとfalseを返す。
  bool bellmanford(int s){
    d.assign( n, inf );
    d[s] = 0;
    bool flag = true;
    rep( i, n ) {
      rep( v, n ) {
	if( d[v] == inf ) continue;
	for( auto w : edge[v] ) {
	  if( d[w.first] > d[v] + w.second ) {
	    d[w.first] = d[v] + w.second;
	    if( i == n - 1 ) {
	      flag = false;
	      node.insert(w.first);
	    }
	  }
	}
      }
    }
    return flag;
  }

  void dfs(int v) {
    visit[v] = true;
    if(node.find(v) != node.end()) f = true;
    for(auto w : rev[v]) {
      if(!visit[w]) dfs(w);
    }
  }
  
  bool check_connect() {
    f = false;
    visit.resize(n, false);
    dfs(n - 1);
    return f;
  }
  
  X get_d(int v) { return d[v]; }
  
  
};
int main()
{
  int n,m;cin >> n >> m;
  ll p;cin >> p;
  vector<int> a(m), b(m);
  vector<ll> c(m);
  rep(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    c[i] = - c[i] + p;
  }    

  Graph<ll> gp(n, m, a, b, c);
  if( !gp.bellmanford(0) ) {
    if(gp.check_connect()) cout << -1 << "\n";
    else cout << max (-gp.get_d(n - 1), (ll)0) << "\n";
  }
  else cout << max (-gp.get_d(n - 1), (ll)0) << "\n";
  
  return 0;
}


Measured memory_bytes: 768
<?php
fscanf(STDIN, "%d %d %d %d", $a,$b,$h,$m);
if($m===0){
$mc=360;
}else{
$mc=$m*360/60;
}
$hc=($h*60+$m)*360/(12*60);
$cos=abs($hc-$mc);
$ans=$a*$a+$b*$b-(2*$a*$b*cos(deg2rad($cos)));
echo sqrt($ans);
?>

Measured memory_bytes: 16580
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
}

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

int main() {
 int N, i, a;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i + 1 < N; i++) {
    cin >> a;
    data.at(a - 1) = data.at(a - 1) + 1;
  }
  for(int i = 0; i < N; i++) {
    cout << data.at(i) << endl;
  }
}

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

pair<int, int> division(int n, int denominator)
{
  int cnt = 0;
  while (n % denominator == 0)
  {
    n /= denominator;
    cnt += 1;
  }
  return {n, cnt};
}

int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> ans;
  int test_n = n;
  for (int i = 2; i * i <= n; ++i)
  {
    if (test_n % i == 0)
    {
      pair<int, int> n_cnt = division(test_n, i);
      test_n = n_cnt.first;
      ans.push_back({i, n_cnt.second});
    }
  }
  if (test_n != 1)
  {
    ans.push_back({test_n, 1});
  }
  cout << n << ":";
  for (int i = 0; i < ans.size(); ++i)
  {
    for (int j = 0; j < ans.at(i).second; ++j)
    {
      cout << " " << ans.at(i).first;
    }
  }
  cout << endl;
}



Measured memory_bytes: 3112
N = int(input())
p = list(map(int, input().split()))

count = 0
for x in range(N - 2):
    if (p[x] < p[x + 1] and p[x + 1] < p[x + 2]) or (p[x] > p[x + 1] and p[x + 1] > p[x + 2]):
        count += 1
print(count)


Measured memory_bytes: 38256
# エラトステネスの篩, 素因数分解
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(n ** 0.5) + 1):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        c = 0
        while n % p == 0:
            n //= p
            c += 1
        result.append((p, c))
    return result


N = int(input())

m = 1000000007

prime_table = make_prime_table(N)

t = [0] * (N + 1)
for i in range(2, N + 1):
    for p, e in prime_factorize(i):
        t[p] += e

result = 1
for i in range(2, N + 1):
    if t[i] == 0:
        continue
    result = result * (t[i] + 1) % m
print(result)


Measured memory_bytes: 9380
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			for (int j = 0; a * j  + 1 <= d; j++)
				x++;
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 23120
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return (power((a*a)%mod,n/2))%mod;
  else
    return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}
int main(){
FASTIO
string s;
cin>>s;
if((s[2]==s[3])&&(s[4]==s[5])){
   cout<<"Yes";
}
else{
   cout<<"No";
}
return 0;
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {	
	int a,b,c,x;
	int ans = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; ++i) {
		for (int j = 0; j <= b; ++j) {
			for (int k = 0; k <= c; ++k) {
				if (i*500 + j*100 + k*50 == x) {
					++ans;
				}
			}
		}
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

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

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int ans1 = 0;
	int ans2 = 0;
	int x,y,size;
	int paper[14][14];
	for(int i = 0; i < 14; i++){
		for(int j = 0; j < 14; j++){
			paper[i][j] = 0;
		}
	}
	while(scanf("%d,%d,%d",&x,&y,&size) != EOF){
		paper[x + 2][y + 2] ++;
		paper[x + 1][y + 2] ++;
		paper[x + 2][y + 1] ++;
		paper[x + 3][y + 2] ++;
		paper[x + 2][y + 3] ++;
		if(size > 1){
			paper[x + 1][y + 3] ++;
			paper[x + 1][y + 1] ++;
			paper[x + 3][y + 1] ++;
			paper[x + 3][y + 3] ++;
		}
		if(size > 2){
			paper[x + 2][y + 4] ++;
			paper[x + 2][y] ++;
			paper[x + 4][y + 2] ++;
			paper[x][y + 2] ++;
		}
	}
	for(int i = 2; i < 12; i++){
		for(int j = 2; j < 12; j++){
			if(paper[i][j] == 0){
				ans1++;
			}
			if(ans2 < paper[i][j]){
				ans2 = paper[i][j];
			}

		}
	}
	printf("%d\n%d\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 1028
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N,A,B;
ll V[55];
map<ll, ll> m;
ll cmb[55][55];
/*==================================================*/
/*function*/
/*==================================================*/

int main() {
    cin>>N>>A>>B;
    REP(i,0,N) cin>>V[i], m[V[i]]++;

    cmb[0][0] = cmb[1][0] = cmb[1][1] = 1;
    REP(i,2,55){
        REP(j,0,i+1){
            if(j == 0 || j == i){
                cmb[i][j] = 1;
            }else{
                cmb[i][j] = cmb[i-1][j-1] + cmb[i-1][j];
            }
        }
    }

    sort(V, V+N);
    //double mx = -1.0;
    pair<ll, ll> mx = make_pair(1,1);
    //pair<double, ll> ans[55];
    pair<pair<ll, ll>, ll> ans[55]; //合計, 選択数, 組み合わせ

    REP(r,A,B+1){
        long long sum = 0.0;
        ll c = 1;
        set<int> st;
        RREP(i,N-r,N){
            sum += V[i];
            if(st.find(V[i]) == st.end()){
                st.insert(V[i]);
                c *= cmb[m[V[i]]][min(m[V[i]], (ll)(i-(N-r)+1))];
                // cout<<"V[i]: "<<V[i]<<endl;
                // cout<<"a="<<m[V[i]]<<", b="<<min(m[V[i]], (ll)(i-(N-r)+1))<<endl;
                // cout<<"cmb: "<<cmb[m[V[i]]][min(m[V[i]], (ll)(i-(N-r)+1))]<<endl;
            }
        }
        //ans[r-A] = make_pair((double)(sum/(double)r), c);
        ans[r-A] = make_pair(make_pair(sum, r), c);
        //mx = max(mx,((double)sum/(double)r));
        if(mx.F*ans[r-A].F.S < mx.S*ans[r-A].F.F){
            mx = make_pair(ans[r-A].F.F, ans[r-A].F.S);
        }
    }

    ll cnt = 0;
    REP(i,0,B-A+1){
        //if(ans[i].F == mx){
        if(mx.F*ans[i].F.S == mx.S*ans[i].F.F){
            cnt += ans[i].S;
        }
    }

    printf("%.7f\n", ((double)mx.F / (double)mx.S));
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	int N, A, B;
	vector<int> h;
	cin >> N >> A >> B;
	for (int i = 0; i < N; ++i) {
		int _hi;
		cin >> _hi;
		h.push_back(_hi);
	}

	sort(h.begin(), h.end(), [](int x, int y){ return x > y; });

	const int MAX_ANS = (h[0] + B - 1) / B;

	int ok = MAX_ANS + 1;
	int ng = 0;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		
		int key = 0;
		for (int i = 0; i < N; ++i) {
			int tmp = h[i] - B * mid;
			if (0 < tmp) key += (tmp + (A - B - 1)) / (A - B);
		}

		if (mid >= key) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}


	cout << ok << endl;



	return 0;
}

Measured memory_bytes: 1400
li1 = [int(x) for x in input().split()]
m1 = min(li1)
li1.remove(m1)
m2 = min(li1)
li1.remove(m2)
m3 = min(li1)
if (m2 -m1) % 2 == 0:
    print(int((m2 - m1)/2 + (m3 - m2)))
else:
    print(int((m2 - m1)//2 +(m3 -m2) + 2))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    int ans = 1;
    rep(i,n){
        if(a[i]==1){
            int j=i;
            while(j<n && a[j]==1) ++j;
            ans = max(ans, j-i+1);

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



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

using namespace std;

bool is_fifty_fifty(const string& s)
{
  char c1 = s.at(0);
  char c2 = 0;
  int cnt1 = 1;
  int cnt2 = 0;
  for (int i = 1; i < 4; i++) {
    if (c1 == s.at(i)) {
      cnt1++;
      continue;
    }
    if (c2 == 0) {
      c2 = s.at(i);
    }
    if (c2 == s.at(i)) {
      cnt2++;
    }
  }
  return cnt1 == 2 && cnt2 == 2;
}

int main()
{
  string s;
  cin >> s;
  if (is_fifty_fifty(s)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#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 repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

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

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 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> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; 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, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    cout << s[i];
    if (i == 3) cout << " ";
  }
  cout << '\n';
}


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

using namespace std;

int main() {
	string a, b;
	int n; cin >> n;
	cin >> a >> b;
	for(int i = 0; i < n; i++) {
		cout << a[i] << b[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int>a(m);
  for(int i = 0;i<m;i++){
    cin >> a[i];
    n -= a[i];}
  if(n>=0) cout << n <<endl;
  else cout << -1 <<endl;
  return 0;
}

Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int arry[33] = {0, 1, 1, 1, 2, 1, 2, 1,  5, 2, 2, 1, 5, 1, 2, 1, 14,
                1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    int k;
    while (cin >> k) {
        cout << arry[k] << endl;
    }
    return 0;
}

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

#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

const int N =100;

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);

}
ll f(ll n) {
	return n * (n - 1) / 2;
}
bool cmp(const tuple<int, string, string>& a,
               const tuple<int, string, string>& b)
{
    return (get<0>(a) < get<0>(b));
}

void solve()
{
    int x;
    cin>>x;
    if(x==0)
        cout<<1;
    else
        cout<<0;
        
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main()
{
    int a, b, c;
    int x;
    int ans = 0;

    cin >> a >> b >> c;
    cin >> x;

    for ( int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if(i * 500 + j * 100 + k * 50 == x) {
                    ans++;
                }
            }
        }
    }


    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;
     
class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int num=Integer.parseInt(br.readLine());
int[] heap=new int[num+1];
int parent,left,right;
StringBuilder sb;
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<num;i++){
heap[i+1]=Integer.parseInt(st.nextToken());
}
for(int i=1;i<=num;i++){
sb=new StringBuilder();
sb.append("node ");
sb.append(i);
sb.append(": key = ");
sb.append(heap[i]);
parent=i/2;
left=i*2;
right=i*2+1;
if(parent>=1&&parent<=num){
sb.append(", parent key = ");
sb.append(heap[parent]);
}
if(left>=1&&left<=num){
sb.append(", left key = ");
sb.append(heap[left]);
}
if(right>=1&&right<=num){
sb.append(", right key = ");
sb.append(heap[right]);
}
sb.append(", ");
out.println(sb);
}
out.flush();
}
}

Measured memory_bytes: 17912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,k,m;
int main()
{
    ll count=0;
    m=100;
     k=1;
    cin>>x;
    while(m<x)
    {
        count++;
        m=m+k;
        k=m/100;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3596
n = int(input())
a = list(map(int, input().split()))
i = 0
cnt = 0
flag = 1
while flag:
    flag = 0
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            flag = 1
            cnt += 1
            a[j], a[j - 1] = a[j - 1], a[j]
    i += 1
print(" ".join(map(str, a)))
print(cnt)


Measured memory_bytes: 5600