akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

int N;
int ans = 0;

int main()
{
	scanf("%d", &N);

	if (N <= 81) {
		for (int i = 1; i < 10; i++) {
			if (N % i == 0 && N / i <= 9) {
				ans = 1;
				break;
			}
		}
	}

	if (ans == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int m,f,r;
		while(true){
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			if( m==-1 && f==-1 && r==-1 ) break;
			if( m==-1 || f==-1 ) System.out.println( "F");
			else if( m+f>=80 ) System.out.println( "A");
			else if( m+f>=65 && m+f<80 ) System.out.println( "B");
			else if( m+f>=50 && m+f<65 ) System.out.println( "C");
			else if( m+f>=30 && m+f<50 ){
				if( r>=50 ) System.out.println( "C");
				else System.out.println( "D");
			}
			else if( m+f<30 ) System.out.println( "F");
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> dp(n);
    dp[n-1] = 0;
    dp[n-2] = abs(h[n-1] - h[n-2]);

    if(n >= 3){
        for(int i=n-3;i>=0;i--){
            dp[i] = min(abs(h[i] - h[i+1])+dp[i+1], abs(h[i] - h[i+2])+dp[i+2]);
        }
    }

    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 1152
import           Control.Applicative
import           Control.Monad

check :: Int -> Bool
check n
    | n `mod` 3  == 0 = True
    | n `mod` 10 == 3 = True
    | otherwise       = div10 n

div10 :: Int -> Bool
div10 n
    | n == 0          = False
    | n `mod` 10 == 3 = True
    | otherwise       = div10 (n `div` 10)

main :: IO ()
main = do
    n <- readLn :: IO Int
    let xs = fmap show $ filter check [1..n]
    let ys = foldr1 (\x acc -> x ++ " " ++ acc) xs
    putStrLn $ ' ' : ys



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

int N, H, W;
int A[1100], B[1100];

int main() {
    cin >> N >> H >> W;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (H <= A[i] && W <= B[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

void solve() {
    int N;
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        int a = i % 10;
        string x = to_string(i);
        int b = x[0] - '0';
        nums[a][b]++;
    }

    ll ans = 0;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            ans += nums[i][j] * nums[j][i];
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
bool b[999999+1];

int main() {
	for (int i = 2; i < 999999 + 1; i++){
		if (b[i] == false){
			for (int j = i * 2; j < 999999 + 1;j+=i){
				b[j] = true;
			}
		}
	}
	int n;
	while (cin >> n){
		int count = 0;
		for (int i = 2; i <= n; i++)if (!b[i])count++;
		cout << count << endl;
	}
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> ans(N+1);
    for(int x = 1; x <= 100; ++x){
        for(int y = 1; y <= 100; ++y){
            for(int z = 1; z <= 100; ++z){
                int value = x*x + y*y + z*z + x*y + y*z + z*x;
                if(value <= N) ans[value]++;
            }
        }
    }
    for(int i = 1; i < ans.size(); ++i) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p))
#define mp make_pair

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

void noobSolve() {

}

void solve() {

}


int main() {
	fast();
	/*int t;
	cin >> t;
	for (int tc = 1; tc <= t; ++tc)
	{
		cout << "Case #" << tc << ": ";
		solve();
		//noobSolve();
	}*/
	string s;
	cin >> s;
	ll store[2019], recentStore[2019], recentCopyStore[2019];
	mems(store);
	mems(recentCopyStore);
	mems(recentStore);
	for (int i = 0; i < s.length(); ++i) {
		int dig = (int)(s[i] - '0');
		for (int i = 0; i < 2019; ++i) {
			recentCopyStore[(i*10+dig)%2019] = recentStore[i];
		}
		++recentCopyStore[dig];
		for (int i = 0; i < 2019; ++i) {
			recentStore[i] = recentCopyStore[i];
			store[i] += recentStore[i];
		}
	}
	ll sum = 0;
	int zeroCons = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == '0') {
			++zeroCons;
		} else {
			sum += ((zeroCons + 1) * zeroCons / 2);
			zeroCons = 0;
		}
	}
	sum += ((zeroCons + 1) * zeroCons / 2);
	cout << store[0] - sum << endl;
}

Measured memory_bytes: 3808
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()
	a, f := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		f[i] = nextInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sort.Ints(f)

	l, r := 0, 1000000000000
	for l < r {
		mid, sum := (l+r)/2, 0
		for i := 0; i < n; i++ {
			if mid < a[i]*f[i] {
				sum += a[i]-(mid/f[i])
			}
		}

		if k >= sum {
			r = mid
		} else {
			l = mid+1
		}
	}

	fmt.Println(r)
}

Measured memory_bytes: 6272
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include<set>
using namespace std; 
int main(void){
    int A,B,C,K;
  	scanf("%d%d%d%d",&A,&B,&C,&K);
	if(A>=K){
      printf("%d",K);
    }else if(A+B>=K){
      printf("%d",A);
    }else{
    	printf("%d",2*A-K+B);
    }
}

Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> h(N);
    int maxH = 0;
    REP(i, 0, N) {
        cin >> h[i];
        maxH = max(maxH, h[i]);
    }

    vector<int> curr(N, 0);
    int ans = 0;
    REP(i, 0, maxH + 1) {
        int len = 0;
        REP(j, 0, N) {
            if (curr[j] < h[j]) {
                len++;
            } else {
                ans += (len > 0);
                len = 0;
            }
        }
        ans += (len > 0);

        REP(j, 0, N) {
            curr[j]++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
    ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

ll lcm(ll a, ll b){
  return a * b / gcd(a,b);
}

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

ll digit__(ll num){
    ll cnt=1;
    while(num > 10){
        cnt ++;
        num /= 10;
    }
    return cnt;
}


int main(){
    int N,frequencyMax=0;
    string S;
    vector <string > frequentStringList;

    cin >> N;
    unordered_map<string, int> frequencyCounter;
    rep(i,N){
        cin >> S;
        frequencyCounter[S] ++;
        if (frequencyCounter[S] > frequencyMax){
            frequencyMax = frequencyCounter[S];
            frequentStringList.clear();
            frequentStringList.push_back(S);
        }else if (frequencyCounter[S] == frequencyMax){
            frequentStringList.push_back(S);
        }
    }

    sort(frequentStringList.begin(), frequentStringList.end());
    rep(i,frequentStringList.size()){
        cout << frequentStringList[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 25656
#include<cstdio>
#include<iostream>
using namespace std;
int n,cntW,cntR;
string str;
int main()
{

	cin>>n;
	cin>>str;

	for (int i = 0; i < n; i++)
	{
		if (str[i] == 'W') cntW++;
		else			   cntR++;
	}

	//cout<<cntR<<' '<<cntW<<endl;
	string str_final = "";
	while(cntR--) str_final+='R';
	while(cntW--) str_final+='W';

	//cout<<str_final<<' ' << cntR<<' '<<cntW<<endl;
	cntR = cntW = 0;
	for (int i = 0; i < n ;i++)
	{
		if (str[i] == 'W' && str_final[i] == 'R') cntW++;
		if (str[i] == 'R' && str_final[i] == 'W') cntR++;
	}

	//cout<<cntW<<' ' <<cntR<<' ' <<str_final<<endl;
	int ans = 0;
	ans+=min(cntW,cntR);
	cntW-=ans;
	cntR-=ans;

	ans+=cntW + cntR;
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3780
import java.util.*;

public class Main {
    static int cnt;
    static int a;
    static int b;
    static String p;
    static String q;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        p = genStrWithoutSpace(sc.nextLine());
        q = genStrWithoutSpace(sc.nextLine());
        //System.out.println("n = " + n);
        //System.out.println("p = " + p);
        //System.out.println("q = " + q);
        int[] ar = genArray(n);
        //System.out.println("ar = " + Arrays.toString(ar));
        permutation(ar, n, new StringBuilder(), n);
        //System.out.println("a = " + a);
        //System.out.println("b = " + b);
        System.out.println(Math.abs(a - b));
    }
    
    static int[] genArray(int size) {
        int[] res = new int[size];
        for(int i = 0; i < size; ++i) res[i] = i + 1;
        return res;
    }
    
    static void permutation(int[] ar, int arSize, StringBuilder sb, int size) {
        if(sb.length() == size) {
            String resPerm = sb.toString();
            ++cnt;
            //System.out.println(cnt + ": " + resPerm);
            if(resPerm.equals(p)) a = cnt;
            if(resPerm.equals(q)) b = cnt;
        } else {
            for(int i = 0; i < arSize; ++i) {
                sb.append(ar[i]);
                permutation(genSubarray(ar, arSize, i), arSize - 1, sb, size);
            }
        }
        if(sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
    }
    
    static int[] genSubarray(int[] ar, int arSize, int skipIndex) {
        int[] subarray = new int[arSize - 1];
        for(int i = 0, subi = 0; i < arSize; ++i) {
            if(i != skipIndex) {
                subarray[subi] = ar[i];
                ++subi;
            }
        }
        return subarray;
    }
    
    static String genStrWithoutSpace(String s) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0, f = s.length(); i < f; ++i) {
            char c = s.charAt(i);
            if(c != ' ') sb.append(c);
        }
        return sb.toString();
    }
}

Measured memory_bytes: 26384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const INF = 1000010000

var used []bool

func main() {
	sc.Split(bufio.ScanWords)

	N, M, R := nextInt(), nextInt(), nextInt()
	r := make([]int, R)
	for i := 0; i < R; i++ {
		r[i] = nextInt() - 1
	}
	sort.Ints(r)

	d := make([][]int, N)
	for i := 0; i < N; i++ {
		d[i] = make([]int, N)
		for j := 0; j < N; j++ {
			d[i][j] = INF
		}
		d[i][i] = 0

	}

	for i := 0; i < M; i++ {
		a, b, c := nextInt()-1, nextInt()-1, nextInt()
		d[a][b] = c
		d[b][a] = c
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j])
			}
		}
	}

	ans := INF
	for {
		path, sum := make([]int, len(r)), 0
		copy(path, r)
		for i := 0; i < len(path)-1; i++ {
			u, v := path[i], path[i+1]
			sum += d[u][v]
		}
		ans = min(ans, sum)
		if !nextPermutation(sort.IntSlice(r)) {
			break
		}
	}
	fmt.Println(ans)

}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}

	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}

	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true

}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}

	return a
}


