akhauriyash/Code-Regression huggingface dataset:
N,_=gets.chomp.split(" ").map{|a|a.to_i}
A=gets.chomp.split(" ").map{|a|a.to_i}
ave = A.inject{|sum,a| sum+a} * 1.0 / N
min = 9999999999999999999
mini = -1
A.each_with_index{|a,i| 
	tmp = (ave - a).abs
	if(min > tmp)
		min = tmp
		mini = i
	end
}
puts mini


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

int n ;

int a[110][2] ;

int dp[110][2] ;

int main(){

    ios_base :: sync_with_stdio(false) ;

    cin >> n ;
    for( int j = 0 ; j <= 1 ; ++ j ){
        for( int i = 1 ; i <= n ; ++ i ){
            cin >> a[i][j] ;
        }
    }
    for( int i = 1 ; i <= n ; ++ i ){
        for( int j = 0 ; j <= 1 ; ++ j ){
            dp[i][j] = dp[i - 1][j] ;
            if(j == 1) dp[i][j] = max(dp[i][j] , dp[i][j - 1]) ;
            dp[i][j] += a[i][j] ;
         }
    }

    cout << dp[n][1] << endl ;

    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
#define NUM 10000
int main(void)
{
	long int num[NUM];
	int n, i, j;
	int min, max;
	long int sum = 0L;

	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%ld", &num[i]);

	min = num[0];
	max = num[0];
	for (j = 0; j < n; j++){
		if (min > num[j])min = num[j];
		if (max < num[j])max = num[j];
		sum += num[j];
	}

	printf("%d %d %ld\n", min, max, sum);

	return 0;
}

Measured memory_bytes: 676
import numpy as np
n = int(input())
A = np.zeros(n)

x, y, z = 1, 1, 1

while x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
    while x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x <= n:
        while x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x <= n:
            i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            A[i - 1] += 1
            z += 1
        z = 1
        y += 1
    y, z = 1, 1
    x += 1
for i in range(n):
    print(int(A[i]))



Measured memory_bytes: 27464
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

bool solve() {
    int n, arr[100000];
    cin >> n;
    if (n == 0) { return false; }
    for (int j = 0; j < n; ++j) {
        cin >> arr[j];
    }
    int ret = 0;
    for (int j = 0; j < n; ++j) {
        for (int k = j+1; k < n; ++k) {
            if (arr[j] > arr[k]) {
                ++ret;
            }
        }
    }
    cout << ret << endl;
    return true;
}

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

Measured memory_bytes: 3064
// Author : Rifayat Samee (Sanzee)
// Problem :
// Algorithm:

/*

*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int main(){

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
    int n;
    string S;
    scanf("%d",&n);
    cin >> S;
    vector<ll>dp(n+1,0);
    for(int i=1;i<=n;i++){
        for(int j = 1;j<i;j++) dp[j] = (dp[j-1] + dp[j])%mod;
        vector<ll>newdp(n+1,0);
        for(int prev = 1;prev<=i;prev++){
            if(i == 1){
                newdp[prev] = 1;
                continue;
            }
            int l,r;
            if(S[i-2] == '<'){
                l = 1;
                r = prev-1;
                //newdp[prev] = (dp[tot] - dp[prev-1] + mod)%mod;
            }
            else{
                l = prev;
                r = i-1;
                //newdp[prev] = dp[prev-1]%mod;
            }
            if(r>=l)
                newdp[prev] = (dp[r] - dp[l-1] + mod)%mod;

        }
        //for(int j = 1;j<=n;j++)printf(" %lld",newdp[j]);
        //printf("\n");
        dp = newdp;
    }
    ll res = 0;
    for(int j = 1;j<=n;j++) res = (res + dp[j])%mod;
    printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = listOfLong()
    val A = listOfLong().sorted().toLongArray()
    val INF = 1000000000000000001L //1e18 + 1
    val n = N.toInt()
    var l = -INF
    var r = INF
    while (l + 1 < r) {
        val x = (l + r) / 2
        val ok = fun(): Boolean {
            var total = 0L
            repeat(n) { i ->
                var l = -1
                var r = n
                if (A[i] >= 0) {
                    while (l + 1 < r) {
                        val c = (l + r) / 2
                        if (A[c] * A[i] < x) l = c else r = c
                    }
                    total += r
                } else {
                    while (l + 1 < r) {
                        val c = (l + r) / 2
                        if (A[c] * A[i] < x) r = c else l = c
                    }
                    total += n - r
                }
                if (A[i] * A[i] < x) total -= 1
            }
            total /= 2
            return total < K
        }()
        if (ok) l = x else r = x
    }
    println(l)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    lint N;
    cin >> N;
    const auto& res = prime_factorize(N);

    map<lint, lint> mp;
    for (auto p : res) {
        for (int i = 0; i < p.second; ++i)
            mp[p.first]++;
    }

    lint cnt = 0;
    for (auto& p : mp) {
        int a = 1;
        while (true) {
            if (p.second >= a) {
                p.second -= a;
                a++;
                cnt++;
            } else {
                break;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string S;
    cin >> S;

    bool m = regex_match(S, regex("(hi)+"));
    cout << (m?"Yes":"No") << endl;
}

Measured memory_bytes: 256
// arock - 2019-02-09

#include <iostream>
#include <vector>

int main() {
    std::vector<int> freq(4);
    for (int i = 0; i < 3; i++) {
        int a, b;
        std::cin >> a >> b;
        freq[a - 1]++;
        freq[b - 1]++;
    }

    std::string ans = "YES";
    for (int f : freq) {
        if (f == 3) {
            ans = "NO";
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){  
	int H, W, i, j, k;
	for(i = 0; i < 90000; i++){
	scanf("%d %d", &H, &W);
	if ( H == 0 && W == 0) break;
	
	for (j = 0; j < H; j++){
		for(k = 0; k < W; k++){
		printf("#");
		}
		printf("\n");
	}printf("\n");}
return 0;}



Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <utility>
#include <numeric>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  int X = 1e5;
  if (k == 0) {
    ans = (ll)n * (ll)n;
    cout << ans << endl;
    return 0;
  }
  FOR(i, k + 1, n + 1) {
    ll m = (ll)(n / i);
    ans += (m * (ll)(i - k)) + (ll)max(n % i - k + 1, 0);
    // cout << i << "  " << (m * (ll)(i - k)) << " " << (ll)max(n % i - k + 1, 0)
    //      << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int N,shima_distance[21][21],D[21],last_visit,sum;
bool visited[21],leaf[21];

struct Info{
	Info(int arg_shima,int arg_cost){
		shima = arg_shima;
		cost = arg_cost;
	}

	bool operator<(const struct Info &arg) const{
			return cost > arg.cost;
	};

	int shima,cost;
};

void recursive(int shima){
	bool FLG = false;

	for(int i = 1; i <= N; i++){
		if(i != shima && shima_distance[shima][i] != BIG_NUM && visited[i] == false){
			visited[i] = true;
			recursive(i);
			FLG = true;
		}
	}

	if(FLG){
		leaf[shima] = false;
	}
}

void calc(int shima){

	for(int i = 1; i <= N; i++){
		if(i != shima && shima_distance[shima][i] != BIG_NUM && visited[i] == false){
			visited[i] = true;
			if(leaf[i] == false){
				sum += 2*shima_distance[shima][i];
			}
			calc(i);
		}
	}
}


int main(){

	int from,to,cost,min_index;
	priority_queue<Info> Q;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		D[1] = 0;
		visited[1] = true;
		leaf[1] = false;

		for(int i = 2; i <= N; i++){
			visited[i] = false;
			leaf[i] = true;
			D[i] = BIG_NUM;
		}

		for(int i = 1; i <= N; i++){
			for(int k = 1; k <= N; k++){
				if(i == k)shima_distance[i][k] = 0;
				else{
					shima_distance[i][k] = BIG_NUM;
				}
			}
		}

		for(int i = 0; i < N-1; i++){
			scanf("%d %d %d",&from,&to,&cost);
			shima_distance[from][to] = cost;
			shima_distance[to][from] = cost;
		}

		recursive(1);

		for(int i = 2; i <= N; i++){
			if(shima_distance[1][i] != BIG_NUM){
				D[i] = shima_distance[1][i];
				Q.push(Info(i,shima_distance[1][i]));
			}
		}

		while(!Q.empty()){

			if(Q.top().cost != D[Q.top().shima]){
				Q.pop();
			}else{
				min_index = Q.top().shima;
				Q.pop();

				for(int i = 1; i <= N; i++){
					if(i != min_index && shima_distance[min_index][i] != BIG_NUM){
						if(D[i] > D[min_index] + shima_distance[min_index][i]){
							D[i] = D[min_index] + shima_distance[min_index][i];
							Q.push(Info(i,D[i]));
						}
					}
				}
			}
		}

		sum = 0;
		last_visit = 0;

		for(int i = 2; i <= N; i++){
			if(leaf[i] == false){
				last_visit = max(last_visit,D[i]);
			}
		}

		for(int i = 2; i <= N; i++){
			visited[i] = false;
		}

		calc(1);

		printf("%d\n",sum-last_visit);
	}

	return 0;
}

Measured memory_bytes: 2680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e9;

vector<vector<ll>> graph;
ll col[SIZE], dist[SIZE], par[SIZE];
pair<ll, ll> bst[SIZE];
bool used[SIZE];

pair<ll, ll> dfs(int v, int par = -1) {
    used[v] = 1;

    /*if (col[v] != -1) {
        if (abs(col[par] - col[v]) % 2 != abs(dist[par] - dist[v]) % 2) {
            cout << "No";
            exit(0);
        }
    }*/
    pair<ll, ll> pr = { -INF, INF };
    if (par != -1) pr = { col[par] - 1, col[par] + 1 };
    if (col[v] != -1) {
        pr = { col[v], col[v] };
    }
    for (auto to : graph[v]) {
        if (!used[to]) {
            dist[to] = dist[v] + 1;
            if (col[v] == -1) {
                pair<ll, ll> q = dfs(to, par);
                pr.first = max(pr.first, q.first - 1);
                pr.second = min(pr.second, q.second + 1);
            }
            else {
                pair<ll, ll> q = dfs(to, v);
                pr.first = max(pr.first, q.first - 1);
                pr.second = min(pr.second, q.second + 1);
            }
        }
    }

    bst[v] = pr;
    return pr;
}

