akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
mod = 1000000007
ans = 0

for i in range(k, n+2):
  i_num = ( i*n - ( i * (i-1) ) + 1 ) % mod
  ans += i_num
  ans %= mod

print(int(ans))

'''
1ko 0 -- n n+1 ko
2ko 1 -- 2n-1 2n-1 ko
3ko 3 -- 3n-3 3n-5 ko
4ko 6 -- 4n-6 4n-11 ko
k-ko sigma 1 - (k-1) -- k*n - sigma(1 - (k-1))
(sigma 1 - (k-1)) = k * (k-1) / 2
k-ko ippannsiki -> k*n - ( k * (k-1) )  + 1
'''

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

int main(){
	vector<int> w,k;
	for(int i=0;i<10;i++){
		int n;
		cin>>n;
		w.push_back(n);
	}
	for(int i=0;i<10;i++){
		int n;
		cin>>n;
		k.push_back(n);
	}
	sort(w.begin(),w.end(),greater<int>());
	sort(k.begin(),k.end(),greater<int>());
	
	cout<<w[0]+w[1]+w[2]<<" "<<k[0]+k[2]+k[1]<<endl;
	
}

Measured memory_bytes: 1220
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;

void printCardsInLine(vector<pair<char, int> > &arr) {
	for(auto itr=arr.begin(); itr!=--(arr.end()); ++itr) {
		printf("%c%d ", (*itr).first, (*itr).second);
	}
	printf("%c%d\n", (*(--arr.end())).first, (*(--arr.end())).second);
}

int main() {
    int n, val;
    char suit;
    vector<pair<char, int> > cards, cards2;
    bool stable, flag;

    scanf("%d", &n);
    for(int i=0; i<n; ++i) {
        scanf(" %c%d", &suit, &val);
        cards.push_back(pair<char, int>(suit, val));
    }

    cards2 = cards;

    for(auto it=cards.begin(); it!=cards.end(); ++it) {
        for(auto rit=--cards.end(); rit!=it; --rit) {
            if((*rit).second<(*(rit-1)).second) {
                swap(*rit, *(rit-1));
            }
        }
    }
    printCardsInLine(cards);
    printf("Stable\n");

    stable = true;
    for(auto it=cards2.begin(); it!=cards2.end(); ++it) {
        auto mini = it;
        for(auto it2=it; it2!=cards2.end(); ++it2) {
            if(flag && (*it2).second<(*mini).second){
                mini = it2;
                stable = false;
            } else if(!flag && (*it2).second<(*mini).second) {
                mini = it2;
            }
            if((*it2).second==(*it).second && it!=it2) flag = true;
        }
        swap(*it, *mini);
        flag = false;
    }

    printCardsInLine(cards2);
    if(stable)  printf("Stable\n");
    else    printf("Not stable\n");
}

Measured memory_bytes: 2752
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            //string A = Console.ReadLine();//Aから読み込む
            string[] s = Console.ReadLine().Split(' ');//BC[0] = b   BC[1] = c　　を読み込む
            int A = int.Parse(s[0]);//buttonA
            int B = int.Parse(s[1]);//buttonB

            //string s = Console.ReadLine();//こいつだけは文字列
            //ここまでが入力部分でーす💛
            if (A<B){
                Console.WriteLine(B+(B-1));
            }else if(A>B){
                Console.WriteLine(A+(A-1));
            }else{
                Console.WriteLine(A + B);
            }
        }
    }
}




