akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner in = new Scanner(System.in);
        int square = in.nextInt();
        int[] height = new int[square];
                
        int tmpmove = 0;
        int maxmove = 0;
        for (int i = 0;i < square;i++) {
            height[i] = in.nextInt();
            
            if (i == 0){
                continue;
            } 
            //System.out.println(height[i] + " " + tmpmove);
            if (height[i-1] >= height[i]){
                tmpmove++;
                if (maxmove < tmpmove){
                    maxmove = tmpmove;
                }
            }else{
               tmpmove = 0;
            }
           
        }

        System.out.println(maxmove);

    }
}


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

int main(){
	int s;
  	cin >> s;
  int a, b, c;
  a = s / 100;
  b = (s - (a * 100)) / 10;
  c = (s - (a * 100) - (b * 10));
  cout << a + b + c << endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >>d;
	if (a + b == c + d)cout << "Balanced" << endl;
	else if (a + b > c + d)cout << "Left" << endl;
	else cout << "Right" << endl;
}


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


int main(){
    int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int> l(10);
	for(int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
    int ans=100000000;
    for(int bit = 1; bit < (1<<n); bit++)
    {
        for(int bit2 = 1; bit2 < (1<<n); bit2++)
        {   
            for(int bit3 = 1; bit3 < (1<<n); bit3++)
            {    
                int cnt=0, aa=0, bb=0, cc=0;
                for(int i = 0; i < n; i++)
                {
                    if(bit&(1<<i) && bit2&(1<<i)) break;
                    if(bit3&(1<<i) && bit2&(1<<i)) break;
                    if(bit&(1<<i) && bit3&(1<<i)) break;
                    if(bit&(1<<i)){
                        if(aa > 0) cnt+=10;
                        
                        aa += l[i];
                    }
                    if(bit2&(1<<i)){
                        if(bb > 0) cnt+=10;
                        
                        bb += l[i];
                    }
                    if(bit3&(1<<i)){
                        if(cc > 0) cnt+=10;
                        cc += l[i];
                    }
                
                }
                cnt += abs(a-aa)+abs(b-bb)+abs(c-cc);
                if(aa == 0 || b == 0 || cc == 0) continue;
                ans = min(ans, cnt);
            }    
        }
        
    }
    
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll x, y;
  cin >> x >> y;
  if(x==4||x==6||x==9||x==11){
    x = 4;
  }
  else if(x==2){
    x = 2;
  }
  else{
    x = 1;
  }
  if(y==4||y==6||y==9||y==11){
    y = 4;
  }
  else if(y==2){
    y = 2;
  }
  else{
    y = 1;
  }
  if(x==y){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int pairs[22][22];
ll dp[22][2100000];
ll solveways(int man,int maskWoman,int n){
    if(man==n+1){
        return 1;
    }
    if(dp[man][maskWoman]!=-1){
        return dp[man][maskWoman];
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        if(pairs[man][i]==1 and (maskWoman & (1<<(i-1)))== 0 ){
            ans = (ans + solveways(man+1,maskWoman|(1<<(i-1)),n) % mod)%mod;
        }
    }
    return dp[man][maskWoman]=ans%mod;

}
int main() {
    int n; cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>pairs[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<solveways(1,0,n)<<endl;
}


Measured memory_bytes: 364488
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-8;
const int N=2e5+10;
const ll mod=1e9+7;
inline ll read()
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar()) x=x*10+ch-'0';
   return x*f;
}
int n,a[N],ans;
int main()
{  cin>>n;
   for(int i=1;i<=n;i++)
   {  char ch;
      cin>>ch;
      if(ch=='R')a[i]=0;
      else a[i]=1;
   }
   //for(int i=1;i<=n;i++)printf("%d ",a[i]);printf("\n");
   
   int l=1,r=n;
   while(l<r)
   {  if(a[l]==1)
      {  while(l<r&&a[r]==1)r--;
         if(l<r)swap(a[l],a[r]),ans++;
         else break;
      }
      l++;
   }
  // for(int i=1;i<=n;i++)printf("%d ",a[i]);printf("\n");
   cout<<ans;
}

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

int dfs(int i,vector<int> &a,vector<vector<int>> &edge,vector<int> &counter,vector<int> &dp){
	if(dp[i]!=-1) return dp[i];
	priority_queue<int> que;
	for(int j=0;j<edge[i].size();j++){
		int num=dfs(edge[i][j],a,edge,counter,dp);
		que.push(num);
	}
	int res=counter[i];
	int j=1;
	while(!que.empty()){
		res=max(res,que.top()+j);
		que.pop();
		j++;
	}
	return dp[i]=res;
}
int main(){
	int n;
	cin>>n;
	vector<int> a(n-1);
	for(int i=0;i<n-1;i++) {
		cin>>a[i];
		a[i]--;
	}
	vector<int> counter(n,0);
	vector<vector<int>> edge(n);
	for(int i=0;i<n-1;i++){
		edge[a[i]].push_back(i+1);
	}
	vector<int> dp(n,-1);
	int res=dfs(0,a,edge,counter,dp);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 19328
#include <cstdio>
#include <cstring>
#define MAXN 200000 + 100
char a[MAXN];
int main() {
    int len;
    scanf("%s", a);
    len = strlen(a);
    int l = 0, r = len - 1;
    while(l < r) {
        if(a[l] != 'A') l++;
        if(a[r] != 'Z') r--;
        if(a[l] == 'A' && a[r] == 'Z')  break;
    }
    printf("%d\n", r - l + 1);
    return 0;
}


Measured memory_bytes: 384
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def max(x:Int,y:Int) = if(x>y) x else y

  def main(args:Array[String]) = {
    val n = readInt
    val b = new ArrayBuffer[Int]

    for(i<-0 until n) {
      val s1 = ' ' + readLine
      val s2 = ' ' + readLine
      val N = s1.length
      val M = s2.length

      val a = Array.ofDim[Int](N,M)
      for(i<-1 until N)
        for(j<-1 until M)
          if(s1(i)==s2(j)) a(i)(j) = a(i-1)(j-1)+1 else a(i)(j) = max(a(i-1)(j), a(i)(j-1))
      b += a(N-1)(M-1)
    }
    println(b.mkString("\n"))
  }
}

Measured memory_bytes: 124624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t,a[10000+2],i,j,k,sum=0;
    long long mx=0,mn=0;
    while(cin>>t)
    {
        for(i=1;i<=t;i++)
        {
            cin>>a[i];
            sum=sum+a[i];
        }
         mx=a[1];
         mn=a[1];
        for(i=2;i<=t;i++)
        {
            if(a[i]>mx)
            {
                mx=a[i];
               // cout<<"mx "<<mx;
            }
            if(a[i]<mn)
            {
                mn=a[i];
            }

        }
        cout<<mn<<" "<<mx<<" "<<sum<<endl;
        sum=0;


    }
    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

vi par, ran;

void init(int n) {
  rep(i,n) {
    par.push_back(i);
    ran.push_back(0);
  }
}

int find(int x) {
  if(par[x]==x) return x;
  return par[x]=find(par[x]);
}

void unite(int x, int y) {
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(ran[x]<ran[y]) par[x]=y;
  else {
    par[y]=x;
    if(ran[x]==ran[y]) ran[x]++;
  }
}

bool same(int x, int y) {
  return find(x)==find(y);
}

int main() {
  int N,M;
  cin >> N >> M;
  init(N);
  vi A(M),B(M);
  rep(i,M) {
    cin >> A[i] >> B[i];
    unite(A[i],B[i]);
  }
  
  int ans=0;
  vi count(N);
  rep(i,N) count[find(i)]++;
  rep(i,N) ans=max(ans,count[i]);
  
  cout << ans << endl;
}

Measured memory_bytes: 7200
#include<iostream>
#include<algorithm>
using namespace std;
long MOD=998244353,n,k,i,ans[2002],p2[2001]={1},C[4001][4001];
long f(long t)
{
	long p=t/2-!(t%2),ans=0,q=0;
	for(;q<=p;q++)ans=(ans+p2[q]*C[p][q]%MOD*(n<q?0:C[k-2*p-!(t%2)+n-1][n-q])%MOD)%MOD;
	return ans;
}
main()
{
	cin>>k>>n;
	for(p2[0]=i=1;i<=2000;i++)p2[i]=p2[i-1]*2%MOD;
	for(i=0;i<=4000;i++)C[i][0]=1;
	for(i=1;i<=4000;i++)for(long j=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
	for(i=1;i++<=k;)
	{
		ans[i]=f(i);
		i%2||(n--,ans[i]+=f(i),n++);
		cout<<ans[i]%MOD<<endl;
	}
	for(--i;--i>1;)cout<<ans[i]%MOD<<endl;
}


Measured memory_bytes: 123648
import sys
from collections import deque

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, readline().split())

G = [[] for _ in range(N+1)]
m = map(int, read().split())
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)

parents = [0] * (N+1)
visited = [0] * (N+1)
root = 1
visited[root] = 1
q = deque([root])
while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        parents[w] = v
        q.append(w)

print('Yes')
print(*parents[2:], sep='\n')


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

const int MAXN = 1e5 + 10;

int n, w[MAXN][3], f[MAXN][3];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) scanf("%d", &w[i][j]);
    }
    for (int i = 1; i <= n; ++i) {
        f[i][0] = max(f[i - 1][1] + w[i][0], f[i - 1][2] + w[i][0]);
        f[i][1] = max(f[i - 1][0] + w[i][1], f[i - 1][2] + w[i][1]);
        f[i][2] = max(f[i - 1][0] + w[i][2], f[i - 1][1] + w[i][2]);
    }
    printf("%d\n", max(f[n][0], max(f[n][1], f[n][2])));
    return 0;
}

