akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000000;

ll dp[200005][5];   //0 : zero left, 1 : even left, 2 : odd, 3 : even right, 4 : zero right

int main()
{
    int l;
    cin >> l;
    ll a[200005];
    for(int i = 0; i < l; i++) cin >> a[i];
    for(int i = 0; i < l; i++) for(int j = 0; j < 5; j++) dp[i][j] = INF;
    for(int j = 0; j < 5; j++) dp[0][j] = 0;
    for(int i = 1; i <= l; i++){
        dp[i][0] = dp[i - 1][0] + a[i - 1];
        if(a[i - 1] == 0) dp[i][1] = min(dp[i][0], dp[i - 1][1] + 2);
        else dp[i][1] = min(dp[i][0], dp[i - 1][1] + a[i - 1] % 2);
        dp[i][2] = min(dp[i][1], dp[i - 1][2] + (a[i - 1] + 1) % 2);
        if(a[i - 1] == 0) dp[i][3] = min(dp[i][2], dp[i - 1][3] + 2);
        else dp[i][3] = min(dp[i][2], dp[i - 1][3] + a[i - 1] % 2);
        dp[i][4] = min(dp[i][3], dp[i - 1][4] + a[i - 1]);
    }
    cout << dp[l][4] << endl;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
	
	int[][] dp;
	int INF = 1001001001;

	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	public void solve() {
		Scanner sc = new Scanner(System.in);
		String price = sc.nextLine();
		sc.close();
		int[] priceArr = new int[price.length()+1];
		for(int i = 0; i < price.length(); i++) {
			priceArr[i] = price.charAt(price.length() - 1 - i) - '0';
		}
		priceArr[price.length()] = 0;
		
		dp = new int[priceArr.length+2][2];
		for(int i = 0; i < dp.length ; i++) {
			for(int j = 0; j < 2; j++) {
				dp[i][j] = INF;
			}
		}
		
		dp[0][0] = 0;
		
		for(int i = 0; i < priceArr.length; i++) {
			for(int j = 0; j < 2 ; j++) {
				int digit = priceArr[i];
				digit = digit + j;
				
				if(digit < 10) {
					dp[i+1][0] = Math.min(dp[i+1][0], dp[i][j] + digit);
				}
				if(digit > 0) {
					dp[i+1][1] = Math.min(dp[i+1][1], dp[i][j] + (10 - digit));
				}
			}
		}
		
		System.out.println(dp[price.length()+1][0]);
		
//		int extraPrice = 0;
//		for(int i = price.length() - 1; i >= 0; i--) {
//			if(priceArr[i] >= 10) {
//				if(i == 0) {
//					extraPrice = priceArr[i] / 10;
//					priceArr[i] = priceArr[i] % 10;
//				}else {
//					priceArr[i - 1] += priceArr[i] / 10;
//					priceArr[i] = priceArr[i] % 10;
//				}
//			}
//			if(priceArr[i] >= 6) {
//				kuriageArr[i] = priceArr[i];
//				if(i == 0) {
//					extraPrice += 1;
//					priceArr[i] = 0;
//				}else {
//					priceArr[i] = 0;
//					priceArr[i - 1] += 1;
//				}
//			}
//		}
//		
//		int ans = extraPrice;
//		for(int i = 0 ; i < price.length(); i++) {
//			int thisPriceArrValue = priceArr[i];
////			int thisPrice = price.charAt(i) - '0';
//			if(kuriageArr[i] > 0) {
//				ans = ans + 10 - kuriageArr[i];
//			}
//			ans += thisPriceArrValue;
// 		}
//		System.out.println(ans);
	}
}


Measured memory_bytes: 66320
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>

using namespace std;

int print_vec(const vector<int>& v)
{
	for (int i = 0; i < v.size(); i++){
		printf("%d%c", v[i], " \n"[i == v.size() - 1]);
	}
	return 0;
}