Measured memory_bytes: 4992
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int D = sc.nextInt();
		long G = sc.nextLong();
		int[] probCnt = new int[D];
		int[] perScore = new int[D];
		for(int i=0;i<D;i++){
			probCnt[i] = sc.nextInt();
			perScore[i] = sc.nextInt() + ((i+1) * probCnt[i] * 100);
		}
		int minCount=Integer.MAX_VALUE;
		for(int bit=0; bit < 1 << D;bit++){
			int score = 0;
			int count = 0;
			for(int i=0;i<D;i++){
				if((bit & (1 << i)) >0)continue;
				score += perScore[i];
				count += probCnt[i];
			}
			if(score<G){
				for(int i=D-1;i>=0;i--){
					if((bit & (1 << i)) ==0)continue;
					for(int j=0;j<probCnt[i];j++){
						if(score >= G) break;
						score += (i+1) * 100;
						count++;
					}
				}
			}
			minCount = Math.min(minCount, count);
		}
		System.out.println(minCount);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22996
d = {}
while 1:
    try:
        se = input().lower()
    except:
        break
    for i in se:
        if i.isalpha():
            d[i] = d.get(i, 0) + 1
for i in 'abcdefghijklmnopqrstuvwxyz':
    d[i] = d.get(i, 0)
    print("{} : {}".format(i, d[i]))