void ch(int v, int par = -1) {
    used[v] = 1;

    if (col[v] != -1 && !(bst[v].first <= col[v] && bst[v].second >= col[v])) {
        cout << "No";
        exit(0);
    }

    bool flag = true;
    if (col[v] == -1) {
        if (bst[v].first <= col[par] - 1 && bst[v].second >= col[par] - 1) {
            col[v] = col[par] - 1;
            flag = false;
        }
        if (flag && bst[v].first <= col[par] + 1 && bst[v].second >= col[par] + 1) {
            flag = false;
            col[v] = col[par] + 1;
        }
    }
    else {
        flag = false;
    }

    if (flag) {
        cout << "No";
        exit(0);
    }
    for (auto to : graph[v]) {
        if (!used[to]) {
            ch(to, v);
        }
    }
}

int main() {
    fastInp;

    ll n, t;
    vector<ll> vec;
    cin >> n >> t;

    vector<ll> suf, pr;
    pr.push_back(INT64_MAX);
    suf.push_back(INT64_MIN);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        vec.push_back(a);
        pr.push_back(min(pr.back(), a));
    }

    for (int i = n - 1; i >= 0; i--) {
        ll a = vec[i];
        suf.push_back(max(suf.back(), a));
    }

    ll bst = 0;
    reverse(suf.begin(), suf.end());
    t -= t % 2;
    t /= 2;
    ll q = 0, q2 = 0;
    for (int i = 0; i < n - 1; i++) {
        bst = max(bst, suf[i + 1] * t - pr[i + 1] * t);
    }

    for (int i = 0; i < n - 1; i++) {
        if (suf[i + 1] * t - vec[i] * t == bst) {
            q++;
        }
    }

    for (int i = n - 1; i > 0; i--) {
        if (vec[i] * t - pr[i] * t == bst) {
            q2++;
        }
    }

    cout << min(q, q2);
    return 0;
}



