akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    ll N,K;
    cin >> N >> K;
    ll R,S,P;
    cin >> R >> S >> P;
    string T;
    cin >> T;//T.size = N
    ll ans = 0;
    rep(i,N){
        if(T[i] == 'r')ans += P;
        else if(T[i] == 's')ans += R;
        else if(T[i] == 'p')ans += S;
    }
    rep(i,N - K){
        if(T[i] == T[i + K] && T[i] == 'r'){
            ans -= P;
            T[i + K] = 'o';
        }
        else if(T[i] == T[i + K] && T[i] == 's'){
            ans -= R;
            T[i + K] = 'o';
        }
        else if(T[i] == T[i + K] && T[i] == 'p'){
            ans -= S;
            T[i + K] = 'o';
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	ll n, sum=0,min=0;
	cin >> n;
	vector<ll>s(n);

	for (ll i = 0; i < n; i++) {
		cin >> s[i];
		sum += s[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		exit(0);
	}
	sort(s.begin(), s.end());
	for (ll i = 0; i < n; i++) {
		if (s[i]%10!=0) {
			min = s[i];
			cout << sum - min << endl;
			exit(0);
		}
	}
	cout << 0 << endl;
	

}


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

char gazou[101][101];


int main(void) {
	int H, W;
	int newH, newW;
	cin >> H >> W;

	for (int i = 1; i <= H; i++)
		for (int j = 1; j <= W; j++)
			cin >> gazou[i][j];

	for (int i = 1; i <= 2*H; i++) {
		for (int j = 1; j <= W; j++) {
			cout << gazou[(i+1)/2][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

let a = ParseInt1 <| Console.ReadLine()
let b = ParseInt1 <| Console.ReadLine()
let h = ParseInt1 <| Console.ReadLine()
printfn "%d" ((a + b) * h / 2)


Measured memory_bytes: 12112
#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin >> n;
    long double ans = 0;
    long long value = 1;
    bool zf = false;
    bool np = false;
    for (int i = 0; i < n; i++)
    {
        long long a;
        cin >> a;
        if (a == 0)
            zf = true;
        if (a != 0)
            ans += log10(a);
        if (ans > 18)
            np = true;
        value *= a;
    }
    if (not zf and (np or value > (long long)1e18))
        cout << "-1";
    else
        cout << value;
}

Measured memory_bytes: 4012
import sys
N,M = map(int, input().split())
A = list(map(int, input().split()))
sorted_A = sorted(A, reverse=True) 
all_A = sum(A)

rule = (1/(4*M))

ans = 0

for i in A:
    if (i / all_A) >= rule:
        ans = ans + 1
    else:
        pass

if ans >= M:
    print("Yes")
else:
    print("No")

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    lint k,n;
    cin >> k >> n;

    lint ans=0, tmp;

    vector<lint> a(n),d(n);
    REP(i, n) { cin >> a[i];}
    sort(ALL(a));
    ans = k - a[n - 1] + a[0];
    REP(i, n-1){
        lint z = a[i + 1] - a[i];
        ans = max(ans, z);
    }
    ans = k - ans;
    cout << ans <<"\n";

    return 0;
}

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

using namespace std;

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

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if ((a[0] == a[1] and a[1] != a[2]) or (a[0] != a[1] and a[1] == a[2])) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
if R - L >= 2019:
    mn = 0
else:
    l, r = L % 2019, R % 2019
    mn = 2018 ** 2
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mn = min(mn, i * j % 2019)
print(mn)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
int P[200];
int main (){
  int X,N;
  cin>>X>>N;
  if(N==0){
    cout<<X;
    return 0;
  }
  rep(i,N){
    int a;
    cin>>a;
    P[a]=1;
  }
    if(P[X]==0){
      cout<<X;
      return 0;
    }
  int a=0;
  while(1){
    if(P[X-a]==0){
      cout<<X-a;
      return 0;
    }
    else if(P[X+a]==0){
      cout<<X+a;
      return 0;
    }
    else{
      a++;
    }
  }
}


Measured memory_bytes: 3640
#ARC073C - Sentou
n, t = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
ans, cur, lim = 0, 0, 0
for i in lst:
    ans += t if i > lim else i - cur
    cur = i
    lim = cur + t
ans += lim - cur
print(ans)

Measured memory_bytes: 26836
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    char b;
    cin>>b;
    if(b=='A'){
        cout<<'T'<<endl;
    }else if(b=='T'){
        cout<<'A'<<endl;
    }else if(b=='C'){
        cout<<'G'<<endl;
    }else{
        cout<<'C'<<endl;
    }
}

Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        string s;
        cin >> s;

        int n = s.size();
        string l = s.substr(0, n / 2);
        string r = s.substr((n + 1) / 2, n / 2);

        string lc = l, rc = r, sc = s;
        reverse(lc.begin(), lc.end());
        reverse(rc.begin(), rc.end());
        reverse(sc.begin(), sc.end());

        if(l == lc && r == rc && s == sc)
            cout << "Yes\n";
        else
            cout << "No\n";
        
    }
    
    return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

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

typedef long long ll;

using namespace std;



/*
class LightSwitchingPuzzle
{
public:
	int minFlips(string s)
	{

	}
}
*/


int main()
{
	int n, m, t, time;
	vector<int> vi;
	
	while (cin >> n >> m)
	{
		if (n == 0 && m == 0) break;
		
		vi.clear();
		time = 0;
		
		vi.push_back(0);
		REP(n)
		{
			cin >> t;
			vi.push_back(t);
		}
		REP(m)
		{
			cin >> t;
			vi.push_back(t);
		}
		
		sort(vi.begin(), vi.end());
		
		for (int i=0; i<vi.size()-1; i++)
		{
			time = max(time, vi[i+1] - vi[i]);
		}
		
		cout << time << endl;
		
		/*
		//テスト出力
		REP(vi.size())
		{
			cout << vi[i] << " ";
		}
		*/
	}
	
	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int r, g;
	cin >> r >> g;
	cout << g + g - r << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			while(true){
				int T = sc.nextInt(), D = sc.nextInt(), L = sc.nextInt();
				if(T==0 && D == 0 && L == 0){
					break;
				}
				int ans = 0, time = 0;
				for(int i = 0; i < T - 1; i++){
					int x = sc.nextInt();
					if(x>=L){
						time = D - 1;
						ans++;
					}else if(time != 0){
						time--;
						ans++;
					}
				}
				sc.nextInt();
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 279876
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D;
  cin >> N >>D;
  D=D*2+1;
  int ans;
  if(N%D==0){
    ans=N/D;
  }else{
  	ans=N/D+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const llong MOD = 1000000007;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N;
llong C;

llong x[100010], v[100010];

llong MAXA[100010], MAXB[100010];

int main() {
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> v[i];
	}

	MAXA[0] = v[0] - x[0];
	llong masa = v[0];

	for (int i = 1; i < N; i++) {
		masa += v[i];
		MAXA[i] = max(masa - x[i], MAXA[i - 1]);
	}

	MAXB[N - 1] = v[N - 1] - C + x[N - 1];
	llong masb = v[N - 1];

	for (int i = N - 2; i >= 0; i--) {
		masb += v[i];
		MAXB[i] = max(masb - C + x[i], MAXB[i + 1]);
	}

	llong ANS = max(MAXA[N - 1], MAXB[0]);

	if (ANS < 0) ANS = 0;
	

	masa = 0;

	for (int i = 0; i < N - 1; i++) {
		masa += v[i];
		ANS = max(ANS, masa - 2 * x[i] + MAXB[i + 1]);
	}

	masb = 0;
	for (int i = N - 1; i > 0; i--) {
		masb += v[i];
		ANS = max(ANS, masb - 2 * (C - x[i]) + MAXA[i - 1]);
	}
	

	cout << ANS;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define mk make_pair
#define int long long
int a[322][322],b[322][322],n,c[322][322],ans,t,pt;
main(){
  cin>>n;
  pt=(1e13)*(n*n-n);
  r(i,n)r(j,n)c[i][j]=1e13;
  r(i,n)c[i][i]=0;
  r(i,n){
    r(j,n){
      cin>>a[i][j];
      b[i][j]=a[i][j];
    }
  }
  /*r(i,n)r(j,n)if(a[i][j]!=a[j][i]){
    cout<<-1<<endl;
    return 0;
  }*/
  r(o,n)r(i,n)r(j,n)a[i][j]=min(a[i][j],a[i][o]+a[o][j]);
  r(i,n)r(j,n){
    if(a[i][j]!=b[i][j]){R:;
      cout<<-1<<endl;
      return 0;
    }
  }
  r(i,n)r(j,n)if(i<j){
    int f=0;
    ans+=a[i][j];
    r(o,n)if(o!=i&&o!=j){
      if(a[i][j]==a[i][o]+a[o][j])f++;
    }
    if(f)ans-=a[i][j];
  }
  cout<<ans<<endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  ll n, m;
  cin >> n >> m;
  m /= 2;
  ll ans;
  if(n >= m) ans = m;
  else ans = (n+m) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

const long long BIGINF = 2e18 + 7;
const int INF = 2e9 + 7;

char mat[30][30];
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int h, w;

bool OK(int row, int col) {
	return (row >= 0 && row < h && col >= 0 && col < w
			&& mat[row][col] == '.');
}


int main () {
	/*#ifndef ONLINE_JUDGE
		freopen("inputf.txt", "r", stdin);
		freopen("outputf.txt", "w", stdout);
		freopen("errorf.txt", "w", stderr);
	#endif*/
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> mat[i];
		//cerr << mat[i] << endl;	
	}
	int ans = 0;
	for (int row = 0; row < h; row++) {
		for (int col = 0; col < w; col++) {
			if (OK(row, col)) {
				vector<pair<int, int>> queue;
				queue.emplace_back(row, col);
				vector<vector<int>> distance(h + 1, vector<int>(w + 1));
				vector<vector<bool>> visited(h + 1, vector<bool>(w + 1));
				visited[row][col] = true;
				for (int i = 0; i < (int)queue.size(); i++) {
					pair<int, int> curr = queue[i];
					for (int direction = 0; direction < 4; direction++) {
						int new_row = curr.first + dx[direction];
						int new_col = curr.second + dy[direction];
						if (OK(new_row, new_col) && !visited[new_row][new_col]) {
							distance[new_row][new_col] = distance[curr.first][curr.second] + 1;
							queue.emplace_back(new_row, new_col);
							visited[new_row][new_col] = true;
							ans = max(ans, distance[new_row][new_col]);
						}
					}
				}
			}
		}
	}
	cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    ll n, ans = 0;
    cin >> n;
    ans += (n / 500) * 1000;
    n %= 500;
    ans += (n / 5) * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll n,k;    cin>>n>>k;
    ll ans = 0;
    if(k%2 == 1){
        ll tmp = n/k;
        ans = tmp*tmp*tmp;
    }else{
        ll a = 0, b = 0;
        for(ll i = 1; i <= n; i++){
            if(i%k == 0)    a++;
            if(i%k == k/2)  b++;
        }
        ans = a*a*a + b*b*b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#pragma GCC optimize ("Ofast")
#include <iostream>
using namespace std;

// K から自分以外が正解した回数を引いて 0 以下なら No
// <=> K - (解答できなかった回数) <= 0 なら No
// <=> K - (Q - 解答できた回数) <= 0 なら No
// <=> K - Q + (解答できた回数) <= 0 なら No
int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	int count[N + 1] = {0}; // count[0] は使わない, count[1]~count[N] を使う
	int A[Q + 1] = {0}; // A[0] は使わない, A[1]~A[i]~A[Q] を使う
	// 解答者の入力 -> 解答者ごとの解答数の集計
	for (int i = 1; i <= Q; ++i) { // i 番目に正解したのは参加者 A[i]
		cin >> A[i];
		++(count[A[i]]);
	}
	// 出力
	for (int j = 1; j <= N; ++j) {
		cout << ((K - Q + count[j] <= 0) ? "No" : "Yes") << endl;
	}
	return 0;
}

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

int n,ans=0;

void dfs(string s){
    int three=0,five=0,seven=0;
    for(int i = 0;i < s.size();i ++){
        if(s[i]=='3') three ++;
        if(s[i]=='5') five ++;
        if(s[i]=='7') seven ++;
    }
    if(three>0&&five>0&&seven>0&&stoll(s)<=n) ans ++;
    if(stoll(s)>n) return;
    dfs(s+'3');
    dfs(s+'5');
    dfs(s+'7');
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    dfs("0");
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n;in(n);
  string s;in(s);
  vector<int> R;
  loop(i,0,n) if (s[i] == 'R') R.push_back(i);
  int ans = 0;
  loop(i,0,n-1) {
    if (s[i] == 'W' and R.size()) {
      int idx = R.back();
      if (idx < i) continue;
      swap(s[i], s[idx]);
      R.pop_back();
      ans++;
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 4352
using System;

namespace _139d
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            Console.WriteLine((1+N-1)*(N-1)/2);

            // long M_total = 0;
            // // float[] N_array = new float[N];
            // for(long i = 0; i < N;i++){
            //     // N_array[i] = i+1;
            //     if(i != N-1){
            //         M_total += i+1;
            //     }
            // }
            // // for(int i = 0; i < N ; i++){
            // //     if(i != N-1){
            // //         M_total += N_array[i]%N_array[i+1];
            // //     }
            // // }
            // Console.WriteLine(M_total);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int sum=0;
    sum=a+b+c;
    if(sum>=22){
        printf("bust\n");
    }
    else
    {
        printf("win\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
int main(){
	string dum;
	std::cin >> dum;
	vector<ll> s(dum.size());//,sdum(dum.size());
	rep(i,dum.size())s[dum.size()-(i+1)]=ctoi(dum[i]);
	ll n=s.size()-1;
	ll sumval=0;
	for (int bit = 0; bit < (1<<n); bit++) {
		/* code */
		sumval+=s[0];
		int power=0;
		rep(i,n){
		
			if(bit&(1<<i)){
				power=0;
				sumval+=s[i+1]*pow(10,power);
				
			}
			else{
			
				power++;
				sumval+=s[i+1]*pow(10,power);
			}
		}
	}
	std::cout << sumval << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)
    {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N;
char S[100010];

int main(){
  int i, j, k;
  int res = 0;

  N = reader(S);
  REP(i,1,N) if(S[i] != S[i-1]) res++;
  writerLn(res);

  return 0;
}


Measured memory_bytes: 512
/**  Author  : APU SANGMA
     Problem : A

**/

#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<assert.h>
#include <bitset>
#include <time.h>

using namespace std;
typedef long long ll;
const int INF=0x7FFFFFFF;

#define __ cin.sync_with_stdio(false);\
           cin.tie();
#define PI 3.141592653589793
#define MOD 1000000007LL
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define FOR(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)

int main()
{
    long long int n,d,a=0,sum=0,sumx=0,x=0;

    scanf("%lld",&n);

    while(n!=0)
    {
        d = n % 10;
        
        n/= 10;
        
        sumx +=d;
        
        a++;
        
        if(d!=9)
            x=1;
    }

    if(x==0)
        sum = a*9;

    else
        sum =((a-1)*9)+d-1;

    if(sum>sumx)
        printf("%lld\n",sum);
    else
        printf("%lld\n",sumx);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        Map<Integer, Double> E = new HashMap<>(); 
        
        int[] p = new int[N];

        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
            if(E.containsKey(p[i])) {
                continue;
            }else {
                E.put(p[i], kitai(p[i]));
            }
        }
        
        double sum = 0;
        for(int i = 0; i < K; i++) {
            sum += E.get(p[i]);
        }
        double ans = sum;
        for(int i = K; i < N; i++) {
            sum -= E.get(p[i - K]);
            sum += E.get(p[i]);
            
            if(ans < sum) {
                ans = sum;
            }
        }
        
        System.out.println(ans);
        
        
        
    }
    
    public static double kitai(int x) {
        double X = 0;
        for(double i = 1; i <= x; i++) {
            X += i / x;
        }
        return X;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++)
    cin >> d.at(i);
  
  int cnt = 0;
  int lim_d = 101;
  for(int i=0; i<N; i++){
    int max_d = 0;
    for(int j=0; j<N; j++){
      if(d.at(j) > max_d && d.at(j) < lim_d){
        max_d = d.at(j);
      }
    }
    if(max_d == 0)
      break;
    cnt++;
    lim_d = max_d;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 110;

//建物 = 1, 内包 = 0, 外 = 2
int field[N][N];
int mx_odd[] = {1, 1, 1, 0, -1, 0};
int mx_even[] = {0, 1, 0, -1, -1, -1};
int my[] = {-1, 0, 1, 1, 0, -1};
int h, w;

bool CanMove(int y, int x){
    if(x < 1) return false;
    if(y < 1) return false;
    if(x > w) return false;
    if(y > h) return false;
    return true;
}

void Set2(int y, int x){
	//cerr<<"y: "<<y<<" x: "<<x<<endl;
    field[y][x] = 2;
    REP(i, 6){
        int ny = y + my[i], nx;
        if(y % 2 == 0) nx = x + mx_even[i];
        if(y % 2 == 1) nx = x + mx_odd[i];

        //debug
        //if(ny == 3 && nx == 2) cout <<y <<", " <<x <<", " <<field[ny][nx] <<endl;
        if(CanMove(ny, nx) && field[ny][nx] == 0) Set2(ny, nx);
    }
}

int Cnt2(int y, int x, bool is_odd){
    int ret = 0;
    REP(i, 6){
        int nx, ny = y + my[i];
        if(is_odd) nx = x + mx_odd[i];
        else nx = x + mx_even[i];
        //debug
        //cout <<ny <<", " <<nx <<", " <<field[ny][nx] <<endl;

        if(!CanMove(ny, nx)) ret++;
        else if(field[ny][nx] == 2) ret++;
    }
    //debug
    //cout <<y <<", " <<x <<", " <<ret <<endl <<endl;
    return ret;
}

int main(){
    cin >>w >>h;
    FOR(i, 1, h + 1){
        FOR(j, 1, w + 1){
            cin >>field[i][j];
        }
    }


    FOR(i, 1, w + 1){
        if(field[1][i] == 0) Set2(1, i);
        if(field[h][i] == 0) Set2(h, i);
    }

    FOR(i, 1, h + 1){
        if(field[i][1] == 0) Set2(i, 1);
        if(field[i][w] == 0) Set2(i, w);
    }

    //debug
	/*
    FOR(i, 1, h + 1){
    	if(i % 2) cout << " ";
    	FOR(j, 1, w + 1){
            cout <<field[i][j] <<" ";
        }
        cout <<endl;
    }
	*/

    int ans = 0;
    FOR(i, 1, h + 1){
        FOR(j, 1, w + 1){
            if(field[i][j] == 1){
                if(i % 2 == 0) ans += Cnt2(i, j, false);
                if(i % 2 == 1) ans += Cnt2(i, j, true);
            }
        }
    }
    cout <<ans <<endl;
    return 0;
}

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

int hight(int a){return (int)pow(2,a+2)-3;}
int p(int a){return (int)pow(2,a+1)-1;}

int S(int l,int x){//レベルlのバーガーの下からx枚
int ans=0;
if(l==0){return x>=1;}
if(x<=1)return 0;
x--;
if(x<hight(l-1))return S(l-1,x);
x-=hight(l-1);ans+=p(l-1);  
if(x)ans++;
x--;
if(x<=0)return ans;
if(x<hight(l-1))return ans+S(l-1,x);
x-=hight(l-1);ans+=p(l-1);  
return ans;
}
signed main(){
int l,x;cin>>l>>x;
cout<<S(l,x)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int r,c,i,j,n;
    int a=0;
    int sum=0;
    int s=0;
    cin>>r>>c;
    int date[r][c];
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cin>>n;
            date[i][j] = n;
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cout<<date[i][j]<<" ";
            sum += date[i][j];
        }
            cout<<sum<<endl;
            a+=sum;
            sum = 0;
    }
    for(j=0;j<c;j++){
        for(i=0;i<r;i++){
            s += date[i][j];
        }
        cout<<s<<" ";
        s=0;
    }
    cout<<a<<endl;
return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, d, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x;
    a = x / 1000;
    b = x % 1000 / 100;
    c = x % 100 / 10;
    d = x % 10;
    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{
        cout << a << '-' << b << '-' << c << '-' << d << '=' << 7 << endl;
    }
}


Measured memory_bytes: 256
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        int knapsack = sc.nextInt();

        int[] weights = new int[n];
        int[] values = new int[n];

        for(int i=0;i<n;i++) {
            weights[i] = sc.nextInt();
            values[i] = sc.nextInt();
        }

        long[][] dp = new long[n][knapsack+1];

        // initial weight
        for(int i=weights[0];i<knapsack+1;i++) {
            dp[0][i] = values[0];
        }
        for(int i=1;i<n;i++) {
            for(int j=1;j<knapsack+1;j++) {
                dp[i][j] = j >= weights[i] ? Math.max(dp[i-1][j-weights[i]] + values[i], dp[i-1][j]) : dp[i-1][j];
            }
        }

        pw.println(dp[n-1][knapsack]);
        pw.close();
	}

}

Measured memory_bytes: 125652
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 200100;
int n;
int a[MAX];
bool spr(int x){
  debug(x);
  int dl = 0;
  vector<PII> st;
  R(i,n){
    if(dl >= a[i]){
      int ost; 
      while(dl > a[i]){
        debug(dl, a[i]);
        ost = st.back().FI;
        dl -= st.back().SE;
        st.pop_back();
      }
      if(a[i] != dl)
        st.PB({ost, a[i] - dl});
      dl = a[i];
      while(SZ(st) && st.back().FI == x-1){
        dl -= st.back().SE;
        st.pop_back();
      }
      debug("mid",st,dl);
      if(st.empty())return 0;
      if(st.back().SE == 1){
        st.back().FI++;
      }else{
        st.back().SE--;
        st.PB({st.back().FI + 1, 1ll});
      }
    }
    if(a[i] != dl)
      st.PB({0ll,a[i] - dl});
    dl = a[i];
    debug(st);
  }
  return 1;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n){
    cin >> a[i];
  }
  int po = 0;
  int ko = n + 1;
  while(po + 1 != ko){
    int m = (po + ko) / 2;
    if(spr(m))
      ko = m;
    else
      po = m;
  }
  cout << ko << "\n";
}


Measured memory_bytes: 9112
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;

    int n = s.size();
    
    int b = 0;
    ll cnt = 0;
    rep(i, n){
        if(s[i] == 'B') b++;
        if(s[i] == 'W') cnt += b;
    }
    
    cout << cnt << endl;
   

    return 0;
}



Measured memory_bytes: 720
import numpy as np
N = int(input())
xy = [list(map(int, input().split(" "))) for i in range(N)]

L = 0
for i in range( N ):
 for j in range( N ):
  a = xy[i][0]-xy[j][0]
  b = xy[i][1]-xy[j][1]
  l = np.sqrt( a**2 +b**2)
  L += l

print(L/N)


Measured memory_bytes: 26940
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
#define N 200005
int a[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n-k;i++) ans+=a[i];
	cout<<ans<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int v = sc.nextInt();
		int e = sc.nextInt();
		Dinic mf = new Dinic(v);
		for(int i=0;i<e;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			mf.addEdge(a, b, c);
		}
		System.out.println(mf.maximumFlow(0, v-1));
	}
}


//O(V E^2)
class Dinic {
	public static final int INF = 1 << 29;
	private ArrayList<Edge>[] g;
	private int[] it;
	private int[] level;
	@SuppressWarnings("unchecked")
	public Dinic(int n) {
		g = new ArrayList[n];
		for(int i=0;i<n;i++) {
			g[i] = new ArrayList<>();
		}
		it = new int[n];
		level = new int[n];
	}
	public void addEdge(int from,int to,int cap) {
		g[from].add(new Edge(to,cap,g[to].size()));
		g[to].add(new Edge(from,0,g[from].size()-1));
	}
	public void addBidirectionalEdge(int from,int to,int cap) {
		addEdge(from,to,cap);
		addEdge(to,from,cap);
	}
	private void bfs(int s) {
		Arrays.fill(level, -1);
		Queue<Integer> q = new ArrayDeque<>();
		level[s] = 0;
		q.offer(s);
		while(!q.isEmpty()) {
			int v = q.poll();
			for(Edge e: g[v]) {
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.offer(e.to);
				}
			}
		}
	}
	private int dfs(int v,int t,int f) {
		if (v == t) {
			return f;
		}
		for(;it[v]<g[v].size();it[v]++) {
			Edge e = g[v].get(it[v]);
			if (e.cap <= 0 || level[v] >= level[e.to]) {
				continue;
			}
			int d = dfs(e.to,t,Math.min(f,e.cap));
			if (d <= 0) {
				continue;
			}
			e.cap -= d;
			g[e.to].get(e.rev).cap += d;
			return d;
		}
		return 0;
	}
	public int maximumFlow(int s,int t) {
		int flow = 0;
		while(true) {
			bfs(s);
			if (level[t] < 0) {
				return flow;
			}
			Arrays.fill(it, 0);
			int f;
			while((f = dfs(s,t,INF)) > 0) {
				flow += f;
			}
		}
	}
	class Edge {
		int to,cap,rev;
		public Edge(int to,int cap,int rev) {
			this.to = to;
			this.cap = cap;
			this.rev = rev;
		}
	}
}

Measured memory_bytes: 34600
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

struct state {
	pii p;
	int c, j;
	state(pii p, int c, int j) : p(p), c(c), j(j) {};
	bool operator<(const state &o)const {
		return o.c<c;
	}
};

int risk(int cd, int nd, int dx) {
	return (cd+nd)*dx;
}

int stone[150][1000];
int field[150][1000][80];

int main() {
	int n, m;
	while(cin >> n >> m, n) {
		REP(i, 150) {
			REP(j, 1000) {
				stone[i][j] = -1;
			}
		}
		int maxx = 0;
		REP(i, n) {
			int k;
			cin >> k;
			REP(j, k) {
				int x, d;
				cin >> x >> d;
				stone[i][x-1] = d;
				maxx = max(maxx, x);
			}
		}

		REP(i, 150) {
			REP(j, 1000) {
				REP(k, 80) {
					field[i][j][k] = INT_MAX;
				}
			}
		}
		priority_queue<state> Q;
		REP(i, maxx) {
			if(stone[0][i] != -1) {
				field[0][i][0] = 0;
				Q.push(state(pii(0, i), 0, 0));
			}
		}
		if(n > 1 && m > 0) {
			REP(i, maxx) {
				if(stone[1][i] != -1) {
					field[1][i][1] = 0;
					Q.push(state(pii(1, i), 0, 1));
				}
			}
		}	

		int ans = INT_MAX;
		while(!Q.empty()) {
			state st = Q.top();
			Q.pop();

			int y = st.p.first, x = st.p.second;
			if(y+2 == n && st.j < m) {
				ans = min(ans, st.c);
				continue;
			}

			if(y+1 == n) {
				ans = min(ans, st.c);
				continue;
			}

			REP(i, maxx) {
				if(stone[y+1][i] != -1) {
					int nc = st.c+risk(stone[y][x], stone[y+1][i], abs(x-i));
					if(nc < field[y+1][i][st.j]) {
						field[y+1][i][st.j] = nc;
						Q.push(state(pii(y+1, i), nc, st.j));
					}
				}
			}

			if(st.j < m && y+2 < n) {
				REP(i, maxx) {
					if(stone[y+2][i] != -1) {
						int nc = st.c+risk(stone[y][x], stone[y+2][i], abs(x-i));
						if(nc < field[y+2][i][st.j+1]) {
							field[y+2][i][st.j+1] = nc;
							Q.push(state(pii(y+2, i), nc, st.j+1));
						}
					}
				}
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 50612
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  int a,b=0,d;
  cin>>a;
  vector<int>c(1000000,0);
  rep(i,a){
    cin>>d;
    c[d]++;
    c[d+1]++;
    c[d+2]++;
    b=max({b,c[d-1],c[d],c[d+1]});
  }
  cout<<b;
  }


Measured memory_bytes: 4096
#include <cstdio>
#include <algorithm>
int num[100005];
bool same[100005];
using namespace std;
pair<int,int>P[100005];
int main(){
	while(1){
	int n;
	scanf("%d",&n);
	if(!n) break;
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	for(int i=0;i<n-1;i++){
		if(num[i]==num[i+1]){
			same[i]=true;
		}else{
            same[i]=false;
        }
	} 
	int ans=0,st=0,e=0;
	for(int i=0;i<n-1;i++){
		if(num[i]!=num[i+1]){
			P[st]=make_pair(num[i],e);
			e=i+1;
			st++;
		}
	}
		P[st]=make_pair(num[n-1],e);
	for(int i=0;i<st;i++){
		if(P[i+1].second%2==1){
			for(int j=i;j>=0 && P[j].first!=P[i+1].first;j--){
				P[j].first^=1;
			}
		}
	}
	for(int i=0;i<=st;i++){
		if(!P[i].first){
			if(i==st){
				ans+=(n-P[i].second);
			}else{
				ans+=(P[i+1].second-P[i].second);
			}
		}
	}
	printf("%d\n",ans);
	}
	return 0;
}
		

Measured memory_bytes: 2296