Measured memory_bytes: 2560
import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

L = []
for i in range(M):
    B, C = map(int, input().split())
    L.append([B,C])
L = np.array(L)
L = L[np.argsort(L[:,1])[::-1]]

i = 0
for b,c in L:
    for j in range(b):
        if i+1 <= len(A):
            if A[i] < c:
                A[i] = c
                i += 1
            else:
                print(sum(A))
                quit()
        else:
            print(sum(A))
            quit()

print(sum(A))

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0;i < N;i++){
    cin >> S.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> T(M);
  for(int i=0;i < M;i++){
    cin >> T.at(i);
  }
  
  vector<int> sum(N);
    
  for(int i=0;i < N;i++){
    
    for(int j=0;j < N;j++){
      
      if(S.at(j) == S.at(i)){
        sum.at(i)++;
      }
      else{
        continue;
      }
      
    }
    
    for(int k=0;k < M;k++){
      
      if(T.at(k) == S.at(i)){
        sum.at(i)--;
      }
      else{
        continue;
      }
      
    }
    
  }
  
  int MAX=0;
  for(int i=0;i < N;i++){
    
    if(sum.at(i) > MAX){
      MAX = sum.at(i);
    }
    
    else{
      continue;
    }
    
  }
  
  cout << MAX << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
ll arr[maxn], n;

int main(void) {
    while(cin >> n) {
        for(int i = 0; i < n; ++i)
            cin >> arr[i];
        sort(arr, arr + n);
        ll ma1 = 0, ma2 = 0;
        for(int i = n - 1; i >= 1; --i) {
            if(arr[i] == arr[i - 1]) {
                ma2 = ma1;
                ma1 = arr[i];
                arr[i] = arr[i - 1] = 0;
                if(ma1 && ma2) break;
            }
        }
        cout << ma1 * ma2 << endl;
    }
}


Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")

def main():
    N, K = LI()
    P = LI1()
    C = LI()

    visit = [False] * N
    where = [-1] * N

    group = []
    group_sum = []
    for i in range(N):
        if visit[i]: continue
        
        now = i
        tmp = []
        cum = 0
        while not visit[now]:
            tmp.append(now)
            visit[now] = True
            where[now] = len(group)
            cum += C[now]
            now = P[now]
        group.append(tmp)
        group_sum.append(cum)

    ans = -INF

    for i in range(N):
        g = group[where[i]]

        if len(g) <= K:
            loop_count = K // len(g) - 1
            rest = K - loop_count * len(g)
        else:
            loop_count = 0
            rest = K

        loop_score = group_sum[where[i]]

        tmp = C[P[i]]
        tmp_max = C[P[i]]
        now = P[i]
        for _ in range(rest-1):
            now = P[now]
            tmp += C[now]
            tmp_max = max(tmp, tmp_max)
        ans = max(ans, max(tmp_max, tmp_max + loop_count * loop_score))
    print(ans)






if __name__ == '__main__':
    main()

Measured memory_bytes: 73884
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}

	for i := range a {
		if i > 0 && a[i-1] == a[i] {
			b[i]++
		}
		if i < n-1 && a[i] == a[i+1] {
			b[i]++
		}
	}

	ans := 0
	for i := 1; i < n-1; i++ {
		if b[i] == 2 {
			ans++
			b[i] = 0
			b[i-1]--
			b[i+1]--
		}
	}
	for i := 0; i < n-1; i++ {
		if b[i] == 1 {
			ans++
			b[i] = 0
			b[i+1] = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
 
int main(){
  int a,p;
  cin >> a >> p;
 
  int ans = (3*a+p)/2;
  
  cout << ans << endl;
 
  return 0;
  
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  n <- readLn
  let (m,a) = head [(k, k*(k+1)`div`2 - n) | k<-[1..], k*(k+1)`div`2 >= n]
  let ans = if a == 0 then [1..m] else [1..a-1] ++ [a+1..m]
  mapM_ print ans


type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 1020
A,B,C,D,E,F=list(map(int,input().split()))
max=0
satou=0
water=0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                a=100*A*i+100*B*j
                s=C*k +D*l
                if a==0:break
                if a+s<=F and (a/100)*E>=s :
                    if max<100*s/(a+s):
                        max=100*s/(a+s)
                        water=a+s
                        satou=s
if satou>0:
    print(water,satou)
else:
    print(100*A,0)

Measured memory_bytes: 73796
N = int(input())
L = list(map(int,input().split()))
L.sort()
count = 0
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j] and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                count += 1
print(count)

Measured memory_bytes: 9200
package main

import (
	"fmt"
	"strings"
)

func intmin() func(int) int {
	isFirst := true
	min := 0
	return func(a int) int {
		if isFirst {
			isFirst = false
			min = a
			return a
		}
		if min > a {

			return a
		}
		return min
	}
}
func main() {
	var S, T string
	fmt.Scan(&S, &T)

	s := strings.Split(S, "")
	t := strings.Split(T, "")

	count := 0
	min := 0
	isFirst := true

	for offset := 0; offset <= len(S)-len(T); offset++ {

		for i := 0; i < len(T); i++ {

			if s[offset+i] != t[i] {
				count++
			}

		}

		min = func(a int) int {
			if isFirst {
				isFirst = false
				return a
			}
			if min > a {
				return a
			}
			return min
		}(count)

		count = 0

	}
	fmt.Println(min)

}


Measured memory_bytes: 1888
#include <iostream>
using namespace std;
typedef long long ll;
ll n, x[110], y[110], h[110], X, Y, H;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];
    for (ll i = 0; i < n; i++){
        if (h[i] != 0){
            X = x[i], Y = y[i], H = h[i];
            break;
        }
    }
    for (ll i = 0; i <= 100; i++){
        for (ll j = 0; j <= 100; j++){
            bool ans = true;
            ll height = H + abs(X - i) + abs(Y - j);
            for (ll k = 0; k < n; k++){
                if (h[k] == 0){
                    if (height > abs(x[k] - i) + abs(y[k] - j)) ans = false;
                } else {
                    if (height != h[k] + abs(x[k] - i) + abs(y[k] - j)) ans = false;
                }
            }
            if (ans){
                cout << i << ' ' << j << ' ' << height << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		int time = scan.nextInt();

		int hour = time/3600;
		time -= hour*3600;
		int min = time/60;
		time -= min*60;
		
		System.out.println(hour + ":" + min + ":" + time);
	}

}



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

int main() {
    long long int n, ans = 0;
    cin >> n;
    long long int a[n];
    map<long long int, long long> mp;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        mp[a[i]]++;
        ans += a[i];
    }
    long long int q, b, c;
    cin >> q;
    for(int i = 0; i < q; ++i) {
        cin >> b >> c;
        ans -= mp[b]*b;
        mp[c] += mp[b];
        ans += mp[b]*c;
        mp[b] = 0;
        cout << ans << '\n';
    }

}


Measured memory_bytes: 10316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,x,t; cin>>n>>x>>t;
    int ans=(n+x-1)/x;
    cout<<ans*t<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}
 
