akhauriyash/Code-Regression huggingface dataset:
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import Data.Tuple (swap)

main :: IO ()
main = do
  [n, m] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  hs <- VU.fromList . map unsafeTextToInt . T.words <$> T.getLine :: IO (VU.Vector Int)
  abs <- sequence . replicate m $ unsafeListToPair . map (pred . unsafeTextToInt) . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    adjacency = fromEdgesToAdjacencyVectorN n . concatMap (pairToList . ((,) <$> id <*> swap)) $ abs :: V.Vector [Int]
    p :: Int -> Bool
    p i = all (< hs VU.! i) . map (hs VU.!) $ adjacency V.! i
  print . length . filter p $ [0..(pred n)]

fromEdgesToAdjacencyVectorN :: Int -> [(Int, Int)] -> V.Vector [Int]
fromEdgesToAdjacencyVectorN n = V.accum (flip (:)) (V.replicate n [])

pairToList :: (a, a) -> [a]
pairToList (x, y) = [x, y]

unsafeListToPair :: [Int] -> (Int, Int)
unsafeListToPair [x, y] = (x, y)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int count=0;
  for(int i=l; i<=r; i++){
    if(i%d==0){
      ++count;
    }
  }
  cout << count;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  r(i,N) cin>>m[i];
  sort(m.begin(),m.end());
  r(i,N) X-=m[i];
  int n = X/m[0] + N;
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<int> x(m);
    rep(i,m) cin>>x[i];
    sort(x.begin(),x.end());
    priority_queue<int> que;
    rep(i,m-1)que.push(x[i+1]-x[i]);
    rep(i,n-1){
        if(que.size()==0)break;
        que.pop();
    }
    int res=0;
    while(que.size()){
        res+=que.top();
        que.pop();
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1276
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<map>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	string s,t;
	cin >> s;
	for(int i = 0; i < s.size(); ++i) {
		if(s[i] == 'B') {
			if(t.size() > 0)
				t.pop_back();
		}
		else
			t.push_back(s[i]);
	}
	cout << t << endl;
}

Measured memory_bytes: 3576
#include <iostream>
int main()
{
    int N;
    std::cin >> N;
    int h_list[110];
    for ( int i = 0; i < N; ++i) std::cin >> h_list[i];

    int count = 0;
    int start = 0;
    while ( true) {
     bool check_flag = false;
     for (int i = 0; i < N; ++i){
         if ( h_list[i] != 0) {
             check_flag = true;
             break;
         }
     }
     if ( check_flag == false) {
         break;
     }
     for (int i = 0; i < N; ++i){
         if ( h_list[i] != 0) {
            start = i;
            break;
         }
     }
     int limit = N;
     for (int i = start; i < N; ++i){
         if ( h_list[i] == 0 ){
             limit = i;
             break;
         }
         h_list[i] = h_list[i] - 1;
     }
     count = count+1;

    }
    std::cout << count << std::endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int h,w;
char grid[120][120];
int resl[120][120],resu[120][120];
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>grid[i][j];
		}
	}
	memset(resl,63,sizeof(resl));
	memset(resu,63,sizeof(resu));
	resl[1][1]=(grid[1][1]=='#');
	resu[1][1]=(grid[1][1]=='#');
	int ff;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==1&&j==1)
				continue;
			if(i>1){
				if(grid[i][j]=='.'){
					resu[i][j]=min(resu[i][j],resl[i-1][j]);
					resu[i][j]=min(resu[i][j],resu[i-1][j]);
				}
				else{
					//a.not turn
					resu[i][j]=min(resu[i][j],resu[i-1][j]+(grid[i-1][j]=='.'));
					//b.turn
					resu[i][j]=min(resu[i][j],resl[i-1][j]+(grid[i-1][j]=='.'));
				}
			}
			if(j>1){
				if(grid[i][j]=='.'){
					resl[i][j]=min(resl[i][j],resl[i][j-1]);
					resl[i][j]=min(resl[i][j],resu[i][j-1]);
				}
				else{
					//a.not turn
					resl[i][j]=min(resl[i][j],resl[i][j-1]+(grid[i][j-1]=='.'));
					//b.turn
					resl[i][j]=min(resl[i][j],resu[i][j-1]+(grid[i][j-1]=='.'));
				}
			}
		}
	}
	cout<<min(resu[h][w],resl[h][w])<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr int N_MAX = 200000;