Measured memory_bytes: 3436
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	string S;
	cin >> S;
	if (S.size()==2)
		cout << S << endl;
	else {
		for (int i = 2; i >= 0; i--)
			cout << S[i];
	}
}

Measured memory_bytes: 256
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let s = read_line () |> split_string
let t = read_line () |> split_string

let rec loop sum s t = match (s, t) with
  | s :: sx, t :: tx -> loop (sum + if s = t then 0 else 1) sx tx
  | _ -> sum

let () = Printf.printf "%d\n" @@ loop 0 s t

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

int main() {
	// your code goes here
	int a, cnt5=0, cnt7=0;
  	for(int i=0; i<3; i++){
    	cin>>a;
    	if(a==5) cnt5++;
    	else if(a==7) cnt7++;
  	}
  	if(cnt5==2 && cnt7==1) cout<<"YES"<<"\n";
  	else cout<<"NO"<<"\n";
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long mod=1e9+7;
#define ll long long
using namespace std;
int lim=0;

/*ll power(ll n)
{
    if(n==0) return 0%mod;
    if(n==1) return 1%mod;
    return ((power(n-1)%mod) + (power(n-2)%mod ))%mod;
}
int main()
{
    ll n;cin>>n;
    cout<<power(n%mod)%mod;
}*/
ll pw(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=res*x*1ll%mod;
        x=x*x*1ll%mod;
        n/=2;
    }return res;
}
int main()
{
    long long i,n,mn,x,y,p;
    cin>>n;mn=n+10;
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            x=i;
            y=(n/i);
            p=min(x,y);
            x-=p;
            y-=p;
            p=(p-1)*2+max(x,y);
            mn=min(p,mn);
        }
    }cout<<mn;
}
// C++ program to find sum of two large numbers.
/*#include<bits/stdc++.h>
using namespace std;

// Function for finding sum of larger numbers
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}

// Driver code
int main()
{
    string str1 ,str2 ;
    cin>>str1>>str2;
    cout << findSum(str1, str2);
    return 0;
}
*/
// CPP program to find (a^b) % MOD where a and
// b may be very large and represented as strings.




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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<power(10, 9) + 7>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int neg = 0;
  for (auto&& e : a) {
    cin >> e;
    neg += e < 0;
  }
  int ub = min(neg, k);
  int lb = k - min(n - neg, k);
  if (ub / 2 * 2 >= lb) {
    sort(begin(a), end(a), [](int x, int y) {
      return abs(x) > abs(y);
    });
    auto f = [](int x) { return x < 0; };
    int cnt = count_if(begin(a), begin(a) + k, f);
    if (cnt & 1) {
      long long ma = -1, mb = 1;
      int mi = -1, mj = -1;
      {
        int i = rend(a) - find_if(rend(a) - k, rend(a), f) - 1;
        int j = find_if_not(begin(a) + k, end(a), f) - begin(a);
        if (j < n and abs(a[j]) * mb > ma * abs(a[i])) {
          ma = abs(a[j]), mb = abs(a[i]);
          mi = i, mj = j;
        }
      }
      {
        int i = rend(a) - find_if_not(rend(a) - k, rend(a), f) - 1;
        int j = find_if(begin(a) + k, end(a), f) - begin(a);
        if (i != -1 and j < n and abs(a[j]) * mb > ma * abs(a[i])) {
          ma = abs(a[j]), mb = abs(a[i]);
          mi = i, mj = j;
        }
      }
      swap(a[mi], a[mj]);
    }
  } else {
    sort(begin(a), end(a), [](int x, int y) {
      return abs(x) < abs(y);
    });
  }
  cout << accumulate(begin(a), begin(a) + k, mint(1), multiplies<>()).v << '\n';
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/e.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