Measured memory_bytes: 5564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

template <class T>
vector<vector<T>> comb(T n) {
  vector<vector<T>> v(n+1,vector<T>(n+1,0));
  rep(i,v.size()){
	v[i][0]=1;
	v[i][i]=1;
  }
  FOR(j,1,v.size())FOR(k,1,j){
	v[j][k]=v[j-1][k-1]+v[j-1][k];
  }
  return v;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	vector<ll> v(n);
	rep(i,n){
		cin>>v[i];
	}
	sort(begin(v),end(v),greater<ll>());
	double ans=0;
	ll tar=v[a-1];
	int cnt1=0,cnt2=0;
	set<ll> now;
	rep(i,n){
		if(i<=a-1){
			ans+=v[i];
			if(v[i]==tar) cnt2++;
			now.insert(v[i]);
		}
		if(v[i]==tar) cnt1++;
	}
	ans/=(double)a;
	cout<<setprecision(10)<<ans<<endl;
	vector<vector<ll>> ret=comb((ll)60);
	if(now.size()!=1){
		cout<<ret[cnt1][cnt2]<<endl;
	}else{
		ll ans=0;
		FOR(i,a,b+1){
			if(i<=cnt1){
				ans+=ret[cnt1][i];
			}
		}
		cout<<ans<<endl;
	}
}

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

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string s;
    cin>>s;
    cout<<(s=="ARC"?"ABC":"ARC");

    return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