Measured memory_bytes: 11092
package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &s, &k)

	x := s[k-1 : k]

	ans := ""
	for _, sr := range s {
		ss := string(sr)
		if ss == x {
			ans += ss
		} else {
			ans += "*"
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
program ABC_076_B_AdditionandMultiplication
   implicit none
   integer N, K, countN, i
   read(*, *) N, K
   countN = 1
   do i = 1, N
       if(countN * 2 <= countN + K) then
	       countN = countN * 2
	   else
	       countN = countN + K
	   end if
   end do
   write(*, *) countN
end program ABC_076_B_AdditionandMultiplication

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class Program
{
    static void Main(string[] args)
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        //入力
        long n = long.Parse(Console.ReadLine());
        var dictionary = new Dictionary<string, int>();
        for(var i = 0; i < n; i++){
          var str = Console.ReadLine();
          if(dictionary.ContainsKey(str)){
            dictionary[str]++;
          }else{
            dictionary.Add(str, 1);
          }
        }
        var max = dictionary.Values.Max();

        var list3 = dictionary.Where(v => v.Value == max).Select(e => e.Key).ToList();
        list3.Sort(StringComparer.Ordinal);
      
        foreach(var s in list3){
          Console.WriteLine(s);
        }
        Console.Out.Flush();
    }
}


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

main()
{
    int n; cin>>n;
    string s; cin>>s;
    string clst="RGB";
    vector acc(3,vector<int>(n+1));
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<3; ++j)
        {
            acc[j][i+1]=acc[j][i]+(s[i]==clst[j]);
        }
    }
    long long ans=0;
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<i; ++j)
        {
            if(s[i]==s[j])
            {
                continue;
            }
            int ci=clst.find(s[i]);
            int cj=clst.find(s[j]);
            int cmid=3-ci-cj;
            ans+=acc[cmid][i]-acc[cmid][j];
            if((i+j)&1) continue;
            ans-=(s[(i+j)/2]==clst[cmid]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3620
A, B, C, X, Y = [int(i) for i in input().split()]
price = 0
if A + B <= C*2:
    price += A*X+B*Y
else:
    price += C*2*min(X, Y)
    if A <= C*2 and X > Y:
        price += A*(X-Y)
    elif B <= C*2 and X < Y:
        price += B*(Y-X)
    else:
        price += C*2*abs(X-Y)
print(price)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const double pi=3.1415926535898;
int main()
{
    fastio;
    ll n,m;
    cin>>n>>m;
    ll a[m],b[m];
    unordered_map<ll,vector<ll>> pref;
    for(ll i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];
        pref[a[i]].push_back(b[i]);
        pref[b[i]].push_back(a[i]);
    }
    vector<ll> v;
    unordered_map<ll,ll> ok;
    v.push_back(1);
    ok[1]=1;
    ll ind=0;
    while(1)
    {
        ll cur=v[ind];
        for(ll ele:pref[cur])
        {
            if(!ok[ele])
            {
                v.push_back(ele);
                ok[ele]=cur;
            }
        }
        ind++;
        if(v.size()==n||ind==v.size())
        {
            break;
        }
    }
    // for(ll i:v)
    // {
    //     cout<<i<<" ";
    // }
    // cout<<endl;
    if(v.size()!=n)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes\n";
        for(ll i=2;i<=n;i++)
        {
            cout<<ok[i]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 22752
N = int(input())


def Base_10_to_n(X, n):
    # X = 18278; n=26
    X_dumy = X
    out = ''
    while X_dumy > 0:
        a = X_dumy % n
        if a == 0:
            a = 26
            X_dumy -= 1
        out = string[a - 1] + out
        X_dumy = int(X_dumy / n)

    return out


string = 'abcdefghijklmnopqrstuvwxyz'
print(Base_10_to_n(N, 26))


Measured memory_bytes: 61780
#include <algorithm>
#include <bitset>
#include <cassert>
#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 <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (a == b && b == c) {
    cout << -1 << endl;
    return 0;
  }
  ll d = abs(a - b);
  ll e = abs(b - c);
  int k = 0;
  while (true) {
    if ((d & 1LL << k) || (e & 1LL << k)) {
      break;
    }
    k++;
  }
  cout << k << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

int n;
vector<P> b, r;
int ans;
bool used[110];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        r.emplace_back(x, y);
    }
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        b.emplace_back(x, y);
    }
    sort(b.begin(), b.end());
    for(auto &p : b){
        int maxi = -1;
        for (int i = 0; i < n; ++i) {
            if (used[i]) continue;
            if (r[i].first < p.first && r[i].second < p.second){
                if (maxi == -1 || r[i].second > r[maxi].second) maxi = i;
            }
        }
        if (maxi != -1){
            used[maxi] = true;
            ++ans;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

ll dp[3010][3010] = {};
bool checked[3010][3010] = {};

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

    int N;
    cin >> N;
    Vl a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i <= N; ++i) {
        for (int j = i; j <= N; ++j) {
            bool f_Taro = ((N - (j - i)) & 1) == 1;
            if (f_Taro) {
                dp[i][j] = L_INF;
            }
            else {
                dp[i][j] = -L_INF;
            }
        }
    }

    queue<Pii> q;
    for (int i = 0; i <= N; ++i) {
        dp[i][i] = 0;
        checked[i][i] = true;
        q.emplace(i, i);
    }
    while (!q.empty()) {
        int l, r;
        tie(l, r) = q.front();
        q.pop();

        bool f_Taro = ((N - (r - l)) & 1) == 1;

        int nl, nr;
        if (f_Taro) {
            nl = l - 1;
            nr = r;
            if (nl >= 0) {
                dp[nl][nr] = max(dp[nl][nr], dp[l][r] + a[nl]);
                if (!checked[nl][nr]) {
                    checked[nl][nr] = true;
                    q.emplace(nl, nr);
                }
            }

            nl = l;
            nr = r + 1;
            if (nr <= N) {
                dp[nl][nr] = max(dp[nl][nr], dp[l][r] + a[nr - 1]);
                if (!checked[nl][nr]) {
                    checked[nl][nr] = true;
                    q.emplace(nl, nr);
                }
            }
        }
        else {
            nl = l - 1;
            nr = r;
            if (nl >= 0) {
                dp[nl][nr] = min(dp[nl][nr], dp[l][r] - a[nl]);
                if (!checked[nl][nr]) {
                    checked[nl][nr] = true;
                    q.emplace(nl, nr);
                }
            }

            nl = l;
            nr = r + 1;
            if (nr <= N) {
                dp[nl][nr] = min(dp[nl][nr], dp[l][r] - a[nr - 1]);
                if (!checked[nl][nr]) {
                    checked[nl][nr] = true;
                    q.emplace(nl, nr);
                }
            }
        }
    }

    cout << dp[0][N] << endl;

    return 0;
}