int dp[4000][4000];
constexpr int P = 1000'000'007;
int64_t qpow(int64_t a, int64_t b) {
  a %= P;
  int64_t res = 1;
  for (; b; b >>= 1, (a *= a) %= P) if (b & 1) (res *= a) %= P;
  return res;
}
void solve(std::istream &in, std::ostream &out) {
  int n, a, b, c, d;
  in >> n >> a >> b >> c >> d;
  vector<int> fac(n + 1, 1), ifac(n + 1, 1), rev(n + 1, 0);
  rev[1] = 1;
  for (int i = 2; i <= n; ++i) {
    rev[i] = (P - (int64_t) (P / i) * rev[P % i] % P) % P;
    fac[i] = (int64_t) fac[i - 1] * i % P;
    ifac[i] = (int64_t) ifac[i - 1] * rev[i] % P;
    assert((int64_t) fac[i] * ifac[i] % P == 1);
  }
  auto choose = [&](int n, int k) -> int64_t {
    if (k > n || k < 0) return 0;
    else return (int64_t) fac[n] * ifac[k] % P * ifac[n - k] % P;
  };
  dp[a - 1][0] = 1;
  for (int i = a; i <= b; ++i) {
    for (int j = n; j >= 0; --j) {
      dp[i][j] = dp[i - 1][j];
      for (int k = c; k <= d && k * i <= j; ++k) {
        (dp[i][j] += (int64_t) dp[i - 1][j - k * i] *
                     choose(n - (j - k * i), k * i) % P * fac[k * i] %
                     P * qpow(ifac[i], k) % P * ifac[k] % P) %= P;
      }
    }
  }
  out << dp[b][n] << '\n';
}

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

