akhauriyash/Code-Regression huggingface dataset:
//      https://www.youtube.com/watch?v=RBtlPT23PTM

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,ans=0,flag=0,mod=1000000007;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    multiset<pair<ll,pll> >s;
    s.insert({-1*a[n-2],{a[n-1],a[n-2]}});
    s.insert({-1*a[n-2],{a[n-1],a[n-2]}});
    ans=a[n-1];
    for(i=n-3;i>=0;i--){
        auto it=s.begin();
        ans+=(-1*(it->ff));
        j=it->ss.ff;
        k=it->ss.ss;
        s.erase(it);
        s.insert({-1*a[i],{a[i],j}});
        s.insert({-1*a[i],{a[i],k}});
    }
    cout<<ans;
}


Measured memory_bytes: 17728
#include <cstdio>

using namespace std;

int main()
{
  int d;
  while(scanf("%d",&d)!=-1){
    int res = 0;
    for(int i=d;i<600;i+=d)
      res += i*i*d;
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.Scanner;

class Main {
  public static void main (String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(reader.readLine());
    String str;

    for(int i=0; i<n; i++){
      str = reader.readLine();
      str = str.replaceAll("Hoshino", "Hoshina");
      System.out.println(str);
    }
  }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

const int INF = 1e15;

int n;
int h[111111];
int dp[111111];

signed main() {
  cin >> n;
  rep (i, n) {
    cin >> h[i];
  }

  fill(dp, dp+n+10, INF);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    if (i - 1 >= 0) {
      chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    }
    if (i - 2 >= 0) {
      chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
  }

  cout << dp[n-1] << endl;
  // print1(dp, dp+n+1);

  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int n,x,count=0;
	int i,j;
	while(1){
		scanf(" %d %d",&n,&x);
		if(n == 0 && x == 0) break;

		for(i = 1;i <= n;i++){
			for(j = i+1;j <= n;j++){
				if(j >= x-i-j) {
					break;
				}
				if(x-i-j > n) {
					continue;
				}
				
				count++;
			}
		}
		printf("%d\n",count);
		count=0;
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=0;i<n;i++) if(s[i]=='C') for(int j=i+1;j<n;j++) if(s[j]=='F') printf("Yes"),exit(0);
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
char s[N];int n,a[N];
struct segment_tree{
	bool is[N*4];
	#define lc x<<1
	#define rc x<<1|1
	void init(int x,int l,int r){
		is[x]=1;
		if (l==r) return;
		int mid=(l+r)>>1;
		init(lc,l,mid);
		init(rc,mid+1,r);
	}
	void flip(int x,int l,int r,int p){
		if (l==r) return void(is[x]^=1);
		int mid=(l+r)>>1;
		if (p>mid) flip(rc,mid+1,r,p);
			else flip(lc,l,mid,p);
		is[x]=is[lc]||is[rc];
	}
	int next(int x,int l,int r,int p){
		if (r<p||!is[x]) return 0;
		if (l==r) return l;
		int mid=(l+r)>>1,ans=next(lc,l,mid,p);
		return ans?ans:next(rc,mid+1,r,p);
	}
}T[10];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) a[i]=s[i]-'0';
	a[n+1]=1e9;
	for (int i=0;i<10;i++) T[i].init(1,1,n);
	for (int i=1;i<=n;i++) T[a[i]].flip(1,1,n,i);
	int ans=0;
	for (int p=1;p<=n;){
		ans++;
		for (int i=p,now=0;i<=n;){
			now=max(now,a[i]);
			int j=T[now].next(1,1,n,i);
			if (!j) j=n+1;
			if (a[j]<now){
				a[i]=0;
				j=n;
				while (a[j]==9){
					T[9].flip(1,1,n,j);
					T[0].flip(1,1,n,j);
					a[j--]=0;
				}
				T[a[j]].flip(1,1,n,j);
				a[j]++;
				T[a[j]].flip(1,1,n,j);
				break;
			}
			for (;i<j;a[i++]=0);
		}
		while (!a[p]) p++;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 21248
import collections as col
n = int(input())
s = list(map(int,input().split()))
t = s[0::2]
r = s[1::2]
a = col.Counter(t)
b = col.Counter(r)
a = sorted(a.items(), key=lambda x:x[1], reverse=True)
b = sorted(b.items(), key=lambda x:x[1], reverse=True)
a.append((-1,0))
b.append((-1,0))
if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    if a[1][1] > b[1][1]:
        print(n - a[1][1] - b[0][1])
    else:
        print(n - a[0][1] - b[1][1])

Measured memory_bytes: 19040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main()
{
    string s;
    GET(s);
    
    int ans = 1000000;
    for(int i = 0; i < s.size() - 2; i++) {
        int tmp = ((s[i] - '0') * 100) + ((s[i + 1] - '0') * 10) + ((s[i + 2] - '0'));
        if(ans > abs(tmp - 753)) {
            ans = abs(tmp - 753);
        }
    }
    
    SHOW(ans);
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>

using namespace std;

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

int n, m;
char a[50][51], b[50][51];

int check(int y, int x){
	rep(i, m) rep(j, m) if(a[y + i][x + j] != b[i][j]) return 0;
	return 1;
}

int solve(){
	rep(i, n - m + 1) rep(j, n - m + 1) if(check(i, j)) return 1;
	return 0;
}

int main(){
	scanf("%d %d", &n, &m);
	rep(i, n) scanf("%s", a[i]);
	rep(i, m) scanf("%s", b[i]);
	puts(solve() ? "Yes" : "No");
	return 0;
}

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

int main(){
	int n, len;
	cin >> n;
	for(int i = 0; i < n; ++i){
		string str;
		cin >> str;
		len = str.length();
		string ans;
		char ch = 0;
		for(int j = 0; j < len; ++j){
			if(str[j] == '0' && ch != 0){ 
				ans.push_back(ch);
				ch = 0;
			}else if(str[j] == '1'){
				if(ch == '.'){
					ch = ',';
				}else if(ch == ','){
					ch = '!';
				}else if(ch == '!'){
					ch = '?';
				}else if(ch == '?'){
					ch = ' '; 
				}else{
					ch = '.';
				}
			}else if(str[j] == '2'){
				if(ch == 'a'){
					ch = 'b';
				}else if(ch == 'b'){
					ch = 'c';
				}else{
					ch = 'a';
				}
			}else if(str[j] == '3'){
				if(ch == 'd'){
					ch = 'e';
				}else if(ch == 'e'){
					ch = 'f';
				}else{
					ch = 'd';
				}
				
			}else if(str[j] == '4'){
				if(ch == 'g'){
					ch = 'h';
				}else if(ch == 'h'){
					ch = 'i';
				}else{
					ch = 'g';
				}
			}else if(str[j] == '5'){
				if(ch == 'j'){
					ch = 'k';
				}else if(ch == 'k'){
					ch = 'l';
				}else{
					ch = 'j';
				}
			}else if(str[j] == '6'){
				if(ch == 'm'){
					ch = 'n';
				}else if(ch == 'n'){
					ch = 'o';
				}else{
					ch = 'm';
				}
				
			}else if(str[j] == '7'){
				if(ch == 'p'){
					ch = 'q';
				}else if(ch == 'q'){
					ch = 'r';
				}else if(ch == 'r'){
					ch = 's';
				}else{
					ch = 'p';
				}
			}else if(str[j] == '8'){
				if(ch == 't'){
					ch = 'u';
				}else if(ch == 'u'){
					ch = 'v';
				}else{
					ch = 't';
				}
			}else if(str[j] == '9'){
				if(ch == 'w'){
					ch = 'x';
				}else if(ch == 'x'){
					ch = 'y';
				}else if(ch == 'y'){
					ch = 'z';
				}else{
					ch = 'w';
				}
			}
		}
		cout << ans << endl;
	}
}

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

int main( void )
{
    long long N;
	cin >> N;
    string S;
    cin >> S;
    
    long long white[N+1] = {};
    long long black[N+1] = {};

    white[0] = 0;
    black[0] = 0;
    for(long long i=1;i<=N;i++){
        if(S[i-1] == '.'){
            white[i] = white[i-1] + 1;
            black[i] = black[i-1];
        }else{
            black[i] = black[i-1] + 1;
            white[i] = white[i-1];
        }
    }

    long long min = white[N];
    //cout << min << "\n";
    for(long long i=1;i<=N;i++){
        long long tmp = black[i] + white[N] - white[i];
        if(min > tmp){
            min = tmp;
        }
        //cout << tmp << "\n";

    }

    cout << min << "\n";
	return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, k,c;
	std::cin >> n >> c >> k;
	std::vector<uint32> t(n);
	for (uint32 i = 0;i < n;++i) {
		std::cin >> t[i];
	}
	std::sort(t.begin(), t.end());
	uint32 b = 0;
	uint32 nt = t[0], nc = 1;
	for (uint32 i = 1;i < n;++i) {
		if (t[i] > nt + k) {
			++b;
			nt = t[i];
			nc = 0;
		}
		else if (nc == c) {
			++b;
			nt = t[i];
			nc = 0;
		}
		++nc;
	}
	std::cout << b + 1 << "\n";
	return 0;
}

Measured memory_bytes: 1024
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

# 二次元配列を作る
BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])

BC = sorted(BC, reverse=True, key=lambda x: x[1])  # Cの値で降順にソートされる

cnt = 0
com = []

for b, c in BC:
    cnt += b
    if cnt > N:  # 操作を加える回数がNを超えることはない
        add = N-cnt+b  # comの要素数の調整
        com.extend([c]*add)
        break
    else:
        com.extend([c]*b)

A.extend(com)

A.sort(reverse=True)
print(sum(A[:N]))


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

map<ll,ll> mapa;

int main(){

    ll n; cin >> n;
    for(ll i = 0; i < n; i++){
        ll x; cin >> x;
        mapa[x]++;
    }

    vector<ii> vec(mapa.begin(), mapa.end());
    vector<ll> area;

    for(ll i = vec.size() - 1; i >= 0; i--)
        while(vec[i].second >= 2 and area.size() < 2)
            area.push_back(vec[i].first), vec[i].second -= 2;
    if(area.size() < 2) cout << 0 << endl;
    else cout << area[0]*area[1] << endl;
    
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main(void){
    long n,b = 1000000,c = -1000000,d = 0;
    cin >>n ;
    int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    for(int i =0;i<n;i++){
    d=d+a[i];
    }
    for(int i =0;i<n;i++){
        if(a[i]<b){b=a[i];}
        if(a[i]>c){c=a[i];}
    }
    cout <<b<<" "<<c<<" "<<d<<endl;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N,M; cin >> N >> M;
    vector <P> p(M);
    rep(i,M) cin >> p[i].first >> p[i].second;
    
    rep(i,1000){
        string S=to_string(i);
        int keta=S.length();
        
        if(N!=keta) continue;
        bool ans=true;
        rep(i,M){
            if (S[p[i].first-1] != p[i].second +'0') ans=false;
        }
        
        if (ans){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  M[101][101];
int main(){
  int n,u,k,v;
  cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<M[i][j];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>
#define N 101

int a[N];
int count=0;

void swap(int *x,int *y){
  int t=*x;
  *x=*y;
  *y=t;
}

void selectionsort(int n){
  int i,j;
  for(i=0;i<n;i++){ // ??????????????¨???????????????????´???????
    int minj=i;
    for(j=i+1;j<n;j++){
      if(a[j]<a[minj]) minj=j;
    }
    if(i!=minj){
    swap(&a[i],&a[minj]);
    count++;
    }
  }
}

int main()
{
  int n;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  selectionsort(n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using  LL = long long;

LL yhaa(LL x, LL n, LL mod){
    if (n == 0){
        return 1;
    }
    if (n%2 == 0){
        LL t = (yhaa(x,n/2, mod)) % mod;//偶数の時は半分
        return (t*t) % mod;
    }
    return (x * yhaa(x, n-1, mod)) % mod;
}

LL nCk(LL n,LL k,LL m){
    int K;
    if (2*k > n){
        K  = n - k;
    }
    else{
        K = k;
    }
    LL X = 1;
    for(int i = 0; i < K;i++){
        X = (X*(n-i)) % m;
    }
    LL Y = 1;
    for(int i = 1; i < K+1; i++){
        Y = (Y*i) % m;
    }
    LL YY = yhaa(Y,1000000005,m);
    return (X*YY) % m;

}


int main(){
    int n, a, b;
    cin >> n >> a >> b;
    long long int m = 1000000007;
    if (n == 2){
        cout << 0 <<endl;
    }
    else{
        LL all = yhaa(2,n,m);
        LL C_a = nCk(n,a,m);
        LL C_b = nCk(n,b,m);
        if((all - C_a - C_b - 1 ) % m > 0){
            cout << (all - C_a - C_b - 1 ) % m << endl;
        }
        else{
            cout << m + (all - C_a - C_b - 1 ) % m << endl;
        }
    }
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  rep(i,n) {
    if(a[i]%2==0) {
      if(a[i]%3!=0&&a[i]%5!=0) {
	cout << "DENIED" << endl;
	return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


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


int main()
{
    int a, b;

    cin >> a;
    cin >> b;

    if(a > b)
        cout << "a > b" << endl;
    if(a < b)
        cout << "a < b" << endl;
    if(a==b)
        cout << "a == b" << endl;
    return 0;


}

Measured memory_bytes: 3064
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

static const double max_l = 1e15;
ll N, K;
vector<double> as;

bool is_ok(double mid){
    ll num_cut = 0;
    rep(i, N){
        // if(as[i]<mid){
        //     return false;
        // }
        num_cut += ceil(as[i] / mid) - 1;
        if(num_cut > K){
            return false;
        }
    }

    return true;
}

void Main(){
    cin >> N >> K;
    as.resize(N);
    double right = 0;
    rep(i, N){
        cin >> as[i];
        right = max(as[i], right);
    }

    double left = 0;
    rep(i, 200){
        double mid = (left + right) * 0.5;
        bool ok = is_ok(mid);
        // cout << "l:"<<left << " r:"<<right << " mid:"<<mid << " ok:"<<ok <<endl;
        if(ok){
            right = mid;
        }else{
            left = mid;
        }
    }

    ll ans = ceil(right);
    cout << ans <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 4416
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        final int N = scan.nextInt();
        scan.close();

        double even = 0;
        double odd = 0;
        for (int i = 1; i <= N; i++) {
            if (i % 2 == 0) {
                even++;
            } else {
                odd++;
            }
        }
        double ans = odd / (even + odd);
        System.out.println(ans);
    }
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    FOR(i, A, B + 1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
    int N, count = 1;
    char s[100000];
    cin >> N >> s[0];
    for (int i = 1; i < N; i++){
        cin >> s[i];
        if(s[i] != s[i-1]) count += 1;
    }
    cout << count << endl;
}


Measured memory_bytes: 384
#include <iostream>
//#include <fstream>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    string S;
    cin >> S;
    
    if (S[0] != S[1] && S[1] != S[2] && S[2] != S[3])
    {
        cout << "Good" << endl;
    }
    else
    {
        cout << "Bad" << endl;
    }
    return 0;
}


Measured memory_bytes: 760
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g.add_edge(u, v);
        g.add_edge(v, u);
    }
    ll s = 0, t = 0;
    for(int u = 0; u < n; u++){
        t++;
        for(int v : g.g[u]){
            if(v < u) t--;
        }
        s += t;
    }
    ll ans = s;
    for(int u = 0; u < n - 1; u++){
        s -= n - u;
        for(int v : g.g[u]){
            if(v > u) s += n - v;
        }
        ans += s;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14980
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  string s;
  cin >> s;
  int cnt = 0;
  int l = s.length();
  REP(i, l / 2) {
    if(s[i] != s[l - i - 1]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int H,W,A,B; cin >> H >> W >> A >> B;
    
    vector<string> M(H,string(W,'1'));
    for(int i = 0; i < B;i++){
        for(int j = 0; j < A;j++){
            M[i][j] = '0';
        }
    }
    for(int i = B; i < H;i++){
        for(int j = A; j < W;j++){
            M[i][j] = '0';
        }
    }
    for(auto s:M) cout << s << endl;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
//#include <cstdlib>
//#include <cmath>

using namespace std;

int main() {
  
  int N, A;
  cin >> N >> A;
  
  while (true){
    
    if (N < 500){
      
      if (N <= A){
        cout << "Yes" << endl;
      }
      else
        cout << "No" << endl;
      
      break;
    }
    
    N -= 500;
  }

}


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

int main() {
  string O, E;
  cin >> O >> E;
  
  rep(i, max(O.size(), E.size())) {
    if(i<O.size()) cout << O[i];
    if(i<E.size()) cout << E[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  string converted_n = "";

  if (n == 0) {
    converted_n = "0";
  } else {
    while (n != 0) {
      if (n % 2 == 0) {
        converted_n = "0" + converted_n;
      } else {
        converted_n = "1" + converted_n;
        n -= 1;
      }
      n /= (-2);
    }
  }

  cout << converted_n << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long H, long long A){
    long long q = H/A;
    long long r = H%A;
    if (r>0) q+=1;
    cout << q << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    func(H, A);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define MACRO(a) for(int a = 1; a < 1001; a++)

using namespace std;

int get(int a)
{
	int ret = 0;
	while (a % 2 == 0)
	{
		a /= 2;
		ret += 1;
	}
	return ret;
}

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int N; cin >> N; auto arr = new int[N]();
	for (int i = 0; i < N; i++) cin >> arr[i];

	int ret = 0;
	for (int i = 0; i < N; i++)
	{
		ret += get(arr[i]);
	}
	cout << ret << endl;
	return 0;
}

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

int main() {
    int a, b, h=100, w=100;
    string s[100];
    char x='.', y='#';
    cin >> a >> b;
    if(a>b){
        int t=b;
        b=a;
        a=t;
        x='#';
        y='.';
    }
    for(int i=0;i<h;i++){
        s[i] = string(w, x);
    }
    for(int i=0;i<h;i+=4){
        for(int j=0;j<w;j+=4){
            if(b>0){
                for(int k=1;k<4;k++){
                    for(int l=1;l<4;l++){
                        s[i+k][j+l] = y;
                    }
                }
                b--;
            }
            if(a>1){
                s[i+2][j+2] = x;
                a--;
            }
        }
    }
    
    cout << h << " " << w << endl;
    for(int i=0;i<h;i++){
        cout<<s[i]<<endl;
    }
	return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, M;
    cin >> N >> M;

    vector<int> X(M);
    REP(i, M) {
        cin >> X[i];
    }
    sort(X.begin(), X.end(), greater<int>());

    int sum = 0;
    vector<int> dist(M - 1);
    REP(i, M - 1) {
        dist[i] = abs(X[i] - X[i + 1]);
        sum += dist[i];
    }
    sort(dist.begin(), dist.end(), greater<int>());
    REP(i, N - 1) {
        if (i >= dist.size()) break;
        sum -= dist[i];
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#define ll long long int
using namespace std;

int main() {
	ll N; cin >> N;
	ll arr[3*N];
	ll front_sum[N+1];
	for(int i = 0; i < 3*N; i++) {
		cin >> arr[i];
	}
	priority_queue<ll, vector<ll>, greater<ll> > partial_front;
	ll sum = 0;
	for(int i = 0; i < N; i++) {
		partial_front.push(arr[i]);
		sum += arr[i];
	}
	front_sum[0] = sum;
	for(int i = N; i < 2*N; i++) {
		partial_front.push(arr[i]);
		ll removed = partial_front.top();
		partial_front.pop();
		sum += (arr[i] - removed);
		front_sum[i-N+1] = sum;
	}

	priority_queue<ll> partial_back;
	sum = 0;
	for(int i = 3*N-1; i >= 2*N; i--) {
		partial_back.push(arr[i]);
		sum += arr[i];
	}
	ll back_sum[N+1];
	back_sum[N] = sum;
	for(int i = 2*N-1; i >= N; i--) {
		partial_back.push(arr[i]);
		ll removed = partial_back.top();
		partial_back.pop();
		sum += arr[i] - removed;
		back_sum[i - N] = sum;
	}

	ll best = -999999999999999;
	for(int i = 0; i < N+1; i++) {
		if(front_sum[i] - back_sum[i] > best) {
			best = front_sum[i] - back_sum[i];
		}
	}

	cout << best << endl;
	/*
	for(int i = 0; i <= N; i++) {
		cout << front_sum[i] << " ";
	}
	cout << endl;
	for(int i = 0; i <= N; i++) {
		cout << back_sum[i] << " ";
	}
	cout << endl; */

}

Measured memory_bytes: 5876
i = 0
while True:
    a,op,b = input().split(" ")
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
        continue
    elif op == "-":
        print(a - b)
        continue
    elif op == "*":
        print(a * b)
        continue
    elif op == "/":
        i = (a / b)
        print(int(i))
        continue
    else:
        break


Measured memory_bytes: 5596
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner(System.in);
//        MyScanner sc = new MyScanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
        TIME_START = System.currentTimeMillis();
        Task.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
//        pw.println("Time used: " + (TIME_END - TIME_START) + ".");
        pw.close();
    }
    //https://arc080.contest.atcoder.jp/tasks/arc080_b
    public static class Task {

        public static void solve(MyScanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[][] grid = new int[n][m];
            int k = sc.nextInt();
            int x = -1, y = 0;
            int dir = 1; // 1 up, 2 down
            for (int i = 1; i <= k; i++) {
                int count = sc.nextInt();
                for (int j = 0; j < count; j++) {
                    switch (dir) {
                        case 1:
                            if (x + 1 < n) {
                                x++;
                            } else {
                                y++;
                                dir = 2;
                            }
                            grid[x][y] = i;
                            break;
                        case 2:
                            if (x - 1 >= 0) {
                                x--;
                            } else {
                                y++;
                                dir = 1;
                            }
                            grid[x][y] = i;
                            break;
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    pw.print(grid[i][j] + " ");
                }
                pw.println();
            }
        }
    }

    static class MyScanner {
        StringTokenizer st;
        BufferedReader br;

        public MyScanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public MyScanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

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

        public boolean ready() throws IOException {return br.ready();}
    }
}


Measured memory_bytes: 23380
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
int Arr[100005];
void seive(){
		Arr[0]=Arr[1]=1;
		for(int i=2;i<100005;++i){
			if(Arr[i]==0)
			for(int j=2*i;j<100005;j+=i)
			Arr[j]=1;
		}
}

bool isprime(int a){
	if(a==2)
	return true;
	if(a%2==0)
	return false;
	for(int i=3;i*i<=a;i+=2)
	if(a%i==0)
	return false;
	return true;
}

void merge(int arr[],int brr[], int l, int m, int r) 
			{ 
			  int i, j, k; 
			  int n1 = m - l + 1; 
			  int n2 = r - m; 
			  int L[n1], R[n2]; 
			  int l1[n1] ,r1[n2];
			  for (i = 0; i < n1; i++) 
				{L[i] = arr[l + i];l1[i]=brr[l+i];} 
			  for (j = 0; j < n2; j++) 
				{R[j] = arr[m + 1+ j];r1[j]=brr[m+1+j];} 
			  i = 0;  
			  j = 0; 
			  k = l;  
			  while (i < n1 && j < n2) 
			  { 
				if (L[i] <= R[j]) 
				{ 
				  arr[k] = L[i];
				  brr[k]=l1[i]; 
				  i++; 
				} 
				else
				{ 
				  arr[k] = R[j];
				  brr[k]=r1[j]; 
				  j++; 
				} 
				k++; 
			  } 
			  while (i < n1) 
			  { 
				arr[k] = L[i]; 
				brr[k]=l1[i];
				i++; 
				k++; 
			  } 
			  while (j < n2) 
			  { 
				arr[k] = R[j];
				brr[k]=r1[j]; 
				j++; 
				k++; 
			  } 
			} 
			void mergeSort(int arr[],int brr[], int l, int r) 
			{ 
			  if (l < r) 
			  { 
				int m = l+(r-l)/2; 
				mergeSort(arr,brr, l, m); 
				mergeSort(arr,brr, m+1, r); 
				merge(arr,brr, l, m, r); 
			  } 
			}
			
// -----------------------------------------------------------------------



int fre[26];

void stt(){
	int arr[5];
	for(int i=0;i<5;++i)
	cin>>arr[i];
	int k; cin>>k;
	int xp=arr[4]-arr[0];
	if(xp>k)
	cout<<":(";
	else
	cout<<"Yay!";
}
void spp(){
	int n,k;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;++i)
	cin>>arr[i];
	sort(arr,arr+n);
	bool choose[n];
	for(int i=0;i<n;++i)
	choose[i]=false;
	int ret=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			if(arr[j]>arr[i] && !choose[j]){
				ret++;
				choose[j]=true;
				break;
			}
		}
	}
	cout<<ret;
}

void solve(){	
	int n; cin>>n;
	int k; cin>>k;
	string s; cin>>s;
	for(int i=0;i<sz(s);++i)
	fre[s[i]-'A']++;
	sort(fre,fre+26);	
	int ans=0;
	for(int i=25;i>=0;--i){
		if(k>=fre[i]){
			ans+=fre[i]*fre[i];
			k-=fre[i];	
		}
		else{
			ans+=k*k;
			k=0;
			break;
		}
	}
	cout<<ans;
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	stt();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){
	int x,y,z;
	int i;
	scanf("%d%d%d",&x,&y,&z);

	for(i=0;;i++){
		if(x-i*y-(i+1)*z<0){
		break;
		}
	}
	printf("%d",i-1);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys 

n = int(input())
s = input()

def comp(str1, str2):
    s1 = set(list(str1))
    s2 = list(str2)
    ans = 0 
    for i in s1: 
        if i in s2: 
            ans += 1
    return ans 

ans = 0 
for i in range(n-1):
   ls = s[:i+1]
   rs = s[i+1:]
   tmp = comp(ls, rs) 
   ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define plll pair<pair<long,long>,long>
#define val first
#define a first
#define b second
#define dif second
#define isEven(a) (!((a)%2))
int main(){
  long n;
  cin>>n;
  vector<plll> v(n);
  for(long i=0;i<n;++i)cin>>v[i].val.a>>v[i].val.b;
  long takahashi=0,aoki=0;
  for(long i=0;i<n;++i)v[i].dif=/*abs*/(v[i].val.a+v[i].val.b);
  sort(v.begin(),v.end(),[](plll p, plll q){
    return p.dif==q.dif?(p.val.a==q.val.a?(p.val.b>q.val.b):p.val.a>q.val.a):p.dif>q.dif;
  });
  for(int i=0;i<n;++i)cerr<<"["<<i<<"] ("<<v[i].val.a<<","<<v[i].val.b<<"),("<<v[i].dif<<")\n";
  
  for(int i=0;i<n;++i)if(isEven(i))takahashi+=v[i].val.a;else aoki+=v[i].val.b;
  cout<<takahashi-aoki<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define ull unsigned long long
using namespace std;
void io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int MAXM = 1e3 + 5;
const int MAXA = 1e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f;
const ll prim = 1e9 + 7;

int f[1 << 12][MAXM];
int a[MAXA];
int b[MAXA];
int n, m;
int t, temp;

int main() {
    io();
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        cin >> t;
        int ans = 0;
        for (int j = 0; j < t; j++) {
            cin >> temp;
            ans |= (1 << (temp - 1));
        }
        b[i] = ans;
    }
    memset(f, 0x3f, sizeof(f));
    f[0][0] = 0;
    for (int p = 0; p < m; p++) {
        for (int s = 0; s < (1 << n); s++) {
            f[s | b[p]][p + 1] =
                min(f[s | b[p]][p + 1], f[s][p] + a[p]);  //买下
            f[s][p + 1] = min(f[s][p + 1], f[s][p]);      //不买
        }
    }
    if (f[(1 << n) - 1][m] >= 1e9) {
        cout << -1;
    } else {
        cout << f[(1 << n) - 1][m];
    }
}


Measured memory_bytes: 19708
from math import sin, cos, pi, sqrt
a, b, C = map(int, input().split())
S = a*b*sin(C*pi/180)/2
c = sqrt(a**2 + b**2 - 2*a*b*cos(C*pi/180))
h = 2*S/a
print(S)
print(a+b+c)
print(h)




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

using namespace std;

int main () {
    int N, T;
    cin >> N >> T;

    int result = 0;
    int s = 0;
    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        
        result += T;
        int diff = s - t;
        if (diff > 0) {
            result -= diff;
        }
        s = t + T;
    }

    cout << result << endl;
}

Measured memory_bytes: 256
import numpy as np
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
x = [30] * 13
x[1] = x[3] = x[5] = x[7] = x[8] = x[10] = x[12] = 31
x[2] = 28
x[0] = 0
print('1' if x[m1] == d1 else '0')


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

void solve() {
	int n,m;
	cin >> n >> m;
	int cnt[31]={0};
	for (int i = 0; i < n; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int a;
			cin >> a;
			cnt[a]++;
		}
	}

	int ans = 0;
	for (int i = 1; i <= m; ++i) {
		if (cnt[i] == n) {
			++ans;
		}
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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


typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n, k;
  cin >> n >> k;
  ll ans=0;
  ll h[n];
  if(n<=k){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  sort(h, h+n);
  for(int i=0; i<n-k; i++){
    ans += h[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5188
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		try{
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
        
			//1???????????????????????????????????°???????????????
			String str = br.readLine();
			//???????????????????????????????????????????????????
			int calcCnt = Integer.parseInt(str);
        
			//???????????????????????°???????????????????????°?????????
			for(int i = 0; i < calcCnt; i++){
				String data = br.readLine();
				String[] strZahyo;
				strZahyo = data.split(" ");
				//?????????????????????????????§?¨?????????????
				double[] zahyo = new double[strZahyo.length];
				for(int j = 0; j < strZahyo.length; j++){
					zahyo[j] = Double.parseDouble(strZahyo[j]); 
				}
				double slope1, slope2, slope1x, slope2x,slope1y,slope2y;
				slope1x = zahyo[2]-zahyo[0];
				slope1y = zahyo[3]-zahyo[1];
				slope2x = zahyo[6]-zahyo[4];
				slope2y = zahyo[7]-zahyo[5];
				
				//?????????????????§???2??????x??§?¨??????????????????´??????????????????
				//2??´?????¨????????????????????§?????´??????YES
				if(Math.abs(slope1x) < 1e-10 && Math.abs(slope2x) < 1e-10){
					System.out.println("YES");
					continue;        	
				//?????????????????????????????§?????´??????NO
				}else if(Math.abs(slope1x) < 1e-10){
					System.out.println("NO");
					continue;
				}else if(Math.abs(slope2x) < 1e-10){
					System.out.println("NO");
					continue;
				}
        	
				slope1 = slope1y/slope1x;
				slope2 = slope2y/slope2x;
            
				if(Math.abs(slope1 - slope2) < 1e-10){
					System.out.println("YES");
				}
				else{
					System.out.println("NO");
				}
			}
		}catch(IOException e){
        	System.out.println(e);
        }
        
	}

}

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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<long long> dp(w + 1);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    for (int j = w - x; j >= 0; j--) {
      dp[j + x] = max(dp[j + x], dp[j] + y);
    }
  }
  cout << dp[w] << '\n';
	return 0;
}



Measured memory_bytes: 3992
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)
#define LOGR(x) for(auto a : (x)) cout << a << '\n';

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll a, b;
    cin>>a>>b;

    if(b - a <= 10){
        ll res = a;
        for(ll i = a + 1; i <= b; i++){
            res ^= i;
        }

        LOG(res);
        return 0;
        
    } 

    ll pairs = 0;
    ll start, end;
    if(a & 1){
        start = a + 1;
    } else {
        start = a;
    }

    if(b & 1){
        end = b;
    } else {
        end = b-1;
    }

    pairs = (end - start + 1) / 2;
    pairs %= 2;

    ll res = 0;
    for(ll i = a; i < start; i++){
        res ^= i;
    }

    for(ll i = b; i > end; i--){
        res ^= i;
    }
    res ^= pairs;
    LOG(res);


    return 0;
}


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

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
 
int main() {
  int N;
  cin >> N;

  vector<int> P(N);
  vector<string> S(N);

  REP(i, N)
  cin >> S.at(i) >> P.at(i);

  int outnum, outscore;
  string out;

REP(k, N){
  outscore = P.at(0);
  outnum = 1;
  out = S.at(0);

    FOR(i,1,N){
      if(S.at(i) == out){ //同一文字列
        if(P.at(i) > outscore){
          outnum = i + 1;
          outscore = P.at(i);
        }
      }else{
        for(int j = 0; j < 10; j++){
          if(S.at(i)[j] == out[j]){
            continue;
          }else if(S.at(i)[j] < out[j]){
            out = S.at(i);
            outnum = i + 1;
            outscore = P.at(i);
            break;
          }else{
            break;
          }
        }
      }
    }

    cout << outnum << endl;
    S.at(outnum - 1) = "zzzzzzzzzzzz";
    P.at(outnum - 1) = -1;
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n, k, l[50], ans = 0;
	cin >> n >> k;
	loop(n)
		cin >> l[i];
	sort(l, l + n);
	loop(k)
		ans += l[n - 1 - i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    vi x; x.resize(m);
    rep(i, m) cin >> x[i];
    sort(all(x));
    vi diff(m);
    rep(i, m) {
        if (i == 0) diff[0] = 0;
        else diff[i] = x[i] - x[i - 1];
    }
    sort(all(diff), greater<int>());
    ll ans = 0;
    rep(i, m) {
        if (i < n - 1) continue;
        ans += diff[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    char b;
    scanf("%c", &b);
    if(b=='A')
    {
        printf("T\n");
    }
    else if(b=='T')
    {
        printf("A\n");
    }
    else if(b=='G')
    {
        printf("C\n");
    }
    else if(b=='C')
    {
        printf("G\n");
    }
    return 0;
}


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

#define    ll    long long int

int main( )
{
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy\n";
    }
    else if (s == "Cloudy") {
        cout << "Rainy\n";
    }
    else {
        cout << "Sunny\n";
    }
    return 0;
}



Measured memory_bytes: 256