Measured memory_bytes: 78464
n=int(input())
s1=list(input())
s2=list(input())
x=-1
if s1[0]==s2[0]:
  ct=3;k=1;p=1
else:
  ct=6;k=2;p=2
for i in range(k,n):
  if x!=i:
    if s1[i]==s2[i]:
      if p==1:
        ct*=2;p=1
      else:
        ct*=1;p=1
    else:
      x=i+1
      if p==1:
        ct*=2;p=2
      else:
        ct*=3;p=2
    ct%=(10**9+7)
print(ct)

Measured memory_bytes: 3064
def is_power(n):
    for p in range(2, 10):
        for b in range(1, 32):
            if b**p == n:
                return True
            if b**p > n:
                break

    return False


x = int(input())
for i in range(x, 0, -1):
    if is_power(i):
        print(i)
        break

Measured memory_bytes: 3060
using System;
class c
{
    static void Main()
    {
        var nab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int n = nab[0], a = nab[1], b = nab[2];
        var s = Console.ReadLine();
        for (int i = 0; i < n; i++)
        {
            if(s[i]=='a'&&(a>0||b>0))
            {
                Console.WriteLine("Yes");
                if (a > 0) a--;
                else b--;
            }
            else if(s[i]=='b'&&b>0)
            {
                Console.WriteLine("Yes");
                b--;
            }
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 15548
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        for(;;){
                int x,y;
                scanf("%d %d",&x,&y);
                if(x==0 && y==0){
                        break;
                }else{
                        if(x>y){
                                printf("%d %d\n",y,x);
                        }else{
                                printf("%d %d\n",x,y);
                        }
                }
        }
        return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
 
int main(void){
	char s[100005];
	cin>>s;
	int ans0=0;
	int ans1=0;
	int i=0;
	while(true){
		if(s[i] == '\0'){
			break;
		}
		if(s[i] == '0'){
			ans0++;
		}
		if(s[i]=='1'){
			ans1++;
		}
		i++;
	}
	cout<<min(ans0,ans1)*2<<endl;
	return 0;
}

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

int n;
vector<int> t(4*500005, 0);
string s;
void build(int v, int tl, int tr) {
    if (tl == tr) {
        // t[v] = a[tl];
        t[v] = 1 << (s[tl] - 'a');
    } else {
        int tm = (tl + tr) / 2;
        build(v*2, tl, tm);
        build(v*2+1, tm+1, tr);
        t[v] = t[v*2] | t[v*2+1];
    }
}
int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           | sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}
void update(int v, int tl, int tr, int pos, char new_val) {
    if (tl == tr) {
    	t[v] = 1 << (new_val - 'a');
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = t[v*2] | t[v*2+1];
    }
}

int main() {
	cin >> n >> s;
	build(1, 0, n-1);
	int q;
	cin >> q;
	while(q--) {
		int ty;
		cin >> ty;
		if(ty == 1) {
			int pos;
			char c;
			cin >> pos >> c;
			--pos;
			update(1, 0, n-1, pos, c);
		}
		else {
			int l, r;
			cin >> l >> r;
			--l; --r;
			int ans = sum(1, 0, n-1, l, r);
			cout << __builtin_popcount(ans) << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 8708
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

struct Process {
    string name;
    int time;
    
    Process (string name, int time) : name(name), time(time) {
    }
    
    
};

void printQueue(queue<Process>&q) {
    while(!q.empty()) {
        Process front = q.front();
        cout << front.name << " " << front.time << endl;
        q.pop();
    }
}

void solve(queue<Process>&q, int qt) {
    int ct = 0;
    while(!q.empty()) {
        Process front = q.front();
        q.pop();
        int time = front.time;
        if (time <= qt) {
            ct += time;
            cout << front.name << " " << ct << endl;
        }
        else {
            ct += qt;
            front.time -= qt;
            q.push(front);
        }
    }
}

int main() {
    int n, qt;
    cin >> n >> qt;
    queue<Process> q;
    for (int i = 0; i < n; i++) {
        string name;
        int time;
        cin >> name >> time;
        q.push(Process(name, time));
    }
    
    //printQueue(q);
    solve(q, qt);
    
    return 0;
}

Measured memory_bytes: 6252
#include <stdio.h>
#include <string.h>
struct node{
    int v,s;//v点，到起点的?数 
}q[110]; 
int n,a[110][110],vis[110],head,tail,step[110];//step[]??各点?数 
void breadth(){
    int u,v;
    head=tail=1;
    vis[1]=1;//3 漏了?句 
    q[head].v=1;
    q[head].s=0;
    step[1]=0;
    tail++;
    while(head<tail){
        u=q[head].v;
        for(v=1;v<=n;v++)
            if(vis[v]==0&&a[u][v]){
                vis[v]=1;//2 漏了?句 
                q[tail].v=v;
                q[tail].s=q[head].s+1;//1 ?句写成  q[tail].s+=1;
                step[v]=q[tail].s;
                tail++;
            }
        head++;
    }
}
int main(){
    int u,k,v,i,j;
    memset(a,0,sizeof(a));
    memset(vis,0,sizeof(vis));
    memset(step,-1,sizeof(step));//3此?写成 memset(step,0,sizeof(step)); 即无路可?，需要?出-1，
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&u,&k);
        for(j=1;j<=k;j++){//4 此?写成 for(j=1;j<=n;j++) 大失水准，?句，?了10分?。 
            scanf("%d",&v);
            a[u][v]=1;
        }
    }
    breadth();
    for(i=1;i<=n;i++)
        printf("%d %d\n",i,step[i]);
    return 0;
}

Measured memory_bytes: 1900
#input
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))


count = {}
for i in range(n):
    if a[i] not in count:
        count[a[i]] = 0
    count[a[i]] += 1
ans = 0
value = list(count.values())
value.sort()
for i in range(max(len(value) - k, 0)):
    ans += value[i]
print(ans)


Measured memory_bytes: 33312
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    int a = -1, z = -1;
    for (int i = 0; i < s.length(); i++) {
        if (a == -1 && s[i] == 'A') {
            a = i;
        }else if (s[i] == 'Z'){
            z = i;
        }
    }
    cout << z - a + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define sz(x) (int) (x).size()
#define INF 0x3f3f3f3f
#define pb push_back

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;

const int N = 100005;
const int mod = 1000000007;

int n, v[N];
int memo[N];

int solve(int pos) {
    if (pos == n - 1) return 0;
    int &ans = memo[pos];
    if (ans != -1) return ans;
    ans = solve(pos + 1) + abs(v[pos + 1] - v[pos]);
    if (pos < n - 2)
        ans = min(ans, solve(pos + 2) + abs(v[pos + 2] - v[pos]));
    return ans;
}

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

