akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// メモ用の DP テーブル
long long dp[100010];

long long rec(int i) {
    // DP の値が更新されていたらそのままリターン
    if (dp[i] < INF) return dp[i];

    // 足場 0 のコストは 0
    if (i == 0) return 0;

    // i-1, i-2 それぞれ試す
    long long res = INF;
    chmin(res, rec(i-1) + abs(h[i] - h[i - 1])); // 足場 i-1 から来た場合
    if (i > 1) chmin(res, rec(i-2) + abs(h[i] - h[i - 2])); // 足場 i-2 から来た場合

    // 結果をメモしながら、返す
    return dp[i] = res;
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 答え
    cout << rec(N-1) << endl;
}

Measured memory_bytes: 9872
#include<stdio.h>
int main()
{
  int juel=0;
  int i=0;
  int j=0;
  int k=0;
  int max=0;
  scanf("%d\n",&juel);
  int point[juel];
  int cost[juel];
  for(i;i<juel;i++)
  {
    scanf("%d",&point[i]);
    printf("\n");
  }
  for(j;j<juel;j++)
  {
    scanf("%d",&cost[j]);
    printf("\n");
  }
  for(k;k<juel;k++)
  {
    if(point[k]-cost[k]>0)
    {
      max+=point[k]-cost[k];
    }
  }
  printf("%d",max);
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  for (int i = 0; i < N; i++)
    if (x > K)
      x += K;
    else
      x *= 2;
  cout << x << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
void func_arrayInit(int array[], int w);
void func_swap(int array[], int a, int b);
void func_output(int array[], int n);
main()
{
	int i = 0, w = 0, n = 0;
	scanf("%d", &w);
	int array[w];
	func_arrayInit(array, w);
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		int a = 0, b = 0;
		scanf("%d,%d", &a, &b);
		func_swap(array, a, b);
	}
	
	func_output(array, w);
	return 0;
}
void func_arrayInit(int array[], int w)
{
	int i = 0;
	for(i = 0; i <= w; i++)
	{
		array[i] = i;
	}
}
void func_swap(int array[], int a, int b)
{
	int temp = 0;
	temp = array[a];
	array[a] = array[b];
	array[b] = temp;
}
void func_output(int array[], int n)
{
	int i = 1;
	for(i = 1; i <= n; i++)
	{
		printf("%d\n", array[i]);
	}
}

Measured memory_bytes: 596
n,a=map(int,input().split())
x=list(map(int,input().split()))
s=max(sum(x)+1,n*a+1)
dp=[[s*[0]for _ in range(n+1)]for _ in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  for j in range(i+1):
    for k in range(s):
      dp[i][j][k]=dp[i-1][j][k]
      if j!=0 and k>=x[i-1]:dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]]
ans=0
for j in range(1,n+1):ans+=dp[-1][j][j*a]
print(ans)

Measured memory_bytes: 92636
#include <bits/stdc++.h>
using namespace std;
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; }
#define ll long long
#define rep(i,n) for (int i = 1; i < (n); i++)