int a[100001];
 
int main() {

    ll n;
    cin >> n;
    ll sum = 0;
    rep(i,n) {
        ll b;
        cin >> b;
        sum += b;
        a[b]++;
    }
    ll q;
    cin >> q;
    rep(i,q) {
        ll b,c;
        cin >> b >> c;
        sum += (c-b)*a[b];

        cout<<sum<<endl;
        
        a[c] += a[b];
        a[b] = 0;
    }


 return 0;
}

Measured memory_bytes: 4012
N, K = map(int, input().split())
A = list(map(int, input().split()))
R = {1:0}
i, t = A[0], 1

while K > t:
    r = R.get(i)
    if r == None:
        R[i] = t
        i = A[i-1]
        t += 1
    else:
        K -= r
        K %= t - r
        for k in range(K):
            i = A[i-1]

print(i)

Measured memory_bytes: 32324
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long int a, b, c;
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << "0" << endl;
	}
	else {
		cout << min(a*b, min(b*c, a*c)) << endl;
	}

}

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

using namespace std;

int N, M, Q;
int a[50];
int b[50];
int c[50];
int d[50];

int ans;

void solve(int k, vector<int>& A)
{
	if (k == 0) {
		A[0] = 1;
		solve(k + 1, A);
	}
	else if (k < N) {
		for (int x = A[k - 1]; x <= M; ++x) {
			A[k] = x;
			solve(k + 1, A);
		}
	}
	else {
		int sum = 0;
		for (int i = 0; i < Q; ++i) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				sum += d[i];
			}
		}
		ans = max(ans, sum);
	}
}

int main()
{
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; ++i) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		--a[i];
		--b[i];
	}

	ans = 0;
	vector<int> A(N);
	solve(0, A);
	cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner; 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<b){
      System.out.println(0);
    }else{
      System.out.println(10);
    }
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int X = sc.nextInt();
    
    int s = X - K + 1;
    int e = X + K - 1;
    
    for (int i=s; i<e; i++)
    	System.out.print(i + " ");
    
    System.out.print(e);
  }
}

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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << "\t|";
    __f(comma + 1, args...);
}

#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}

// dp[index][heads] => probability of number of heads till this index
double dp[3000][3000];
double p[3000];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i];
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];
    
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            // tails
            dp[i][j] = dp[i - 1][j] * (1 - p[i]);
            // heads
            if (j > 0)
                dp[i][j] += dp[i - 1][j - 1] * p[i];
        }
    }
    
//    for (int i = 0; i < n; i++) {
//        for (int j = 0; j < n; j++) {
//            cout << dp[i][j] << ' ';
//        }
//        cout << '\n';
//    }
    
    double ans = 0;
    for (int i = n/2 + 1; i <= n; i++) {
        ans += dp[n - 1][i];
    }
    cout << setprecision(9) << fixed << ans << '\n';
    return 0;
}


