akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
using namespace std;
int N, Q, L, R; unsigned long long h, v[300002], p[300002], sum[300002]; char str[300002], com[5];
int main() {
	scanf("%d %d %s", &N, &Q, str); R = 1, p[0] = 1, sum[0] = 0;
	for(int i = 1; i < N; i++) p[i] = p[i - 1] * 257;
	for(int i = 1; i <= N; i++) sum[i] = sum[i - 1] * 257 + str[i - 1];
	for(int i = 0; i < Q; i++) {
		scanf("%s", com);
		switch(com[0] + com[1]) {
			case 119: L++; break;
			case 121: L--; break;
			case 125: R++; break;
			case 127: R--; break;
		}
		v[i] = sum[R] - sum[L] * p[R - L];
	}
	sort(v, v + Q);
	int ret = 1;
	for(int i = 1; i < Q; i++) {
		if(v[i - 1] != v[i]) ret++;
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 10012
solve n []
	| n >= 0 = n
	| otherwise = -1
solve n (a:as) = solve (n - a) as

main = do
	line1 <- getLine
	let n = read . head $ words line1
	line2 <- getLine
	let as = map (read) . words $ line2
	putStrLn $ show $ solve n as



Measured memory_bytes: 7544
parseInt(x) = parse(Int, x)
n = parseInt(readline())

x = parseInt.(split(readline()))

ans = 100000000000000000000

for i in 1:100
    sum = 0
    for j in 1:n
        sum += (x[j] - i)^2
    end
    if sum < ans
        ans = sum
    end
end
println(ans)

Measured memory_bytes: 123528
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll X; cin >> X;
    for(ll a=-200;a<=200;a++){
        for(ll b=-200;b<=200;b++){
            if(pow(a,5)-pow(b,5)==X){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x, y,z,w,h, sum= 0, ans = 0;
void dfs(string s,char mx) {
	if (s.size() == n) cout << s << endl;
	else {
		for (char c = 'a'; c <= mx; c++) {
			if (mx == c) dfs(s + c, mx + 1);
			else dfs(s + c, mx);
		}
	}
}
int main() {
	cin >> n;
	dfs("",'a');
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >>a>>b;
  
  vector<int> c(3);
  c.at(0)=a+b;
  c.at(1)=a-b;
  c.at(2)=a*b;
  
  sort(c.begin(),c.end());
  cout <<c.at(2)<<endl;
}
  
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 300005,mod = 998244353;
typedef long long ll;
int n,ans,now[3],hav[3];char s[N];
int trs(char c){return c=='R'?0:(c=='B'?1:2);}
int main()
{
	scanf("%d%s",&n,s+1);ans=1;
	for(int i=n*3;i;i--)
	{
		int x=trs(s[i]);
		if(hav[x])ans=(ll)ans*hav[x]%mod,hav[x]--;
		else
		{
			bool flag=0;
			for(int j=0;j<3;j++)
				if(x!=j&&now[j])
					ans=(ll)ans*now[j]%mod,now[j]--,hav[3-x-j]++,flag=1;
			if(!flag)now[x]++;
		}
	}
	for(int i=1;i<=n;i++)ans=(ll)ans*i%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum;
		String x;
		
		do {
			
			x = scan.nextLine();
					
			if(x.equals("0"))break;
			sum = 0;
			
			for(int i = 0; i < x.length(); i++) {
				char c = x.charAt(i);
				sum += (int)c - 48;
			}
			
			System.out.println(sum);
			
		}while(true);
	}
}



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

int main() {
  int m, f, r;
  while (true) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;
    if (m == -1 || f == -1) {
      cout << 'F' << endl;
    } else {
      int total = m + f;
      if (total >= 80) {
        cout << 'A' << endl;
      } else if (total >= 65) {
        cout << 'B' << endl;
      } else if (total >= 50) {
        cout << 'C' << endl;
      } else if (total >= 30) {
        cout << (r >= 50 ? 'C' : 'D') << endl;
      } else {
        cout << 'F' << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3056
// from a scalar

#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
#define moder 1000000007

ll moding( ll x , ll y ){
   
    ll ans = x % y;

    if(ans < 0)ans = ans + y ;

    return ans ;

}


bool isprime(ll n){
    if(n==2) return true;
    if(n==3) return true;
    if(n%2 == 0) return false;
    if(n%3 == 0) return false;

    ll i = 5,w=2;

    while(i*i <= n){
        if(n%i == 0)return false;

        i += w;
        w = 6 - w;
    }

    return true;
}




int main(){

    int n; cin >> n;
    string arr; cin >> arr;

    int siz = arr.size();

    int t ;

    for(int i = 0; i< siz ; i++){
        t = arr[i]  % 65;
        t = t + n;
        t = moding(t , 26) + 65;
        printf("%c", t);
    }

    printf("\n");
     
     
        
    return 0;
}
      
       

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
  ll n;
  cin>>n;
  vector<ll>vec(n);
  for(ll i=0;i<n;i++) {
    ll b;
    cin>>b;
    vec.at(i)=b;
  }
  ll ans=0;
  sort(vec);
  for(ll i=0;i<n-1;i++) {
    ans+=vec.at(i);
  }
  rever(vec);
  ll a=(vec.at(0)/2);
  ans+=a;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
ll gcd(ll a,ll b){
  if (a%b==0) return(b);
  else return(gcd(b,a%b));
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

int main(){
  int N;
  cin >> N;
  int d[N];
  rep(i,N) cin >> d[i];
  sort(d,d+N);
  cout << d[N/2]-d[N/2-1] << endl;
  return 0;
}

Measured memory_bytes: 640
<?php
$n = trim(fgets(STDIN));
$array = explode(" ", trim(fgets(STDIN)));
for($i = 0; $i < $n; $i++){
    @$map[$i % 2][$array[$i]]++;
}
if(maxKey($map[0]) != maxKey($map[1])){
    echo $n - max($map[0]) - max($map[1]);    
}else{
    //map[0]のMaxを採用する場合
    for($i = 0; $i < 2; $i++){    
        $map0 = $map[$i % 2];
        $map1 = $map[($i + 1) % 2];
        rsort($map0);
        rsort($map1);
        array_shift($map0);
        $num[] = $n - array_shift($map0) - array_shift($map1);
    }
    echo min($num);
}
function maxKey($array){
    $max = max($array);
    foreach($array as $key => $value){
        if($value == $max)return $key;
    }
}

Measured memory_bytes: 23028
void main(){
	int n = _scan();
	int[] d = _scanln();
	int ans;
	
	foreach(i; 0..n){
		foreach(j; i+1..n){
			ans += d[i]*d[j];
		}
	}
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2652
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main(){
	string s;
	cin>>s;
	for(int i=0;i<(int)s.size()-7;++i){
		string t=s.substr(i,8);
		sort(t.begin(),t.end());
		if(t=="AADINNUY"){
			s=s.substr(0,i)+"AIZUNYAN"+s.substr(i+8);
			i+=7;
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn = 1e5 + 10;
typedef pair<int, int> pii;
int n, m, p[maxn], par[maxn];
vector<int> c;

int findSet(int x)
{
    return x == par[x] ? par[x] : par[x] = findSet(par[x]);
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++)
        scanf("%d", &p[i]), par[i] = i;

    for(int i = 0; i < m; i ++) {
        int x, y;
        scanf("%d%d", &x, &y);
        int px = findSet(x), py = findSet(y);
        par[px] = py;
    }

    int ans = 0;
    for(int i = 1; i <= n; i ++) {
        if(findSet(p[i]) == findSet(i))
            ans ++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)
group = [-1] * N
count = [0] * 2
stack = []
group[0] = 0
count[0] = 1
stack.append(0)
while stack:
    u = stack.pop()
    for v in G[u]:
        if group[v] == -1:
            group[v] = 1 - group[u]
            count[group[v]] += 1
            stack.append(v)
zeros = list(range(3, N+1, 3))
ones = list(range(1, N+1, 3))
twos = list(range(2, N+1, 3))
ans = [0] * N
for g in range(2):
    if count[g] <= N//3:
        for i in range(N):
            if group[i] == g:
                ans[i] = zeros.pop()
            else:
                if len(twos) > 0:
                    ans[i] = twos.pop()
                elif len(ones) > 0:
                    ans[i] = ones.pop()
                else:
                    ans[i] = zeros.pop()
        print(' '.join(map(str, ans)))
        exit()
for i in range(N):
    if group[i] == 0 and len(ones) > 0:
        ans[i] = ones.pop()
    elif group[i] == 1 and len(twos) > 0:
        ans[i] = twos.pop()
    else:
        ans[i] = zeros.pop()
print(' '.join(map(str, ans)))


Measured memory_bytes: 118732
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
A=list(map(lambda x : int(x)*(-1),input().split()))
import heapq
heapq.heapify(A)
for i in range(M):
    a=heapq.heappop(A)
    heapq.heappush(A,-(-a//2))
print(-sum(A))


Measured memory_bytes: 68248
package main

import "fmt"

type Point struct {
	x, y int
}

func (p Point) distance(nextP Point) int {
	return abs(p.x, nextP.x) + abs(p.y, nextP.y)
}

func abs(a, b int) int {
	if a >= b {
		return a - b
	} else {
		return b - a
	}
}

var students map[int]Point
var checks map[int]Point
var N, M int

func findChecks(student Point) int {
	min := checks[0].distance(student)
	num := 0
	for i := 0; i < M; i++ {
		d := checks[i].distance(student)
		if d < min {
			min = d
			num = i
		}
	}
	return num
}

func main() {
	var x, y int
	fmt.Scan(&N, &M)
	students = make(map[int]Point)
	checks = make(map[int]Point)
	for i := 0; i < N; i++ {
		fmt.Scan(&x, &y)
		students[i] = Point{x: x, y: y}
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&x, &y)
		checks[i] = Point{x: x, y: y}
	}

	for i := 0; i < N; i++ {
		fmt.Println(findChecks(students[i]) + 1)
	}

}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> dist;
    for (int i = 0; i < 3; i++) {
        int tmp;
        cin >> tmp;
        dist.push_back(tmp);
    }
    sort(dist.begin(), dist.end());
    cout << dist.at(0) + dist.at(1) << '\n';
    return 0;
}

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

int gcd(int a, int b){
    if(b == 0){
        return a;
    }

    return gcd(b, a % b);
}

int main(){
    int K;
    int res = 0;

    cin >> K;

    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                res += gcd(i,gcd(j,k));
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ios();
    int n;
    cin >> n;
    ll ans = 0;
    int a = 0, b = 0, ba = 0; 
    REP(i, n){
        string s;
        cin >> s;
        REP(j, size(s)-1){
            if(s[j] == 'A' && s[j+1] == 'B') ans++;
        }
        if(s[0] == 'B' && s.back() == 'A') ba++;
        else if(s[0] == 'B') b++;
        else if(s.back() == 'A') a++;
    }
    
    ans += max(0, ba - 1);
    if(ba > 0){
        if(a > 0){a--; ans++;}
        if(b > 0){b--; ans++;}
    }
    ans += min(a,b);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int ans = (1<<31)-1;
        for(int i=0;i<N;i++){
            int A = sc.nextInt();
            int tmp = 0;
            while(A%2 == 0){
                A /= 2;
                tmp++;
            }
            ans = Math.min(ans, tmp);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 200005;
const ll MOD = 1000000007;

string s;
int lst[26], nxt[MAXN][26], dp[MAXN], fwd[MAXN][26];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> s;
    int n = SZ(s);
    REP1 (i, n+1) {
        REP (j, 26) {
            nxt[i][j] = lst[j];
        }
        if (i != n+1) {
            lst[s[i-1]-'a'] = i;
        }
    }

    fill(lst, lst+26, n+1);
    for (int i=n; i>=0; i--) {
        REP (j, 26) {
            fwd[i][j] = lst[j];
        }
        if (i) {
            lst[s[i-1]-'a'] = i;
        }
    }

    dp[0] = n + 1;
    int len = 0;
    REP1 (i, MAXN-1) {
        int mn = n + 1;
        REP (j, 26) {
            mn = min(mn, nxt[dp[i-1]][j]);
        }
        dp[i] = mn;
        len = i;
        debug(i, dp[i]);
        if (dp[i] == 0) {
            break;
        }
    }

    debug(len);
    string ans;
    int cur = 0;
    REP (i, len) {
        REP (j, 26) {
            if (dp[len-i-1] <= fwd[cur][j]) {
                ans += 'a' + j;
                cur = fwd[cur][j];
                break;
            }
        }
    }

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


Measured memory_bytes: 42004
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        BigDecimal totalDebt = new BigDecimal(100000);

        // ?¨??????\???
        Scanner sc = new Scanner(System.in);
        int term = sc.nextInt();

        // ?????¨??±????????????????????????
        for (int i = 0; i < term; i++) {

            totalDebt = totalDebt.multiply(BigDecimal.valueOf(1.05)).setScale(-3, BigDecimal.ROUND_UP);
        }

        System.out.println(totalDebt.longValue());

        sc.close();

    }
}

Measured memory_bytes: 26108
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int a, b;
 cin >> a >> b;
 cout << 6-a-b;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;
    int a = 0 , b  = 0,c = 0;
    cin >>s;
    for (int i = 0; i < 3 ; i++) {
        if(s[i] == 'a')
            a++;
        if(s[i] == 'b')
            b++;
        if(s[i] == 'c')
            c++;
    }
    if(a == 1 && b == 1 && c == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;

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

  int H, W;
  cin >> H >> W;
  vector<string> s;
  for (int i = 0; i < H; i++) {
    string buf;
    cin >> buf;
    s.push_back(buf);
  }

  int white_count = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '.') white_count += 1;
    }
  }

  const int unreachable = 1000000007;
  vector<vector<int> > dist(H, vector<int>(W, unreachable));
  dist[0][0] = 0;
  bool updated = true;
  while (updated) {
    updated = false;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (dist[i][j] != unreachable) {
          if (i > 0) {
            if (s[i-1][j] == '.' && dist[i-1][j] > dist[i][j] + 1) {
              dist[i-1][j] = dist[i][j] + 1;
              updated = true;
            }
          }
          if (j > 0) {
            if (s[i][j-1] == '.' && dist[i][j-1] > dist[i][j] + 1) {
              dist[i][j-1] = dist[i][j] + 1;
              updated = true;
            }
          }
          if (i < H-1) {
            if (s[i+1][j] == '.' && dist[i+1][j] > dist[i][j] + 1) {
              dist[i+1][j] = dist[i][j] + 1;
              updated = true;
            }
          }
          if (j < W-1) {
            if (s[i][j+1] == '.' && dist[i][j+1] > dist[i][j] + 1) {
              dist[i][j+1] = dist[i][j] + 1;
              updated = true;
            }
          }
        }
      }
    }
  }
  if (dist[H-1][W-1] == unreachable) {
    cout << -1 << endl;
  }
  else {
    int score = white_count - dist[H-1][W-1] - 1;
    cout << score << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// ABC177A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int D, T, S;
	cin >> D >> T >> S;

	if (T * S >= D) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3656
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}

		long diff = Long.MAX_VALUE;
		int diffi = 0;
		for (int i = 0; i < n; i++) {
			long tmp = t * 1_000 - h[i] * 6;
			tmp = Math.abs(a * 1000 - tmp);
			
//			pr.println(tmp);
			
			if (tmp < diff) {
				diff = tmp;
				diffi = i;
			}
		}
		
		pr.println(diffi + 1);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 25300
#include<iostream>
#include<math.h>

#define PI 3.141592653589793238

using namespace std;

double max(double x[], double y[], int n);
double abs(double value);

int main() {

	int n = 0;
	double x[1000] = { 0 };
	double y[1000] = { 0 };
	double ans[4] = { 0 };

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> x[i];

	}

	for (int i = 0; i < n; i++) {

		cin >> y[i];

	}

	for (int i = 0; i < 3; i++) {

		for (int u = 0; u < n; u++) {

			ans[i] += pow(abs(x[u] - y[u]), i + 1);

		}

		ans[i] = pow(ans[i], 1.0 / double(i + 1));

	}

	ans[3] = max(x, y, n);

	for (int i = 0; i < 4; i++) {

		cout << fixed << ans[i] << endl;

	}

	return 0;

}

double max(double x[], double y[], int n){

	double ans = 0;

	for (int i = 0; i < n; i++) {

		if (ans < abs(x[i] - y[i])) {

			ans = abs(x[i] - y[i]);

		}

	}

	return ans;
}

double abs(double value) {

	if (value < 0) {

		value *= -1;

	}

	return value;

}



Measured memory_bytes: 3496
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
#include<algorithm>
int main(){
	for(int i=0;i<4;i++){
		int t,n,ans=0;
		cin>>t>>n;
		if(t==1)cout<<6000*n<<endl;
		if(t==2)cout<<4000*n<<endl;
		if(t==3)cout<<3000*n<<endl;
		if(t==4)cout<<2000*n<<endl;
	}
	return 0;
}

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

public class Main {

	public static void main(String ars[]) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int sum = 0;

		int[] A = {a,b,c};

		Arrays.sort(A);

		for(int i = 1; i < A.length; i++){
			sum += A[i] - A[i-1];
		}

		System.out.println(sum);

	}

}


Measured memory_bytes: 23892
N,M,X=list(map(int, input().split()))
A=list(map(int, input().split()))

back=999
foward=999

for i in range(M):
    if A[i]==X:
        back=i
        foward=M-i+1
        break
    if A[i]>X:
        back=i
        foward=M-i
        break
    
print(min(back,foward))

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**7)
from collections import *

def f(n):
    if memo[n]!=-1:
        return memo[n]
    
    if n==0:
        memo[n] = 0
        return 0
        
    if n==1:
        memo[n] = D
        return D
        
    res = n*D
    
    for p, c in [(2, A), (3, B), (5, C)]:
        up = (n+p-1)//p*p
        down = n//p*p
        res = min(res, (up-n)*D+f(up//p)+c, (n-down)*D+f(down//p)+c)
    
    memo[n] = res
    return res

T = int(input())

for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    memo = defaultdict(lambda: -1)
    print(f(N))

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

int main(){

int n, k;
int count=0;
cin >> n >> k;
vector<int> vec(n);
for(int i=0;i<n;i++){
    cin >> vec.at(i);
    if(vec.at(i)>=k){
        count++;
    }
}
cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

inline int read () {
    int ret = 0, t = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') t = -1, c = getchar();
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
    return ret * t;
}
int n;
#include <map>
map <int, int> rua;

int main () {
    n = read();
    while (n--) {
        int x = read();
        if (rua[x] != 0) { puts("NO"); return 0;}
        rua[x]++;
    } puts("YES");
    return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

i64 popCount(i64 n, int k)
{
    const i64 b = (1LL << k);
    const i64 i = n / b;
    const i64 ans = (i / 2) * b;
    if (i & 1) return ans + (n % b) + 1;
    else return ans;
}

i64 f(i64 x)
{
    i64 b = 0;
    rep(i, 42) {
        if (popCount(x, i) & 1) b |= (1LL << i);
    }

    return b;
}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);

    i64 a, b;
    cin >> a >> b;
    cout << (f(b) ^ f(max(0LL, a-1))) << endl;

    return 0;
}



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

int main(){
  ll a, b, k;
  cin >> a >> b >> k;
  if(a>k){
    a-=k;
  }
  else if(a+b>k){
    k-=a; a=0; b-=k;
  }
  else{
    a=0; b=0;
  }
  
  cout<<a<<" "<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
x = int(input())
a = list(map(int,input().split()))

sum=sum(a)
k=0
for i in range(x-1):
  if sum/2-k-a[i]<=a[i+1]:
    print(int(2*min(sum/2-k-a[i],k+a[i]+a[i+1]-sum/2)))
    sys.exit()
  else:
    k+=a[i]

Measured memory_bytes: 26220
import java.util.Scanner;

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

        int x[];
        x = new int[n];

        for (int i = 0; i < n; i++) {
            x[i] = num.nextInt();
        }
        int count = 0;

        for(int i = 0; i <= n-1; i++){
            int minj = i;
            for(int j = i; j <= n-1; j++){
                if(x[j] < x[minj]){
                    minj = j;
                }
            }
            if(x[i] != x[minj]){
                int tmp = x[i];
                x[i] = x[minj];
                x[minj] = tmp;
                count++;
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.printf("%d", x[i]);
            if (i != n - 1) System.out.printf(" ");
            else System.out.printf("\n");
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 26816
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define Sec     second
#define ALL(V)  V.begin(),V.end()
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,i;
    cin>>N;
    
    vlli V(N);
    lli Sum=0,Maximum=0;
    
    rep(i,0,N)
    {
        cin>>V[i];
    
        Sum+=V[i];
    }
    
    if(Sum%10)
    {
        cout<<Sum;
        exit(0);
    }
    
    rep(i,0,N)
    {
        if((Sum-V[i])%10)
        {
            Maximum=max(Maximum,Sum-V[i]);
        }
    }
    
    cout<<Maximum;
    
    
    
    
    









 return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, K, S = 0;
	int a[51];
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> a[i];
	sort(a, a + N, greater<int>());
	for (int i = 0; i < K; i++)S += a[i];
	cout << S << endl;
}

Measured memory_bytes: 256
a,b,c,d=list(input())
a,b,c,d=int(a),int(b),int(c),int(d)
op=["+","-"]
for i in range(2):
  for j in range(2):
    for k in range(2):
      if i == 0:
        if j == 0:
          if k == 0:
            ans = a+b+c+d
          else:
            ans = a+b+c-d
        else:
          if k == 0:
            ans = a+b-c+d
          else:
            ans = a+b-c-d
      else:
        if j == 0:
          if k == 0:
            ans = a-b+c+d
          else:
            ans = a-b+c-d
        else:
          if k == 0:
            ans = a-b-c+d
          else:
            ans = a-b-c-d
      if ans == 7:
        print(str(a)+op[i]+str(b)+op[j]+str(c)+op[k]+str(d)+"=7")
        quit()

Measured memory_bytes: 61704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};



int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<mint> data;
    mint temp(1);
    rep(i, k-1) {
        temp *= n-1-i;
        temp /= (i+1);
    }
    data.push_back(temp);
    rep(i, n-k) {
        temp /= n-1-i;
        temp *= n-i-k;
        data.push_back(temp);
    }
    data.push_back(mint(0));
    mint ans(0);
    rep(i, n) {
        if (i>=k-1) ans += data[n-1-i]*a[i];
        if (i<=n-k+1) ans -= data[i]*a[i];
    }
    
    
    
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[123456];
signed main() {
    int n, a, b; cin >> n >> a >> b;
    cout << max((long long)0, n - b) << ' ' << max((long long)0, min(a, (n + a) - b)) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(X: int, Y: int):
    if abs(X - Y) <= 1:
        ret = "Brown"
    else:
        ret = "Alice"
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int Q; cin >> Q;
    int cnt = 0;
    string L = "", R = "";
    while (Q--) {
        int com; cin >> com;
        if (com==1) {
            cnt = 1-cnt;
        } else {
            int t;
            char c;
            cin >> t >> c;
            if (t==1) {
                if (cnt) R += c;
                else L += c;
            } else {
                if (cnt) L += c;
                else R += c;
            }
        }
    }

    if (cnt) {
        reverse(all(S));
        reverse(all(R));
        R += S;
        R += L;
        cout << R << ln;
    } else {
        reverse(all(L));
        L += S;
        L += R;
        cout << L << ln;
    }
}

Measured memory_bytes: 1300
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    int ans = 0;
    FOR(i,N-10000000,N+1){
        ans = max(ans, (A*i)/B-A*(i/B));
    }
    if(B>=10000){
        int i = B-1;
        while(i<=N){
            ans = max(ans,(A*i)/B-A*(i/B));
            i+=B;
        }   
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int count(int N)
{
        int cnt = 0;
        while (N)
        {
                cnt += N % 10;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int N,K;
        cin >> N>>K;
        vector<int> l(N + 1);
        rep(i, N) cin >> l[i];
        sort(l.begin(), l.begin() + N);
        reverse(l.begin(), l.begin() + N);

        int ans = 0;
        rep(i, K)
        {
                ans += l[i];
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#ifndef KHOKHO
//#pragma GCC optimize("O3")
#endif
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//#define CHKR
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define ARRS int(1e6+500)
#define MAX ((long long)(1e18+1))
#define EP ((double)(1e-12))
#define HS1 ((ll)(1000001329))
#define HS2 ((ll)(1000001531))
#define MOD ((long long)1000000007ll)
#define AT9 ((long long)1000000000ll)
#define PI 3.14159265358979323846264338327950288419716939937510
#define LG 20

ll a[2];

int main(){
	#ifdef KHOKHO
		freopen("in.in","r",stdin);
		freopen("out.out","w+",stdout);
	#endif //KHOKHO
	ll n,m,d=1,k,mx=0;
	cin>>n>>k;
	a[0]=1;
	a[1]=0;
	for(int i=0; i<n; i++){
		cin>>m;
		ll t=a[1];
		a[m%2]+=a[0];
		a[(m+1)%2]+=t;
//		cout<<a[0]<<" "<<a[1]<<endl;
	}
	cout<<a[k];
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 924844033
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,K;

vector<int> line;
ll dp[4040][4040][2];

void add(ll &a,ll b){
    a=(a+b)%MOD;
    return;
}

int main(){
  cin>>N>>K;

  for(int i=0;i<2*K;i++){
      if(i>=N) break;

      bool fir=true;
      if(i>=K){
          line.push_back(1);
          fir=false;
      }

      for(int j=i;j+K<N;j+=K){
          if(j==i&&fir) line.push_back(1);
          else line.push_back(0);
      }
  }

  dp[0][0][0]=1;
  for(int i=0;i<line.size();i++){
      for(int j=0;j<=i;j++){
          if(line[i]==1){
              add(dp[i+1][j+1][1],dp[i][j][0]+dp[i][j][1]);
          }else{
              add(dp[i+1][j+1][1],dp[i][j][0]);
          }
          
          add(dp[i+1][j][0],dp[i][j][0]+dp[i][j][1]);
      }
  }

  vector<ll> fact(N+1,0);
  fact[0]=1;
  for(int i=1;i<=N;i++) fact[i]=fact[i-1]*i%MOD;

  ll ans=0;
  for(int i=1;i<=N;i++){
      ll res=dp[line.size()][i][0]+dp[line.size()][i][1];
      res%=MOD;
      res=res*fact[N-i]%MOD;

      if(i%2==0) res=-res;
      add(ans,res);
  }

  ans=(fact[N]-ans+MOD)%MOD;
  add(ans,MOD);

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 252288
#include <stdio.h>
#include <math.h>
#define Ze 0
#define On 1
#define Tw 2
#define Th 3
#define Tho 100
#define M_PI 3.14159265358979

typedef struct point_
{
    double x;
    double y;
}point;

void kock(int,point,point);

void kock(int n,point p1,point p2)
{
    if(n == Ze) return;
    point s,t,u;
    
    s.x = (Tw*p1.x+On*p2.x)/Th;
    s.y = (Tw*p1.y+On*p2.y)/Th;
    t.x = (On*p1.x+Tw*p2.x)/Th;
    t.y = (On*p1.y+Tw*p2.y)/Th;
    u.x = (t.x-s.x)*cos(60 * M_PI/180.0)-(t.y-s.y)*sin(60 * M_PI/180.0)+s.x;
    u.y = (t.x-s.x)*sin(60 * M_PI/180.0)+(t.y-s.y)*cos(60 * M_PI/180.0)+s.y;
    
    
    kock(n-1, p1, s);
    //print s;
    printf("%.8f %.8f\n",s.x,s.y);
    kock(n-1, s, u);
   // print u;
    printf("%.8f %.8f\n",u.x,u.y);
    kock(n-1, u, t);
    //print t;
    printf("%.8f %.8f\n",t.x,t.y);
    kock(n-1, t, p2);
    return;
}

int main(){
    int n;
    scanf("%d",&n);
    point p1,p2;
    p1.x = Ze;
    p1.y = Ze;
    p2.x = Tho;
    p2.y = Ze;
    printf("%.8f %.8f\n",p1.x,p1.y);
    kock(n,p1,p2);
    printf("%.8f %.8f\n",p2.x,p2.y);
    return Ze;
}


Measured memory_bytes: 2108
import collections
N=int(input())
s=[input() for i in range(N)]
S=[]
ans=0
for i in s:
  a=sorted(i)
  a="".join(a)
  S.append(a)
c=collections.Counter(S)
d=list(map(int,c.values()))
for i in d:
  ans+=i*(i-1)/2
print(int(ans))
  


Measured memory_bytes: 26960
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

Measured memory_bytes: 256
import sys, math, heapq

def move2(Maps, dists, start, goal, inf):
    """
    deque = []
    heapq.heappush(deque, [ dists[start_y][start_x], start_x, start_y])
    """

    queue = []
    heapq.heappush(queue, [0, start[1], start[0]]) # x, y

    while( len(queue) >0 ):
        dist_pos = heapq.heappop(queue)

        dist, x, y = map(int, dist_pos)
        if(dists[y][x] < dist_pos[0]):
            continue
        if(x == goal[1] and y == goal[0]):
            print(dists[y][x])
            return
        Flag = -1 # L, R, D, U
        N_Flag = 0
        for dx, dy, i in ( (-1, 0, 0), (1, 0, 1), (0, -1, 2), (0, 1, 3) ):
            if( x+ dx < 0 or x+ dx > W-1 or y+ dy < 0 or y+ dy > H-1):
                continue
            if(Maps[y+dy][x+dx]=="#"):
                Flag = i
                N_Flag += 1
                continue

            next = [x+ dx, y+ dy]
            #print([x, y], next)
            if(dists[next[1] ][next[0] ] > dists[y][x]):
                dists[next[1] ][next[0] ] = dists[y][x]
                heapq.heappush(queue, [dists[next[1] ][next[0] ], next[0], next[1] ])

        if(N_Flag>1):

            dy_max = min(H-y, 3)
            dy_min = max(-y, -2)
            dx_min = max(-x, -2)
            dx_max = min(W-x, 3)
            for dy in range( dy_min, dy_max ):
                for dx in range( dx_min, dx_max ):
                    next = [x+ dx, y+ dy]
                    if(Maps[y+dy][x+dx] == "." and dists[next[1] ][next[0] ] == inf):
                        dists[next[1] ][next[0] ] = dists[y][x]+1
                        heapq.heappush(queue, [dists[next[1] ][next[0] ], next[0], next[1] ])


        elif(N_Flag > 0):
            # L, R, D, U
            dy_max = min(H-y, 3)
            dy_min = max(-y, -2)
            dx_min = max(-x, -2)
            dx_max = min(W-x, 3)
            if(Flag == 3):
                dy_min = 1
            elif(Flag == 2):
                dy_max = 0
            elif(Flag == 1):
                dx_min = 1
            else:
                dx_max = 0

            for dy in range( dy_min, dy_max ):
                for dx in range( dx_min, dx_max ):
                    next = [x+ dx, y+ dy]
                    if(Maps[y+dy][x+dx] == "." and dists[next[1] ][next[0] ] == inf):
                        dists[next[1] ][next[0] ] = dists[y][x]+1
                        heapq.heappush(queue, [dists[next[1] ][next[0] ], next[0], next[1] ])

    if( dists[goal[0]][goal[1]]==inf ):
        print(-1)




if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    H, W= map(int, input().strip().split() )
    start = list( map(int, input().strip().split() ) ) # [y, x]
    goal = list( map(int, input().strip().split() ) ) # [y, x]
    for i in range(2):
        start[i] -= 1
        goal[i] -= 1
    Maps = [ [] for _ in range(H) ]
    for i in range(H):
        Maps[i] = input().strip()

    inf = 10**7

    dists = [ [inf for _ in range(W) ] for _ in range(H)] # [y][x]
    dists[start[0]][start[1]] = 0


    y, x = start[0], start[1]

    move2(Maps, dists, start, goal, inf)


Measured memory_bytes: 121240
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  ll s;
  cin >> s;
  if (s / 100 == 00 || s / 100 >= 13) {
    if (s % 100 == 00 || s % 100 >= 13) {
      cout << "NA" << endl;
    }
    else {
    cout << "YYMM" << endl;
    }
  }
  else {
    if (s % 100 == 0 || s % 100 >= 13) {
      cout  << "MMYY" << endl;
    }
    else {
      cout << "AMBIGUOUS" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  priority_queue<ll> a, b;
  for (ll i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    a.push(x);
    b.push(y);
  }

  ll cnt = 0;
  while (h > 0 && b.size() > 0 && a.top() < b.top()) {
    h -= b.top();
    b.pop();
    cnt++;
  }

  if (h > 0) cnt += ceil((double)h / a.top());

  cout << cnt << endl;
}

Measured memory_bytes: 2036
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int MAX_C = 21;
const int MAX_N = 101;
const int INF = INT_MAX / 3;

int calc_price(int dist, vector<int> &q, vector<int> &r) {
	if(dist == INF) return INF;	
	int res = 0, prev = 0; 
	rep(i, q.size()) {
		rep(j, q[i]-prev) {	
			res += r[i];	
			--dist;
			if(dist <= 0) return res;
		}
		prev = q[i];
	}

	while(true) {
		res += r[r.size()-1];
		--dist;
		if(dist <= 0) break;;
	}
	return res;
}

int main() {
	int N, M, C, S, G;
	while(cin >> N >> M >> C >> S >> G, N) {
		--S; --G;	
		int dist[MAX_C][MAX_N][MAX_N];	
		fill_n((int *)dist, MAX_C*MAX_N*MAX_N, INF);
		int x, y, d, c;	
		rep(i, M) {
			cin >> x >> y >> d >> c;
			--x; --y; --c;
			dist[c][x][y] = dist[c][y][x] = min(d, dist[c][y][x]);
		}

		vector<int> P(C, 0);
		rep(i, C) cin >> P[i];
	
		vector<vector<int>> Q(C);
		vector<vector<int>> R(C);
		rep(i, C) {
			Q[i].assign(P[i]-1, 0);
			R[i].assign(P[i], 0);
			rep(j, P[i]-1) {
				cin >> Q[i][j];	
			}
			rep(j, P[i]) {
				cin >> R[i][j];	
			}
		}
		
		rep(c, C) rep(k, N) rep(i, N) rep(j, N) dist[c][i][j] = min(dist[c][i][j], dist[c][i][k] + dist[c][k][j]);
		rep(c, C) rep(i, N) rep(j, N) dist[c][i][j] = calc_price(dist[c][i][j], Q[c], R[c]);
		
		vector<vector<int>> ans(N, vector<int>(N, INF));
		rep(c, C) rep(i, N) rep(j, N) ans[i][j] = min(ans[i][j], dist[c][i][j]);
		rep(c, C) rep(k, N) rep(i, N) rep(j, N) ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);

		cout << (ans[S][G] == INF ? -1 : ans[S][G]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n;
vector<int> v;

int main() {
  cin >> n;
  v = vector<int>(n, 0);
  for (int &i: v) cin >> i;
  vector<int> w(v);
  sort(w.begin(), w.end());
  int l = w[n/2 - 1], r = w[n/2];
  if (l == r) {
    for (int i = 0; i < n; ++i) cout << l << endl;
  } else {
    for (int i = 0; i < n; ++i) {
      v[i] <= l ? cout << r << endl : cout << l << endl;
    }
  }
}



Measured memory_bytes: 3712