    int n;
    cin >> n;
    vector<int> dp(n, INF);
    for (int i = 0; i < n; i++) cin >> v[i];
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout << dp[n - 1] << "\n";

    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 4032
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 2e5+5, OO = 0x3f3f3f3f;
//int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Directio
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class BUnhappyHackingABCEdit {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s;
        in >> s;
        string ans = "";
        for(int i = 0; i < s.size(); ++i) {
            if (s[i] != 'B') ans += s[i];
            else {
                if (ans.size() == 0) continue;
                else ans.pop_back();
            }
        }
        out << ans << el;
	}
};


int main() {
	BUnhappyHackingABCEdit solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi; ///VECTOR<VECTOR<INT>NAME>NAME 2
typedef vector<vl> vvl;///LONG LONG
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;///VECTOR WITH PAIR
typedef vector<pll> vll;
typedef double dl;

#define endl "\n"
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define over return 0;

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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


///--------> YOUR JOURNEY STARTS HERE <-------



int main(){

int SUN=7;
int SAT=1;
int MON=6;
int TUE=5;
int WED=4;
int THU=3;
int FRI=2;

string h;
cin>>h;
if(h=="SUN"){


cout<<7<<endl;
}
else if(h=="SAT"){
    cout<<1<<endl;
}
else if(h=="MON"){
    cout<<6<<endl;
}
else if(h=="TUE"){
    cout<<5<<endl;
}

else if(h=="WED"){
    cout<<4<<endl;
}

else if(h=="THU"){
    cout<<3<<endl;
}


else if(h=="FRI"){
    cout<<2<<endl;
}




over
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<math.h>
#include<sstream>
using namespace std;
int main(){
int n;
cin >>n;
int a[110];

for(int i=0; i<n;i++)
cin >>a[i];

sort(a,a+n);

int alice=0;
int bob=0;
for(int i=0;i<=(n+1)/2;i++){
  if(n-1-2*i>=0) alice+=a[n-1-2*i];
  else break;
  if(n-1-(2*i+1)>=0)bob+=a[n-1-(2*i+1)];
  else break;
}
cout<<alice-bob<<endl;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeMap;

class Main {
	public static void main(String args[]) {
		StringBuilder sb = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		TreeMap<Integer, Integer> tm = new TreeMap<>(Comparator.reverseOrder());
		int a;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			if (tm.containsKey(a)) {
				tm.put(a, tm.get(a) + 1);
			} else {
				tm.put(a, 1);
			}
		}

		int b, c;
		for (int i = 0; i < m; i++) {
			b = sc.nextInt();
			c = sc.nextInt();
			if (tm.containsKey(c)) {
				tm.put(c, tm.get(c) + b);
			} else {
				tm.put(c, b);
			}
		}
		long ans = 0;
		for (int i : tm.keySet()) {
			if (n - tm.get(i) > 0) {
				ans += (long) i * tm.get(i);
				n -= tm.get(i);
			} else {
				ans += (long) i * n;
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 109132
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> b(n-1);
    for(int i = 0; i < n-1; i++){
        cin >> b[i];
    }
    vector <int> a(n);
    for(int i = 1; i < n-1; i++){
        a[i]=min(b[i-1],b[i]);
    }
    a[0]=b[0];
    a[n-1]=b.back();
    long ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        int s1 = n / 6, s2 = n / 9;
        int[] TS = new int[n + 1];
        int[] TN = new int[n + 1];
        for (int i = 0; i <= n; i++) {
            int temp = i;
            while (temp / 6 > 0) {
                TS[i] += temp % 6;
                temp /= 6;
            }
            TS[i] += temp;
            temp = i;
            while (temp / 9 > 0) {
                TN[i] += temp % 9;
                temp /= 9;
            }
            TN[i] += temp;
        }
        for (int i = 0; i <= s1; i++) {
            int six = 6 * i;
            int nine = (n - six) - (n - six) % 9;
            if (six + nine <= n && six <= n && nine <= n) ans = min(ans, TS[six] + TN[nine] + (n - six - nine));
        }
        out.println(ans);
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint inf = 1e18;
struct edge { int to; lint cost; edge(int to, lint cost) : to(to), cost(cost) {} };

template<class T> V<T> dijkstra(int s, const VV<edge>& g) {
  V<T> d(g.size(), inf);
  using P = pair<T, int>;
  priority_queue<P, V<P>, greater<P> > pq;
  pq.emplace(d[s] = 0, s);
  while (!pq.empty()) {
    T dv; int v; tie(dv, v) = pq.top(); pq.pop();
    if (dv > d[v]) continue;
    for (auto&& e : g[v]) {
      if (d[e.to] <= d[v] + e.cost) continue;
      pq.emplace(d[e.to] = d[v] + e.cost, e.to);
    } 
  }
  return d;
}

const lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m, s, t; cin >> n >> m >> s >> t, s--, t--;
  VV<edge> g(n);
  for (int i = 0; i < m; i++) {
    int u, v, d; cin >> u >> v >> d, u--, v--;
    g[u].emplace_back(v, d);
    g[v].emplace_back(u, d);
  }
  V<lint> ds = dijkstra<lint>(s, g), dt = dijkstra<lint>(t, g);
  V<> vs;
  for (int i = 0; i < n; i++) if (ds[i] + dt[i] == ds[t] and ds[i] == dt[i]) vs.push_back(i);
  V< pair<int, int> > ps;
  for (int i = 0; i < n; i++) for (auto&& e : g[i]) if (ds[i] < ds[e.to] and 2 * ds[i] < ds[t] and 2 * dt[e.to] < ds[t] and ds[i] + e.cost + dt[e.to] == ds[t]) ps.emplace_back(i, e.to);
  auto f = [&](int s, const V<lint>& d) {
    V<lint> dp(n);
    V< pair<lint, int> > a(n);
    for (int i = 0; i < n; i++) a[i] = {d[i], i};
    sort(a.begin(), a.end());
    dp[s] = 1;
    for (int i = 0; i < n; i++) for (auto&& e : g[a[i].second]) if (d[a[i].second] + e.cost == d[e.to]) (dp[e.to] += dp[a[i].second]) %= mod;
    return dp;
  };
  auto dps = f(s, ds), dpt = f(t, dt);
  lint res = dps[t] * dpt[s] % mod;
  for (int v : vs) (res -= dps[v] * dps[v] % mod * dpt[v] % mod * dpt[v]) %= mod;
  for (auto&& p : ps) (res -= dps[p.first] * dps[p.first] % mod * dpt[p.second] % mod * dpt[p.second]) %= mod;
  cout << emod(res) << '\n';
}

Measured memory_bytes: 18596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e2+20;
const int inf=1e5;
int n,A,B;
int dp[45][N][N];//dp[i][a][b] Ç°i¼þ ²ÄÁÏÎª[a,b]Ê±µÄ×îÐ¡¼ÛÇ® 
struct node{
	int a,b,c;
}p[N];
bool cmp(node a,node b)
{
	if(a.a==b.a)
	{
		if(a.b==b.b)
		return a.c<b.c;
		else
		return a.b<b.b;
	}
	return a.a<b.a;
}
int gcd(int a,int b)
{
	if(b==0)
	return a;
	else
	return gcd(b,a%b);
}
int main()
{
	while(cin>>n>>A>>B)
	{
		int ans=1e5;
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=400;j++)
			{
				for(int k=0;k<=400;k++)
				dp[i][j][k]=inf;
			}
		}
		dp[0][0][0]=0;
		for(int i=1;i<=n;i++)
		{
			cin>>p[i].a>>p[i].b>>p[i].c;
		}
		sort(p+1,p+1+n,cmp);
		for(int i=1;i<=n;i++)
		{
			dp[i][0][0]=0;
			for(int j=1;j<=400;j++)
			{
				for(int k=1;k<=400;k++)
				{
					if(j>=p[i].a&&k>=p[i].b)
						dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-p[i].a][k-p[i].b]+p[i].c);
					else
						dp[i][j][k]=dp[i-1][j][k];	
					
					int d=gcd(j,k);
					if(j/d==A&&k/d==B)
					{
						ans=min(ans,dp[i][j][k]);
					}
				}	
			}	
		}
		if(ans==1e5)
		ans=-1;
		
		cout<<ans<<endl;
	}
	return 0;	
}

Measured memory_bytes: 28800
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  ll ans = 0LL;
  int cnt = 0;
  for(int i=0;i<N;i++){
    if(s[i] == 'B'){
      ans += N - 1 - i;
      cnt++;
    }
  }

  for(int i=0;i<cnt;i++){
    ans -= i;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		Dice dice = new Dice(input());
		dice.roll(input());
		System.out.println(dice.getTop());

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

class Dice {

	private int top;
	private int front;
	private int right;
	private int left;
	private int back;
	private int bottom;

	public Dice (String num) {

		String[] partsNum = num.split(" ");

		top = Integer.parseInt(partsNum[0]);
		front = Integer.parseInt(partsNum[1]);
		right = Integer.parseInt(partsNum[2]);
		left = Integer.parseInt(partsNum[3]);
		back = Integer.parseInt(partsNum[4]);
		bottom = Integer.parseInt(partsNum[5]);

	}

	public void roll(String direction) {

		int temp;

		for (int i = 0; i < direction.length(); i++) {

			switch (direction.charAt(i)) {

			case 'E':

				temp = top;
				top = left;
				left = bottom;
				bottom = right;
				right = temp;
				break;

			case 'N':

				temp = top;
				top = front;
				front = bottom;
				bottom = back;
				back = temp;
				break;

			case 'S':

				temp = top;
				top = back;
				back = bottom;
				bottom = front;
				front = temp;
				break;

			case 'W':

				temp = top;
				top = right;
				right = bottom;
				bottom = left;
				left = temp;
				break;

			}
		}
	}

	public int getTop() {

		return top;

	}
}

Measured memory_bytes: 26212
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char ch[510000];
int dp[510000][27],n,m,r[510000],go[510000][19];
int main(){
	scanf("%s",ch+1);
	n=strlen(ch+1);
	scanf("%d",&m);
	for (int i=n+1;i<=n+10;i++)
		for (int j=0;j<27;j++) dp[i][j]=n+1;
	for (int i=n;i;i--){
		int w=ch[i]-'a'; dp[i][w]=i;
		for (int j=w+1;j<27;j++)
			dp[i][j]=dp[dp[i][j-1]+1][j-1];
		r[i]=dp[i][26];
		for (int j=0;j<w;j++) dp[i][j]=dp[r[i]+1][j];
	}
	for (int i=1;i<=n;i++) go[i][0]=r[i];
	for (int i=n+1;i<=n+10;i++)
		for (int j=0;j<=18;j++) go[i][j]=n+1;
	for (int i=1;i<=n;i++) go[i][0]=r[i];
	for (int j=1;j<=18;j++)
		for (int i=1;i<=n;i++)
			go[i][j]=go[go[i][j-1]+1][j-1];
	for (;m;m--){
		int l,r; scanf("%d%d",&l,&r);
		for (int i=18;i>=0;i--){
			//	cout<<l<<" "<<i<<" "<<go[l][i]<<endl;
			if (go[l][i]<=r){
				l=go[l][i]+1;
			}
		}
		if (l==r+1) printf("Yes\n"); else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 93696
#include<iostream>
#include<algorithm>

using namespace std;

char tyle[30][30]={'0'};

int find_tyle(int i,int j){
  if(tyle[i+1][j]=='.'){
    tyle[i+1][j]='a';
    find_tyle(i+1,j);
  }
  if(tyle[i][j+1]=='.'){
    tyle[i][j+1]='a';
    find_tyle(i,j+1);
  }
  if(tyle[i-1][j]=='.'){
    tyle[i-1][j]='a';
    find_tyle(i-1,j);
  }
  if(tyle[i][j-1]=='.'){
    tyle[i][j-1]='a';
    find_tyle(i,j-1);
  }
}

int main(){
  
  int w,h;
  
  while(cin>>w>>h,w){
    int ans=0;
    for(int i=1;i<=h;++i){
      for(int j=1;j<=w;++j){
      cin>>tyle[i][j];
      }
    }
    for(int i=1;i<=h;++i){
      for(int j=1;j<=w;++j){
	if(tyle[i][j]=='@'){
	  find_tyle(i,j);
	  tyle[i][j]='a';
	}
      }
    }
    for(int i=1;i<=h;++i){
      for(int j=1;j<=w;++j){
	if(tyle[i][j]=='a'){
	  ans++;
      }
    }
  }
    cout<<ans<<endl;

   for(int i=0;i<30;++i){
      for(int j=0;j<30;++j){
      tyle[i][j]='0';
      }
    }
    
  }
}

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

using namespace std;

const int INF = 0x0fffffff;

int N;
int K;

typedef pair<int, int> ii;

vector< vector<int> > M;
vector<bool> V; // visited

vector<ii> R; // range

const ii inf = make_pair(-INF, INF);
const ii fail = make_pair(INF, -INF);

ii dfs(int i) {
    if (V[i]) {
        return inf;
    }

    V[i] = true;

    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i

        ii rv = dfs(ni);

        if (rv == make_pair(-INF-1, INF+1)) {
            rv = inf;
        }

        if (rv == fail) {
            return fail;
        } else if (R[i] == inf){
            R[i] = rv;
        } else if (rv == inf) {
            continue;
        } else if (R[i].first % 2 != rv.first % 2) {
            return fail;
        //} else if (R[i].second < rv.first) {
        //    return fail;
        //} else if (rv.second < R[i].first) {
        //    return fail;
        } else {
            R[i].second = min(R[i].second, rv.second);
            R[i].first  = max(R[i].first, rv.first);
        }
    }

    if (R[i].second < R[i].first) {
        return fail;
    }

    return make_pair(R[i].first-1, R[i].second+1);
}

void dfs2(int i) {
    if (V[i]) {
        return;
    } 

    V[i] = true;

    R[i] = make_pair(R[i].first, R[i].first);
    
    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i
        
        if (V[ni]) {
            continue;
        }

        R[ni] = make_pair(max(R[ni].first, R[i].first-1), min(R[ni].second, R[i].second+1));

        dfs2(ni);
    }
}

int main(int argc, char* argv[]) {
    // for cin
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;

    M.resize(N);

    for (int i = 0; i < N; ++i) {
        M[i].clear();
    }

    for (int i = 0; i < N-1; ++i) {
        int a;
        int b;

        cin >> a >> b;
        a--;
        b--;

        M[a].push_back(b);
        M[b].push_back(a);
    }

    V.resize(N);
    fill(V.begin(), V.end(), false);

    R.resize(N);
    fill(R.begin(), R.end(), inf);

    cin >> K;

    for (int i = 0; i < K; ++i) {
        int v;
        int p;

        cin >> v >> p;
        v--;

        R[v] = make_pair(p, p);
    }

    ii rv = dfs(0);

    if (rv == fail) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    fill(V.begin(), V.end(), false);

    dfs2(0);

    for (int i = 0; i < N; ++i) {
        printf("%d\n", R[i].first);
    }

    return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <ctime>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <queue>
#include <deque>
#include <climits>
#include <cstring>
#include <random>
#include <bitset>

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    #ifdef LOCAL
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    
    int n, k;
    cin >> n >> k;
    int res = 0;
    if (k % 2 == 0) {
        int cnt = 0;
        if (n % k >= k / 2) {
            cnt = (n + k - 1) / k;
        } else {
            cnt = (n) / k;
        }
        res += cnt * cnt * cnt;
    }
    int cnt = n / k;
    res += cnt * cnt * cnt;
    cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    int sum = 0;
    cin >> s;
    for (int i = 1 ; i <= 4 ; i++){
        switch (s[i - 1]){
            case '+':
                sum++;
                break;
            case '-':
                sum--;
                break;
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int v[n],c[n];
    rep(i,n){
        cin >> v[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    int ans = 0;
    rep(i,n){
        ans += max(0, v[i] - c[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  int tmp;
  tmp=n/1.08;

  if((int)(tmp*1.08)==n) cout<<tmp;
  else if((int)((tmp+1)*1.08)==n) cout<<tmp+1;
  else cout<<":(";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
int ans[N] = {-1};
void bfs() {
    queue<int> que;
    que.emplace(1);
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (const int &v : G[u]) {
            if (!ans[v]) {
                ans[v] = u;
                que.emplace(v);
            }
        }
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    while (m--) {
        int u, v;
        cin >> u >> v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    bfs();
    bool flag = true;
    for (int i = 2; i <= n; i++)
        if (!ans[i]) {
            flag = false;
            break;
        }
    if (flag) {
        cout << "Yes\n";
        for (int i = 2; i <= n; i++)
            cout << ans[i] << "\n";
    }
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 10412
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

n,m=input_list()
c=[True for _ in range(n+1)]
mod=10**9+7

for _ in range(m):
    num=int(input())
    c[num]=False

fib=[1,1]
if not c[1]:
    fib[1]=0

for i in range(2,n+1):
    if c[i]:
        fib.append((fib[i-1]+fib[i-2])%mod)
    else:
        fib.append(0)


print(fib[-1]%mod)
        




Measured memory_bytes: 8180
use std::io;
use std::str::FromStr;

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn my_sum(n: u64) -> u64 {
    n * (n + 1) / 2
}

fn main() {
    let (n, k) = input_tuple();
    let p_vec = input_vec();    
    let mut prev = 0;
    for i in 0..k {
        prev += p_vec[i as usize];
    }
    let mut max = prev;
    let mut max_idx = 0usize;
    for i in 1..(n-k+1) as usize {
        prev -= p_vec[i - 1];
        prev += p_vec[i + (k - 1)];
        if prev > max {
            max = prev;
            max_idx = i as usize;
        }
    }

    // println!("{}", max_idx);
    let mut ans = 0f64;
    for i in max_idx..max_idx+(k as usize) {
        ans += (p_vec[i] + 1) as f64 / 2f64;
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, m, x = nm()
    arr = []
    for _ in range(n):
        temp = nl()
        arr.append(temp)

    costs = []
    for i in range(2**n):
        binary = bin(i)[2:]
        binary = '0'*(n-len(binary)) + binary
        count = [0]*m
        cost = 0
        for i, num in enumerate(binary):
            if num == '1':
                for j in range(m):
                    count[j] += arr[i][j+1]
                cost += arr[i][0]
        #print(binary, cost)
        flag = True
        for value in count:
            if value < x:
                flag = False
        if flag:
            costs.append(cost)
    if costs == []:
        print(-1)
    else:
        print(min(costs))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9820
#include <iostream>
#include <queue>
#include <vector>

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

    std::vector<std::priority_queue<int>> Qs(n);

    for (int i = 0; i < q; i++) {
        int op, t;
        std::cin >> op >> t;

        if (op == 0) {
            int x;
            std::cin >> x;
            Qs[t].push(x);
        } else if (op == 1) {
            if (!Qs[t].empty()) {
                std::cout << Qs[t].top() << std::endl;
            }
        } else if (op == 2) {
            if (!Qs[t].empty()) {
                Qs[t].pop();
            }
        }
    }
}



Measured memory_bytes: 4064
/*
....................
....................
*/
#include<bits/stdc++.h>
#define ll long long int
#define here cout<<"here\n"
#define pb push_back
#define mp make_pair
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
using namespace std;

const ll mod = 1e9+7;

const int MAX = 100005;


int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll A[n],i,j;
    for(i=0;i<n;i++)
    {
    	cin>>A[i];
    }
    ll dp[n]={0};
    dp[0]=0;
    for(i=1;i<n;i++)
    {
    	ll ans = INT_MAX;
    	for(j=1;j<=min(i,k);j++)
    	{
    		ans = min(ans,dp[i-j]+abs(A[i]-A[i-j]));
    	}
    	// dp[i]=min(dp[i-2]+abs(A[i]-A[i-2]),);
    	dp[i]=ans;
    }
    cout<<dp[n-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 5216
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i=0; i<n; ++i)
		cin >> a[i];

	reverse(a.begin(), a.end());
	
	if(a[0] != 2)
	{
		cout << "-1\n";
		return 0;
	}
	
	ll l=2,r=3;
	for(int i=1; i<n; ++i)
	{
		ll l2 = (l+a[i]-1)/a[i]*a[i];
		ll r2 = r/a[i]*a[i] + a[i]-1;
		if(r2 < l2)
		{
			cout << "-1\n";
			return 0;
		}
		l = l2;
		r = r2;
	}
	
	cout << l << " " << r << "\n";

	return 0;
}


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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> x;
    cout << x+(x*x)+(x*x*x) << endl;
}


Measured memory_bytes: 3528
#include<iostream>
using namespace std;
int main(){
	char n;
	cin>>n;
	for(int c=65;c<=90;c++){
		if(char(c)==n){
			cout<<"A";
		}
	}
	for(int c=97;c<=122;c++){
		if(char(c)==n){
			cout<<"a";
		}
	}
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import static java.lang.System.*;

public class Main {
	
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String S = sc.nextLine();
      String T = sc.nextLine();
      
      if(S.equals(T.substring(0,S.length()))){
        out.println("Yes");
      }
      else{
        out.println("No");
      }
    }
}

Measured memory_bytes: 35660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>

using namespace std;
int n;
int A[108];

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

void solve(){
  for(int i=0;i<n;i++){
    int v=A[i];
    int j;
    for( j=i;j>0&&A[j-1]>v;j--)A[j]=A[j-1];
    A[j]=v;
    for(int k=0;k<n;k++){
      cout<<A[k];
      if(k==n-1) cout<<endl;
      else cout<<' ';
    }
  }
}
int main(){
  input();
  solve();
}

Measured memory_bytes: 3100