akhauriyash/Code-Regression huggingface dataset:
using System;
//using System.Collections.Generic;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			n++;
			string[] s = Console.ReadLine().Split(' ');
			int[] a = new int[s.Length];
			for (int i = 0; i < s.Length; i++)
			{
				a[i] = int.Parse(s[i]);
			}
			int count = 0;

			for (int i = 1; i < a.Length; i++)
			{
				for (int j = i - 1; j >= 0; j--)
				{
					if (a[j] > a[j + 1])
					{
						int v = a[j + 1];
						a[j + 1] = a[j];
						a[j] = v;
						count++;
					}
					else break;
				}
			}
			for (int i = 0; i < a.Length; i++)
			{
				Console.Write(a[i]);
				if (i == a.Length - 1) Console.Write("\n");
				else Console.Write(" ");
			}
			Console.Write("{0}\n", count);
		}
	}
}

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

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
using ll = long long;

const int INF = 1001001001;

int main()
{
	int h, w, n, mx, mn, sum(0), ans(0);
	cin>>h>>w>>n;
	mx = max(h, w);
	mn = min(h, w);
	while(true){
	    if(sum>=n)break;
	    sum += mx;
	    ans++;
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, x;
  cin >> x >> a >> b;
  if(b <= a) cout << "delicious" << endl;
  else if(b-a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;

  return 0;
}


Measured memory_bytes: 256
cnt = 0
n, m = map(int, input().split())
h = list(map(int, input().split()))

ki = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ki[b].append(a)
    ki[a].append(b)

# print(ki)
for i in range(n):
    m = 0
    if len(ki[i]) == 0:
        cnt += 1
        continue
    for j in ki[i]:
        m = max(m, h[j])
    if h[i] > m:
        # print(i, j, h[i])
        cnt += 1
print(cnt)


Measured memory_bytes: 92896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef pair<int,P> PP;

template<class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

void mod(ll &val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll N;
    cin >> N;
    if(N == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ret = RS(10ll,N,MOD) - 2 * RS(9ll,N,MOD);
    mod(ret,MOD);
    ret = ret + RS(8ll,N,MOD);
    mod(ret,MOD);
    cout << ret << endl;
}

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

int main() {
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; i++) cin >> d[i];
    sort(d, d + n);
    int ans = 0;
    for (int k = 1; k <= 100000; k++) {
        int idx = lower_bound(d, d + n, k) - d;
        if (idx == n / 2) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;
	long N, x; cin >> N >> x;
	long a[1000]; for (int i = 1; i <= N; i++) cin >> a[i];

	sort(a + 1, a + N + 1);

	for (int i = 1; i <= N; i++) {
		if (x >= a[i]) { x -= a[i]; res++;}
		else break;

		if (i == N && x > 0) res--;
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

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


	/*string s;
	cin >> s;
	int sum = 0;
	rep(i, s.size()) {
		sum += int(s[i] - '0');
	}
	if (sum % 9 == 0)puts("Yes");
	else puts("No");*/


	/*int n;
	cin >> n;
	ll a;
	ll ma = 0;
	ll ans = 0;
	rep(i, n) {
		cin >> a;
		if (a < ma)ans += ma - a;
		ma = max(ma, a);
	}
	cout << ans;*/


	int h, w;
	cin >> h >> w;
	int ch, cw, dh, dw;
	cin >> ch >> cw >> dh >> dw;
	ch--, cw--, dh--, dw--;
	vector<vector<char>>s(h, vector<char>(w));
	rep(i, h)rep(j, w)cin >> s[i][j];
	deque<pair<int, int>>dq;
	const int INF = 1e9;
	vector<vector<int>>dist(h, vector<int>(w, INF));
	dist[ch][cw] = 0;
	dq.emplace_front(ch, cw);
	int di[] = { 1, 0, -1, 0 }, dj[] = { 0,1,0,-1 };

	while (dq.size()) {
		int i = dq.front().first;
		int j = dq.front().second;
		dq.pop_front();
		int d = dist[i][j];
		rep(k, 4) {
			int ni = i + di[k], nj = j + dj[k];
			if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
			if (s[ni][nj] == '#')continue;
			if (dist[ni][nj] <= d)continue;
			dist[ni][nj] = d;
			dq.emplace_front(ni, nj);
		}

		for (int ei = -2; ei <= 2; ei++) {
			for (int ej = -2; ej <= 2; ej++) {
				int ni = i + ei, nj = j + ej;
				if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
				if (s[ni][nj] == '#')continue;
				if (dist[ni][nj] <= d + 1)continue;
				dist[ni][nj] = d + 1;
				dq.emplace_back(ni, nj);
			}
		}
	}
	int ans = dist[dh][dw];
	if (ans == INF)ans = -1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 8656
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	bricks := scanIntSlice(n)

	count, target := 0, 1
	for _, b := range bricks {
		if b == target {
			target++
		} else {
			count++
		}
	}

	if target == 1 {
		fmt.Println("-1")
	} else {
		fmt.Printf("%d\n", count)
	}
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  string S;
  cin >> N >> S;
  bool ans = true;
  if (N % 2 != 0) ans = false;
  else {
    for (int i = 0; i < (N / 2); i++){
      if (S.at(i) != S.at(i + N / 2)) ans = false;
    }
  }
  if (ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	if (s == "RRR") {
		ans = 3;
	} else if (s == "RRS" || s == "SRR") {
		ans = 2;
	} else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") {
		ans = 1;
	}
	return cout << ans, 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int, string>;

int main() {
  int N;
  cin >> N;
  map<string,int> M;
  set<string> ss;
  string S;
  for (int i=0; i<N; i++) {
    cin >> S;
    M[S]++;
    ss.insert(S);
  }
  vector<string> V(ss.size());
  for (int i=0; i<(int)V.size(); i++) {
    S=*begin(ss);
    ss.erase(S);
    V[i]=S;
  }
  int m=0;
  for (int i=0; i<(int)V.size(); i++) {
    m=max(m, M[V[i]]);
  }
  vector<string> VV;
  for (int i=0; i<(int)V.size(); i++) {
    if (M[V[i]]==m) {VV.push_back(V[i]);}
  }
  sort(V.begin(), V.end());
  for (int i=0; i<(int)VV.size(); i++) {
    cout << VV[i] << endl;
  }
}

Measured memory_bytes: 49136
#include <bits/stdc++.h>
// https://boostjp.github.io/tips/multiprec-int.html
// https://boostjp.github.io/tips/multiprec-float.html
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using namespace std;

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll n,m,k;
string s;
int main() {
    INIT();

    cin >> n;
    ll cnt = 0;
    REPS(i, 1, n + 1) {
        cnt += (n - 1) / i;
    }
    cout << cnt;
}

Measured memory_bytes: 3656
s = int(input())

dp = [0 for _ in range(s+1)]
MOD = 10**9+7

for i in range(3,s+1):
  dp[i] = 1
  for j in range(3,i-2):
    dp[i] += dp[i-j]
    dp[i] %= MOD

print(dp[s])


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

int n;
int s = 0;
string ans;

int digitsSum(int n){
    int s = 0;
    int i = n;
    while(i > 0) {
        s += i%10;
        i /= 10;
    }
    return s;
}

int main() {
    cin >> n; 

    if (n % digitsSum(n) == 0)
    {
        ans = "Yes";
    } else {
        ans = "No";
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d,n,ans;
	while(scanf("%d",&n)!=EOF){
		ans=0;
		for (a=0 ; a<=9 ; a++){
			for (b=0 ; b<=9 ; b++){
				for (c=0 ; c<=9 ; c++){
					for (d=0 ; d<=9 ; d++){
						if(a+b+c+d== n)
							ans++;
					}
				}
			}
		}
	printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1688
n = int(input())

if n == 3:
    print(2, 5, 63)
    exit()

n -= 4
a, b = 2, 2

k = min(n // 3, 4999)
a += k * 3
n -= k * 3

if n % 2 == 1:
    a += 1
    n -= 1
b += n

for i, j in enumerate(range(2, 30001, 2)):
    if i == a:
        break
    print(j)

for i, j in enumerate(range(3, 30001, 6)):
    if i == b:
        break
    print(j)

Measured memory_bytes: 3424
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    vll A(N);
    REP(i, N) cin >> A[i];

    ll cur = 1000;
    REP(i, N - 1) {
        ll stock = 0;
        if (A[i] < A[i + 1]) stock = cur / A[i];
        cur += (A[i+1] - A[i]) * stock;
    }

    print(cur);
    
}


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

int main(){
  int N;
  int a[110];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i< N; i++){
    if ( i%2 == 0){
      Alice += a[i];
    }else{
      Bob += a[i];
    }
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

int main(){
    int x, y;
    cin >> x >> y;

    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

    if(a[x] == a[y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a;
	d=a%10;
	c=a/10%10;
	b=a/100%10;
	a=a/1000;
	if(a+b+c+d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a+b+c-d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a+b-c+d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a+b-c-d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a-b+c+d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a-b+c-d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a-b-c+d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a-b-c-d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var RGBN = ReadLine().Split().Select(int.Parse).ToArray();
        var R = RGBN[0];
        var G = RGBN[1];
        var B = RGBN[2];
        var N = RGBN[3];

        var a = 0;
        for (int i = 0; i <= 3000; i++)
        {
            for (int j = 0; j <= 3000; j++)
            {
                var m = N - i * R - j * G;
                if (m >= 0)
                {
                    if (m % B == 0) a++;
                }
            }
        }

        WriteLine(a);
    }
}

Measured memory_bytes: 13396
void main()
{
    long[] a = readln.split.to!(long[]);

    writeln(a.sum >= 22 ? "bust" : "win");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;

#define MAX_W 20
#define MAX_H 20
int W, H;
int sx, sy;
char maze[MAX_H][MAX_W];

vector<int> ans_list;

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

int solve(int x, int y){
  int tmp = 1;
  maze[y][x] = '#';
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx >= 0 && nx < W && ny >= 0 && ny < H && maze[ny][nx] != '#'){
      tmp += solve(nx, ny);
    }
  }
  return tmp;
}

int main(){

  while(true){
    
    cin >> W >> H;
    if(W == 0 && H == 0)
      break;

    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> maze[i][j];
	if(maze[i][j] == '@'){
	  sy = i;
	  sx = j;
	}
      }
    }

    ans_list.push_back(solve(sx, sy));
    
  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1236
//╔╗───────────╔╗────────────────────╔╗─
//║║──────────╔╝╚╗──────────────────╔╝╚╗
//║╚═╗╔══╗╔══╗╚╗╔╝╔══╗╔═╗╔╗╔╗╔══╗ ╔╗╚╗╔╝
//║╔╗║║╔╗║║╔╗║─║║─║║═╣║╔╝║╚╝║║╔╗║─╣║─║║─
//║╚╝║║╔╗║║║║║─║╚╗║║═╣║║─║║║║║╚╝║─║║─║╚╗
//╚══╝╚╝╚╝╚╝╚╝─╚═╝╚══╝╚╝─╚╩╩╝╚══╝─╚╝─╚═╝ 

#include <bits/stdc++.h>

#define pb push_back
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
    IO;
    int n,x=0,maxi = 0;
    string s;
    cin >> n >> s;
    forn(i,s.sz){
        if(s[i] == 'I'){
            ++x;
        }else{
            --x;
        }
        maxi = max(maxi,x);
    }
    cout << maxi;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int n;
    cin>>n;
    vector<vector<int>> shouziki(n,vector<int>(n,-1));
    rep(i,n){
        int a;
        cin>>a;
        rep(j,a){
            int x,y;
            cin>>x>>y;
            x--;
            shouziki[i][x]=y;
        }
    }

    int ans=0;
    for(int bit=0; bit<(1<<n); bit++){
        int count=0;
        vector<int> a;
        rep(i,n){
            if(bit&(1<<i)) a.push_back(1);
            else a.push_back(0);
        }
        bool judge=true;
        rep(i,n){
            if(a[i]==1){
                rep(j,n){
                    if(shouziki[i][j]!=a[j]&&shouziki[i][j]!=-1) judge=false;
                }
            }
        }
        if(judge) {
            rep(i,n){
                if(a[i]==1) count++;
            }
            ans=max(ans,count);
        }
        a.clear();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3580
def main():
  from collections import deque
  n,m=map(int,input().split())
  g=[[] for _ in range(n)]
  for _ in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    g[a].append(b)
    g[b].append(a)
  dp=[[False]*2 for _ in range(n)]
  dp[0][0]=True
  bfs=deque([0])
  while bfs:
    top=bfs.popleft()
    cur,par=top>>1,top&1
    for to in g[cur]:
      if not dp[to][par^1]:
        dp[to][par^1]=True
        bfs.append((to<<1)+(par^1))
  x=0;y=0;z=0
  for i in range(n):
    if dp[i][0] and dp[i][1]:
      x+=1
    elif dp[i][0]:
      y+=1
    elif dp[i][1]:
      z+=1
  ans=-m
  ans+=x*(x-1)>>1
  ans+=x*(y+z)
  ans+=y*z
  print(ans)

if __name__=='__main__':
  main()

Measured memory_bytes: 34924
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

ll N;

void solve() {
	cin >> N;
	vector<int> vec(N);

	ll ans = 0;
	rep(i, N) {
		cin >> vec[i];
		if (vec[i] != i+1) ans++;
	}

	if (ans == 2 || ans==0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

}

int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
vector<int> v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int i=0,cnt=0;
    while(i<(int)s.size()-1){
        if(s[i]=='0'&&s[i+1]=='1'||s[i]=='1'&&s[i+1]=='0'){
            cnt+=2;
            s.erase(s.begin()+i);
            s.erase(s.begin()+i);
            if(i>0) i--;
        }
        else i++;
    }
    cout<<cnt<<endl;

    return 0;
}



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

int main(){
  int t,n;

  for(int i=0;i<4;i++){
    cin >> t >> n;
    if(t==1){
      cout << 6000*n << '\n';
    }else if(t==2){
      cout << 4000*n << '\n';
    }else if(t==3){
      cout << 3000*n << '\n';
    }else{
      cout << 2000*n << '\n';
    }
  }
  return 0;
}



Measured memory_bytes: 3100
import sys

N,M = map(int, input().split(' '))
num = 0
if N == 1:
    if M < 2:
        print(1)
        sys.exit()
    print(str(M-2))
    sys.exit()
elif N == 2:
    print(0)
    sys.exit()
else:
    if M < 2:
        num = N-2
    else:
        num = (M-2)*(N-2) 
    print(num)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
   int n, x[10000], y[10000], i;
   x[0] = 1;
   n = 1;
   while(x[n-1] != 0 || y[n-1] != 0){
      scanf("%d %d", &x[n], &y[n]);
      n++;
   }

   for(i = 1; i < n-1; i++){
      if(x[i] < y[i]){
	printf("%d %d\n", x[i], y[i]);
      }
      else{
	printf("%d %d\n", y[i], x[i]);
      }
   }
   return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <set>
#include <algorithm>

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

    n = (1 << n);

    int maxi = 18;
    int maxj = (1 << 18);

    int a[n + 5];
    std::multiset<int> seti[maxj + 5] = {};
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        seti[i].insert(a[i]);
    }

    for (int i = 0; i < maxi; ++i)
    {
        for (int j = 0; j < maxj; ++j)
        {
            if ((j & (1 << i)))
            {
                int low = (j ^ (1 << i));
                for (auto it : seti[low])
                    seti[j].insert(it);

                while (seti[j].size() > 2)
                    seti[j].erase(seti[j].begin());
            }
        }
    }

    long long int maxans = 0;
    for (int k = 1; k < n; ++k)
    {
        auto it = seti[k].begin();
        long long int sum = *it;
        ++it;
        sum += *it;
        maxans = std::max(maxans, sum);
        std::cout << maxans << "\n";
    }
}


Measured memory_bytes: 40960
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <algorithm>
using namespace std;


int check(int n){
  if(n<=12&&1<=n){
  	return 0;
  }
  return -1;
}

int main(){
	int num,a,b;
	cin>>num;
	a=num/100;
	b=num%100;
	if(check(a)==0&&check(b)==0){
	  cout<<"AMBIGUOUS"<<endl;
	}else if(check(b)==0){
		cout<<"YYMM"<<endl;
	}else if(check(a)==0){
		cout<<"MMYY"<<endl;
	}else{
		cout<<"NA"<<endl;
	}
	return 0;
	}

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

void printArray(int array[], int length) {
    for (int ixArray = 0; ixArray < length; ixArray++) {
        if (ixArray != 0) printf(" ");
        printf("%d", array[ixArray]);
    }
}

int selectionSort(int array[], int length) {
    int swapCount = 0;
    int temp, minIndex, i, j;

    for (i = 0; i < length; i++) {
    	minIndex = i;
            
    	for (j = i + 1; j < length; j++)
            if (array[j] < array[minIndex])
    		    minIndex = j;

        if (array[i] != array[minIndex]) swapCount++;
        temp = array[i];
        array[i] = array[minIndex];
        array[minIndex] = temp;

    }

    return swapCount;
}

int main(int argc, char** argv) {
    int length;
    scanf("%d", &length);

    const int nxArray = length;
    int array[nxArray];
    for (int ixArray = 0; ixArray < nxArray; ixArray++)
        scanf("%d", &array[ixArray]);

    int nos = selectionSort(array, nxArray);
    
    printArray(array, nxArray);
    printf("\n");
    printf("%d\n", nos);
 

    return (EXIT_SUCCESS);
}






Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int X;
    cin >> X;
    for (ll i = -2000; i < 2000; i++){
        ll a = pow(i, 5);
        for (ll j = -2000; j < 2000; j++){
            ll b = pow(j, 5);
            if(a - b == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


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

const int mod = 1e9+7;

#define REP(i, n) for (int (i) = 0; (i) < (n); ++(i))

int f[65][2][2][2], a[65], sz = 62;

void add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}

int calc(long long n) {
	memset(f, 0, sizeof f);
	REP(i, sz) a[i] = n % 2, n /= 2;
	reverse(a, a + sz);
	f[0][0][0][0] = 1;
	REP(i, sz) REP(x, 2) REP(y, 2) REP(z, 2) if (f[i][x][y][z]) {
		int bit = a[i];
		REP(a, 2) REP(b, a+1) REP(c, 2) {
			int val1 = a^b^c;
			int val2 = a^b;
			int shift = (a+b+c)/2;
			if (shift ^ z) continue;
			if (!x && val1 > bit) continue;
			if (!y && val2 > bit) continue;
			add(f[i+1][x|(val1<bit)][y|(val2<bit)][c], f[i][x][y][z]);
		}
	}
	int result = 0;
	REP(x, 2) REP(y, 2) add(result, f[sz][x][y][0]);
	return result;
}

int main() {
	long long n;
	cin >> n;
	cout << calc(n) << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=2e3+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int dp[2005][2005];
int sum[maxn<<2];
#define lss rt<<1
#define rss rt<<1|1
#define lson lss,l,Mid
#define rson rss,Mid+1,r
void insert(int rt,int l,int r,int pos,int k){
    // cout<<l<<" "<<r<<endl;
    if(l==r)return (void)(sum[rt]=k);
    if(pos<=Mid)insert(lson,pos,k);
    else insert(rson,pos,k);
    sum[rt]=(sum[lss]+sum[rss])%mod;
}
int query(int rt,int l,int r,int L,int R){
    if(R<L)return 0;
    if(L<=l&&r<=R)return sum[rt];
    int res=0;
    if(L<=Mid)res+=query(lson,L,R);
    if(R>Mid)res=(res+query(rson,L,R))%mod;
    return res;
}
signed main(){
    //file(a);
    n=read();
    if(n<3){puts("0");return 0;}
    if(n==3){puts("1");return 0;}
    dp[0][0]=1;
    insert(1,1,n+1,0+1,1);//return 0;
    rep(i,1,n/3){
        rep(j,3,n){
            dp[i][j]=query(1,1,n+1,0+1,j-3+1);
            // cout<<"now"<<j<<" "<<0+1<<" "<<j-3+1<<" "<<dp[i][j]<<endl;
            /*rep(g,3,j){
                dp[i][j]+=dp[i-1][j-g];dp[i][j]%=mod;
            }*/
        }
        rep(j,0,n)insert(1,1,n+1,j+1,dp[i][j]);
    }int ans=0;
    rep(i,1,n/3)ans+=dp[i][n],ans%=mod;
    printf("%d\n",ans);


    return 0;
}


Measured memory_bytes: 13984
#include <cstdio>

int main(){
    int D,N;
    scanf("%d%d",&D,&N);
    if(D == 0){
        if(N < 100){
            printf("%d",N);
        }else{
            printf("%d",N + 1);
        }
    }else if(D == 1){
        if(N < 100){
            printf("%d",100 * N);
        }else{
            printf("%d",100 * N + 100);
        }
    }else if(D == 2){
        if(N < 100){
            printf("%d",100 * 100 * N);
        }else{
            printf("%d",10000 * N + 10000);
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int iCount = 1;
    bool bLoop = true;
    int input;
    
    while (bLoop)
    {
        cin >> input;
        
        if (input == 0)
        {
            bLoop = false;
            break;
        }
        else
        {
            cout << "Case " << iCount << ": " << input << endl;
        }
        ++iCount;
    }
    return 0;
}


Measured memory_bytes: 3008
n = int(input())
# a, b = map(int, input().split())
# c = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(n)]
s = input()

W = []
S = []

if s[0] == 'W':
    W.append(1)
    S.append(0)
else:
    W.append(0)
    S.append(1)

for i in range(1, n):
    c = s[i]
    if c == 'W':
        W.append(W[i - 1] + 1)
        S.append(S[i - 1])
    else:
        W.append(W[i - 1])
        S.append(S[i - 1] + 1)


min = min(S[n - 1] - S[0], W[n - 2])


for i in range(1, n - 1):
    tmp = W[i - 1] + S[n - 1] - S[i]
    if min > tmp:
        min = tmp




print(min)

Measured memory_bytes: 18164
import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,K = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    for b in (A[:N-K] < A[K:]):
        print('Yes' if b else 'No')
main()


Measured memory_bytes: 50096
import numpy as np
import itertools
N,M,X=map(int,input().split())
a=[]
b=[]
seq=[]

for i in range(0,N):
    seq.append(i)
for _ in range(0,N):
    a.append(list(map(int,input().split())))
a=np.array(a)
ans=10**7+1
for j in range(1,N+1):
    alist=list(itertools.combinations(seq,j))
    for k in range(len(alist)):
        b=list(alist[k])
        c=sum(a[b])
        if min(c[1:])>=X:
            ans=min(ans,c[0])
if ans==10**7+1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27476
s = list(input())

DOUBLE_HEAD = 1
DOUBLE_TAIL = 2
SINGLE = 3

count = 1
stat = SINGLE;
for i in range(1, len(s)):
  if stat == SINGLE:
    if s[i - 1] == s[i]:
      stat = DOUBLE_HEAD
    else:
      count += 1
      stat = SINGLE
  elif stat == DOUBLE_HEAD:
    count += 1
    stat = DOUBLE_TAIL
  elif stat == DOUBLE_TAIL:
    count += 1
    stat = SINGLE
#  else:
#    print("error")
    
print(count)

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define INF 5e+19
#define ll long long
int main(){
  ll ans = INF;
  int n,k;
  cin >> n >> k;
  ll x[n], y[n];
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }
  for(int rx=0;rx<n;rx++){
    for(int lx=0;lx<n;lx++){
      for(int uy=0;uy<n;uy++){
        for(int dy=0;dy<n;dy++){
          ll xmax = max(x[lx], x[rx]);
          ll xmin = min(x[lx], x[rx]);
          ll ymax = max(y[uy], y[dy]);
          ll ymin = min(y[uy], y[dy]);
          int cnt = 0;
          for(int s=0;s<n;s++){
            if(xmax>=x[s] && xmin<=x[s] && ymax >= y[s] && ymin <= y[s]){
              cnt++;
            }
          }
          if(cnt >= k)
            ans = min(ans, (xmax-xmin)*(ymax-ymin));
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
T=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
a,b=map(int,input().split())
for i in range(a):
  L=list(input().split())
  if "snuke" in L:
    p=L.index("snuke")
    i=str(i+1)
    print(T[p]+i)
    sys.exit()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, q;
vector<int> vec[100010];
int nex[20][100010];
int d[100010];

void bfs() {
	queue<P> que;
	d[0] = 0;
	que.push({ 0,0 });
	while (!que.empty()) {
		P p = que.front(); que.pop();
		int t = p.second;
		for (int i = 0; i < vec[t].size(); i++) {
			d[vec[t][i]] = p.first + 1;
			que.push({ p.first + 1,vec[t][i] });
		}
	}
}

int query(int a, int b) {
	if (d[a] > d[b])swap(a, b);
	int t = d[b] - d[a];
	for (int i = 0; i <= log2(n); i++)if (t&(1 << i))b = nex[i][b];
	if (a == b)return a;
	for (int i = log2(n); i >= 0; i--) {
		if (nex[i][a] != nex[i][b]) {
			a = nex[i][a];
			b = nex[i][b];
		}
	}
	return nex[0][a];
}

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int c; 
			cin >> c;
			vec[i].push_back(c);
			nex[0][c] = i;
		}
	}
	nex[0][0] = -1;
	for (int i = 1; i <= log2(n); i++) {
		for (int j = 0; j < n; j++) {
			if (nex[i - 1][j] == -1)nex[i][j] = -1;
			else nex[i][j] = nex[i - 1][nex[i - 1][j]];
		}
	}
	bfs();
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		cout << query(a, b) << endl;
	}
}


Measured memory_bytes: 22808
/*
Author: Srinjoy
Language: C++ 17
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;

template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }
 
template<class T>
istream& operator >> (istream& in, pair<T, T> & v){ in >> v.fi >> v.se;return in; }

void printArr(vector<int> arr){
	cout<<"\n------------------------------------\n";

	for(int i=0;i<arr.size();i++) cout<<arr[i]<<" ";
	
	cout<<"\n------------------------------------\n";
}

void printArr(vector<vector<int> > arr){
	cout<<"\n------------------------------------\n";

	for(vector<int> i:arr){
		for(int j:i){
			cout<<j<<" ";
		}
		cout<<endl;
	}
	
	cout<<"\n------------------------------------\n";

}


int main(){
	optimiza_io
	
	ll n,k;
	cin>>n>>k;
	vector<ll> arr(n);
	cin>>arr;

	sort(arr.begin(),arr.end());

	ll ans = 0;

	for(int i=0;i<n-k;i++){
		ans += arr[i];
	}

	cout<<ans<<endl;


	
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=2e5+7;
int a[N],cnt[N],q[N];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=ri(),k=ri(),i,ans=0;
	for(i=1;i<=n;i++)	a[i]=ri(),cnt[a[i]]++;
	for(i=n;i>=1;i--)	if(cnt[i])	q[++q[0]]=cnt[i];
	sort(q+1,q+1+q[0]);
	for(i=1;i<=q[0]-k;i++)	ans+=q[i];
	wi(ans);putchar('\n');
	return 0;
}


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

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

    vector<int> me(n);
    REP(i,n) cin>>me[i];

    vector<int> man(n);
    REP(i,n) cin>>man[i];

    vector<int> add(n-1);
    REP(i,n-1) cin>>add[i];

    int ans=0;

    REP(i,n){
        REP(j,n)if(me[i] == j+1)ans += man[j];
        int v = me[i];
        if(me[i] == me[i-1] +1) ans += add[v-2];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $n, $m);
$ans = [];
for($i = 0; $i < $n; $i++) {
    $k = explode(' ', trim(fgets(STDIN)));
    $_k = array_slice($k, 1);
//var_dump($_k);
    foreach($_k as $v) {
        if(!array_key_exists($v, $ans)) $ans[$v] = 0;
        $ans[$v] += 1;
    }
}
//var_dump($ans);
$c = 0;
foreach($ans as $key => $v) {
    if($v == $n) $c += 1;
}
echo $c, PHP_EOL;

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll u[N-1], v[N-1]; rep(i,N-1) { cin >> u[i] >> v[i]; if (u[i]>v[i]) swap(u[i],v[i]); }
  ll result = 0; repr(i,1,N+1) result += (ll)i * ((ll)i+1) / 2;
  rep(i,N-1) result -= u[i] * (N-v[i]+1);
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 6724
#include <iostream>
using namespace std;
 
int main()
{
  int N;
  cin>>N;
  bool Possible = false;
  for(int i = 0; i <= N/4; i++)
  {
    for(int j = 0; j <= (N-4*i)/7; j++)
    {
      if(i*4+j*7 == N) 
      {
        Possible = true;
        break;
      }
    }
  }
  
  if(Possible)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main()
{
	string s;
	cin>>s;
	
	int minv=700;
	for(int i=0;s[i+2]!='\0';i++){
		int num=(int)(s[i]-'0')*100+(int)(s[i+1]-'0')*10+(int)(s[i+2]-'0');
		if(abs(num-753)<minv) minv=abs(num-753);
	}
	
	cout<<minv<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,x,bf=0,ch=0,cnt=0;
  cin>>N;
  rep(i,N){
    cin>>x;
    if(ch==0){
      if(bf==0){
        bf=x;
        continue;
      }else if(bf<x){
        ch=1;        
      }else if(bf>x){
        ch=-1;
      }
    }
    if(bf<x&&ch==-1){
      cnt++;
      ch=0;
    }
    if(bf>x&&ch==1){
      cnt++;
      ch=0;
    }
    bf=x;
  }
  cout<<cnt+1<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_131
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string s = Read();
            for(int i = 1; i < s.Length; i++)
            {
                if (s[i] == s[i - 1])
                {
                    WriteLine("Bad");
                    return;
                }
            }
            WriteLine("Good");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 1;
  char c = s[0];
  for(int i = 0;i < n;i++){
    if(s[i] != c){
      ans++;
      c = s[i];
    }
  }

  cout << ans << endl;
}


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

using namespace std;

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

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

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

long long gcd(long long ag, long long bg) {
	if (ag < bg)
		swap(ag, bg);
	while (bg != 0) {
		ag %= bg;
		swap(ag, bg);
	}
	return ag;
}
long long p, q, a, n;
long long dfs(long long bunsi, long long bunbo, long long mal, long long num, long long mi) {
	long long cnt = 0;
	if (num == 1 && bunsi != 1)
		return 0;
	if (bunsi == 1&&bunbo*mal<=a&&bunbo>=mi) {
		cnt++;
		if (num <= 1)
			return 1;
	}
	if (bunsi == 0)
		return 0;
	if (mi*mal > a)
		return cnt;
	for (long long i = mi;i*mal <= a;i++) {
		if (bunsi*i < bunbo)
			continue;
		if (num*bunbo < bunsi*i)
			break;
		long long g = gcd(bunsi*i - bunbo, bunbo*i);
		cnt += dfs((bunsi*i - bunbo) / g, bunbo*i / g, mal*i, num - 1, i);
	}
	return cnt;
}

int main() {
	while (cin >> p >> q >> a >> n, p | q | a | n) {
		int g = gcd(p, q);
		cout << dfs(p/g, q/g, 1, n, 1) << endl;
	}
}

Measured memory_bytes: 3008