int main()
{	int count =0 ,n; 
	string a,b;

	cin >>a >> b;
	n= a.size();
	for (int i=0 ; i< n; i++ )
	{
		if (a[i]!=b[i])
		count++ ;
		
	} 
	
		
	cout<< count ;
	return 0;
	
	}
	
	


Measured memory_bytes: 3780
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//19234567892927;
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,a,b;cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
	return 0;
}

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




int main(){
    int n,S[10010],q,T[510],cnt=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
    cin>>q;
    
    for(int i=0;i<q;i++){
        cin>>T[i];
        for(int j=0;j<n;j++){
            if(T[i]==S[j]){
                cnt++;
                break;
            }
        }
        
    }
    cout<<cnt<<endl;
}






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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  while(b>0){
    if(a<1){cout<<"No"<<endl;return 0;}
    else{c-=b;}
    if(c<1){cout<<"Yes"<<endl;return 0;}
    else{a-=d;}
  }
  
  return 0;
}

Measured memory_bytes: 3624
/*
in the name of ALLAH
author: Sepehr_Noori
*/
#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define pp pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef map<int,int> mpii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef double db;
typedef long double ld;
const int mod = 1e9+7;
////////////////////////



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

    ll s=0,k,n,x;
    vi h;
    cin>>n>>k;
    for (int i =1;i<=n;i++){
        cin>>x;
        h.pb(x);
    }
    sort(all(h));
    while(k-- &&SZ(h))
        h.pp();
    for (auto z:h){
        s+=z;
    }
    cout<<s<<endl;

}
    /*int h,n,x,s=0;
    cin>>h>>n; 
    for (int i = 0;i<n;i++){
        cin>>x;
        s+=x;
    }
    if(s>=h){
        cout<<"Yes"<<endl;
        return 0;
    }else
    {
        cout<<"No"<<endl;
        return 0;
    }
    
}
    /*db h,a;
    cin>>h>>a;
    cout<<ceil(h/a)<<endl;;

    return 0;
}*/

Measured memory_bytes: 1400
N = int(input())
A=[]
B=[]
for i in range(N):
    a,b = map(int,input().split())
    c = 0
    A.append(a)
    B.append(b)
def merge_sort(arr,b):
    if len(arr) <= 1:
        return (arr,b)

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]
    leftt =b[:mid]
    rightt = b[mid:]

    # 再帰的に分割を行う
    left,leftt = merge_sort(left,leftt)
    right,rightt = merge_sort(right,rightt)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right,leftt,rightt)