int main()
{
	map<string, vector<int> > dict;
	string word;
	int page;
	while (cin >> word >> page){
		if (!dict.count(word)){
			vector<int> v;
			v.push_back(page);
			dict[word] = v;
		}
		else dict[word].push_back(page);
	}
	for (map<string, vector<int> >::iterator it = dict.begin(); it != dict.end(); ++it){
		sort(it->second.begin(), it->second.end());
		cout << it->first << "\n";
		print_vec(it->second);
	}
}

Measured memory_bytes: 1256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

class Program
{
   

    static void Main(string[] args)
    {
        int n = crI();
        var arr = arrInt();
        long sum = 0;
        for(int i = 1; i < n; i++)
        {
            if(arr[i-1] > arr[i])
            {
                sum += (arr[i - 1] - arr[i]);
                arr[i] = arr[i - 1];
            }
        }
        Console.WriteLine(sum);
        
    }

   
   

    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }
}

Measured memory_bytes: 46964
#include <bits/stdc++.h>
using namespace std;
// define
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...)                                 \
  GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
  (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...)                                    \
  GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
  (__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a)-1, n, d, >=)

#define repc(...)                                    \
  GET_MACRO(__VA_ARGS__, repc4, repc3, repc2, repc1) \
  (__VA_ARGS__)
#define repc1(n) repc2(_, n)
#define repc2(i, n) repc3(i, 0, n)
#define repc3(i, a, n) repc4(i, a, n, 1)
#define repc4(i, a, n, d) rep5(i, a, n, d, <=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
// func
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

void solve()
{
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  vcin(l, r);

  cout << max(*min_element(r.begin(), r.end()) - *max_element(l.begin(), l.end()) + 1, 0) << endl;
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}


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

int H, W;
char S[105][105];

std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int>>, std::greater<std::tuple<int, int, int>>> pq;
int dist[105][105];

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