Measured memory_bytes: 74040
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool sqr[105][105];
int main()
{
	//freopen("out.txt","w",stdout);
	int A,B;scanf("%d%d",&A,&B);
	A--;B--;
	for(int i=0;i<100;i++)
		for(int j=0;j<100;j++)
			sqr[i][j]=i<50;
	int x,y;
	x=0,y=0;
	//white false/black true
	while(A--)
	{
		sqr[x][y]=false;
		y+=2;
		if(y>=100) x+=2,y=0;
	}
	x=99;y=0;
	while(B--)
	{
		sqr[x][y]=true;
		y+=2;
		if(y>=100) x-=2,y=0;
	}
	printf("100 100\n");
	for(int i=0;i<100;i++)
	{
		if(i) puts("");
		for(int j=0;j<100;j++)
			printf("%c",sqr[i][j]? '#':'.');
	}
	return 0;
}


Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s;

    cin >> s;

    bool ok = true;

    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
                ok = false;
            }
        } else {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
                ok = false;
            }
        }
    }

    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;


int main(void){
	string s;
	cin>>s;
	int r=0,b=0;
	rep(i,s.length()){
		if(s[i]=='0')r++;
		else b++;
	}
	if(r<b)cout<<r*2<<endl;
	else cout<<b*2<<endl;

	return 0;

}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int inp[110][2];

ll dp[110][100010];

int main(){


    int n;
    cin>>n;

    int w;
    cin>>w;

    for(int i = 1; i <= n; i++) {
        cin>>inp[i][0]>>inp[i][1];
    }

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= 100000; j++) {
            dp[i][j] = 2000000000;
        }
    }

    dp[1][0] = 0;
    dp[1][inp[1][1]] = inp[1][0];

    for(int i = 2; i <= n; i++) {
        dp[i][0] = 0;
        for(int j = 1; j <= 100000; j++) {
            if(j >= inp[i][1]) {
                dp[i][j] = min(dp[i][j], dp[i-1][j-inp[i][1]] + inp[i][0]);
            }
            dp[i][j] = min(dp[i][j] , dp[i-1][j]);
        }
    }

    for(int i = 100000; i >= 1; i--) {
        if(dp[n][i] <= w) {
            cout<<i<<endl;
            break;
        }
    }
    


}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

const int N = 3123;
vector<vector<vector<ll>>> dp(N, vector<vector<ll>>(N, vector<ll>(2, -141222)));
int n;
vector<ll> a(N);

ll solve(int l, int r, int id) {
  int c = id ? -1 : 1;
  if (l==r) return c*a[l];
  if (dp[l][r][id] != -141222) return dp[l][r][id];
  if (id) return dp[l][r][id] = min(c*a[l]+solve(l+1,r,id^1), c*a[r]+solve(l,r-1,id^1));
  else    return dp[l][r][id] = max(c*a[l]+solve(l+1,r,id^1), c*a[r]+solve(l,r-1,id^1));
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i,0,n) cin >> a[i];


  cout << solve(0,n-1,0) << '\n';

}

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

using namespace std;
using ll = long long;

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

ll lg(ll n) {
    int ans = 0;
    while(n) {
        ans++;
        n >>= 1;
    }
    return ans;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    cout << binpow(2, lg(n)) - 1;
    return 0;
}


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

using namespace std;

static const int32_t limit{ 30000 };

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

	int32_t n;
	cin >> n;

	int32_t p_i;
	vector<int32_t> a(n, 0), b(n, 0);
	for (auto i = 1; i <= n; ++i) {
		cin >> p_i;
		a[i - 1] += limit * i;
		b[i - 1] += limit * (n - i) ;
		b[p_i - 1] += i;
	}

	for (auto itr = a.cbegin(); itr != a.cend(); ++itr) cout << *itr << ' ';
	cout << '\n';
	for (auto itr = b.cbegin(); itr != b.cend(); ++itr) cout << *itr << ' ';
	cout << '\n';
}


Measured memory_bytes: 768
import sys
readline=sys.stdin.readline

def main():
    p=10**9+7
    n=int(input())
    s1=readline().strip()
    s2=readline().strip()
    pl=[]
    tempiter=iter(range(n))
    for i in tempiter:
        if s1[i]==s2[i]:
            pl.append(0)
        else:
            pl.append(1)
            _=next(tempiter)
    ans=1
    #print(pl)
    for i,_ in enumerate(pl[:-1]):
        s=pl[i]-pl[i+1]+2*pl[i]*pl[i+1]
        if s==0:
            ans=ans*2 % p
        elif s==1:
            ans=ans*2 % p
        elif s==2:
            ans=ans*3 % p
    if pl[-1]==0:
        ans=ans*3 % p
    else:
        ans=ans*6 % p
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 9136
n  = int(input())
plan = [tuple(map(int, input().split())) for _ in range(n)]