int main() {
  int N;
  cin >> N;
  int flag=0;
  rep(i,10) rep(j,10) if(i*j==N) flag=1;
  if(flag==1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3588
use std::io;

fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}

fn main() {
    let r: f64 = read();
    println!(
        "{} {}",
        std::f64::consts::PI * r * r,
        2.0 * std::f64::consts::PI * r
    );
}



Measured memory_bytes: 5068
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    string S,SC;
    ll K;
    cin >> S >> K;
    SC = S;
    ll count = 0;
    char kee = ' ';
    bool alp = 1;
    REP(i,S.size()-1){
        if(S[i] != S[i+1] || S.size()%2 == 0){
            alp= 0;
            break;
        }
    }
    if(alp)count = S.size()*(K/2)+S.size()*(K%2)/2;
    if(alp == 0){
        REP(i,S.size()){
        kee = S[i];
        if(kee == S[i+1]){
            count++;
            if(i != S.size()-1)S[i+1] = '@';
        }
    }
    int much = 0;
    if(S[0] == S[S.size()-1]){
        much = 1;
        for(int i= 0;;i++){
            if(SC[i] == SC[i+1]){
                much+=1;
            }else{
                break;
            }
            if(i >= S.size()-2)break;
        }
    }
    int ex = 0;
    if(much%2 == 1)ex = 1;
    count = count * K + ex*(K-1);
    }
    cout <<count<< "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

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

    int n;
    cin >> n;

    vector<pair<int,int>> a(n);
    for(int i = 0; i < n; i++){
        int x,l;
        cin >> x >> l;

        a[i].first = x + l;
        a[i].second = x - l;
    }

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

    int ans = 0; int t = -1e9;
    for(int i = 0; i < n; i++){
        if(t <= a[i].second){
            ans++;
            t = a[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    a.append(list(input()))
for i in range(m):
    b.append(list(input()))
#print(a,b)
ans='No'
cnt=0
for i in range(n-m+1):
    for j in range(n-m+1):
        for i1 in range(m):
            for j1 in range(m):
                if b[i1][j1]==a[i+i1][j+j1]:
                    cnt+=1
        #print(cnt)
        if cnt==m**2:
            ans='Yes'
            cnt=0
        else:
            cnt=0
print(ans)

Measured memory_bytes: 40688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c1x = sc.nextInt();
        int c1y = sc.nextInt();
        int c1r = sc.nextInt();
        int c2x = sc.nextInt();
        int c2y = sc.nextInt();
        int c2r = sc.nextInt();
        int dx = c1x - c2x;
        int dy = c1y - c2y;
        int sum = c1r + c2r;
        int diff = c1r - c2r;
        int sumR = sum * sum;
        int diffR = diff * diff;
        int distance = dx * dx + dy * dy;
        if (distance == diffR) {
            System.out.println(1);
        } else if (distance < diffR) {
            System.out.println(0);
        } else if (distance == sumR) {
            System.out.println(3);
        } else if (distance < sumR) {
            System.out.println(2);
        } else {
            System.out.println(4);
        }
    }
}

Measured memory_bytes: 26252
#include <bits/stdc++.h>
#define repeat(i, n) for(ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
	int N, R;
	cin >> N >> R;
	int result = 0;

	if (N < 10) {
		result = 100 * (10 - N);
	}

	result += R;
	

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n;
    cin>>n;
    vl a(n);
    
    forr(i, n)  cin>>a[i];
    
    vector<vl> dp(n, vl(n, 0));
    for(ll left=n-1; left>=0; left--)
    {
        for(ll right=left; right<n; right++)
        {
               
            if(left==right)
            {
                dp[left][right]=a[left];
            }    
            else 
            {
                dp[left][right]=max(a[left]-dp[left+1][right], a[right]-dp[left][right-1]);
                
            }
            //cout<<left<<" "<<right<<" "<<dp[left][right]<<endl;
        }
    }
    
    cout<<dp[0][n-1];
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        long jpy = 0L;
        BigDecimal btc = new BigDecimal("0");
        BigDecimal yenBtc = new BigDecimal("380000.0");

        for (int i = 0; i < N; i++) {
            String value = sc.next();
            String unit = sc.next();
            if (unit.equals("JPY")) {
                jpy += Long.valueOf(value);
            } else {
                BigDecimal bigDecimal = new BigDecimal(value);
                btc = btc.add(new BigDecimal(value));
            }
        }

        String result = btc.multiply(yenBtc).add(new BigDecimal(jpy)).toString();
        System.out.print(result);

    }
}