vector<int> graph[N_MAX];
vector<int> parent(N_MAX);
vector<ll> cnt_subtree_nodes(N_MAX, 0);

ll dfs(int node, int par) {
    parent[node] = par;
    ll ret = 0;
    for(int child: graph[node]) {
        if(child == par) continue;
        cnt_subtree_nodes[child] = dfs(child, node);
        ret += cnt_subtree_nodes[child];
    }
    return ret + 1;
}

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a, b;
    for(int i=0;i<n-1;++i) {
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    cnt_subtree_nodes[0] = dfs(0, -1);

    vector<ll> all_white(N_MAX);
    for(int i=0;i<n;++i) {
        all_white[i] = modpow(2LL, cnt_subtree_nodes[i]);
    }

    ll ans = 0;
    for(int i=0;i<n;++i) {
        if(graph[i].size() <= 1) continue;
        ll tmp = (1 - modpow(modpow(2LL, n-1), MOD-2) + MOD) % MOD;
        for(int j: graph[i]) {
            if(j == parent[i]) {
                tmp = (tmp - ((modpow(2LL, n-cnt_subtree_nodes[i]) - 1) * modpow(modpow(2LL, n-1), MOD-2)) % MOD + MOD) % MOD;
                continue;
            }
            tmp = (tmp - ((all_white[j] - 1) * modpow(modpow(2LL, n-1), MOD-2)) % MOD + MOD) % MOD;
        }
        ans += tmp;
        ans %= MOD;
    }
    ans *= modpow(2LL, MOD-2);
    ans %= MOD;

    cout << ans << endl;
}


Measured memory_bytes: 26240
import sys
input = sys.stdin.readline
l, r = map(int, input().split())
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        tmp = 0
        tmp = i * j % 2019
        ans = min(ans, tmp)
        if ans == 0:
            print(ans)
            exit()
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
    ll x,a,b, dp[240];
    cin >> x;
    REP(i,120){
        dp[i*2] = i;
        dp[i*2+1]=-i;
        REP(j,4){
            dp[i*2] *= i;
            dp[i*2+1]*=i;
        }
    }
    
    REP(i,240){
        REP(j,240){
            if(dp[i]-dp[j]==x){
                a = i/2;
                if(i%2!=0) a = -a;
                b = j/2;
                if(j%2!=0) b = -b;
            }
        }
    }

    cout << a <<" " << b << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
 
using namespace std;
 