now, now_x, now_y = 0, 0, 0

for t, x, y in plan:
    if abs(x - now_x) + abs(y - now_y) > t - now:
        print('No')
        exit()
    elif ((t - now) - abs(x - now_x) - abs(y - now_y)) % 2 == 1:
        print('No')
        exit()
    now = t
    now_x = x
    now_y = y
print('Yes')

Measured memory_bytes: 22412
fun main(args: Array<String>) {
  val (a, b, c, x, y) = readLine()!!.split(" ").map { it.toInt() }
  print(if (a + b > c + c) {
    when {
      x < y -> listOf(c * 2 * x + (b * (y - x)), c * 2 * y).min()
      x > y -> listOf(c * 2 * y + (a * (x - y)), c * 2 * x).min()
      else -> c * 2 * x
    }
  } else a * x + (b * y))
}

Measured memory_bytes: 37616
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int m=n;
	int flag=1;
	if(n%4==0)
	{
		flag=0;
		printf("Yes\n");
	}	
	else if(n%7==0)
	{
		flag=0;
		printf("Yes\n");
	
	}
	if(flag)
	{
		while(n>4)
		{
			n=n-7;
			if(n%4==0)
			{
				printf("Yes\n");
				flag=0;
				break;
			}
		}
	}
	if(flag||m<=3)
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split(" ")))

    count = 0
    next_num = 1
    for i in range(n):
        if next_num == a[i]:
            next_num += 1
        else:
            count += 1

    print(count if count != len(a) else -1)

Measured memory_bytes: 24744
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        list.add(Integer.parseInt(sc.next()));
        list.add(Integer.parseInt(sc.next()));
        list.add(Integer.parseInt(sc.next()));
        list.add(Integer.parseInt(sc.next()));
        list.add(Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int result = list.indexOf(0) + 1;

        // 出力
        System.out.println(result);
    }
}


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

typedef long long ll;

int main(){
 int n, m, c, seikai = 0;
 cin >> n >> m >> c;
 vector<int> b(m, 0);
 rep(i, m) cin >> b.at(i);
 rep(i, n) {
   vector<int> a(m, 0);
   rep(j, m){
   cin >> a.at(j);
 }
 ll ans = c;
 rep(k, m){
   ans += a.at(k) * b.at(k);
 }
   if(ans >0) seikai++;
 }
cout << seikai;
}


Measured memory_bytes: 3644
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-05-02 21:13:46
 * @LastEditTime: 2020-05-02 21:21:27
 * @FilePath: \VSC\C++\Practice\AC abc165 D.cpp
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long

int A,B,N;
signed main(){
    scanf("%lld%lld%lld",&A,&B,&N);
    int x=min(B-1,N);
    int temp=x/B;
    cout<<A*x/B-A*temp<<'\n';
    return 0;
} 

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

int main(){
  int n;
  cin >> n;
  vector<int> c(n), v(n);
  int i;
  for(i=0; i<n; i++)cin >> v[i];
  for(i=0; i<n; i++)cin >> c[i];
  int cp = 0;
  for(i=0; i<n; i++)
    if(v[i]-c[i] > 0){
      cp += v[i];
      cp -= c[i];
    }
  cout << cp << endl;
  return 0;
}


Measured memory_bytes: 256
A, B, M = gets.split.map(&:to_i)

aa = gets.split.map(&:to_i)
bb = gets.split.map(&:to_i)

min = aa.min + bb.min

M.times {
  x, y, c = gets.split.map(&:to_i)
  price = aa[x - 1] + bb[y - 1] - c
  min = price if price < min
}