def merge(left, right,leftt,rightt):
    merged = []
    mergedd = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            mergedd.append(leftt[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            mergedd.append(rightt[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
        mergedd.extend(leftt[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
        mergedd.extend(rightt[r_i:])
    return (merged,mergedd)
B,A = merge_sort(B,A)
found = True
SUM = 0
for i in range(N):
    SUM = SUM + A[i]
    if B[i] < SUM:
        found = False
if found:
    print("Yes")
else:
    print("No")
    



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

#define ll long long
int absolute(int a);



int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   char a;
   cin>>a;
   if(a>='a' && a<='z')
      cout<<'a';
   else
      cout<<'A';



   return 0;
}





int absolute(int a)
{
   if (a<0)return -a;
   return a;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n-1){
        vector<int> x(26), y(26);
        rep(j,i+1) x[s[j]-'a']++;
        
        for(int j = i+1; j < n; j++) y[s[j]-'a']++;
        
        int cnt = 0;
        rep(j,26) if(x[j] > 0 && y[j] > 0) cnt++;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
//#include<iostream>
using namespace std;
#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int ans,cnt[30];
string s;
 
signed main(){
    cin>>s;
    int len=s.size();
    ans=len*(len-1)/2+1;
    rep(i,0,len)cnt[s[i]-'a']++;
    rep(i,0,26)ans-=cnt[i]*(cnt[i]-1)/2;
    cout<<ans<<endl;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n<=500){
		printf("%d",n);
		for(int i=1;i<=n;++i){
			printf("\n");
			for(int j=1;j<=n;++j)printf("%d ",j);
		}
	}else{
		printf("500");
		for(int i=1;i<=500;++i){
			printf("\n");
			for(int j=1;j<=500;++j){
				int T=j+500-i;
				if(T%500<n-500){
					printf("%d ",T%500+1+500*(T*(T<=500)+min(i,j)&1));
				}else printf("%d ",T%500+1);
			}
		}
	}
}

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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  bool b1 = false;
  bool b2 = false;
  bool b3 = false;
  bool b4 = false;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }
  if(c.at(0).at(1) - c.at(0).at(0) == c.at(1).at(1) - c.at(1).at(0) && c.at(0).at(1) - c.at(0).at(0) == c.at(2).at(1) - c.at(2).at(0)) {
    b1 = true;
  }
  if(c.at(0).at(2) - c.at(0).at(1) == c.at(1).at(2) - c.at(1).at(1) && c.at(1).at(2) - c.at(1).at(1) == c.at(2).at(2) - c.at(2).at(1)) {
    b2 = true;
  }
  if(c.at(1).at(0) - c.at(0).at(0) == c.at(1).at(1) - c.at(0).at(1) && c.at(1).at(1) - c.at(0).at(1) == c.at(1).at(2) - c.at(0).at(2)) {
    b3 = true;
  }
  if(c.at(2).at(0) - c.at(1).at(0) == c.at(2).at(1) - c.at(1).at(1) && c.at(2).at(1) - c.at(1).at(1) == c.at(2).at(2) - c.at(1).at(2)) {
    b4 = true;
  }
  if(b1 && b2 && b3 && b4) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
# 19:04
n = int(input())
s = input()


def check(s, i, j, k):
    ii = 0
    jj = 0
    for l in range(len(s)):
        if ii == 1:
            if jj == 1:
                if s[l] == str(k):
                    return 1
            elif s[l] == str(j):
                jj = 1
        elif s[l] == str(i):
            ii = 1
    return 0


sum = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            sum += check(s, i, j, k)


print(sum)


Measured memory_bytes: 43100
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;
const int mod = 998244353;

int main(){
    string s; cin >> s;
    if (s[2] == s[3] and s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int H = Integer.parseInt(S[0]);
    int W = Integer.parseInt(S[1]);
    int N = Integer.parseInt(sc.nextLine());
    int[][] field = new int[H][W];
    
    int count = 0;
    int now = Integer.parseInt(sc.next());
    int p = 1;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(count == now){
          now = Integer.parseInt(sc.next());
          count = 0;
          p++;
        }
        if(i%2 == 0){
          field[i][j] = p;
        }else{
          field[i][W-j-1] = p;
        }
        count++;
      }
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(j == W-1){
          System.out.println(field[i][j]);
        }else{
          System.out.print(field[i][j]+" ");
        }
      }
    }
  }
}

Measured memory_bytes: 31400
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	if (*(int*)a < *(int*)b)return 1;
	if (*(int*)a > * (int*)b)return -1;
	return 0;
}
int main()
{
	int n, W;
	scanf("%d %d", &n, &W);
	int i, j;
	int w[102], v[102];
	for (i = 0; i < n; i++)
		scanf("%d %d", &w[i], &v[i]);
	int vv[4][102], l[4];
	l[0] = l[1] = l[2] = l[3] = 0;
	for (i = 0; i < n; i++)
	{
		vv[w[i] - w[0]][l[w[i] - w[0]]] = v[i];
		l[w[i] - w[0]]++;
	}
	qsort(vv[0], l[0], sizeof(int), asc);
	qsort(vv[1], l[1], sizeof(int), asc);
	qsort(vv[2], l[2], sizeof(int), asc);
	qsort(vv[3], l[3], sizeof(int), asc);
	int sum[4][102];
	for (i = 0; i < 4; i++)
	{
		sum[i][0] = 0;
		for (j = 0; j < l[i]; j++)
			sum[i][j + 1] = sum[i][j] + vv[i][j];
	}
	int ans = 0;
	int a, b, c, d;
	for (a = 0; a * w[0] <= W && a <= l[0]; a++)
		for (b = 0; a * w[0] + b * (w[0] + 1) <= W && b <= l[1]; b++)
			for (c = 0; a * w[0] + b * (w[0] + 1) + c * (w[0] + 2) <= W && c <= l[2]; c++)
				for (d = 0; a * w[0] + b * (w[0] + 1) + c * (w[0] + 2) + d * (w[0] + 3) <= W && d <= l[3]; d++)
					if (ans < sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d])
						ans = sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
nm = gets.chomp.split.map {|s| s.to_i }
s = Array.new(nm[0]) do |i|
  gets.chomp.split.map {|s| s.to_i }
end
d = Array.new(nm[1]) do |i|
  gets.chomp.split.map {|s| s.to_i }