int main () {
    scanf("%d%d", &H, &W);
    for(int i = 0; i < H; i++) {
        scanf("%s", S[i]);
        for(int j = 0; j < W; j++) {
            dist[i][j] = 1e9;
        }
    }

    dist[0][0] = (S[0][0] == '#');
    pq.emplace(dist[0][0], 0, 0);
    
    while(!pq.empty()) {
        int _d, x, y; std::tie(_d, x, y) = pq.top(); pq.pop();
        if(dist[x][y] != _d) continue;
        if(x == H-1 && y == W-1) {
            printf("%d\n", _d);
            return 0;
        }
        for(int d = 0; d < 2; d++) {
            int nx = x + dx[d], ny = y + dy[d];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            int nv = dist[x][y] + (S[nx][ny] != S[x][y] && S[nx][ny] == '#');
            if(dist[nx][ny] > nv) {
                dist[nx][ny] = nv;
                pq.emplace(nv, nx, ny);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int main()
{
	string input;
	string ans;
	int num;	//繰り返しの回数
	
	while (cin >> input)
	{
		ans = "";
		for (int i=0; i<input.length(); i++)
		{
			if (input[i] == '@')
			{
				num = (int)input[i+1] - 48;
				//cout << "num = " << num << endl;
				for (int j=0; j<num; j++)
				{
					ans += input[i+2];
				}
				i += 2;
			} else {
				ans += input[i];
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include <stdio.h>
using namespace std;
  
int main(){
	int a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	int e=a*p;
	int f;
	int g=d*(p-c);
	if(c>p){
		f=b;}else{
		f=b+g;}
		if(f>e){
			cout<<e<<endl;}else{
			cout<<f<<endl;}
	return 0;}


Measured memory_bytes: 1160
#include <cstdint>
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

using namespace std;

int64_t cnt[60];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int64_t a;
    scanf("%lld", &a);
    for (int j = 0; j < 60; j++) {
      if (a & (1ll << j)) {
        cnt[j]++;
      }
    }
  }
  int64_t ans = 0;
  for (int i = 0; i < 60; i++) {
    ans += ((1ll << i) % 1000000007) * (cnt[i] * (n - cnt[i]) % 1000000007);
    ans %= 1000000007;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(b-a == c-b){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 23892
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int A, B;
        cin >> A >> B;
        if (A%2==0||B%2==0)
        {
                cout << "No" << endl;
        }else{
                cout << "Yes" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int cnt[110];


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=0;
  for(int i=a;i<b;i++)cnt[i]++;
  for(int i=c;i<d;i++)cnt[i]++;
  for(int i=0;i<102;i++){
     if(cnt[i]>=2)ans++;
  } 
  cout<<ans<<endl;
}

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


int main(){
    int h,w,c[10][10];
    long long int ans=0;
    cin>>h>>w;
    for(int i=0; i<10; i++) {
        for(int j=0; j<10; j++) {
            cin>>c[i][j];
        }
    }

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                c[j][k]=min(c[j][k],c[j][i]+c[i][k]);
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin>>a;
            if(a!=1&&a!=-1) ans+=c[a][1];
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; ++i)  cin >> s[i];

    int ans = 0;
    for(int sx = 0; sx < h; ++sx){
        for(int sy = 0; sy < w; ++sy){
            if(s[sx][sy] == '#')    continue;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            queue<P> que;
            que.emplace(sx, sy);
            dist[sx][sy] = 0;
            while(!que.empty()){
                P p = que.front();
                que.pop();
                int x = p.first, y = p.second;
                for(int i = 0; i < 4; ++i){
                    int nx = x + dx[i], ny = y + dy[i];
                    if(nx < 0 || nx >= h || ny < 0 || ny >= w)  continue;
                    if(s[nx][ny] == '#')    continue;
                    if(chmin(dist[nx][ny], dist[x][y] + 1)){
                        que.emplace(nx, ny);
                    }
                }
            }
            for(int i = 0; i < h; ++i){
                for(int j = 0; j < w; ++j){
                    if(dist[i][j] == INF)   continue;
                    chmax(ans, dist[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,x;
int c[15],a[15][15];
int X[15];
bool ANS=false;
bool t;
int cnt;
int ans=1000000000;
int main(void){
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(int bit=0;bit<(1<<n);bit++){
		t=true;
		cnt=0;
		for(int i=0;i<m;i++){
			X[i]=0;
		}
		for(int i=0;i<n;i++){
			if(bit&(1<<i)){
				cnt+=c[i];
				for(int j=0;j<m;j++){
					X[j]+=a[i][j];
				}
			}
		}
		for(int i=0;i<m;i++){
			if(X[i]<x){
				t=false;
			}
		}
		if(t){
			ans=min(ans,cnt);
			ANS=true;
		}
	}
	if(ANS){
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
	
}


Measured memory_bytes: 3628
#include<cstdio>

int main(){

	int count[26];
	for(int i = 0;i < 26;i++) {
		count[i] = 0;
	}
	char s[1300];
	while(fgets(s,1300,stdin) != NULL) {
        for(int i = 0;s[i] != '\0';i++) {
            if(s[i] >= 'A' && s[i] <= 'Z') {
                count[s[i] - 'A']++;
            }
            if(s[i] >= 'a' && s[i] <= 'z') {
                count[s[i] - 'a']++;
            }
        }
	}

	for(int i = 0;i < 26;i++) {
		printf("%c : %d\n",'a' + i,count[i]);
	}
	return 0;
}


Measured memory_bytes: 2620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;

int V, E;
vector<pair<int, int> > G[10100];
priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > Q;

int main() {
  cin >> V >> E;

  int visited[V];
  int d[V];
  int p[V];

  REP(i, E) {
    int s, t, w;
    cin >> s >> t >> w;

    G[s].push_back(make_pair(t, w));
    G[t].push_back(make_pair(s, w));
  }
  REP(i, V) {
    visited[i] = 0;
    p[i] = -1;
    d[i] = IINF;
  }


  d[0] = 0;
  Q.push(make_pair(d[0], 0));

  // REP(_, V) {
  while (!Q.empty()) {
    // int mincost = IINF;
    // int minv = -1;
    // REP(v, V) {
    //   if (!visited[v] && d[v] < mincost) {
    //     minv = v;
    //     mincost = d[v];
    //   }
    // }
    int mincost = Q.top().first;
    int minv = Q.top().second;
    Q.pop();
    if (visited[minv]) continue;
    visited[minv] = 1;

    for (vector<pair<int, int> >::iterator it = G[minv].begin(); it != G[minv].end(); it++) {
      int v = it->first;
      int w = it->second;

      if (!visited[v] && w < d[v]) {
        d[v] = w;
        p[v] = minv;
        Q.push(make_pair(d[v], v));
      }
    }
  }

  ll sum = 0;
  REP(i, V) {
    if (p[i] != -1) {
      for (vector<pair<int, int> >::iterator it = G[i].begin(); it != G[i].end(); it++) {
        if (it->first == p[i]) {
          sum += it->second;
          break;
        }
      }
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 6236
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,u,v,tot,dep[N],lg[N],fa[N][20],head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
void dfs(int u,int p)
{
    dep[u]=dep[p]+1;fa[u][0]=p;
    for(int i=1;1<<i<=dep[u];i++)
        fa[u][i]=fa[fa[u][i-1]][i-1];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs(v,u);
    }
}
int LCA(int u,int v)
{
    if(dep[u]<dep[v]) swap(u,v);
    while(dep[u]>dep[v]) u=fa[u][lg[dep[u]-dep[v]]];
    if(u==v) return u;
    for(int i=lg[dep[u]];i>=0;i--)
        if(fa[u][i]!=fa[v][i])
        u=fa[u][i],v=fa[v][i];
    return fa[u][0];
}
int DIS(int u,int v)
{
    return dep[u]+dep[v]-2*dep[LCA(u,v)];
}
int main()
{
    for(int i=1;i<N;i++) lg[i]=lg[i-1]+(1<<lg[i-1]==i);
    for(int i=1;i<N;i++) lg[i]--;
    scanf("%d%d%d",&n,&u,&v);
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    dfs(1,0);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(DIS(u,i)>DIS(v,i)) continue;
        ans=max(ans,DIS(v,i)-1);
    }
    cout<<ans;
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, K, C;
    cin >> N >> K >> C;

    string s;
    cin >> s;

    vector<int> L(K);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'o') {
            L[cnt] = i;
            cnt++;
            
            i += C;
            //cout << i << endl;
        }
        if (cnt == K)
            break;
    }

    vector<int> R(K);
    cnt = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (s[i] == 'o') {
            R[cnt] = i;
            cnt++;
            i -= C;
        }
        if (cnt == K)
            break;
    }

    for (int i = 0; i < K; i++) {
        //printf("L[%d]=%d R[%d]=%d\n", i, L[i], K - 1 - i, R[K - 1 - i]);
        if (L[i] == R[K - 1 - i])
            cout << L[i]+1 << endl;
    }
}

Measured memory_bytes: 3332
N, T = gets.strip.split.map(&:to_i)
t = gets.strip.split.map(&:to_i)

result = 0;

(1..N-1).to_a.each do |index|
  current_diff = t[index]-t[index-1]
  if current_diff > T
    result += T
  else
    result += current_diff
  end
end

result += T

p result


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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        cin>>l>>r;
        ll tt=r;
        ll t1=(r-l+1)/2019;
        if(t1){
                cout<<0<<endl;
                return;
        }
        ll ans=1e9;
        for(i=l;i<=r;i++){
                for(j=i+1;j<=r;j++){
                        ans=min(ans,(i*j)%2019);
                }
        }
        cout<<ans<<endl;
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3512
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  string A;
  int c = 0;
  for(int i = 0; i < H; ++i){
    cin >> A;
    for(int j = 0; j < W; ++j){
      if(A[j] == '#') ++c;
    }
  }
  if(c == H+W-1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 02-Aug-2020 18:06:52
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void INT(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void INT(T &x, W &y) {INT(x), INT(y);}
template <TN T, TN W, TN Q> inline void INT(T &x, W &y, Q &z) {INT(x, y), INT(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    int n; cin >> n;
    int rem = 0, to = 1000 * 1000 * 10;
    vector<bool> gotBefore(n, false);
    for (int i = 1; i <= to; ++i) {
        rem = rem * 10 + 7;
        rem %= n;
        if (rem == 0) {
            return printf("%d\n", i);
        }
        if (gotBefore[rem]) {
            return printf("-1\n");
        }
        gotBefore[rem] = true;
    }

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // INT(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  int N,M;
  cin>>N>>M;
  int X[M];
  for(int i=0;i<M;i++){
    cin>>X[i];
  }
  
  sort(X,X+M);
  
  int Y[M-1];
  for(int i=0;i<M-1;i++){
    Y[i]=X[i+1]-X[i];
  }
  sort(Y,Y+M-1);
  int xx=M-N;
  
  int sum=0;
  for(int i=0;i<xx;i++){
    sum+=Y[i];
  }
  cout<<sum<<endl;
  







  


}


  
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 5010;
int N,K;
ll v[N_MAX];

//v[index]を使わずにk-v[index]<= Sum < kとなる挿話が作れるならfalse
bool isNoNeed(int index){
  //i枚目まで使った時にjにできるか
  //trueできる，falseできない
  bool dp[N+1][K];
  rep(i,N+1) rep(j,K) dp[i][j] = false;
  dp[0][0] = true;
  rep(i,N){
    rep(j,K){
      dp[i+1][j] = dp[i][j];
      if(i==index)continue;
      if(j-v[i]>=0 && dp[i][j-v[i]]){
        if(j>=K-v[index]) return false;
        dp[i+1][j] = true;
      }
    }
  }
  return true;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int n;cin >> n >> K;
  N=0;
  rep(i,n){
    int x;cin >> x;
    if(x>=K)continue;
    else v[N++]=x;
  }
  sort(v,v+N);
  int l = 0, r=N;
  if(!isNoNeed(l)){
    cout << 0 << endl;
    return 0;
  }
  while(r-l>1){
    int m = (r+l)/2;
    bool isnoneed = isNoNeed(m);
    if(isnoneed) l = m;
    else r = m;
  }
  cout << r << endl;
  return 0;
}



Measured memory_bytes: 24704
s = input()

n = len(s)
ans = 0
s0 = s[0]
lastI = 0

if len(list(set(s))) == 1:
    print(0)
    exit()

for i in range(1, n-1):
    # print(s0)
    # print(s[i])
    # print(s[i+1])
    # print("----------")
    if s[i] != s0 and s[i+1] == s0:
        ans += 2
        lastI = i+1

if lastI != n-1 and s0 != s[-1]:
    ans += 1

print(ans)

Measured memory_bytes: 3188
import numpy as np

N, M = (int(i) for i in input().split())

A = []
B = []
for i in range(N):
    tmp = [int(i) for i in input().split()]
    A.append(tmp[0])
    B.append(tmp[1])

idx = np.argsort(A)
A = np.array(A)[idx]
B = np.array(B)[idx]

buy_cnt = 0
cost = 0
for m in range(N):
    buy = B[m]
    if buy_cnt + buy > M:
        buy = M - buy_cnt
    
    buy_cnt += buy
    cost += buy*A[m]

    if buy_cnt == M:
        break

print(cost)

Measured memory_bytes: 22300
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vvi g;
vi dp;

bool ff(vi& a,int I,int L){
	int N=a.size();
	bool B=1;
	for(int i=0;i<(N-1)/2;i++) if(a[(i<I?i:i+1)]+a[(N-i-1>I?N-i-1:N-i-2)]>L) B=0;
	return B;
}

bool f(int v,int p,int L){
	bool B=1;
	vi a;
	for(auto u:g[v]) if(u!=p){
		B&=f(u,v,L)&&dp[u]!=L;
		a.push_back(dp[u]+1);
	}
	if(!B) return 0;
	sort(a.begin(),a.end());
	int N=a.size();
	if(N%2==0){
		for(int i=0;i<N/2;i++) if(a[i]+a[N-i-1]>L) B=0;
		if(B) return 1;
		a.pop_back();
		N--;
	}
	int l=-1,r=N;
	while(r-l>1){
		int m=(l+r)/2;
		if(ff(a,m,L)) r=m;
		else l=m;
	}
	if(r==N) return 0;
	dp[v]=a[r];
	return 1;
}

int main(){
	cin>>n;
	g=vvi(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int A=0,v,l=0,r=n-1;
	for(int i=0;i<n;i++){
		int S=g[i].size();
		A+=S%2;
		if(S==1) v=i;
	}
	A/=2;
	while(r-l>1){
		dp=vi(n);
		int m=(l+r)/2;
		if(f(v,-1,m)) r=m;
		else l=m;
	}
	dp=vi(n);
	cout<<A<<' '<<r<<endl;
}

Measured memory_bytes: 19056
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double dis = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
	printf("%.6f", dis);
	char c;
	cin >> c;
}

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

void  GoodInt(int n){

int a,b,c,d;
 a=n/1000;
 b=(n/100)%10;
 c=(n/10)%10;
 d=n%10;

 if(a==b&&b==c||b==c&&c==d||a==b&&b==c&&c==d) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;



}


int main(){

  int n;

cin>>n;
 GoodInt(n);

return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())  
B = np.array(input().split(), dtype=np.int64)

ans = 0
ans += B[0] + B[N-2]

for i in np.arange(N-2):
    ans += np.min(np.array([B[i], B[i+1]]))
    
print(int(ans))

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t; cin >> s >> t;
	int ans = 1001;
	int k1 = s.size(), k2 = t.size();
	for(int i = 0; i <= k1 - k2; i++){
		int c = 0;
		for(int j = i; j < i + k2; j++){
			c += (s[j] != t[j - i]);
		}
		// cout << "C = " << c << '\n';
		ans = min(ans, c);
	}			
	cout << ans << '\n';			
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main() {
	int a, b, w;
	int ans1, ans2;
	cin >> w >> a >> b;

	int c = a + w;
	int d = b + w;

	
	ans1 = b - c;
	ans2 = a - d;
	

	if (c < b) {
		if (ans1 < 0) {
			cout << 0 << endl;
		}
		else {
			cout << ans1 << endl;
		}
	}
	else {
		if (ans2 < 0) {
			cout << 0 << endl;
		}
		else {
			cout << ans2 << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    vector<bool> p(n);
    int tSum = 0;
    int aSum = 0;
    const int apb=a+b;
    for(int i = 0;i < n;i++)
    {
        if(s[i] == 'c')
        {
            p[i] = false;
        }
        else if(s[i] == 'a')
        {
            if(tSum < apb)
            {
                p[i] = true;
                tSum++;
            }
            else
            {
                p[i] = false;
            }
        }
        else
        {
            if(tSum < apb)
            {
                if(aSum < b)
                {
                    p[i] = true;
                    aSum++;
                    tSum++;
                }
                else
                {
                    p[i] = false;
                }
            }
            else
            {
                p[i] = false;
            }
            
        }
    }
    for(auto e : p)
    {
        if(e)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    
}

Measured memory_bytes: 896
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
const long double epsA=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}


int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int i,n,m;cin>>n>>m;
	vector<int>v(n);
	vector<vector<int>>go(n);
	vector<vector<int>>rev(n);
	vector<int>zi(n);
	vector<int>dim(n);//次元的な何か
	for(i=0;i<n;i++){cin>>v[i];}
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;a--;b--;
		go[a].pub(b);
		rev[b].pub(a);
		zi[a]++;
	}
	stack<int>que;
	for(i=0;i<n;i++){if(zi[i]==0){que.push(i);}}
	vector<int>gru(n+1,-1);
	while(que.size()){
		int t=que.top();que.pop();
		for(auto it:go[t]){gru[dim[it]]=t;}
		int bas=0;
		while(gru[bas]==t){bas++;}
		dim[t]=bas;
		for(auto it:rev[t]){
			zi[it]--;
			if(zi[it]==0){que.push(it);}
		}
	}
	vector<int>ans(n);
	for(i=0;i<n;i++){ans[dim[i]]^=v[i];}
	for(i=0;i<n;i++){if(ans[i]>0){cout<<1<<endl;return 0;}}
	cout<<2<<endl;
	return 0;
}



Measured memory_bytes: 3332
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

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

    int N = s.size();
    cout << s.substr(0, N-8) << endl;
    
}

Measured memory_bytes: 256
k,t = map(int,input().split())
a = list(map(int,input().split()))
M = max(a)
if M <= -(-k//2):
    print(0)
else:
    if k % 2 == 0:
        print((M-k//2)*2-1)
    else:
        print((M+1-k//2)*2)

Measured memory_bytes: 3060
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {q:usize}
    let mut med = 0;
    let mut lower = PriorityQueue::new();
    let mut upper = PriorityQueue::new();
    let mut lower_sum = 0;
    let mut upper_sum = 0;
    let mut bsm = 0i64;
    for _ in 0..q {
        input! {t:usize}
        match t {
            1 => {
                input! {a:i64,b:i64}
                bsm += b;
                if lower.is_empty() {
                    lower.push(a);
                } else {
                    if a < med {
                        lower.push(a);
                        lower_sum += med - a;
                    } else {
                        upper.push(a);
                        upper_sum += a - med;
                    }
                }

                while lower.len() < upper.len() || lower.len() > upper.len() + 1 {
                    if lower.len() < upper.len() {
                        let upper_min = *upper.peek_min().unwrap();
                        let diff = upper_min - med;
                        lower_sum += lower.len() as i64 * diff;
                        upper_sum -= upper.len() as i64 * diff;
                        upper.pop_max();
                        lower.push(upper_min);
                    } else {
                        let lower_max = lower.pop_max().unwrap();
                        let diff = med - lower.peek_max().unwrap();
                        upper.push(lower_max);
                        lower_sum -= lower.len() as i64 * diff;
                        upper_sum += upper.len() as i64 * diff;
                    }
                    med = *lower.peek_max().unwrap();
                }
                med = *lower.peek_max().unwrap();
            }
            _ => {
                println!("{} {}", med, bsm + lower_sum + upper_sum);
            }
        }
    }
}

struct PriorityQueue<T: Ord + Copy> {
    que_max: BinaryHeap<T>,
    que_min: BinaryHeap<Reverse<T>>,
}
impl<T: Ord + Copy> PriorityQueue<T> {
    fn new() -> PriorityQueue<T> {
        PriorityQueue {
            que_max: BinaryHeap::<T>::new(),
            que_min: BinaryHeap::<Reverse<T>>::new(),
        }
    }
    fn is_empty(&mut self) -> bool {
        self.que_max.is_empty()
    }
    fn push(&mut self, x: T) {
        self.que_max.push(x);
        self.que_min.push(Reverse(x));
    }
    fn len(&mut self) -> usize {
        self.que_max.len()
    }
    fn pop_max(&mut self) -> Option<T> {
        self.que_min.pop();
        self.que_max.pop()
    }
    fn pop_min(&mut self) -> Option<T> {
        self.que_max.pop();
        if let Some(x) = self.que_min.pop() {
            let Reverse(y) = x;
            Some(y)
        } else {
            None
        }
    }
    fn peek_max(&mut self) -> Option<&T> {
        self.que_max.peek()
    }
    fn peek_min(&mut self) -> Option<&T> {
        if let Some(x) = self.que_min.peek() {
            let Reverse(y) = x;
            Some(y)
        } else {
            None
        }
    }
}


Measured memory_bytes: 10356
using System;
using System.Collections.Generic;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            // get N and Q
            string[] nq = Console.ReadLine().Split(' ');
            int number = Convert.ToInt32(nq[0]) - 1;
            int question = Convert.ToInt32(nq[1]);
            // get string
            string str = Console.ReadLine();
            int[] answer = new int[question];
            Dictionary<int, int> strDic = new Dictionary<int, int>(); // position, accumulate
            int acc = 0;

            for (int i = 0; i < number; i++)
            {
                strDic[i] = acc;
                if (str[i] == 'A' && str[i + 1] == 'C')
                {
                    acc++;
                }
            }
            strDic[number] = acc;

            for (int i = 0; i < question; i++)
            {
                string[] lr = Console.ReadLine().Split(' ');
                int l = Convert.ToInt32(lr[0]) - 1;
                int r = Convert.ToInt32(lr[1]) - 1;

                int count = 0;
                if (l < r && r > 1)
                {
                    count = strDic[r] - strDic[l];
                }
                Console.WriteLine(count);
            }
        }
    }

Measured memory_bytes: 22600
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;
struct ${$(){ios_base::sync_with_stdio(false);cin.tie(NULL);}}$;

typedef long long LL;
const int Maxn = 200005;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    stack <char> temp;

    if(!(s[0] == 'S' && s[1] == 'T')) {
        temp.push(s[0]);
        temp.push(s[1]);
    }
    for(int i = 2; i < n; i++) {
        if(s[i] == 'S')
            temp.push(s[i]);
        else {
            if(temp.empty()) {
                temp.push(s[i]);
            }
            else if(temp.top() == 'S') {
                assert(!temp.empty());
                temp.pop();
            } else {
                temp.push(s[i]);
            }
        }
    }

    int ans = 0;
    while(!temp.empty()) {
        temp.pop();
        ans++;
    }
    cout <<  ans << endl;
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    ll x;
    cin >> x;

    cout << (x/11)*2 + (x%11)/7 + min((x%11), 1LL) << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	//再利用の時はここからけす

		while(true) {
			int getDatax = sc.nextInt();
			int getDatay = sc.nextInt();

			if(getDatax == 0 && getDatay == 0) {
				break;
			}

			if(getDatax > getDatay) {
				System.out.println(getDatay  + " " + getDatax);
			}else {
				System.out.println(getDatax  + " " + getDatay);
			}

		}





	//ここから上を消すこと
	}
}



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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;


signed main(){
	int a,b;
	cin >> a >> b;
	cout << a-min(a,2*b);
}


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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long

using namespace std;

const int MOD = 1000000007;
int modpow(int a, int p){
    if(p == 0){
        return 1;
    }
    int t = modpow(a, p / 2);
    if(p % 2 == 0){
        return t * t % MOD;
    }
    return t * t % MOD * a % MOD;
}
int modinv(int a) { return modpow(a, MOD - 2); }

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);
        if(x != y) {
            if(data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
};

signed main() {
    vector<int> As;
    map<int, int> m;
    int N;
    cin >> N;
    for(auto i = 0LL; i < N; i++){
        int t;
        cin >> t;
        As.push_back(t);
        m[t]++;
    }
    int ans = 0;
    for(auto j = m.begin(); j != m.end(); j++) {
        int t = j->second;
        ans += t * (t - 1) / 2;
    }
    for(auto i = 0LL; i < N; i++){
        int t = m[As[i]];
        if(t != 0)
            t--;
        cout << ans - t << endl;
    }
    return 0;
}

Measured memory_bytes: 11120
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#define F first
#define S second
using namespace std;

int h, w, r, c, v[1005][1005];
char s[1005];
queue<pair<int, int>> qu;

void push(int p, int q, int r) {
	if(!v[p][q]) {
		v[p][q] = r;
		qu.push({p, q});
	}
}

int main() {
	int i, j;
	memset(v, -1, sizeof(v));
	cin >> h >> w;
	for(i=1; i<=h; i++) {
		scanf("%s", &s[1]);
		for(j=1; j<=w; j++) {
			v[i][j] = 0;
			if(s[j]=='#') {
				v[i][j] = 1;
				qu.push({i, j});
			}
		}
	}
	while(!qu.empty()) {
		r = qu.front().F;
		c = qu.front().S;
		qu.pop();
		push(r+1, c, v[r][c]+1);
		push(r-1, c, v[r][c]+1);
		push(r, c+1, v[r][c]+1);
		push(r, c-1, v[r][c]+1);
	}
	cout << v[r][c] - 1;
	return 0;
}


Measured memory_bytes: 12432
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

int abs(int n) {
    return n < 0 ? -n : n;
}

void main() {
    int[] arr = readln.chomp.split.to!(int[]);
    bool flg = false;

    writeln(
        (abs(arr[0] - arr[2]) <= arr[3] || abs(arr[0] - arr[1]) <= arr[3] && abs(arr[1] - arr[2]) <= arr[3]) ? "Yes" : "No"
    );
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b && b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
return 0;
}


Measured memory_bytes: 2140