puts min

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, m;
    vector<int> x;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    sort(x.begin(), x.end());

    vector<pair<int, int>> p;
    for (int i = 1; i < m; i++)
    {
        p.push_back(make_pair((x[i] - x[i - 1]), i));
    }

    // cout << "a" << endl;
    sort(p.begin(), p.end(), greater<pair<int, int>>());
    // cout << "a" << endl;
    for (auto itr = p.begin(); itr != p.end(); itr++)
    {
        // cout << "< " << itr->first << "," << itr->second << " >" << endl;
    }
    // cout << "a" << endl;
    vector<int> arr;
    for (int i = 0; i < p.size(); i++)
    {
        if (i >= n - 1)
            break;
        arr.push_back(p[i].second);
    }
    sort(arr.begin(), arr.end());
    for (auto itr = arr.begin(); itr != arr.end(); itr++)
    {
        // cout << "deg:" << *itr << endl;
    }
    int sum = 0;
    int prev = 0;
    int idx = 0;
    for (int i = 0; i < m; i++)
    {
        if (idx < arr.size())
        {
            if (i == arr[idx])
            {
                idx++;
                if (i >= 2)
                {
                    // cout << "a:" << prev << "," << (x[i - 1] - x[prev]) << endl;
                    sum += (x[i - 1] - x[prev]);
                }
                prev = i;
            }
        }
        else
        {
            // cout << "b:" << prev << "," << (x[m - 1] - x[prev]) << endl;
            sum += (x[m - 1] - x[prev]);
            break;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int de[101010];
int a[101010];

int o[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for (int i=2;i<=n;i++){
		cin>>a[i];
		o[a[i]]++;
	}
	priority_queue<pair<int, int> > q;
	for (int i=1;i<=n;i++){
		if (o[i]==0){
			q.push({0, i});
		}
	}
	int v=0;
	while (!q.empty()){
		auto x=q.top();
		q.pop();
		if (x.S==1) continue;
		de[a[x.S]]=max(de[a[x.S]], de[x.S])+1;
		//cout<<x.S<<" v "<<a[x.S]<<" "<<de[a[x.S]]<<endl;
		v=max(v, de[a[x.S]]);
		o[a[x.S]]--;
		if (o[a[x.S]]==0){
			q.push({-de[a[x.S]], a[x.S]});
		}
	}
	cout<<v<<endl;
}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std ;
int a[4][4] ;
int main() {
	memset(a,0,sizeof(a));
	for(int i = 1;  i <= 3 ; i++) {
		for(int j = 1 ; j <= 3 ; j++) {
			cin >> a[i][j] ;
		}
	}
	int q ;
	cin >> q ;
	for(int i = 1 ; i <= q ; i++) {
		int n ;
		cin >> n ; 
		for(int i = 1;  i <= 3 ; i++) {
		for(int j = 1 ; j <= 3 ; j++) {
			if(a[i][j] == n) {
				a[i][j] = 0 ;
			}
		}
	}
	} 
	if((a[1][1]==a[1][2]&&a[1][2]==a[1][3])||(a[2][1]==a[2][2] && a[2][2]==a[2][3])||
	(a[3][1]==a[3][2]&&a[3][2]==a[3][3])||(a[1][1]==a[2][1] && a[2][1]==a[3][1]) ||
	(a[1][2] == a[2][2] && a[2][2] == a[3][2])||(a[1][3]==a[2][3] &&a[2][3] == a[3][3])||
	(a[1][1] == a[2][2] &&a[2][2]==a[3][3]) || (a[1][3] == a[2][2] && a[2][2] == a[3][1]))
	{
		cout << "Yes" << endl ;
	}
	else cout << "No" << endl ; 
	return 0 ;
}

Measured memory_bytes: 256
fn main(){
    let mut sc = Scanner::new();
    while sc.read() {
        let n = sc.next();
        let ma:usize = sc.next();
        let mb:usize = sc.next();

        let inf = 1000000000i32;
        let mut dp = [[inf; 420]; 420];
        dp[0][0] = 0;
        for _ in 0..n {
            let a:usize = sc.next();
            let b:usize = sc.next();
            let c:i32 = sc.next();
            
            for i in (0..400).rev() {
                for j in (0..400).rev() {
                    if dp[i+a][j+b] > dp[i][j] + c {
                        dp[i+a][j+b] = dp[i][j] + c;
                    }
                }
            }
        }
        let mut res = inf;
        for i in 1..420 {
            for j in 1..420 {
                if i*mb == j*ma && res > dp[i][j] {
                    res = dp[i][j];
                }
            }
        }
        if res == inf { res = -1; }
        println!("{}", res);
    }
}

#[allow(dead_code)]
struct Scanner {
    buf: Vec<u8>, i: usize, next: Option<String>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: vec![], i: 0, next: None, }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }

    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut res = Vec::<T>::with_capacity(n);
        for _ in 0..n { res.push(self.next()) }
        res
    }

    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.read();
        self.next.take().and_then(|s| s.parse::<T>().ok())
    }

    fn read(&mut self) -> bool {
        if self.next.is_some() { return true }
        let mut s = String::with_capacity(16);
        while let Some(c) = self.get_char() {
            if !c.is_whitespace() { s.push(c); }
            else if !s.is_empty() { break; }
        }
        self.next = if !s.is_empty() { Some(s) } else { None };
        self.next.is_some()
    }

    fn get_char(&mut self) -> Option<char> {
        if self.i >= self.buf.len() {
            use std::io::BufRead;
            let reader = std::io::stdin();
            let mut buffer = reader.lock();
            let len = match buffer.fill_buf() {
                Ok(bytes) => {
                    self.buf.resize(bytes.len(), b'\0');
                    self.buf.copy_from_slice(bytes);
                    Some(bytes.len())
                },
                Err(_) => None,
            };
            self.i = 0;
            if len.is_some() { buffer.consume(len.unwrap()); }
            if len.is_none() || len.unwrap() == 0 { return None }
        }
        self.i += 1;
        Some(self.buf[self.i - 1] as char)
    }
}