Measured memory_bytes: 24020
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main() {
	int Q;
	scanf("%d", &Q);
	
	long sum = 0;
	long small_sum = 0, big_sum = 0;
	priority_queue<int> small;
	priority_queue<int, vector<int>, greater<int>> big;
	for(int i = 0; i < Q; i++) {
		int query;
		scanf("%d", &query);
		switch(query) {
			case 1: {
				int a, b;
				scanf("%d %d", &a, &b);
				sum += b;
				
				if(small.size() < big.size()) {
					int tmp = big.top();
					if(a <= tmp) {
						small.push(a);
						small_sum += a;
					} else {
						big.pop();
						big_sum -= tmp;
						small.push(tmp);
						small_sum += tmp;
						big.push(a);
						big_sum += a;
					}
					
				} else {
					if(big.empty()) {
						big.push(a);
						big_sum += a;
					} else {
						int tmp = small.top();
						if(a >= tmp) {
							big.push(a);
							big_sum += a;
						} else {
							small.pop();
							small_sum -= tmp;
							big.push(tmp);
							big_sum += tmp;
							small.push(a);
							small_sum += a;
						}
					}
				}
				
				break;
			}
			case 2:
				long x = (small.size() == big.size()) ? small.top() : big.top();
				long ans = (x * small.size() - small_sum) - (x * big.size() - big_sum) + sum;
				printf("%d ", x);
				printf("%ld\n", ans);
				break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#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()


int main(){
  int n;cin>>n;
  int a[n];rep(i,n)cin>>a[i];
  int lean=0;
  int ans=0;
  rep(i,n-1){
    if(a[i+1]==a[i])continue;
    if(a[i+1]>a[i]){
      if(lean==-1){
        ans++;
        lean=0;
      }
      else if(lean==1)continue;
      else lean=1;
    }
    else{
      if(lean==1){
        ans++;
        lean=0;
      }
      else if(lean==-1)continue;
      else lean=-1;
    }
  }
  cout<<ans+1<<endl;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	char hai[100];

	while(1){
		cin>>n;
		int hito[n] ={};
		if(n  == 0)break;
		for(int i = 0;i<100;i++)cin>>hai[i];
		int b = 0;
		for(int i = 0;i<100;){
			for(int j = 0;j<n;i++,j++){
				if(hai[i] == 'M'){
					//cout<<'M'<<endl;
					hito[j]++;
				}else if(hai[i] == 'L'){
					//cout<<'L'<<endl;
					hito[j]++;
					hito[j] += b;
					b = 0;
				}else if(hai[i] == 'S'){
					//cout<<'S'<<endl;
					hito[j]++;
					b += hito[j];
					hito[j] = 0;
				}
			}
		
		}
		sort(hito,hito+n);
		for(int i = 0;i<n;i++){
			cout<<hito[i]<<" ";
		}
		cout<<b<<endl;
				
	}
		

	return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>
#include<string.h>

int main()
{
    int u =1;
int a[101][101];
int b[101][u];//指定する必要なし 指定しても大丈夫みたい　
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		scanf("%d",&a[i][j]);
	}
}
for(int i=0;i<m;i++){
	scanf("%d",&b[i][1]);//行列一つ一つで分ける！！
}
for(int i=0;i<n;i++){
	int ans=0;
	for(int j=0;j<m;j++){
		ans+=a[i][j]*b[j][1];//計算と読み取りは別にする！
	}
	printf("%d\n",ans);
}
return 0;
}


Measured memory_bytes: 2760
from sys import stdin
input = stdin.readline
n = int(input())
a = [0]*4

for i in range(n):
    s = input().strip()
    if s == "AC":
        a[0] += 1
    elif s == "WA":
        a[1] += 1
    elif s == "TLE":
        a[2] += 1
    else:
        a[3] += 1
        
print("AC x",a[0])
print("WA x",a[1])
print("TLE x",a[2])
print("RE x",a[3])

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;

    if (s[0] == 'L') {
        rep(i, n) {
            if (s[i] == 'R')
                s[i] = 'L';
            else
                s[i] = 'R';
        }
    }

    int ans = 0;
    rep(i, n - 1) {
        if (s[i] == s[i + 1]) ans++;
    }

    int i = 0;
    while (i < n) {
        if (k == 0) break;
        if (s[i] == 'L') {
            while (s[i] == 'L') {
                i++;
            }
            if (i >= n) {
                ans += 1;
                cout << ans << endl;
                return 0;
            }
            ans += 2;
            k--;
            i++;
        }
        if (s[i] == 'R') i++;
    }
    cout << ans << endl;
}


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

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a >= 13) printf("%d\n", b);
    else if (a >= 6 && a <= 12) printf("%d\n", b / 2);
    else printf("0\n");
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

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; }


string s,t;
int a,b;
string u;

int main(){
	cin >> s >> t >> a >> b >> u;
	
	if(s == u){
		cout << a-1 << " " << b << endl;
	}
	else{
		cout << a << " " << b-1 << endl;
	}
	
	return 0;
}

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