end
s.each do |e|
  m = 100000000000
  res = 0
  d.each_with_index do |x, idx|
    res = idx if ((e[0]-x[0]).abs + (e[1]-x[1]).abs) < ((e[0]-d[res][0]).abs + (e[1]-d[res][1]).abs)
  end
  puts res + 1
end

Measured memory_bytes: 1788
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int h, w; rd(h, w);
  auto d=new int[][](10, 10);
  foreach(i; 0..10) d[i]=readln.split.to!(int[]);
  auto a=new int[][](h, w);
  foreach(i; 0..h) a[i]=readln.split.to!(int[]);

  foreach(_; 0..10)foreach(i; 0..10)foreach(j; 0..10){
    d[i][j]=min(d[i][j], d[i][_]+d[_][j]);
  }
  int sum=0;
  foreach(i; 0..h)foreach(j; 0..w){
    if(a[i][j]>=0) sum+=d[a[i][j]][1];
  }

  writeln(sum);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int digitSum(int n){
    int sum = 0;
    while (n > 0){
        sum += n %10;
        n /= 10;
    }
    return sum;
}
int main() {
    int N;
    cin >> N;
    int count = 100000;
    int total = 0;
    for (int i = 1; i <= N/2; ++i) {
        total = digitSum(i) + digitSum(N-i);
        count = min(count, total);
        /*for (int j = 1; j <= N; ++j) {
            if(i+j == N){
                total = digitSum(i) + digitSum(j);
                count = min(count, total);
            }
        }
         */
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var h, cnt, ans, flg int
	flg = 1
	l := 1000000000
	for i := 0; i< n; i++ {
		fmt.Scan(&h)
		if flg == 1  {
			flg = 0
		} else if flg == 0 && l >= h {
			cnt++
			if i == n-1 {
				if cnt > ans {
					ans = cnt
				}
				fmt.Println(ans)
				return
			} else {
				flg = 0
			}
		// i番目の値が一顧前のものよりデカかったとき。
		} else {
			if cnt > ans {
				ans = cnt
			}
			cnt = 0
		}
		if i == n-1 {
			fmt.Println(ans)
			return
		}
		l = h
	}
	fmt.Println(ans)
}

Measured memory_bytes: 5504
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
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)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}

ll const mod =1e9+7;
int main() {
  int N; cin >> N;
  map<int,int> col;
  int a,free=0;
  rep(i,N) {
    cin >> a;
    a/=400;
    if (a<=7) col[a]++;
    else free++;
  }
  cout << max(1,(int)col.size()) << ' ' << (int)col.size()+free << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int n , m ; 
	cin >> m >> n ;
	vi a(n) ;
	for(auto& x : a) cin >> x ;
	int sm = accumulate(all(a), 0LL) ;
	if(sm >= m) cout << "Yes\n" ;
	else cout << "No\n" ; 

}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N+2);
    a[0] = a[N+1] = 0;
    for (int i = 1; i <= N; i++) cin >> a[i];

    vector<int> dif1(N+1), dif2(N+1);
    for (int i = 0; i <= N; i++) dif1[i] = abs(a[i] - a[i+1]);
    for (int i = 0; i < N; i++) dif2[i] = abs(a[i] - a[i+2]);
    int sum = accumulate(dif1.begin(), dif1.end(), 0);
    for (int i = 0; i < N; i++) {
        cout << sum - dif1[i] - dif1[i+1] + dif2[i] << '\n';
    }
}


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

#define N 100

void insertionSort(int *,int);

int main()
{
  int i,j,n,get;
  int array[N];
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&array[i]);
      }
  insertionSort(array,n);
  
  return 0;
}

void insertionSort(int A[], int n)
{
  int i,j,v,k;

  for(k = 0; k < n-1; k++){
      printf("%d ",A[k]);
    }
  printf("%d",A[n-1]);
  printf("\n");
  
  for(i = 1; i < n; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k = 0; k < n-1; k++){
      printf("%d ",A[k]);
    }
    printf("%d",A[n-1]);
    printf("\n");
  }
}



Measured memory_bytes: 2060
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	if((A + B) / 2 < C){
		cout << A * X + B * Y << endl;
	}else{
		int ans = 0;
		int c = min(X,Y);
		ans += c * 2 * C;
		if(X>c){
			if(2*C < A){
				ans += 2 * C * (X - c);
			}else{
				ans += A * (X - c);
			}
		}
		if(Y>c){
			if(2*C < B){
				ans += 2 * C * (Y - c);
			}else{
				ans += B * (Y - c);
			}
		}
		cout << ans << endl;
	}

}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