int main(){
    char str[20001];
    int m,tmp,length;
    while(true){
        scanf("%s",str);
        if(str[0] == '-') break;
        length = 0;
        for(int k = 0; str[k] != '\0';k++) length++;
        scanf("%d",&m);
        int index = 0;
        for(int i = 0; i < m; i++){
            scanf("%d",&tmp);
            for(int j = 0; j < tmp; j++){
                str[index+length] = str[index];
                index++;
            }
        }
        for(int p = 0; p < length; p++){
            printf("%c",str[index+p]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 2500
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC043 C - いっしょ
// 2020.06.15

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  int ans = 1e9;
  for(int i = -100; i <= 100; i++){
    int res = 0;
    REP(j, N){
      res += (i-A[j])*(i-A[j]);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
L=[1]
n=int(input())
x = 6
y = 9
while x <= n:
  L.append(x)
  x *= 6
while y <= n:
  L.append(y)
  y *= 9
L.sort()#[1,6,9,36,81]
dp = [float("Inf")]*(n+1)
dp[0] = 0
for i in range(n+1):#0~81
  for j in L:#1,6,9
    if i+j <= n:
      dp[i+j] = min(dp[i+j],dp[i]+1)#dp=[0,1,...1,.1]
    else:
      break
print(dp[n])

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

#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;

int main(){

    /*string s;

    string t;

    cin >> s;

    int m=0;
    int l=0;
    string u;

    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size()-i+1;j++){
            t = s.substr(i,j);
            bool ok=true;
            for(int k=0;k<t.size();k++){
                if(t[k]=='T' || t[k] == 'A' || t[k] == 'G' || t[k] == 'C') ;
                else ok = false;
            }
            l = t.size();
            if(ok == true && t.size()>m)u=t;
            if(ok) m=max(m,l);
        }
    }

    cout << m << endl;*/

    string s;
    cin >> s;
    ll m=0;
    ll a=0;
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' || s[i]=='C' ||s[i]=='G' || s[i]=='T')a++;
        else{
            m=max(a,m);
            a=0;
        }
    }
    m=max(a,m);
    cout << m<< endl;
    
    

     

}

Measured memory_bytes: 3596
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) <= (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long R, long long G, long long B, long long N) {
  ll ans = 0;
  rep(r, 3000) {
    ll rest = N - R * r;
    if (rest < 0) {
      break;
    }
    rep(g, 3000) {
      ll rest2 = rest - G * g;
      if (rest2 < 0) {
        break;
      }
      if (rest2 >= 0 && rest2 % B == 0) {
        ans++;
      }
    }
  }
  print(ans);
}

int main() {
  long long R;
  scanf("%lld", &R);
  long long G;
  scanf("%lld", &G);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  solve(R, G, B, N);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

  	static int a[] ={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};
	
    public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      
        System.out.println(a[n-1]);
    }
}

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

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	queue<ll> q;
	int k;
	ll lunlun;
	cin >> k;
	for(int i = 1; i < 10; i++) q.push(i);
	for(int i = 0; i<k; i++) {
		lunlun = q.front();
		q.pop();	
		if(lunlun%10 != 0) q.push(lunlun*10 + lunlun%10 - 1);
		q.push(lunlun*10 + lunlun%10);
		if(lunlun%10 != 9) q.push(lunlun*10 + lunlun%10 + 1);
	}
	cout << lunlun;

}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		int count=0;
		boolean sw=false;
		//int answer=0;
		String answer="No";
		//List<Integer> h=new ArrayList<Integer>();
		//int af=Integer.MAX_VALUE;
		int N=0;
		//int X=0;
		int max=0;
		int min=0;
		int sum=0;
		int a=0;
		//int t[]=new int[(int)Math.pow(10,5)];
		
		//入力
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		//X=sc.nextDouble();
		int L[]=new int[N];
		for(int i=0;i<N;i++)
		{
			L[i]=sc.nextInt();
		}
		//String S=sc.next();
		
		//処理
		for(int i=0;i<N;i++)
		{
			max=Math.max(max,L[i]);
		}
		for(int i=0;i<N;i++)
		{
			if(count==0 && L[i]==max)
			{
				count++;
			}else
			{
				sum+=L[i];
			}
		}
		if(sum>max)
		{
			answer="Yes";
		}
		// 出力
		//System.out.println(Arrays.deepToString(td));
		System.out.println(answer);
		//System.out.println(max+" "+min);
	}
}

Measured memory_bytes: 23764
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++) cin >> W[i];
    int right = 0;
    for(int i = 0; i < N; i++) right += W[i];
    int dist = 1000000;
    int left = 0;
    for(int i = 0; i < N; i++){
        left += W[i];
        right -= W[i];
        dist = min(dist, abs(left-right));
    }
    cout << dist << endl;
}


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

num = 0
for d1, d2 in Dss:
    if d1 == d2:
        num += 1
        if num >= 3:
            print('Yes')
            break
    else:
        num = 0
else:
    print('No')


Measured memory_bytes: 9164
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,k;
  cin >> n >> k;
  vector<LL> v(n);
  for(auto &x:v) cin >> x;
  LL answer = 0;
  REP(i,n+1) {
    REP(j,n+1-i) {
      if(i+j>k) continue;
      vector<LL> hand;
      REP(p,i) hand.push_back(v[p]);
      REP(q,j) hand.push_back(v[n-1-q]);
      sort(hand.begin(),hand.end());
      REP(r,k-(i+j)) {
        if(r<i+j && hand[r]<0) hand[r] = 0;
      }
      answer = max(answer, accumulate(hand.begin(),hand.end(),0ll));
    }
  }
  cout << answer << endl;
  return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  auto res = vector<int>(n);
  for(int i = 0;i < n-1;++i){
    int a;
    scanf("%d\n", &a);
    --a;
    ++res[a];
  }
  for(int i = 0;i < n;++i){
    printf("%d\n", res[i]);
  }
  return 0;
}