Measured memory_bytes: 5116
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]
n = int(input())

n -= 1
print(a[n])


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int x, t;
	cin >> x >> t;
	if (t > x) cout << "0\n";
	else cout << x - t << "\n";

	return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	string S;
	cin >> S;

	int answer = 0; 
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '+') {
			answer++;
		}
		if (S[i] == '-') {
			answer--;
		}
	}

	cout << answer << endl;
	return 0;
}


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


int main(){
	int h,w,n;
	cin>>h>>w>>n;

	int max_hw = max(h,w);
	if(n%max_hw==0){
		cout<<n/max_hw<<endl;
	}else{
		cout<<n/max_hw+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

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

	std::vector<lld> v(n);
	std::vector<lld> suff(n+1);

	for(lld i=0;i<n;i++)
		cin>>v[i];


	for(lld i=n-1;i>=0;i--)
	{
		suff[i]=suff[i+1]+v[i];
		suff[i]%=mod;
	}

	lld ans=0;
	for(lld i=0;i<n;i++)
	{
		ans+= (v[i]*(suff[i+1]));
		ans%=mod;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 6360
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
#define INF 1e9+5
void solve(){
    int n,k;
    cin>>n>>k;
    int h[n];
    rep(i,0,n){
        cin>>h[i];
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    rep(i,0,n){
        for(int j=i+1;j<=i+k;j++){
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<"\n";
}
int32_t main(){
    c_p_c();
    int t;
    t=1;
    //cin>>t;
    while(t--){
       solve(); 
    }
	return 0;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	while (b <= a) {
		b *= 2;
		k--;
	}
	while (c <= b) {
		c *= 2;
		k--;
	}
	if (k < 0)
		cout << "No\n";
	else
		cout << "Yes\n";
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n, m;

signed main()
{
    cin >> n >> m;
    vector<int> a(n);

    int sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    int b = ceil((double)sum / (4.0 * (double)m));

    int ans = 0;

    rep(i, n)
    {
        if (b <= a[i])
        {
            ans++;
        }
    }

    if (ans >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
    vector<int> x;
    bool tf = true;
    for (int i = 0; tf; i++) {
        int n;
        scanf("%d", &n);
        x.push_back(n);
        if (x.at(i) == 0) {
            break;
        }
    }
    for (int i = 1; i < x.size() ; i++) {
        printf("Case %d: %d\n", i, x.at(i-1));
    }   
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
	cin>>x>>y;
	cout<<(a[x]==a[y]?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256