void solve(){
    ll x,k,d; cin>>x>>k>>d; x=abs(x);
    if(x>=k*d && (k*d>=0)){ cout<<x-k*d<<endl; }
    else{
        ll sub = x/d; k-=sub; x-=(sub*d);
        ll f = k/2; k-=f;
        cout<<min(abs(x+((k-f)*d)), abs(x+((f-k)*d)))<<endl;
    }
}
 
int main(){
    ffast
    ll t=1;
    //cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 3652
/*************************************************************************
    > File Name: D.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-05-26 20:09:01
 ************************************************************************/

#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,a[MAXN],ans;
int main()
{
    scanf("%lld",&n);
    ans=0;
    for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
    ll st=1,ed=1,now=0;
    do
    {
        while(ed<=n&&(now+a[ed])==(now^a[ed]))
        {
            now+=a[ed];
            ed++;
        }
        ans+=ed-st;
        //printf("%lld %lld %lld\n",st,ed,now);
        now-=a[st];
        st++;
    }while(st<=n);
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123;
int h[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }
    int ans = 0;
    for (int i = 0; i < N;) {
        if (!h[i]) {
           i++;
           continue;
        }
        int j = i;
        while (j < N && h[j]) {
              h[j]--;
              j++;
        }
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int[] freq = new int[26];
		
		for(int i=0; i<26; i++){
			freq[i] = 0;
		}
		
		for(int i=0; i<s.length(); i++){
			freq[s.charAt(i)-97]++;
		}
		
		String lowerLetter = "None";
		for(int i=0; i<26; i++){
			if(freq[i] == 0){
				lowerLetter = (char)(i+97) + "";
				break;
			}
		}
		
		System.out.println(lowerLetter);
	}
}

Measured memory_bytes: 25044
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b<c*2:
    ans = a*x+b*y
else:
    if x>y:
        ans = min(2*c*y+(x-y)*a, 2*c*x)
    else:
        ans = min(2*c*x+(y-x)*b, 2*c*y)
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n+2);
	a[0] = 0; a[n + 1] = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	vector<int> b(n + 2);
	vector<int> c(n + 2);
	b[0] = 0; c[n + 1] = 0;
	for (int i = 1; i <= n; ++i) {
		b[i] =b[i-1]+ abs(a[i] - a[i - 1]);
		c[n + 1 - i] = c[n + 2 - i] + abs(a[n + 2 - i] - a[n + 1 - i]);
	}
	for (int i = 1; i <= n; ++i) {
		cout << b[i - 1] + abs(a[i - 1] - a[i + 1]) + c[i + 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 2432
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACoffee solver = new ACoffee();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACoffee {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            out.println(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5) ? "Yes" : "No");
        }

    }
}



Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#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 repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;
    cout << (n + 1000 - 1) / 1000 * 1000 - n << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3628