Measured memory_bytes: 4132
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n;
        String s;
        boolean flag;

        flag = false;
        n=nextInt();
        s=next();
        if(n%2==1){
            print("No");
            System.exit(0);
        }
        else{
            for(int i=0;i<n/2;i++){
                if(s.charAt(i)==s.charAt(i+n/2)){
                    flag=true;
                }
                else{
                    print("No");
                    System.exit(0);
                }
            }
            if(flag) print("Yes");
        }
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h> 
using namespace std;
int x[5];
int main() 
{
	for(int i=1;i<=5;i++)
	cin>>x[i];
	for(int i=1;i<=5;i++)
	if(x[i]==0)
	cout<<i;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

typedef struct {int id, solved, penalty;} Team;

int compare(const void *a, const void *b) {
	const Team ta = *(Team *)a, tb = *(Team *)b;

	if (ta.solved != tb.solved)
		return tb.solved - ta.solved;
	if (ta.penalty != tb.penalty)
		return ta.penalty - tb.penalty;
	return ta.id - tb.id;
}

int main(void) {
	int i;
	int t, p, r;

	while (scanf("%d %d %d", &t, &p, &r), t) {
		Team team[50] = {0};
		int wrong[50][10] = {0};

		for (i = 0; i < t; i++)
			team[i].id = i + 1;

		for (i = 0; i < r; i++) {
			int tid, pid, t;
			char mes[10];

			scanf("%d %d %d %s", &tid, &pid, &t, mes);
			tid--;
			pid--;

			if (mes[0] == 'C') {
				team[tid].solved++;
				team[tid].penalty += wrong[tid][pid] * 1200 + t;
			} else
				wrong[tid][pid]++;
		}

		qsort(team, t, sizeof(Team), &compare);

		for (i = 0; i < t; i++)
			printf("%d %d %d\n", team[i].id, team[i].solved, team[i].penalty);
	}

	return 0;
}

Measured memory_bytes: 616
k = gets.to_i

queue = (1..9).to_a
ans = 0
k.times do |i|
  ans = queue.shift
  queue << ans * 10 + ans % 10 - 1 if ans % 10 != 0
  queue << ans * 10 + ans % 10
  queue << ans * 10 + ans % 10 + 1 if ans % 10 != 9
end
p ans

Measured memory_bytes: 16364
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <iomanip>

using namespace std;

const long long N = 100 * 1000 + 5;
long long n;
long long a, b;
long long damage = 0;
long long ans = 0;
long long monster[N];

bool isval(long long k)
{
	long long cnt = 0;
	for (long long i = 0; i < n; i++)
	{
		long long x = monster[i];
		x -= k * b;
		if (x <= 0)
			continue;
		cnt += (x / (a - b)) + bool(x % (a - b));
	}
	return cnt <= k;
}

long long bsearch()
{
	long long down = 0;
	long long up = 1000 * 1000 * 1000 + 5;
	while (up - down > 1)
	{
		long long md = (up + down) / 2;
		if (isval(md))
		{
			up = md;
		}
		else
		{
			down = md;
		}
	}
	return up;
}
 
 
int main() 
{
	cin >> n >> a >> b;
	for (long long i = 0; i < n; i++)
	{
		cin >> monster[i];
	}
	cout << bsearch();

}



























Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
    int a,b;
    cin >> a >> b;
    if(b<a){
      cout << a-1 << endl;
    }else{
      cout << a << endl;
    }
    return 0;
  }    

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n").map(Number);
    if(input[0]==input[1]){
        console.log("EQUAL");
    }else{
        console.log(input[0]>input[1]?"GREATER":"LESS");
    }
}Main(require("fs").readFileSync("/dev/stdin","utf8").trim());


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b; cin >> a >> b;
	if ((a == 1 || b == 1) && a != b) {
		puts(b == 1 ? "Bob" : "Alice");
	}
	else if (a == b) puts("Draw");
	else {
		puts(a > b ? "Alice" : "Bob");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string.h>

using namespace std;

int main(){
  int n,q;
  int cum[100005]={};
  string s;
  scanf("%d %d",&n,&q);
  cin>>s;

  for(int i=2;i<=n;i++){
    if(s[i-2]=='A'&&s[i-1]=='C') cum[i]=cum[i-1]+1;
    else cum[i]=cum[i-1];
  }

  for(int i=0;i<q;i++){
    int l,r;
    scanf("%d %d",&l,&r);
    printf("%d\n",cum[r]-cum[l]); 
  }

  return (0);
}


Measured memory_bytes: 1408
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double t = sc.nextInt();
        double a = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }
        int plan = 0;
        double sub = 0.0;
        double temp = 0;
        double minsub = 100000.0;
        for(int i = 0; i < n; i++){
            temp =  t - h[i] * 0.006;
            sub = Math.abs(a - temp);
            if(sub < minsub){
                minsub = sub;
                plan = i+1;
            }
        }
        System.out.print(plan);
    }
}

