akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
using ll = long long;

int main()
{
    ll i,j;
    string s;
    cin >> s;
    ll n = s.size();
    for(i = 0;i < n-1;++i){
        if(s.at(i) == s.at(i+1)){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for(i = 0;i < n-2;++i){
        if(s.at(i) == s.at(i+2)){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
//2013/11/15(Fri)

#include <iostream>
using namespace std;
int main()
{
	int n,m;
	int a,b,cost[100][100],time[100][100];
	int k;
	int p,q,r;
	int INF = 1000001;

	while(true){
		cin >> n >> m;
		if(n==0 && m==0)
			break;

		for(int i=0; i<m; i++)
			for(int j=0; j<m; j++){
				if(i==j){
					cost[i][j] = 0;
					time[i][j] = 0;
				}		
				else{
					cost[i][j] = INF;
					time[i][j] = INF;
				}
			}

		for(int i=0; i<n; i++){
			cin >> a >> b ;
			cin >> cost[a-1][b-1] >> time[a-1][b-1];
			cost[b-1][a-1] = cost[a-1][b-1];
			time[b-1][a-1] = time[a-1][b-1];
		}  

		for(int h=0; h<m; h++)
			for(int i=0; i<m; i++)
				for(int j=0; j<m; j++){
					if(cost[i][j] > cost[i][h] + cost[h][j])
						cost[i][j] = cost[i][h] + cost[h][j];
					if(time[i][j] > time[i][h] + time[h][j])
						time[i][j] = time[i][h] + time[h][j];
				}

		cin >> k;
		for(int i=0; i<k; i++){
			cin >> p >> q >> r;

			if(r == 0)
				cout << cost[p-1][q-1] << endl;
			else if(r == 1)
				cout << time[p-1][q-1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main(void) {

int n;
int a,b,c,d;
int ok=1;
string ar;


cin >> n >> a >> b >> c >> d;
cin >> ar;
ar="."+ar;
    char prev='.';
for(int i=a+1;i<=c;i++){
        if(prev=='#' && ar[i]=='#')
            ok=0;
            prev=ar[i];
    }
prev='.';
    for(int i=b+1;i<=d;i++){
    if(prev=='#' && ar[i]=='#')
            ok=0;
            prev=ar[i];
}
if(ok==0){
    cout << "No";
    return 0;
}
if(c<d){
    cout << "Yes";
    return 0;
}
ok=0;

    for(int i=b;i<=d;i++){
        if(ar[i-1]=='.' && ar[i]=='.' && ar[i+1]=='.')
            ok=1;
    }
   if(ok==0){
    cout << "No";
    return 0;
}
cout << "Yes";
return 0;




}


Measured memory_bytes: 772
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define vd vector<double>
#define all(a) a.begin(),a.end()
using namespace std;
ll inf =1e9;

int main(){
  int h,w,n,c=1;
  ll count=0;
  cin>>h>>w>>n;
  ve a(n),A(h*w);
  for(int i=0;i<n;i++) cin>>a[i]; 
  for(int i=1;i<=n;i++){
    for(int j=0;j<a[i-1];j++){
      A[count]=i;
      count++;
    }
  }
  count=0;
  for(int i=0;i<h;i++){
    if(i%2==0){
      for(int j=0;j<w;j++){
        cout<<A[count]<<' ';
        count++;
      }
      cout<<endl;
    }
    else{
      for(int j=w;j>0;j--){
        cout<<A[count+j-1]<<' ';
      }
      count+=w;
      cout<<endl;
    }
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	rep(i, S.size() - 8) {
		cout << S[i];
	}
	cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll N;
map<string, ll>dp[111];
string ACGT = "ACGT";

int main(){
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                string s = "";
                s += ACGT[i];
                s += ACGT[j];
                s += ACGT[k];
                int ok = 1;
                if(s == "AGC")ok = 0;
                if(s == "ACG")ok = 0;
                if(s == "GAC")ok = 0;
                if(ok)dp[3][s] = 1;
            }
        }
    }
    for(int i = 3; i < 100; i++){
        map<string, ll>::iterator it = dp[i].begin();
        for(;it != dp[i].end();it++){
            string from = (*it).first;
            ll num = (*it).second;
            for(int j = 0; j < 4; j++){
                char c = ACGT[j];
                string to = "";
                to += from[1];
                to += from[2];
                to += c;
                int ok = 1;
                if(from[1] == 'A' && from[2] == 'G' && c == 'C')ok = 0;
                if(from[0] == 'A' && from[1] == 'G' && c == 'C')ok = 0;
                if(from[0] == 'A' && from[2] == 'G' && c == 'C')ok = 0;
                if(from[1] == 'G' && from[2] == 'A' && c == 'C')ok = 0;
                if(from[1] == 'A' && from[2] == 'C' && c == 'G')ok = 0;
                if(ok){
                    dp[i + 1][to] = (dp[i + 1][to] + num) % MOD;
                }
            }
        }
    }
    ll N;
    cin >> N;
    map<string, ll>::iterator it = dp[N].begin();
    ll ans = 0;
    for(;it != dp[N].end(); it++){
        ans = (ans + (*it).second) % MOD;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
int main()
{
	int A, B, C, D, E, F;
	std::cin >> A >> B >> C >> D >> E >> F;
	int ans = 0;
	ans = ans + A + B + C + D + E + F;
	int a;
	a = std::min(E, F);
	ans -= a;
	int b;
	b = std::min({ A,B,C,D });
	ans -= b;
	std::cout << ans << std::endl;
	return 0;
}


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

main(){
  int N;
  cin >> N;
  int d[N];
  for(int ii=0;ii<N;ii++){
    cin >> d[ii];
  }
  int ans=0;
  for(int ii=0;ii<N;ii++){
    for(int jj=ii+1;jj<N;jj++){
      ans+=d[ii]*d[jj];
    }
  }
  cout << ans << endl;
}


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

int main(){
    int a;
    char buf[30];

    fgets(buf, sizeof(buf), stdin);

    a = atoi(buf);
    if (1 <= a && a <= 10)
    {
        int n = a + a*a + a*a*a;
    printf("%d\n", n);
    }
}

Measured memory_bytes: 1672
#include<stdio.h>
int main()
{
    int i,j,ans=1,num=9;
    for(i=1,num=9;ans<=72;num=num+9,i++)
    {
    for(i=i,j=1;ans<num;j=j++)
    {

    ans=i*j;
    printf("%dx%d=%d\n",i,j,ans);
    }

    }
    return 0;
}

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

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

int gcd(int a, int b)
{
  if (a < b) swap(a, b);
  return b ? gcd(b, a%b) : a;
}

void solve(long long K){
  long long sum = 0;
  rep(a, K) {
    rep(b, K) {
      rep(c, K) {
	sum += gcd(gcd(a, b), c);
      }
    }
  }
  cout << sum << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
  scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3764
s = input()

if len(s) < 5:
    print("NO")
    exit()

while len(s) >= 5:
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        print("NO")
        exit()

if len(s) > 0:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 134964
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include <sstream>
#include <iomanip>

using namespace std;

int64_t binary(int64_t bina) {
	int64_t ans = 0;
	for (int64_t i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}

int main() {
	
	int64_t N, M, X;

	vector<int64_t> C;

	cin >> N >> M >> X;
	int64_t A[12][12];


	


	for (int64_t i = 0; i < N; i++) {
		int64_t c;
		cin >> c;
		C.push_back(c);

		for (int64_t j = 0; j < M; j++) {
			
			cin >> A[i][j];
			
		
		}


	}
	

	

	string str;
	string one="1";
	int64_t min_value = 9223372036854775807;
	
	for (int64_t i = 0; i < pow(2, N); i++) {
	
		ostringstream ss;
		ss << setfill('0') << setw(N) << binary(i);
		str = ss.str();
		
		vector<int64_t> ability(M);
		int64_t value=0;
		
		for (int j = 0; j < N; j++) {
		
			if (str[j] == one[0]) {
				
				for (int k = 0; k < M; k++) {
					ability[k] += A[j][k];
					
				}
				value += C[j];
				
			}


		}
		int64_t count = 0;
		for (int k = 0; k < M; k++) {
			if (ability[k] >= X)count++;
			
		}
		

		if (count == M) {
			if (min_value > value) {
				min_value = value;
			}


		}
	

	}

	if (min_value == 9223372036854775807) {
		cout << -1;
		return 0;
	}
	else {
		cout << min_value;
		return 0;
	}

	


}

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

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            int temp = A[j];
            A[j] = A[i];
            A[i] = temp;
        }
    }
    A[r] = A[i+1];
    A[i+1] = x;
    return i + 1;
}

int main() {
    int n;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int q;
    q = partition(A, 0, n-1);

    for (int i = 0; i < n; i++) {
        if (i != 0) {
            cout << " ";
        }
        if (i == q) {
            cout << "[" << A[i] << "]";
        }
        else {
            cout << A[i];
        }
    }
    cout << endl;
}



Measured memory_bytes: 3428
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    string s; cin>>s;
    int num=0;
    rep(i,s.size())num+=s[i]-'0';
    int res=stoi(s);
    cout<<(res%num?"No":"Yes")<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a)  a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;

void a(){
    ll x,y,z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x<< ' ' << y<< ' ' << z;
}

void b(){
    ll n,m; cin >> n >> m;
    auto a = v<>(n,0);
    rep(i,n) cin >> a[i];
    ll sum = accumulate(all(a),0);
    sort(all(a));
    ll check = ceil((double)sum/(4*m));
    ll ans = n - (lower_bound(all(a),check)-a.begin());
    if(ans>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

void c(){
    ll n,k; cin >> n >> k;
    ll d = n%k;
    cout << min(d,abs(d-k)) << endl;
}

void d(){
    ll k; cin >> k;
    priority_queue<ll,v<ll>,greater<ll>> que;
    v<ll> s{1,2,3,4,5,6,7,8,9};
    for(auto i:s) que.push(i);
    if(k<10){
        cout << s[k-1]<< endl;
        return;
    }
    while(s.size()<k){
        ll u = que.top(); que.pop();
        if(u%10-1>=0){
            que.push(u*10+u%10-1);
            s.push_back(u*10+u%10-1);
        }
        
        que.push(u*10+u%10);
        s.push_back(u*10+u%10);
        
        if(u%10+1<10) {
            que.push(u*10+u%10+1);
            s.push_back(u*10+u%10+1);
        }
        
        //sort(all(s));
    }

    cout << s[k-1] << endl;

}

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

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

int main(){
    
   int N;
    string s,t;
    cin>>N>>s>>t;
    int cnt=N;
    for(int j=0;j<N;j++){
        bool flag=true;
    for(int i=0;i<N-j;i++){
        if(s[j+i]!=t[i]){
            flag=false;
            break;
        }
    }
        if(flag){
            cnt=j;
            break;
        }
    }
    cout<<N+cnt<<endl;
}


Measured memory_bytes: 256
from math import sqrt
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
div = []
for i in range(1, int(sqrt(s)+1)):
	if s%i == 0:
		if i*i != s:
			div.append(s//i)
		div.append(i)
div.sort(reverse=True)
#print(div)

for d in div:
	b = [x%d for x in a if x%d != 0]
	if not b:
		print(d)
		break
	b.sort(key=lambda x: x%d)
	y, z = 0, d*len(b)-sum(b)
	res = 10**30
	for x in b:
		y += x
		z -= d-x
		res = min(res, max(y, z))
	if res <= k:
		print(d)
		break

Measured memory_bytes: 3064
import java.util.*;
// cin=sc.nextInt();
// List<Integer> a = new ArrayList<Integer>(n);
 
public class Main {
    public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);	
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if(c>=a && c <= b){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
	}
}

Measured memory_bytes: 21460
N, K = 5, 2
R, S, P = 8, 7, 6
TRR = ['r', 's', 'r', 'p', 'r']

N, K = map(int,input().split())
R, S, P = map(int,input().split())
TRR = list(input())


def calculate(n, k, r, s, p, trr):
    commands = []
    points = 0

    for i in range(n):
        command = ""
        point = 0

        if trr[i] == 'r':
            command = "p"
            point = p

        if trr[i] == 's':
            command = 'r'
            point = r

        if trr[i] == 'p':
            command = 's'
            point = s

        if i - k >= 0:
            if commands[i - k] == command:
                command = ""
                point = 0

        commands.append(command)
        points = points + point

    print(points)


calculate(N, K, R, S, P, TRR)


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


 int main()
 {
 	int a;
 	cin >> a;
 	if(a<105){
 		cout << 0 << endl;
 	}else if(a<135){
 		cout << 1 << endl;
 	}else if(a<165){
 		cout << 2 << endl;
 	}else if(a<189){
 		cout << 3 << endl;
 	}else if(a<195){
 		cout << 4 << endl;
 	}else{
 		cout << 5 << endl;
 	}
 }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
    int n,k;
    cin >> n >> k;
    double ans = 0.0;
    vector<int> count;
    for(int i = 1;i <= n;i++){
      count.push_back(i);
    }
    int num = 0;
    int cn_z = 0;
    while(true){
      for(int i = 0;i < count.size();i++){
        if(count[i] >= k){
          ans += pow(0.5,num);
          count[i] = 0;
          cn_z++;
        }
        else if(count[i] == 0) cn_z++;
        else count[i] *= 2;
      }
      num++;
      if(cn_z == count.size()) break;
      cn_z = 0;
    }
    ans /= n;
    printf("%.12f\n",ans);
}


Measured memory_bytes: 892
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

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

int main() {
	ll d, g; ll res = INF;
	cin >> d >> g;
	vector<ll> p(d);
	vector<ll> c(d);
	vector<ll> pc(d);
	rep(i, d) {
		cin >> p[i] >> c[i];
		pc[i] = p[i] * 100 * (i + 1) + c[i];
	}
	for (int bit = 0; bit < (1 << d); bit++) {
		ll sum = 0;
		ll cnt = 0;
		rep(i, d) {
			if (bit & (1 << i)) {
				sum += pc[i];
				cnt += p[i];
			}
		}
		if (sum >= g)chmin(res, cnt);
		if (sum < g) {
			for (ll i = d - 1; i >= 0; i--) {
				if (bit & (1 << i))continue;
				rep(j, p[i]) {
					if (sum >= g)break;
					sum += 100 * (i + 1);
					cnt++;
				}
			}
		}
		chmin(res, cnt);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    while(cin>>s){
        bool pal=1;
        for(int i=0,j=(int)s.size()-1;i<(int)s.size();i++,j--){
            if(s[i]!=s[j]){
                pal=0;
                break;
            }
        }
        if(!pal){
            cout << "No\n";
        }
        else{
            for(int i=0,j=(((int)s.size()-1)/2)-1;i<((int)s.size()-1)/2;i++,j--){
                if(s[i]!=s[j]){
                    pal=0;
                    break;
                }
            }
            if(!pal){
                cout << "No\n";
            }
            else{
                for(int i=(((int)s.size()+3)/2)-1,j=(int)s.size()-1;i<s.size();i++,j--){
                    if(s[i]!=s[j]){
                        pal=0;
                        break;
                    }
                }
                if(!pal){
                    cout << "No\n";
                }
                else {
                    cout << "Yes\n";
                }
            }
        }
    }
    return 0;
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  int ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    int res = __builtin_ctz(a);
    ans += res;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n >> m;
  n += m;
  if(n > 23)n -= 24;
  print(n);
  return 0;
}

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

int main() {
    int D, G;
    cin >> D >> G;
  
    vector<int> p(D);
    vector<int> c(D);
    for (int i = 0; i < D; i++) {
        cin >> p.at(i) >> c.at(i);
    }
  
    bitset<10> b;
    int score, p_num, min_p_num = 1000;
    for (int tmp = 0; tmp < (1 << D); tmp++) {
        b = tmp;
        score = 0;
        p_num = 0;
        for (int i = 0; i < D; i++) {
            if (b.test(i)) {
                score += 100 * (i + 1) * p.at(i) + c.at(i);
                p_num += p.at(i);
            }
        }
        if (p_num >= min_p_num) {
            continue;
        }
        if (score > G) {
            min_p_num = p_num;
            continue;
        }

        int highest = D - 1;
        while (b.test(highest)) highest--;
        
        int add = 100 * (highest + 1) * (p.at(highest) - 1);
        if (score + add < G) {
            continue;
        }

      	while (score < G) {
          score += 100 * (highest + 1);
          p_num++;
        }
        min_p_num = min(min_p_num, p_num);
    }
    cout << min_p_num << endl;
}


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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define RFOR(i, a, n) for (ll i = (ll)a; i >= n; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FOR(i, 1, n + 1)
#define RREP(i, n) RFOR(i, n - 1, 0)
#define RREPN(i, n) RFOR(i, n, 1)
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll extGCD(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }

    ll d = extGCD(b, a & b, y, x);
    y -= a / b * x;
    return d;
}

inline ll mod(ll &a, ll m)
{
    a = (a % m + m) % m;
    return a;
}

ll modinv(ll a, ll m)
{
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}

ll modadd(ll &a, ll b)
{
    mod(a, MOD);
    mod(b, MOD);
    a += b;
    return mod(a, MOD);
}

ll modsub(ll &a, ll b)
{
    return modadd(a, -b);
}

ll modmulti(ll &a, ll b)
{
    mod(a, MOD);
    mod(b, MOD);
    a *= b;
    return mod(a, MOD);
}

ll moddiv(ll &a, ll b)
{
    mod(a, MOD);
    a *= modinv(b, MOD);
    return mod(a, MOD);
}

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

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

//a,bの最大公約数
inline ll gcd(ll a, ll b)
{
    ll temp;
    while (a % b != 0)
    {
        temp = a;
        a %= b;
        b = temp;
    }
    return b;
}

//a,bの最小公倍数
inline ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

const int MAX_N = 1e5 + 10;

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n,m;
vi vert[1111111];
vpii cp[1111111];
int num[1111111];

vi g[1111111];
int dp[1111111];

struct UnionFind{
	int f[1111111];
	int sz[1111111];
	UnionFind(){
		FOR(i,0,1111111)f[i]=i,sz[i]=1;
	}
	int F(int x){
		return (f[x]==x?x:f[x]=F(f[x]));
	}
	inline void M(int a,int b){
		a=F(a);
		b=F(b);
		if(a==b)return ;
		if(sz[a]<sz[b]){
			f[a]=b;
			sz[b]+=sz[a];
		}
		else {
			f[b]=a;
			sz[a]+=sz[b];
		}
	}
}uf;
queue<int>q;
int I_Love_Hashimoto_Kanna() {
  fastio;
  n=read();
  m=read();
  FOR(i,0,m){
  	int a=read()-1,b=read()-1,c=read();
  	cp[c].push_back({a,b});
  	vert[c].push_back(a);
  	vert[c].push_back(b);
	}
	int nn=n;
  FOR(c,0,1000001){
  	if(cp[c].size()==0)continue;
  	SORT(vert[c]);
  	FOR(j,0,cp[c].size()){
  		uf.M(cp[c][j].first,cp[c][j].second);
		}
  	FOR(j,0,vert[c].size()){
  		if(j)if(vert[c][j]==vert[c][j-1])continue;
  		if(!num[uf.F(vert[c][j])]){
  			num[vert[c][j]]=num[uf.F(vert[c][j])]=nn++;
			}
			else num[vert[c][j]]=num[uf.F(vert[c][j])];
		}
		FOR(j,0,vert[c].size()){
  		if(j&&vert[c][j]==vert[c][j-1])continue;
  		g[num[vert[c][j]]].push_back(vert[c][j]);
  		g[vert[c][j]].push_back(num[vert[c][j]]);
  		num[vert[c][j]]=0;
  		uf.f[vert[c][j]]=vert[c][j];
  		uf.sz[vert[c][j]]=1;
  	}
	}
	FOR(i,0,nn){
		dp[i]=-2;
	}
	dp[0]=0;
	q.push(0);
	while(!q.empty()){
		int x=q.front();q.pop();
		FOR(i,0,g[x].size()){
			int to=g[x][i];
			if(dp[to]==-2){
				dp[to]=dp[x]+1;
				q.push(to);
			}
		}
	}
  
  Tone(dp[n-1]/2);
  
  
  return 0;
}


Measured memory_bytes: 113408
N = int(input())
W = list(map(int, input().split()))

min_abs = 100000
for i in range(N+1):
    under = W[:i]
    over = W[i:]
    a = abs(sum(under) - sum(over))
    if a < min_abs:
        min_abs = a

print(min_abs)

Measured memory_bytes: 3060
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    s = input()
    if s[0]!="A":
        print("WA")
        exit()
    if s[2:-2].count('C')!=1:
        print("WA")
        exit()
    s=s.replace('A','')
    s=s.replace('C','')
    if s.islower()==False:
        print("WA")
        exit()
    else:
        print("AC")


if __name__=="__main__":
    main()

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

int main() {
  int x;
  cin >> x;
  int ans = 1;
  for (int i = 2; i < x; i++) {
    int res = i;
    for (int j = 1; j < 11; j++) {
      res *= i;
      if (res > x) break;
      ans = max(ans, res);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define MAX 26

int main(void)
{
	char c;
	int i;
	int cnt[MAX] = {0};

	while ((c = getchar()) != EOF) {
		if ((c>='A') && (c<='Z')) {
			c += ' ';
		}
		cnt[c-'a']++;
	}
	
	for (i=0; i<MAX; i++) {
		printf("%c : %d\n", 'a'+i, cnt[i]);
	}
	return 0;
}




Measured memory_bytes: 3156
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = Integer.parseInt(sc.next());
    int g = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int n = Integer.parseInt(sc.next());

    int res = 0;
    int total = 0;
    
    for (int x = 0; x <= n/r; x++) {
      if (r*x <= n) {
        for (int y = 0; y <= n/g; y++) {
          if (r*x+g*y <= n) {
            total = n - r*x - g*y;
            if (total%b == 0) {
              res++;
            }
          }
        }
      }
    }
    
    System.out.println(res);
  }
}


Measured memory_bytes: 23380
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

ll dp[110][2][110];

int main() {
    string s; cin >> s;
    int K; cin >> K;

    int len = s.size();

    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    rep(i,len) {
        int d = s[i] - '0';
        rep(j,2) rep (k, K+1) {
            for (int l = 0; l <= (j ? 9 : d); l++) {
                if (l != 0) dp[i+1][j || (l<d)][k+1] += dp[i][j][k];
                else dp[i+1][j || (l<d)][k] += dp[i][j][k];
            }
        }
    }

    cout << dp[len][1][K] + dp[len][0][K] << endl;

    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-


def main():
    from math import ceil
    n = int(input())
    ans = ''

    if n == 0:
        print(0)
        exit()

    while n != 0:
        mod_n = ceil(n / (-2))
        ans += str(n - mod_n * (-2))
        n = mod_n

    print(ans[::-1])


if __name__ == '__main__':
    main()


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


int main() {
	string s, t;
	cin >> s >> t;
	map<char, int> mp;
	for (int i = 0; i < (int) s.length(); i++) {
		mp[s[i]]++;
	}
	bool ok = true;
	for (int i = 0; i < (int)t.length(); i++) {
		if (mp[t[i]] <= 0) ok = false;
	}
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}
	long long last = 0;
	long long sum = 0;
	long long n = s.length();
	for (int i = 0; i < (int)t.length(); i++) {
		int x = s.substr(last, n-last).find(t[i]);
		if (x == -1) {
			sum += n - last;
			x = s.find(t[i]);
			last = 0;
		}
		sum += x +1ll;
		
		last += x+1ll;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3832
import java.util.Scanner;

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


    if(a<=5){
      System.out.println(0);
    }
    else if(a<=12){
      System.out.println(b/2);
    }
    else{
      System.out.println(b);
    }

    //System.out.println("");
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define eb emplace_back
#define endl "\n"
#define FOR(P,Q) for(int P=0;P<Q;P++)
#define FORR(P,Q) for(int P=1;P<=Q;P++)
#define pb push_back
typedef long long ll;
using namespace std;


    
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif

	int n,W;
	cin>>n>>W;
	vector <int> dp(W+1,0);
	FORR(i,n){
		int w,v;
		cin>>w>>v;
		for(int x=W-w;x>=0;x--){
			dp[x+w]=max(dp[x]+v,dp[x+w]);
		}
	}
	
	cout<<dp[W];
	


return 0;
}

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

int main() {

	int a, b, c, d; cin >> a >> b >> c >> d;
	string  ans = "No";
	if (abs(c - a) <= d) ans = "Yes";
	if (abs(b - a) <= d && abs(c - b) <= d) ans = "Yes";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000003
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define INF 1e18
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl




int32_t main()
{
    fast;
    string s;cin>>s;
    int n=s.size();
    int cnta=0;
    int ans=0;
    for(int i=0;i<=n-2;i++)
    {
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
        {
            s[i]='B',s[i+1]='C',s[i+2]='A';
            ans++,ans+=cnta,i++;
        }
        else if(s[i]=='A')
            cnta++;
        else
            cnta=0;
    }
    cout<<ans;
}

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

int main(){
    int n; cin >> n;
    vector<string> s(50);
    map<char, int> memo;
    for(int i=0; i<n; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        char tmp;
        int cnt=0;
        map<char, int> dis;
        for(int j=0; j<s[i].length(); j++){
            if(dis.count(s[i][j])){
                dis[s[i][j]]++;
            }else{
                dis[s[i][j]]=1;
            }

        }
        for(int j=0; j<26; j++){
            if(!dis.count('a'+j)) dis['a'+j]=0;
            if(memo.count('a'+j)){
                memo['a'+j] = min(memo['a'+j], dis['a'+j]);
            }else{
                memo['a'+j] = dis['a'+j];
            }
        }
    }
    for(int i=0; i<26; i++){
        if(memo.count(i+'a')){
            for(int j=0; j<memo[i+'a']; j++){
                char tmp = 'a' + i;
                printf("%c", tmp);
            }
        }
    }
    printf("\n");
    return 0;

}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    long long A,B,K;
    cin>>A>>B>>K;
    if(B-A>=2*K){
    for(int i=0;i<K;i++){
        cout<<A+i<<endl;
    }
    for(int i=K-1;i>=0;i--){
        cout<<B-i<<endl;
    }
    }else{
        for(int i=A;i<=B;i++){
            cout<<i<<endl;
        }
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int res[11][11];
    for(int i=0;i<11;i++){
        for(int j=0;j<11;j++)res[i][j]=0;
    }
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int top=s[0]-'0';
        int last=i%10;
        res[top][last]++;
    }
    int ans=0;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            ans+=res[i][j]*res[j][i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int X = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			int sum = X;
			if((1 <= A && B <= 1000) && (A + B <= X && X <= 10000)){
				sum = sum - A;
				sum = sum % B;
				System.out.println(sum);
			}}}

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

int main() {
    int i = 1;
    
    while (1) {
        int x;
        cin >> x;
        
        if (x == 0) {
            break;
        }
        
        cout << "Case " << i << ": " << x << endl;
        i++;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3100
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    count = [0] * 41
    for a in A:
        for i in range(40, -1, -1):
            if (a >> i) & 1:
                count[40 - i] += 1

    x = 0
    for i in range(40, -1, -1):
        if count[40 - i] <= N / 2:
            if (x | 1 << i) <= K:
                x |= 1 << i

    ans = 0
    for a in A:
        ans += a ^ x
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15500
#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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n,m;
vector<ll> a, b;

void input(){
    cin >> n >> m;
    a.resize(m);
    b.resize(m);
    for(int i=0;i<m;i++){
      cin >> a[i] >> b[i];
      a[i]--;
      b[i]--; 
    }
}

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    UnionFind uf(n);
    ll cur = n*(n-1)/2;
    vector<ll> res;
    for(int i=0;i<m;i++){
      res.push_back(cur);
      int A = a[m-1-i];
      int B = b[m-1-i];
      if(uf.issame(A, B)) continue;
      ll sa = uf.size(A);
      ll sb = uf.size(B);
      cur -= sa*sb;
      uf.merge(A, B);
    }
    reverse(res.begin(), res.end());
    for(int i=0;i<res.size();i++) cout << res[i] << endl;
    return 0; 
}

Measured memory_bytes: 4212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc153_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            long N = long.Parse(NK[0]); //攻撃モンスターの体力を1減らす
            long K = long.Parse(NK[1]); //必殺技モンスターの体力を0にする

            long[] H = new long[N];



            string[] input = Console.ReadLine().Split(' ');

            for (int i = 0; i < N; i++)
            {
                H[i] = long.Parse(input[i]);
            }

            Array.Sort(H); //並び替え(オーバーフロー対策)

            long ans = 0; //攻撃回数の最小値

            //必殺技の回数を引いた数だけans+
            for (int i = 0; i < N - K; i++)
            {
                ans += H[i];
            }

            Console.WriteLine(ans);

            Console.Read();
        }
    }
}


Measured memory_bytes: 33408
N = gets.to_i
a = gets.split.map(&:to_i)

cnt = 0
N.times do |i|
    minJ = i
    for j in i..(N - 1) do
        minJ = j if a[j] < a[minJ]
    end
    if minJ != i then
        tmpV = a[i]
        a[i] = a[minJ]
        a[minJ] = tmpV
        cnt += 1
    end
end

puts a.join(' ')
puts cnt


Measured memory_bytes: 6876
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; using P=pair<int,int>; using ll=long long; ll m=1e9+7;

int main() {
  int a,b,c; cin>>a>>b>>c;
  int an=0;
  if ((a+b+c)%2==0) { // 偶数にせねば
    if (a%2&&b%2) a++,b++,an++;
    else if (a%2&&c%2) a++,c++,an++;
    else if (b%2&&c%2) b++,c++,an++;
  } else { // 奇数にせねば
    if (a%2==0&&b%2==0) a++,b++,an++;
    else if (b%2==0&&c%2==0) b++,c++,an++;
    else if (c%2==0&&a%2==0) c++,a++,an++;
  }
  int mx=max(a,max(b,c));
  an+=(mx-a)/2;
  an+=(mx-b)/2;
  an+=(mx-c)/2;
  cout<<an<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector <int> B = A;
    sort(B.begin(), B.end());
    for(int i = 0; i < N; i++) {
        int j = N-1;
        if(A.at(i) == B.at(j)) {
            j--;
        }
        cout << B.at(j) << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  char c;
  cin>>c;
  int d = c - 'a';
  if(0 <= d && d < 26){
    cout << 'a' << endl;
  }else{
    cout << 'A' << endl;
  }
  return 0;
}


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

int main() {
  long s;
  cin >> s;
  map<long,int> a;
  for(int i=1;true;i++) {
    if(a.count(s)) {
      cout << i << endl;
      break;
    } else {
      a[s]=1;
    };
    if(s%2==0) s=s/2;
    else s=s*3+1;
  };
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
bool bs[55], vis[55];
int A[55], B[55];

bool check() {
	// check if all A[i] are reachable to B[i] for every i without using number m
	for (int i = 0; i < N; ++i) {
		memset(vis, 0, sizeof(vis));
		vis[A[i]] = true;
		for (int j = A[i]; j >= 0; --j) {
			if (vis[j]) {
				for (int k = 1; k <= j; ++k) {
					if (!bs[k]) continue;
					vis[j % k] = true;
				}
			}
		}
		if (!vis[B[i]]) return false;
	}
	return true;
}


int main()
{
	int i, j, k, x;
	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		scanf("%d", &A[i]);
	}

	for (i = 0; i < N; ++i) {
		scanf("%d", &B[i]);
	}
	for (i = 1; i <= 50; ++i) bs[i] = true;
	for (i = 0; i < N; ++i) {
		if (A[i] != B[i]) break;
	}
	if (i == N) {
		printf("0");
		return 0;
	}
	if (!check()) {
		printf("-1");
		return 0;
	}
	ll sum = 0LL;
	for (i = 50; i >= 1; --i) {
		bs[i] = false;
		if (!check()) {
			bs[i] = true;
			sum += (1LL << i);
		}
	}
	printf("%lld", sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	long long a;
	double b;
	cin>>a>>b;
	int c = round(b*100);
	cout<<(a*c)/100<<endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
ll u18 = 1000000000000000000;
int main()
{
    
    int n; 
    cin >> n ;
    vector<ll> a(n+1); 
    for( int i = 1; i <= n; i++ ) cin >> a[i] ;

    for( int i = 1; i <= n; i++ ) {
    if(a[i] == 0 ){
        cout << 0 << endl;
        return 0;
    }
    }

    long long ans = 1;
    long long d;
    for( int i = 1; i<n+1; i++){
        ans = ans * a[i];
        if( i != n ){
          d = u18/a[i+1];
        }
        else if ( i == n ){
          d = u18;
        }
        if(ans>d){
            cout << "-1" << endl;
            return 0;
        }
        }
    cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 3996
#include <iostream>
#include <string>

using namespace std;

void yes_yes_yes(bool& what)
{
	what = true;
}

int main()
{
	string gnirts;
	cin >> gnirts;
	bool gettodaze = false;
	bool yattaze = false;
	for(int i_want_to_name_it_more_funny_but_i_cannot_so_i_did_this = 0; i_want_to_name_it_more_funny_but_i_cannot_so_i_did_this < gnirts.length(); i_want_to_name_it_more_funny_but_i_cannot_so_i_did_this++)
	{
		if(gnirts[i_want_to_name_it_more_funny_but_i_cannot_so_i_did_this] == 'C')
		{
			yes_yes_yes(*(&gettodaze));
		}
		if(gettodaze && gnirts[i_want_to_name_it_more_funny_but_i_cannot_so_i_did_this] == 'F')
		{
			yes_yes_yes(*(&yattaze));
		}
	}
	if(yattaze)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

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

using namespace std;

int main(){
    int n, num, resp, total = 0, soma = 0, aux;

    cin >> n;

    vector<int> v;

    for(int i = 0; i < n; i++){
        cin >> num;
        total += num;
        v.push_back(num);
    }

    for(int i = 0; i < n; i++){
        soma += v[i];
        aux = abs((total-soma)-soma);
        if(i == 0){
            resp = aux; 
        }else if(aux < resp){
            resp = aux;
        }
    }

    cout << resp << endl;


    return 0;

}

Measured memory_bytes: 256