using namespace std;
int main() {
	unsigned long long int x;
	cin >> x;
	int i = 1;
	unsigned long long int a = 101;
	for (; a < x; i++) {
		a = 1.01*a;
	}
	cout << i << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<algorithm>
#define lson l, mid, i<<1
#define rson mid+1, r, i<<1|1
#define PII pair<int, int>
using namespace std;
typedef long long LL;
const int MOD = 1e9+7;
//const auto INF  = 0x3f3f3f3f;
const int N = 1e5+5;

int main() {
    LL n, m;
    scanf("%lld%lld", &n, &m);
    if(abs(n-m) >= 2) {
        printf("0\n");
        return 0;
    }
    LL answer = 1, x = 1;
    for(LL i=1; i<=max(n, m); i++) {
        x = (x*i)%MOD;
        if(i == n) {
            answer = (answer * x)%MOD;
        }
        if(i == m) {
            answer = (answer * x)%MOD;
        }
    }
    if(n == m)
        answer = (answer * (LL)2)%MOD;
    printf("%lld\n", answer);
}





Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#define ll long long
#define rgi register int
#define il inline

using namespace std;

const int N = 50 + 10;

int n;
int v[N];

priority_queue <double> pq;

il int read()
{
	rgi f = 0, x = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main()
{
	n = read();
	for(rgi i = 1; i <= n; ++i)
	{
		v[i] = read();
		pq.push(-v[i]);
	}
	while(pq.size() > 1)
	{
		double x = pq.top();
		pq.pop();
		double y = pq.top();
		pq.pop();
		pq.push((x + y) / 2.0);
	}
	cout << -pq.top();
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

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

int dp[401][401];
int main() {
    for(int i = 0; i < 401; i++) {
        for (int j = 0; j < 401; j++) {
            dp[i][j] = INF;
        }
    }
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<int> A, B, C;
    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
    }
    dp[0][0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 400; j >= 0; j--) {
            for (int k = 400; k >= 0; k--) {
                if (j + A[i] > 400 || k + B[i] > 400) continue;
                dp[j + A[i]][k + B[i]] = min(dp[j + A[i]][k + B[i]], dp[j][k] + C[i]);
            }
        }
    }

    int g = gcd(Ma, Mb);
    Ma /= g;
    Mb /= g;
    int Ma_ = Ma;
    int Mb_ = Mb;

    int ans = INF;
    while(Ma < 401 && Mb < 401) {
        ans = min(ans, dp[Ma][Mb]);
        Ma += Ma_;
        Mb += Mb_;
    }
    if (ans == INF) {
        cout << "-1" << endl;
    } else {
        cout << ans << endl;
    }



    return 0;
}

Measured memory_bytes: 896
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    E[u-1].append(v-1)
    E[v-1].append(u-1)

par = [None]*N
q = [(0, -1)]
iq = 0
while iq<len(q):
    x, p = q[iq]
    iq += 1

    if par[x] is not None: continue

    par[x] = p
    for chd in E[x]:
        q.append((chd, x))

ans = 0
for x in range(N):
    p = par[x]
    Nl = N-1 - max(x,p)
    Nr = min(x,p)
    Nb = abs(p-x)-1
    N1 = Nl*(Nl+1)//2 + Nr*(Nr+1)//2 + Nb*(Nb+1)//2

    Nl = N-1 - x
    Nr = x
    N2 = Nl*(Nl+1)//2 + Nr*(Nr+1)//2
    
    N3 = N2 - N1 # myself only

    deg = len(E[x])

    if x==0:
        N1=0
        N3=N2
    #print(x, deg, N1, N2, N3,max(0, deg-2) * N1, max(0, deg-1) * N3)
    #ans += max(0, deg-2) * N1
    #ans += max(0, deg-1) * N3

    ans += (deg-2) * N1
    ans += (deg-1) * N3

print(ans+N*(N+1)//2)
    


Measured memory_bytes: 73816
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
int n,a[N],A;
long long s[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		s[i]=s[i-1]+a[i];
	for(int i=1;i<n;i++)
		if(s[i]*2<a[i+1])
			A=i;
	cout<<n-A;
	return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,k,x,n,setcnt,ff;
	int win,lose,drow,mx=-1;
	char kuni[11][21];
	int tokuten[11];
	char team[21];
	setcnt=0;
	while(1) {
		cin>>n;
		if(n==0) break;
		else if(setcnt!=0)cout<<endl;
		for(i=0;i<n;i++) {
			cin>>kuni[i]>>win>>lose>>drow;
			tokuten[i]=win*3+drow;
		}
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++) {
				if(mx<tokuten[j] && tokuten[j]!=-1) {
					mx=tokuten[j];
					ff=j;
					strcpy(team,kuni[j]);
				}
			}
			cout<<team<<","<<mx<<endl;
			tokuten[ff]=-1;mx=-1;
		}
		setcnt++;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
 
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
 
typedef long long ll;
typedef pair<int, int> PII;
 
const double EPS = 1e-10;
 
vector<string> res;
 
void search(string s, char c) {
  if (c=='a') {
    res.psb(s);     
    return;
  } 
 
  for (int i=0; i<(int)s.size(); i++) {
    if (s[i]==c) return;
    if (s[i]==c-1) {
      string t = s;
      t[i] = c;
      search(t, c-1);
    }
  }
 
  search(s, c-1);
}
 
int main() {
  string s, t;
  int i;
  while (1) {
    cin >> s;
    if (s=="#") break;
 
    res.clear();
    search(s, 'z');
 
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end()); 
    cout << res.size() << endl;
    if (res.size() <= 10) {
      for (i=0; i<(int)res.size(); i++)     
        cout << res[i] << endl;
    } else {
      for (i=0; i<5; i++)     
        cout << res[i] << endl;
      for (i=0; i<5; i++) 
        cout << res[res.size() - 5 + i] << endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 2352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC094_A solver = new ABC094_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC094_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int x = in.nextInt();

            if (x < a || a + b < x) {
                out.print("NO");
            } else {
                out.print("YES");
            }
        }

    }
}



Measured memory_bytes: 23636
#pragma GCC optimize(2)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 531445;

int N,m;
int sum[MAXN];
int to[2][MAXN];

vector<int> add[2][MAXN];

char s[MAXN];

int main()
{
	scanf("%d%s",&N,s + 1);
	m = strlen(s + 1);
	for (int i = 1;i <= m;i++)
	{
		sum[i] = sum[i - 1] + (s[i] == 'S');
		if (s[i] == 'R')
			add[0][0].push_back(i);
	}
	int v = 1;
	for (int i = 1;i <= N;i++,v *= 3)
		for (int j = 0;j < 3;j++)
			for (int k = 0;k < v;k++)
			{
				to[i & 1][k + v * j] = to[~i & 1][k];
				add[i & 1][k + v * j].clear();
				int cur = j,lst = 0;
				for (int l = 0;l < add[~i & 1][k].size();l++)
				{
					int p = add[~i & 1][k][l];
					if ((sum[p] - sum[lst]) & 1)
					{
						cur = (cur == 1 || cur == 2 ? 3 - cur : cur);
						lst = p;
					}
					cur++;
					if (cur == 3)
					{
						add[i & 1][k + v * j].push_back(p);
						cur = 0;
					}
				}
				if ((sum[m] - sum[lst]) & 1)
					cur = (cur == 1 || cur == 2 ? 3 - cur : cur);
				to[i & 1][k + v * j] += v * cur;
			}
	for (int i = 0;i < v;i++)
		printf("%d ",to[N & 1][i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 54852
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        char[] s = scanner.next().toCharArray();
        int ans = 0;
        int count = 0;
        for (char c : s) {
            if (c == 'R') {
                count++;
            } else {
                ans = Math.max(ans, count);
                count = 0;
            }
        }
        System.out.println(Math.max(count, ans));
    }

}

Measured memory_bytes: 35704
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    rank = 'F'
    mf = m + f
    if m == -1 or f == -1:
        rank = 'F'
    elif mf >= 80:
        rank = 'A'
    elif mf >= 65 and mf < 80:
        rank = 'B'
    elif mf >= 50 and mf < 65:
        rank = 'C'
    elif mf >= 30 and mf < 50:
        if r >= 50:
            rank = 'C'
        else:
            rank = 'D'
    else:
        rank = 'F'
    print(rank)
 


Measured memory_bytes: 5592
#include <iostream>

bool isDivisible(int n) {
  for (int i = 0; i <= n; ++i) {
    if (i % 4 == 0 && (n - i) % 7 == 0) {
      return true;
    }
  }
  return false;
}

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

  if (isDivisible(n)) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <sstream>  
#include <string>

  
bool IsOp(char c)
{
    return c == '+' || c == '-' || c == '*' || c == '/';
}
int main()
{
    std::stack<int> Stack;
    // while(std::cin.eof() == false){
    // while(std::cin){
    while(true){
        std::string in;
        std::cin >> in;
        if(std::cin.eof()){
            break;
        }
        if(IsOp(in[0]) == false){
            int Num;
            std::stringstream ss;
            ss << in;
            ss >> Num;
            Stack.push(Num);
            continue;
        }
        int a = Stack.top();
        Stack.pop();
        int b = Stack.top();
        Stack.pop();
        
        switch(in[0]){
        case '+': Stack.push(b + a); break;
        case '-': Stack.push(b - a); break;
        case '*': Stack.push(b * a); break;
        }
    }
    std::cout << Stack.top() << std::endl;
    return 0;
}

Measured memory_bytes: 3180
n = gets.chomp.to_i
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]

m = n % 10

if hon.include?(m)
    puts "hon"
elsif pon.include?(m)
    puts "pon"
else
    puts "bon"
end

Measured memory_bytes: 14348
H, N = map(int, input().split())
A=[]
B=[]
for i in range(N):
	a,b = map(int, input().split())
	A.append(a)
	B.append(b)
#dp[i+1][h] := i番目の魔法まで見て、ライフをh以上削った時の最小魔力コスト
dp=[[float("inf")]*(H+1) for _ in range(N+1)]

for i in range(N):
	for h in range(H+1):
		if A[i]>=h:
			dp[i+1][h] = min(dp[i][h], B[i])
		else:
			dp[i+1][h] = min(dp[i][h], dp[i+1][h-A[i]]+B[i], dp[i][h-A[i]]+B[i])
print(dp[-1][-1])

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  int best = a[n / 2];
  long long total = 0;
  for (int i = 0; i < n; ++i) {
    total += abs(best - a[i]);
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto& i : v)
    {
        cin >> i;
    }
    int alice = 0, bob = 0;
    for (size_t i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            auto iter = max_element(v.begin(), v.end());
            alice += *iter;
            v.erase(iter);
        }
        else
        {
            auto iter = max_element(v.begin(), v.end());
            bob += *iter;
            v.erase(iter);
        }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  while(cin >> N,N){
    vector<set<int>> know(N);
    for(int i=0;i<N;i++){
      int M;
      cin >> M;
      for(int j=0;j<M;j++){
	int p;
	cin >> p;
	know[i].insert(p-1);
      }
    }
    int K;
    cin >> K;
    vector<int> k(K);
    for(int i=0;i<K;i++){
      cin >> k[i];
      k[i]--;
    }
    vector<int> ans;
    for(int i=0;i<N;i++){
      bool f=true;
      for(int j=0;j<K;j++)
	if(know[i].find(k[j])==know[i].end())
	  f=false;
      if(f)
	ans.push_back(i);
    }
    if(ans.size()==1)
      cout << ans[0]+1 << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<P> D(n);
  rep(i,n) {
    int d1, d2; cin >> d1 >> d2;
    D[i] = make_pair(d1,d2);
  }
  string ans = "No";
  rep(i,n) {
    int cnt = 0;
    while (i < n && D[i].first == D[i].second) {
      i++;
      cnt++;
    }
    if (cnt >= 3) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=1000;
int n,m;
typedef long long ll;
struct CAKE
{
    ll A,B,C;
}cak[MAXN+5];
int i,j,k;
bool cmp(CAKE a,CAKE b)
{
    return a.A*i+a.B*j+a.C*k>b.A*i+b.B*j+b.C*k;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld%lld",&cak[i].A,&cak[i].B,&cak[i].C);
    ll ans=0;
    for(i=-1;i<=1;i+=2)
        for(j=-1;j<=1;j+=2)
            for(k=-1;k<=1;k+=2)
            {
                sort(cak+1,cak+n+1,cmp);
                ll tot[3]={};
                for(int p=1;p<=m;p++)
                    tot[0]+=cak[p].A,tot[1]+=cak[p].B,tot[2]+=cak[p].C;
                ans=max(ans,tot[0]*i+tot[1]*j+tot[2]*k);
            }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  vi ame(3);
  rep(i,3) { int a; cin >> a; ame[i]=a;}
  sort(all(ame));
  if( ame[2] == ame[0]+ame[1]) cout << "Yes" << endl;
  else cout << "No" << endl;  
  
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;
const double pi = acos(-1.0);
const double circle = 2*pi*10;

int LIS(const vector<pair<int, int> > &XY){
    const int inf = 1<<30;
    int n = XY.size();
    if(n==0)return 0;
    vector<int> L(n, inf);
    int p = 0;
    REP(i, n){
        int v = XY[i].second;
        if(L[p] < v){
            L[++p] = v;
        }else{
            int j = lower_bound(ALL(L), v) - L.begin();
            L[j] = v;
        }
    }
    return p+1;
}

int main(){
    int x1, y1, x2, y2, N;
    vector<pair<int, int> > XY;
    cin >> x1 >> y1 >> x2 >> y2 >> N;
    if(x1>x2){
        swap(x1, x2);
        swap(y1, y2);
    }
    REP(i, N){
        int x, y;
        cin >> x >> y;
        if(x<x1 || x>x2 || y<min(y1, y2) || y>max(y1, y2))continue;
        XY.push_back(make_pair(x, y));
    }
    sort(ALL(XY));
    if(y1>y2)REP(i, XY.size())XY[i].second *= -1;
    int lis = LIS(XY);
    // cerr << lis << endl;
    double res = (abs(y1-y2) + x2-x1) * 100.0;
    int width = min(abs(y1-y2), x2-x1);
    if(width<lis){
        double diff = circle / 2.0 - 20;
        res += diff;
        lis--;
    }
    double diff = 20 - circle / 4.0;
    res -= lis*diff;
    printf("%.18f\n", res);

    return 0;
}


Measured memory_bytes: 2544
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
double dis(double x, double y)
{
	return x*x + y*y;	
}
int main()
{
	int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    int flag = 0;
    int cnt = 0;
    for(int i=0;i<n;i++)
    {
        if(s[i] == 'R') cnt++;
    }
    int c = 0;
    for(int i=0; i< cnt;i++)
    {
        if(s[i] == 'W') c++;
    }
    
    cout << c << endl;
	return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n;
  cin >> n;
  vector<int> nums(n, 0);
  for (int i=1; i<n; ++i ){
    int temp;
    cin >> temp;
    nums[temp-1]++;
  }
  for (auto& a : nums) {
    cout << a << endl;
  }
  return 0;
}

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

int main() {
  cout << fixed << setprecision(6);
  long double X = 0,x = 0,ans = 0;
  cin >> X;
  x = X/3;
  ans = x*x*x;
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
#define int long long

signed main(){

   int x;
   cin>> x;

   int y=(x+11-1)/11;
   int z=x%11;
   if(1<=z&&z<=6){
      cout<< 2*y-1<< endl;
   }else{
      cout<< 2*y<< endl;
   }

   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);
 */

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int D = Integer.parseInt(tmp[0]);
		int G = Integer.parseInt(tmp[1]);

		ArrayList<Integer> p = new ArrayList<Integer>();
		ArrayList<Integer> c = new ArrayList<Integer>();
		int max_dec = (int) Math.pow(2, D) - 1;

		for (int d = 0; d < D; d++) {
			tmp = br.readLine().split(" ");
			int pp = Integer.parseInt(tmp[0]);
			int cc = Integer.parseInt(tmp[1]);
			p.add(pp);
			c.add(cc);
		}
		int best = 99999999;

		// TODO:D=1の処理
		// 求めて出力、exit(0);

		if(D==1){
			int point=0;
			int count=0;
			for(int i = 0;i<p.get(0)-1;i++){
				point += 100;
				count++;
				if(point>=G){
					System.out.println(count);
					System.exit(0);
				}
			}
			System.out.println(p.get(0));
			System.exit(0);
		}

		for (int i = 1; i <= max_dec; i++) {
			String bin = Integer.toBinaryString(i);

			while (bin.length() < D) {
				bin = "0" + bin;
			}
			int point = 0;
			int solvedProblem = 0;
			int maxZero = 0; // 0を持つ最大桁を探索する


			for (int j = 0; j < bin.length(); j++) {
				int b = bin.charAt(bin.length() - j - 1);
				if (b == 49) {
					boolean isFull = false;
					for (int r = 0; r < p.get(j); r++) {
						if (point >= G) {
							isFull = true;
							break;
						}
						point += (j + 1) * 100;
						solvedProblem++;
					}

					if (!isFull) {
						point += c.get(j);
					}
				} else {
					maxZero = j;
				}
			}

			if (point < G) {
				for (int j = 0; j < p.get(maxZero) - 1; j++) {
					point += (maxZero + 1) * 100;
					solvedProblem++;
					if (point >= G)
						break;
				}

				if (point < G)
					solvedProblem = 99999999;
			}

			best = Math.min(solvedProblem, best);

		}
		System.out.println(best);

	}

}

Measured memory_bytes: 23380
#include <stdio.h>

#define N 100
#define A 100

int main(){

  int i,j,in,num[N],count=0,minj,key,min1;

  scanf("%d",&in);

  for(i=0;i<in;i++){
    scanf("%d",&num[i]);
  }

  for(i=0;i<in-1;i++){
    minj=num[i];
    for(j=i;j<in;j++){
      if(num[j]<minj){

	min1=j;
	minj=num[j];
      }
    }
    if(num[i]!=minj){
	key=num[i];
	num[i]=num[min1];
	num[min1]=key;
	count++;
    }
      }
    

      for(i=0;i<in-1;i++){
	printf("%d ",num[i]);
      }
      printf("%d",num[i]);
      printf("\n");
      printf("%d\n",count);

      return 0;
}
 

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    bool flag=true;
    for(int i=1;i<n;i++){
        if(a[i-1]==a[i])flag=false;
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x"=" << x <<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3

#define MAX_N 1000000001

int main(){
	cin.sync_with_stdio(false);
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	if (n <= k) {
		cout << n * x << endl;
	} else {
		cout << k * x + (n - k) * y << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define maxn 55
#define eps 1e-8
const double g=9.8;
using namespace std;
int n;
double v,x,y;
double l[maxn],b[maxn],r[maxn],t[maxn];
double cal(double t,double vy)
{
    return vy*t-g*t*t/2;
}
int cmp(double lowb,double upb,double a)
{
    if(a<lowb+eps)
        return -1;
    if(a>upb-eps)
        return 1;
    return 0;
}
bool judge(int qx,int qy)//通??个点的??是tt
{
    double a=g*g/4,bb=g*qy-v*v,c=qx*qx+qy*qy;
    double d=bb*bb-4*a*c;
    if(d<0&&d>-eps)
        d=0;
    if(d<0)
        return false;
    for(int cnt=-1;cnt<=1;cnt+=2)
    {
        double t_sq=(-bb+cnt*sqrt(d))/(2*a);
        if(t_sq<=0)
            continue;
        double tt=sqrt(t_sq);
        double vx=qx/tt,vy=(qy+g*tt*tt/2)/tt;
        double yt=cal(x/vx,vy);//猪的正上方坐?
        if(yt<y-eps)
            continue;
        bool ans=true;
        for(int i=0;i<n;i++)
        {
            if(l[i]>=x)
                continue;
            if(r[i]==x&&b[i]<=yt&&t[i]>=y)
                ans=false;
            int yl=cmp(b[i],t[i],cal(l[i]/vx,vy));
            int yr=cmp(b[i],t[i],cal(r[i]/vx,vy));
            int xh=cmp(l[i],r[i],vx*vy/g);
            int yh=cmp(b[i],t[i],cal(vy/g,vy));
            if(yl*yr<=0)
                ans=false;
            if(xh==0&&yh>=0&&yl<0)
                ans=false;
        }
        if(ans)
            return true;
    }
    return false;
}
int main()
{
    while(scanf("%d%lf%lf%lf",&n,&v,&x,&y)!=EOF)
    {
        for(int i=0;i<n;i++)
            scanf("%lf%lf%lf%lf",&l[i],&b[i],&r[i],&t[i]);
        for(int i=0;i<n;i++)
            r[i]=min(r[i],x);
        bool flag=judge(x,y);
        for(int i=0;i<n;i++)
        {
            flag=flag|judge(l[i],t[i]);
            flag=flag|judge(r[i],t[i]);
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

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

typedef long long ll;
using namespace std;

int main (){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    for (ll i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    ll hp=0;
    for (ll i = 0; i < n-k; i++){
        hp+=h[i];
    }
    cout << hp << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using namespace std;


void printV(vll v){
	cout << "size (" << v.size() << "): ";
	for(ll i = 0; i < v.size(); i++){
		cout << v[i] << " ";
	}
	cout << "\n";
}

void printM(vector<vll> v){
	cout << "size (" << v.size() << "," << v[0].size() << "): ";
	for(ll i = 0; i < v.size(); i++){
		for(ll j = 0; j < v[i].size(); j++){
			cout << v[i][j] << " ";
		}
		cout << "\n";
	}
}

ll powermod(ll x, ll y){
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1){
			res = (res * x) % mod;
		}
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}

ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i){
			res = (res * i) % mod;
		}
		n /= mod;
	}
	res %= mod;
	return res;
}

void solve(){
	ll n;
	cin >> n;
	if(n >= 400 and n <= 599){
		cout << "8\n";
	}
	else if(n >= 600 and n <= 799){
		cout << "7\n";
	}
	else if(n >= 800 and n <= 999){
		cout << "6\n";
	}
	else if(n >= 1000 and n <= 1199){
		cout << "5\n";
	}
	else if(n >= 1200 and n <= 1399){
		cout << "4\n";
	}
	else if(n >= 1400 and n <= 1599){
		cout << "3\n";
	}
	else if(n >= 1600 and n <= 1799){
		cout << "2\n";
	}
	else if(n >= 1800 and n <= 1999){
		cout << "1\n";
	}
}


int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
//	ll t;
//	cin >> t;
//	while (t--){
		solve();
//	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)

constexpr ll mod = 1'000'000'007;
int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);

  int n; cin >> n;
  vector<int> c[n];
  rep(i, n) {
    int m; cin >> m;
    c[i].resize(m);
    rep(j, m) cin >> c[i][j];
  }

  ll res = 0;
  priority_queue<int> hp;
  repr(i, n) {
    for (auto cx : c[i]) hp.push(cx);
    res += hp.top(); hp.pop();
  }
  cout << res << "\n";
}



Measured memory_bytes: 19508
#include<bits/stdc++.h>
using namespace std;
int main() {
 string s;
 cin>>s;
 int len=s.size();
 int cont=0;
 for(int i=0;i<len;i++)
 {
     if(i%2==0||i==0) cout<<s[i];

 }

   return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <queue>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int D,G,p[11],c[11];
    cin >> D >> G;
    rep(i,D){
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;

    for(int mask=0;mask<(1<<D);mask++){
        int s=0,num=0,rest_max=-1;
        rep(i,D){
            if(mask&1<<i){
                s+=100*(i+1)*p[i]+c[i];
              	num+=p[i];
            }else{
                rest_max=i;
            }
        }
        if(s<G){
            int s1 =100 * (rest_max+1);
            int need = (G-s+s1-1)/s1;
            if(need>=p[rest_max]){
                continue;
            }
            num+=need;
        }
        ans = min(ans,num);
    }
    cout << ans << endl;
    return 0;
}

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

#include<iostream>
#include<string>

using namespace std;

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

#define rep1(i,n) for(ll i=1;i<=n;i++)

typedef long long ll;

ll comb(ll n){
	return n*(n-1LL)/2LL;
}

ll cnt[26];

string s;

ll N;
ll ans;

int main()

{
	cin>>s;
	N=s.size();
	ans=comb(N)+1LL;
	rep(i,s.size()){
		cnt[s[i]-'a']++;
	}
	rep(i,26LL){
		if(cnt[i]>=2LL) ans-=comb(cnt[i]);
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;

int re(int a){
  return a*a*a*a*a;
}

int main(){
  int x; cin >> x;
  for(int a = 0; a < 1000000; a++){
    for(int b = 0; b < 1000000; b++){
      if(re(a) == x+re(b)){
        cout << a << " " << b;
        return 0;
      }else if(re(a) == x-re(b)){
        cout << a << " " << b*-1 << endl;
        return 0;
      }else if(re(a)*-1 == x+re(b)){
        cout << a*-1 << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//


signed main(){
    IOS;
    CIN(N);
    CIN(ans);
    rep(i,N-1){CIN(cur);ans=GCD(ans,cur);}
    COUT(ans);

    return 0;
}

Measured memory_bytes: 256
faces = {'N': (1, 5, 2, 3, 0, 4),
        'E': (3, 1, 0, 5, 4, 2),
        'S': (4, 0, 2, 3, 5, 1),
        'W': (2, 1, 5, 0, 4, 3)
        }
dice = list(map(int, input().split()))
face = input()
for f in face:
    dice = [dice[i] for i in faces[f]]
print(dice[0])


Measured memory_bytes: 5604
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = 0;

	void doIt() {
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		StringBuilder strb = new StringBuilder();
		for(int i = 0; i < n; i++) {
			strb.append(s[i]);
			strb.append(t[i]);
		}
		System.out.println(strb.toString());
		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21844