Measured memory_bytes: 23764
N=int(input())
dp=[0]*(100000+1)
a=1
b=6
c=9
for i in range(1,N+1):
  if i>=b*6:
    b*=6
  if i>=c*9:
    c*=9
  if i<6:
    dp[i]=i
  elif i<9:
    dp[i]=min(dp[i-a]+1,dp[i-b]+1)
  else:
    dp[i]=min([dp[i-a]+1,dp[i-b]+1,dp[i-c]+1])
print(dp[N])


Measured memory_bytes: 9668
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input0 = Console.ReadLine().Split(' ');
        int n = int.Parse(input0[0]);
        int m = int.Parse(input0[1]);
        string[] a = Console.ReadLine().Split(' ');
        for (int i = 0; i < m; i++)
        {
            n -= int.Parse(a[i]);
        }
        if (n <= -1)
        {
            n = -1;
        }
        Console.WriteLine(n);
    }
}

Measured memory_bytes: 19244
#include <stdio.h>
#include <stdlib.h>
#define INF 1000000001

void merge(int, int, int);
void mergeSort(int, int);

int n;
int A[200000];
int L[100001], R[100001];
long cnt = 0;
	
int main()
{
	int i;
	int n;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}
	
	mergeSort(0, n);

	printf("%ld\n", cnt);
	
	return 0;
}

void mergeSort(int left, int right)
{
	int mid;

  	if(left + 1 < right)
    {
     	mid = (left + right)/2;
     	mergeSort(left, mid);
     	mergeSort(mid, right);
   		merge(left, mid, right);
    }
}