from itertools import combinations

N = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for _ in range(N):
    s = input()[0]
    if s in 'MARCH':
        d[s] += 1
ans = 0
for a, b, c in combinations(d.values(), 3):
    ans += a * b * c
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define FOR(i,m,n) for(int (i)=m;(i)<n;(i)++)




int main(){
    int cnt=0;
    int cnt_tmp=0;
    int rep=1;
    int j=0;
    string s;
    cin>>s;
    string q;
    q="";
   
        for(int i=0;i<s.length();i++){
            if(abs(s[i]=='0')){
                cnt+=1;
            }
        }
        
        
    
    cout<<(min(cnt,(int)s.length()-cnt))*2<<endl;

    return 0;

}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, A, B; cin >> N >> A >> B;
    cout << min(A*N, B) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main()
{
    long int a, b, c;
    long int r, l;
    
    scanf("%lld %lld %lld", &a, &b, &c);

    r=4*a*b;
    l=c-a-b;

    if(r<l*l&&l>0)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}


Measured memory_bytes: 128
/*
	Author: Luis Manuel Díaz Barón (LUISMO)
	Problem:
	Online Judge:
	Link:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 2;

ll N, A, B;

void solve()
{
	cin >> N >> A >> B;
	ll k = N / (A + B);
	k *= A;
	k += min(A, N % (A + B));
	cout << k;
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


Measured memory_bytes: 256
def Numseque(a, l):
    a = list(str(a))
    while len(a) < l:
        a.insert(0,"0")
    a.sort()
    a0 = a
    a0 = "".join(a0)
    a.sort(reverse=True)
    a1 = a
    return int("".join(a1))-int(a0)

def main(a0, l):
    a = [a0]
    while 1:
        a.append(Numseque(a[-1], l))
        if a[-1] in a[:len(a) - 1]:
            for i in range(len(a)):
                if a[-1] == a[i]:
                    j = i
                    break
            print(j, a[-1], len(a)-1-j)
            return 


while 1:
    a, l = map(int, input().split())
    if a == l == 0:
        break
    main(a,l)


Measured memory_bytes: 5600
#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()
{
    ll n;
    cin >> n;
    if (n == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    ll count = 1;
    ll Lb = 2, La = 1;
    ll ans = 0;
    while (count != n)
    {
        ans = Lb + La;
        Lb = La;
        La = ans;
        count++;
    }
    cout << ans << endl;
}


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

int abs(int x, int y) { return x > y ? x - y : y - x; }

int main(){
	vector<int> ansvec;
	for (;;){
		int n, m;
		cin >> n >> m;
		if (n == 0) break;

		set<int> tarocards;
		int tarosum = 0;
		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			tarocards.insert(s);
			tarosum += s;
		}
		set<int> hanakocards;
		int hanakosum = 0;
		for (int i = 0; i < m; i++){
			int s;
			cin >> s;
			hanakocards.insert(s);
			hanakosum += s;
		}

		if (abs(hanakosum - tarosum) % 2 == 1){
			ansvec.push_back(-1);
			continue;
		}

		int taroans = -1, hanakoans = -1;
		int tmpcardsum = 1000;
		for (auto it = tarocards.begin(); it != tarocards.end(); it++){
			int tmptaroans = *it;
			int tmphanakoans = hanakosum - tarosum + 2 * tmptaroans;
			tmphanakoans /= 2;
			if (hanakocards.count(tmphanakoans) > 0 && (tmptaroans + tmphanakoans) < tmpcardsum){
				taroans = tmptaroans;
				hanakoans = tmphanakoans;
				tmpcardsum = tmptaroans + tmphanakoans;
			}
		}

		if (taroans > 0){
			ansvec.push_back(taroans);
			ansvec.push_back(hanakoans);
		}
		else{
			ansvec.push_back(-1);
		}
	}
	
	for (auto it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it;
		if (*it != -1) cout << " " << *(++it);
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = Math.max(a + b, Math.max(a * b, a - b));
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int w, a, b;cin>>w>>a>>b;

    if((b<=a && a<=b+w) || (b-w<=a && a<=b)){
      cout<<0<<endl; return 0;
    }

    if(b+w<a){
      cout<<a-b-w<<endl;return 0;
    }else if(b>a+w){
      cout<<b-a-w<<endl; return 0;
    }

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())

res = 0
for b in range(k+1,n):
    kk = b-k
    
    r = n//b
    kkk = n%b
    if r > 0:
        res += kk*r
    if k == 0:
        res += kkk
    elif kkk>=k:
        res += kkk-k+1
res += n-k
print(res)


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

int main(){
  int h, m, s;
  cin >> s;
  h = s / 3600;
  s %= 3600;
  m = s / 60;
  s %= 60;
  
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 30000;
	public static final int SQRT = (int)(Math.ceil(Math.sqrt(MAX)));
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		boolean[] is_prime = new boolean[MAX + 1];
		int[] primes = new int[MAX];
		int prime_count = 0;
		Arrays.fill(is_prime, 2, MAX + 1, true);
		for(int i = 2; i <= MAX; i++){
			if(is_prime[i]){
				primes[prime_count] = i;
				prime_count++;
				
				for(int j = i * 2; j <= MAX; j += i){
					is_prime[j] = false;
				}			
			}
		}
		
		
		while (true) {
			final int T = sc.nextInt();
			
			if(T == 0){ break; }
			
			long count = 0;
			
			for(int fst = 0; fst < prime_count; fst++){
				final int fst_num = primes[fst];
				if(fst_num > T){ break; }
				
				for(int snd = fst; snd < prime_count; snd++){
					final int snd_num = primes[snd];
					if(fst_num + snd_num > T){ break; }
					
					final int thd_num = T - (fst_num + snd_num);
					
					if(snd_num > thd_num){ break; }
					if(fst_num + snd_num + thd_num > T){ break; }
					else if(thd_num >= snd_num + fst_num){ continue; }
					else if(!is_prime[thd_num]){ continue; }	
					
					//System.out.println(fst_num + " " + snd_num + " " + thd_num);
					
					count++;
				}
			}
			
			System.out.println(count);
		}

	}
}

Measured memory_bytes: 21288
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    int ans = A - 2 * B;
    if(ans <= 0) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
# define pb push_back
typedef long long ll;

int main(){
    int n;
    cin >> n;
    if(n%2==0){
        cout << 0.5;
    }
    else{
        cout << fixed << setprecision(15) <<  (double)(n+1)/(2*n);
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll n, a, b;
vector<ll> h;

bool func(ll s){
    ll res = 0;
    rep(i, n){
        ll p = h[i] - s * b;
        if(p > 0) res += (p + a - b - 1) / (a - b);
    }
    if(res <= s) return true;
    else return false;
}

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

    cin >> n >> a >> b;
    h.resize(n);
    rep(i, n) cin >> h[i];

    ll r = *max_element(all(h));
    ll l = -1;

    while(r - l > 1){
        ll mid = (l + r) / 2;
        if(func(mid)) r = mid;
        else l = mid;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define f(x) x*x
int main(void)
{
	int d,i;
	while(scanf("%d",&d)!=EOF){
		long sum=0;
		for(i=d;i<600;i+=d){
			sum+=f(i)*d;
		}
		printf("%ld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 596
n = int(input())
ans = 0
t = 0
J = 0
for i in range(1,n):
    for j in range(i,n):
        if i*j >= n:break
        if i == j : t+=1
        ans +=1
        J = j
    if i*J >= n:break

print(2*ans -t)


Measured memory_bytes: 9172
#include<iostream>
using namespace std;
int main(){
  int A, B, C, K;
  cin>>A>>B>>C>>K;
  int baisuu=0;
  while(B<=A){
    B*=2;
    baisuu++;
  }
  while(C<=B){
    C*=2;
    baisuu++;
  }
  if(baisuu<=K){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;



int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int x3=x2-(y2-y1);
  int y3=y2+(x2-x1);
  int x4=x3-(x2-x1);
  int y4=y3-(y2-y1);
  cout<< x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#define _AOJ_
#include "bits/stdc++.h"
using namespace std;
typedef long long i64;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)
#define all(c) c.begin(),c.end()

//define pfs,bellmanford,etc.

int main(){
	i64 n,k;cin>>n>>k;
	i64 s=1,ans=1;
	vector<i64>a(1,1);
	while(s<=n){
		a.push_back((s+k-1)/k);
		s+=a.back();
		if(s<=n)ans=a.size();
	}
	cout<<ans<<endl;
}

//sub-EOF


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int x;
    cin>>x;
    if ( x == 0 ){
        cout<<"1"<<endl;
    }
    else{
        cout<<"0"<<endl;
    }
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3644
import Data.List

main = do
  n <- (read :: String -> Int) <$> getLine
  input <- map (read :: String -> Int) . words <$> getLine
  let max = maximum input
      min = minimum input
  solve min max input

increase :: Int -> [[Int]]
increase n = [[a, a+1] | a <- [1..n-1]]

decrease :: Int -> [[Int]]
decrease n = reverse [[a+1, a] | a <- [1..n-1]]

makeList :: Int -> Int -> [[Int]]
makeList n m = [[m, a] | a <- [1..n], a /= m]

solve :: Int -> Int -> [Int] -> IO ()
solve min max s
  | min >= 0          = do
    print (length s - 1)
    putStr . toString . increase $ length s
  | max <= 0          = do
    print (length s - 1)
    putStr . toString . decrease $ length s
  | abs min < abs max = do
    let maxIndex = (+1) . head . elemIndices max $ s
    print $ (length s - 1) * 2
    putStr $ toString $ makeList (length s) maxIndex
    putStr . toString . increase $ length s
  | otherwise         = do
    let minIndex = (+1) . head . elemIndices min $ s
    print $ (length s - 1) * 2
    putStr $ toString $ makeList (length s) minIndex
    putStr . toString . decrease $ length s

toString :: [[Int]] -> String
toString = unlines . map (unwords . map show)


Measured memory_bytes: 892
N = int(input())
A = list(map(int, input().split()))
data = [0] * (N + 1)


def add(k, x, M):
    while k <= M:
        data[k] += x
        k += k & -k


def get(k):
    s = 0
    while k > 0:
        s += data[k]
        k -= k & -k

    return s


left, right = 0, 10 ** 9 + 1
while right - left > 1:
    x = (left + right) // 2

    S = [0] * (N + 1)
    for i in range(N):
        if A[i] >= x:
            S[i + 1] = S[i] + 1
        else:
            S[i + 1] = S[i] - 1

    a = abs(min(S)) + 1
    for i in range(N + 1):
        S[i] += a

    b = max(S)
    data = [0] * (b + 1)
    num = 0
    for i in S:
        num += get(i)
        add(i, 1, b)

    if num * 2 >= (N * (N + 1) // 2):
        left = x
    else:
        right = x

print(left)


Measured memory_bytes: 108516
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;  
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   N     =  5e3+8;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;

void solve(){
	cin>>n;
	if(n >= 400 and n < 600) deb1(8)
	if(n >= 600 and n < 800) deb1(7)
	if(n >= 800 and n < 1000) deb1(6)
	if(n >= 1000 and n < 1200) deb1(5)
	if(n >= 1200 and n < 1400) deb1(4)
	if(n >= 1400 and n < 1600) deb1(3)
	if(n >= 1600 and n < 1800) deb1(2)
	if(n >= 1800 and n < 2000) deb1(1)
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 3648