ll amari(ll a){
    if(abs(a) % 2 == 0) return 0;
    else return 1;
}

ll sho(ll a){
    if(a<0 && amari(a)==1) return (a / (-2)) + 1;
    else return a / (-2);
}

stack<char> base2(ll a){
    stack<char> res;
    if(a == 0){
        res.push('0');
        return res;
    }
    while(true){
        if(a == 1){
            res.push('1');
            break;
        }
        else{
            if(amari(a) == 1){
                res.push('1');
                a = sho(a);
            }
            else if(amari(a) == 0){
                res.push('0');
                a = sho(a);
            }
        }
    }
    return res;
}

int main(void){
    ll n;
    cin >> n;
    stack<char> ans = base2(n);
    while(!ans.empty()){
        cout << ans.top();
        ans.pop();
    }
    return 0;
}

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

int n,k;
int d[10]={-1,-1,-1, -1, -1, -1, -1 ,-1,-1,-1};

bool check(int n){
  bool flag=true;
  int a;
  for(int i=n;i!=0;i/=10){
    a=i%10;
    for(int j=0;j<10;j++){
      if(a==d[j]) flag=false;
    }
  }
  return flag;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<k;i++){
    cin>>d[i];
  }
  
  for(int i=n;i<100000;i++){
    bool flag=false;
    flag=check(i);
    if(flag) {
      cout << i << '\n';
      break;
    }
  }
    
  return 0;
}


Measured memory_bytes: 3172
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 105
int N,ans=0x3f3f3f3f,cost;
int a[MAXN];
int Abs(int x)
{
	if(x<0) return -x;
	else return x;
}
int main()
{
	bool f=0;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		if(i>1&&a[i]!=a[i-1]) f=1;
	}
	if(!f)
	{
		printf("0\n");
		return 0;
	}
	sort(a+1,a+N+1);
	for(int i=a[1];i<=a[N];i++)
	{
		cost=0;
		for(int j=1;j<=N;j++)
			cost+=Abs((a[j]-i)*(a[j]-i));
		if(cost<ans) ans=cost;
	}
	printf("%d\n",ans);
	return 0;
}

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

const int N = 10;
int a[N]; long long ans, tmp;
int main () {
	for (int i = 1; i <= 7; ++i) cin >> a[i];
	ans = 1ll * a[2] + a[1] / 2 * 2 + a[4] / 2 * 2 + a[5] / 2 * 2;
	if ((a[1] & 1) && (a[4] & 1) && (a[5] & 1)) ans += 3;
	tmp = 1ll * a[2] + (a[1] - 1) / 2 * 2 + (a[4] - 1) / 2 * 2 + (a[5] - 1) / 2 * 2 + 3;
	if (a[1] && a[4] && a[5]) ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
   ll A, B, C;
   cin>>A>>B>>C;
   cout<<C<<" "<<A<<" "<<B<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n, x, y, sum=0;
    cin>>n>>x;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        // sum+=y;
    }
    sort(a.rbegin(), a.rend());
    for(int i = x; i < n; i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    // if(n>sum) cout<<"No"<<endl;
    // else cout<<"Yes"<<endl;
    // int ans = ceil(1.0*n/(1.0*x));
    // cout<<ans<<endl;
}

Measured memory_bytes: 1792
from itertools import product

N = int(input())
a = list(map(int, input().split()))

c = {}
for e in a:
    c.setdefault(e, 0)
    c[e] += 1

if len(set(c)) > 3:
    print('No')
    exit()

t = {}
for x, y in product(set(c), repeat=2):
    i = x
    j = y
    t[i] = 1
    if t[i] > c[i]:
        continue
    t.setdefault(j, 0)
    t[j] += 1
    if t[j] > c[j]:
        continue
    for _ in range(N - 2):
        k = i ^ j
        t.setdefault(k, 0)
        t[k] += 1
        c.setdefault(k, 0)
        if t[k] > c[k]:
            j = -1
            break
        i, j = j, k
    if j ^ x == y:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 14500
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 - 1;
	}
	else {
		cout << n / 2;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

template <typename T>
bool is_prime(T N)
{
    if (N < 2)
        return false;
    for (T i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}

int x;

int main()
{
    cin >> x;
    int next = 0;
    while (!is_prime(x + next))
        next++;

    cout << x + next << endl;
}

Measured memory_bytes: 256