void merge(int left, int mid, int right)
{
  	int i, j, k;
	int n1, n2;
 
	n1 = mid - left;
 	for(i = 0; i < n1; i++)
    {
    	L[i] = A[left + i];
    }
  	L[n1] = INF;
  
  	n2 = right - mid;
  	for(j = 0; j < n2; j++)
    {
      	R[j] = A[mid + j];
    }
  	R[n2] = INF;

	i = 0;
	j = 0;
  	for(k = left; k < right; k++)
  	{
      	if(L[i] <= R[j])
	    {
	    	A[k] = L[i];
	    	i++;
	    }
      	else
	  	{
	  		A[k] = R[j];
	    	cnt += n1 - i;
	    	j++;
	  	}
	}
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define brk break
#define cont continue
#define all(a) a.begin(),a.end()
#define E9 1000000007
#define E5 100007
#define INF 1e18+7
typedef long long int lli;  //  e-18 to e18
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
typedef map<int,int> mii;
typedef vector<long long int> vll;
typedef pair<long long int,long long int> pll;
typedef vector<vector<long long int>> vvll;
void solve(){
    lli n,k;
    cin >> n >> k; 
    vll a(n+1);
	for(lli i = 1; i <= n; i++) cin >> a[i]; 
	lli ans = 0, K = (k * (k + 1) / 2) % E9, KK = (k * (k - 1) / 2) % E9; 
	for(lli i = 1; i <= n; i++) {
		lli l = 0, r = 0; 
		for(lli j = 1; j < i; j++) l += (a[j] > a[i]); 
		for(lli j = i + 1; j <= n; j++) r += (a[j] > a[i]); 
		ans = (ans + l * K % E9 + r * KK % E9) % E9; 
	}
	cout << ans << el; 
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}

// compilation flags

// normal
//      g++ -std=c++17 -O2 -Wall a.cpp -o a
// fast running time
//      g++ -O2 -std=c++17 -Wno-unused-result -Wshadow -Wall -o a a.cpp
// check for mistakes
//      g++ -std=c++17 -Wshadow -Wall -o a a.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

// use digit separator for better readbility e.g. 10000000 (base 10 - decimal) =  1'000'0'000' (separate at every 3 digits)
// 0b0101000 (base 2 - binary ) =  0b010'1000' (separate at every 4 digits-nibble)
// integer literals - suffixes and prefixes e.g. 0b1010 = binary - prefix for base of number
// 0x9A01 = hexadecimal
// 0733 = octal
// 153 = decimal
// 1645241684131 ll =  suffix for data type here long long int lly for others
// use M_PI for value of pi
// and check function defination for every new function used

// snippets

//     int n,k;
//     cin>>n>>k;
//     vi a(n);
//     f0(0,n) cin>>a[i];


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {

	long long int A, B,K;
	cin >> A >> B >> K;

	long long int ans1, ans2;

	if (K <= A) { ans1 = A - K; ans2 = B; }
	else if (K-A <= B) { ans1 = 0; ans2 = B - (K-A); }
	else { ans1 = 0; ans2 = 0; }

	cout << ans1 << " " << ans2 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  int a;
  map<int,int>d;
  for(int i=0;i<n;i++){
    cin>>a;
    d[a]++;
    if(d[a]==2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  }

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String ans = "Yes";
		for (int i = 0; i < N; i++) {
			int t = in.nextInt();
			int x = in.nextInt();
			int y = in.nextInt();
			if (t < x + y || ((t % 2 == 0) != ((x + y) % 2 == 0))) {
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
		in.close();
	}
}

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

int main()
{
    int h, w, count = 0;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s.at(i);
    }
    const int x[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
    const int y[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s.at(i).at(j) == '.')
            {
                for (int k = 0; k < 8; k++)
                {
                    int xx = j + x[k];
                    int yy = i + y[k];
                    if (xx >= 0 && xx < w && yy >= 0 && yy < h)
                    {
                        if (s.at(yy).at(xx) == '#')
                        {
                            count++;
                        }
                    }
                }
                s.at(i).at(j) = (char)(count + '0');
                count = 0;
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        cout << s.at(i) << endl;
    }
}

Measured memory_bytes: 256
/* author: Tarek */ 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
string plain;
cin>>plain;
int c=0;
int l=0;
int r = plain.size()-1;
while(l<r){
if(plain[l]!=plain[r])c++;
l++;
r--;
}
cout<<c<<endl;
return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,Mod=1e9+7,a[22][22],dp[(1<<21) + 10];
pair<int,int>S[(1<<21) + 10];  
int get(int x)
{
    int ans = 0;
    while(x)
        ans += x & 1, x /= 2;
    return ans;
}
int main()
{
    cin >> n;
    for(int i=1; i<=n; i++) 
    {
        for(int j=1; j<=n; j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i=0; i<(1<<n); i++)
    {
        S[i].first = get(i);
        S[i].second = i;
    }
    sort(S,S+(1<<n));
    dp[0] = 1;
    for(int i=0; i<(1<<n); i++)
    {
        int x = S[i].first;
        int y = S[i].second;
        int p = y; 
        for(int j=n-1; j>=0; j--)
        {
            if(!(p & 1))
            {
                int man = n - j;
                int woman = x + 1; 
                int num = y + (1 << man - 1);
                if(man > n || woman > n || num > (1<<n)) continue;
                if(a[man][woman]) dp[num] += dp[y];
                dp[num] %= Mod;
            }
            p /= 2;
        }
    }
    cout << dp[(1<<n) - 1];
}

Measured memory_bytes: 24832
#include<stdio.h>
int main(void){
    int c,co = 0;
    scanf("%d", &c);
    while(c >= 500){
        c = c - 500;
        co = co + 1000;
    }
    while(c >= 5){
        c = c - 5;
        co = co + 5;
    }
    printf("%d\n", co);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN (int)3003
#define MOD 998244353

int a, b, c, d;

ll dp[MAXN][MAXN];

ll solve(int i, int j){
    if(i == a && j == b) return 1;
    if(i < a || j <b) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    return dp[i][j] = (solve(i-1, j)*j
                        + solve(i,j-1)*i
                        - solve(i-1,j-1)*(i-1)*(j-1))%MOD;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin >> a >> b >> c >> d;
    ll ans = solve(c,d);
    cout << (ans >= 0 ? ans : ans+MOD) << endl;
    // for(int i=0; i<=c; i++){
    //     for(int j=0; j<=d; j++)
    //         cout << solve(i,j) << " ";
    //     cout << endl;
    // }
}


Measured memory_bytes: 74392
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import Decimal #floatの高精度ver, 渡すのはstr型で
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
class BIT:
    def __init__(self,n):
        self.n=n
        self.data= [0]*(n+1) #これがBIT
        self.el= [0]*(n+1) #これが元データ
    def sum(self,i):  #iまでの和
        s=0
        while i>0:
            s+=self.data[i]
            i-= i&(-i)
        return s
    def add(self,i,x):  #iにxを足す(x<0)
        self.el[i]+=x
        while i<= self.n:
            self.data[i]+= x
            i+= i&-i
    def get(self,i,j=None):  #iからjまでの和、iだけなら普通の要素iを取得(いる？)
        if j is None:
            return self.el[i]
        return self.sum(j)-self.sum(i)
    

n,q=map(int,input().split())
C=list(map(int,input().split()))
C=[i-1 for i in C]  #球の純粋配置
Q=[]
for i in range(q):
    l,r=map(int,input().split())
    l-=1;r-=1
    Q.append([i,l,r])
Q=sorted(Q, key=lambda x:x[2]) 
ANS=[-1]*q

B=BIT(n)
YOI=[-1]*n #色iの良い球の位置
for i in range(Q[0][2],-1,-1):
    if YOI[C[i]]==-1:
        YOI[C[i]]=i
        B.add(i+1,1)

# 
ANS[Q[0][0]]= B.sum(Q[0][2]+1)- B.sum(Q[0][1])
left=Q[0][1]; right=Q[0][2]
#print(B.data)
# right=-1
for l in Q[1:]:
    newleft,newright=l[1],l[2]
    for i in range(newright,right,-1):
        if YOI[C[i]]==-1: #新種の色
            YOI[C[i]]=i
            B.add(i+1, 1)
        elif YOI[C[i]]>i:
            continue
        else:
            B.add(YOI[C[i]]+1, -1)
            YOI[C[i]]=i
            B.add(i+1, 1)
    ANS[l[0]]= B.sum(newright+1)- B.sum(newleft)
    right=newright
    #print(B.data)
for i in ANS:
    print(i)


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

	char S[20], T[20], U[20];

	int A, B;
	
	scanf("%s %s", S, T);
	scanf("%d %d", &A, &B);
	scanf("%s", U);
	if(strcmp(U,S) == 0)
	{
		printf("%d %d",A - 1,B);
	}
	if(strcmp(U,T) == 0)
	{
		printf("%d %d",A,B - 1);
	}
	
	return 0;	
}

Measured memory_bytes: 1728
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    for(double i=1;i<=100000;i++){
        int x=i*0.08;
        int y=i*0.10;
        if(x==a&&y==b){
            cout<<(int)i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;

    
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

    int h, w;
    cin >> h >> w;

    string ans;
    vector<string>str;

    while (h--)
    {
        cin >> ans;
        str.pb(ans);
        str.pb(ans);

    }


    for (auto it : str)
    {
        cout << it << endl;
    }

}


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

using namespace std;

void copyArray(const vector<int> a, vector<int> &b, int arraySize)
{
	for (int i = 0; i < arraySize; i++)
	{
		b.at(i) = a.at(i);
	}
}

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	vector<int> b(n);
	copyArray(a, b, n);
	sort(b.begin(), b.end());
	int maxValue = b.at(n - 1);
	int secondMaxValue = b.at(n - 2);

	for (int i = 0; i < n; i++)
	{
		if (a.at(i) == maxValue)
		{
			cout << secondMaxValue << endl;
		}
		else
		{
			cout << maxValue << endl;
		}
	}
}

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

bool isprime(int x){
	if(x==2){
		return true;
	}
	if(x<2||x%2==0){
		return false;
	}
	for(int i=3;i*i<=x;i+=2){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(isprime(x)){
			cnt++;
		}
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3096
import sys
input = sys.stdin.readline
list1 = list(input())
del list1[-1]
ans = 0
def func(flist):
    count0 = 0
    for i in flist:
        if i == "0":
            count0 += 1
    count1 = len(flist)-count0
    return len(flist)-abs(count1-count0)

if __name__ == "__main__":
    print(func(list1))

Measured memory_bytes: 49008
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a,b = mi()
c = ''
if a <= b:
    for i in range(b):
        c += str(a)
else:
    for i in range(a):
        c += str(b)

print(c)



Measured memory_bytes: 3060
fn main() {
    let n: usize = {
        let mut n = String::new();
        std::io::stdin().read_line(&mut n).ok();
        n.trim().parse().unwrap()
    };

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let mut line: Vec<i32> = line.split_whitespace()
                                   .map(|c|c.parse().unwrap())
                                   .collect();
    line.sort();
    line.dedup();
    println!("{}", if n == line.len() { "YES" } else { "NO" });
}

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

int main() {
 int a, b, output, check;
cin >> a >> b;
 check = (a+b) % 2;
if(check > 0){
 output = ((a+b) /2 )+1;
}else{
 output = ((a+b) /2 );
}

  cout << output  << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,s,p;
    cin>>n>>m;
    s=n*2;
    p=n*4;
    if(m>=s&&m<=p&&m%2==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

map<long long int, ll> prime_factor(long long int n) {
    map<ll, ll> ret;
    for (long long int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    ll N, P;
    cin >> N >> P;

    map<ll, ll> prime = prime_factor(P);

    ll output = 1;
    for (auto num : prime) {
        if (num.second / N > 0) {
            output *= powl(num.first, (num.second / N));
        }
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3704
using System;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int sum = 0;
            string[] p = Console.ReadLine().Split(' ');
            int[] P = new int[n];
            for(int i = 0; i < n; i++)
            {
                P[i] = int.Parse(p[i]);
            }
            Array.Sort(P);
            for(int j = 0; j < P.Length; j++)
            {
                sum += P[j];
                if (j == k-1) break;
            }
            Console.WriteLine(sum);

        }
    }
}


Measured memory_bytes: 18468
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
 
int main(){
  int R[MAX], n;
 
  cin >> n;
  for ( int i = 0; i < n; i++) cin >> R[i];
 
  int maxv = -2000000000;
  int minv = R[0];
 
  for ( int i = 1; i < n; i++ ) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
 
  cout << maxv << endl;
 
  return 0;
}


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

int main() {
	string s,t;
	cin >> s >> t;
	int ans=0;
	for (int i=0;i<s.size();i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3916
def main():

    n = int(input())
    x = list(str(input()))

    p = 0
    for i in range(n):
        if x[i] == '1':
            p += 1

    if p == 0:
        ans = [1]*n
        for i in range(n):
            print(ans[i])
        exit()

    if p == 1:
        ans = [0]*n
        for i in range(n):
            if x[i] == '1':
                ans[i] = 0
            else:
                if i != n-1:
                    if x[-1] != 1:
                        ans[i] = 1
                    else:
                        ans[i] = 2
                else:
                    ans[i] = 2
        for i in range(n):
            print(ans[i])
        exit()

    def power(a, n, mod):
        bi=str(format(n,"b")) #2進数
        res=1
        for i in range(len(bi)):
            res=(res*res) %mod
            if bi[i]=="1":
                res=(res*a) %mod
        return res

    X1 = 0
    X2 = 0
    import copy
    s = copy.copy(x)
    s.reverse()
    #print(s)
    for i in range(n):
        if s[i] == '1':
            X1 += power(2, i, p+1)
            X2 += power(2, i, p-1)

    #print(p)
    #print(X1)
    #print(X2)
    ans = [0]*n
    for i in range(n):
        if x[i] == '0':
            temp = X1
            temp += power(2, n-1-i, p+1)
            temp %= (p+1)
            if temp == 0:
                ans[i] = 1
                continue
            cnt = 0
            d = p+1
            while temp:
                cnt += 1
                temp %= d
                b = format(temp, 'b')
                d = 0
                for j in range(len(b)):
                    if b[j] == '1':
                        d += 1
        else:
            temp = X2
            temp -= power(2, n-1-i, p-1)
            temp %= (p-1)
            if temp == 0:
                ans[i] = 1
                continue
            cnt = 0
            d = p-1
            while temp:
                cnt += 1
                temp %= d
                b = format(temp, 'b')
                d = 0
                for j in range(len(b)):
                    if b[j] == '1':
                        d += 1
        ans[i] = cnt
    #print(*ans)
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 88388
#include<stdio.h>
int main()
{
    int n,i,j=0,c=0,count=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        j=i;
        while(j!=0)
        {
            c++;
            j=j/10;
        }
        if(c%2!=0)
        {
            count++;
        }
        c=0;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1720