akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

int N, M, res = 200200;
pair<int, int> p[200200];

int f (int k) {
        priority_queue<pair<int, int>> q;

        int j = N-1, ans = 0;
        for (int i = k; i >= 1; i--) {
                while (j >= 0 && p[j].first >= i) {
                        q.push(MP(p[j].second, j));
                        j--;
                }
                if (q.size()) ans++, q.pop();
        }

        while (j >= 0) {
                q.push(MP(p[j].second, j));
                j--;
        }
        for (int i = M; i > k; i--) {
                while (q.size() && q.top().first > i) q.pop();
                if (q.size()) ans++, q.pop();
        }

        return ans;
}

int main () {
        scanf("%d %d", &N, &M);
        fo(i, 0, N) {
                int x, y; scanf("%d %d", &x, &y);
                p[i] = MP(x, y);
        }
        sort(p, p+N);

        int lo = 0, hi = M-1, mid;
        while (lo <= hi) {
                mid = (lo + hi) / 2;
                int m1 = f(mid), m2 = f(mid+1);
                res = min(res, N - max(m1,m2));
                if (m1 == m2) break;
                else if (m1 < m2) lo = mid+1;
                else if (m1 > m2) hi = mid-1;
        }

        printf("%d\n", res);

        return 0;
}


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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  string s;
  cin >> s;
  bool ok = true;
  
  rep(i, s.size()){
    if(s.at(i)=='h'){
      if((i != s.size()-1) && (s.at(i+1) == 'i')){
        i++;
      }
      else{
        ok = false;
        break;
      }
    }
    else{
      ok = false;
      break;
    }
  }
  
  if(ok == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}




Measured memory_bytes: 256
s = input()
n = len(s)

rev_s = s[::-1]
fs = s[0:(n-1)//2]
rev_fs = fs[::-1]
ls = s[(n+3)//2-1:n]
rev_ls = ls[::-1]

if s == rev_s and fs == rev_fs and ls == rev_ls:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

typedef struct{
  char name[10];
  int time;
} DATA;

void enqueue(char *,int);
DATA dequeue(void);

DATA queue[QSIZE];
int head = 0;
int tail = 0;

int main(){
  int n,qtime,q,i,sam = 0;
  char str[10];
  DATA Via;

  scanf("%d%d",&n,&qtime);

  for(i = 0;i < n;i++){
    scanf("%s %d",str,&q);
    enqueue(str,q);
  }

  while(1){
    Via = dequeue();
    if((Via.time - qtime) <= 0){
      sam += Via.time;
      printf("%s %d\n",Via.name,sam);
    }

    else {
      sam += qtime;
      Via.time -= qtime;
      enqueue(Via.name,Via.time);
    }
    if(head == tail) break;
  }
  return 0;
}

void enqueue(char *str,int q){
  int next = (tail + 1) % QSIZE;

  if(head == next) exit(2);

  strcpy(queue[tail].name,str);
  queue[tail].time = q;

  tail = next;
}

DATA dequeue(){
  DATA Q;

  if(head == tail) exit(3);

  Q = queue[head];

  head = (head + 1) % QSIZE;

  return Q;
}



Measured memory_bytes: 3320
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.TreeMap;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 1; i <= n; i++) {
            map.put(fs.nextInt(), i);
        }

        for (int s : map.keySet()) {
            System.out.println(map.get(s));
        }

    }

}


Measured memory_bytes: 125112
#include<iostream>
using namespace std;
struct task {
	char name[10];
	int time;
};
const int len = 100005;
task* queue = new task[len];
int head = 0;
int tail = 0;
void enqueue(task t) {
	queue[tail++] = t;
	tail %= len;
}
task dequeue() {
	task temp = queue[head];
	head++;
	head %= len;
	return temp;
}
bool isEmpty() {
	return head == tail;
}
int main() {
	int len;
	cin >> len;
	int op;
	cin >> op;
	int clock = 0;
	for (int i = 0; i < len; i++) {
		task temp;
		cin >> temp.name >> temp.time;
		enqueue(temp);
	}
	while(!isEmpty()){
		task temp = dequeue();
		clock += (temp.time <= op) ? temp.time : op;
		if ((temp.time -= op) > 0)
			enqueue(temp);
		else
			cout << temp.name << " " << clock << endl;
	}
	return 0;
}


Measured memory_bytes: 4660
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

def main():
    S = list(input())
    T = list(input())

    ans = 0
    for i in range(len(S)):
        if S[i] == T[i]: continue
        ans += 1
    
    print(ans)





if __name__ == "__main__":
    main()

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D ){
   cout << "Left" << endl; 
  }
  else if (A+B == C+D){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl; 
  }
  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  const double PI = acos(-1);
  int a;
  cin >> a;
  cout << a*2*PI << endl;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    int arr[n+5],ck[n+5],ans;
    vector<int>v(n);
    bool ok=false;
    for(int i=0; i<n; ++i)
    {
        cin>>v[i];
        if(v[i]==x){
            ok=true;
        }
        //ck[i]=arr[i];
    }
    /*for(int i=0;i<n;++i){
        ck[i]=(x-ck[i]);
        //cout<<ck[i];
    }
    int mn=INT_MAX,ans=INT_MAX;
    for(int i=0;i<n;++i){
        mn=min(mn,ck[i]);
    }
    for(int i=0;i<n;++i){
        if(ck[i]==mn){
            ans=min(arr[i],ans);
        }
    }*/
    int z=x,chk=x;
    if(n==0 || ok==false)
    {
        cout<<x;
    }
    else
    {
        while(1)
        {
            auto it= find(v.begin(),v.end(),x-1);
            if(it!=v.end())
            {
                x--;
            }
            auto it2= find(v.begin(),v.end(),z+1);
            if(it2!=v.end())
            {
                z++;
            }
            if(it==v.end() || it2==v.end())
            {
                z++;
                x--;
                int p=z-chk;
                int n=chk-x;
                //cout<<z<<x;
                if(p<n)
                {
                    cout<<z;
                }
                else
                    cout<<x;
                break;
            }
        }

    }
}




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

int main() {
	int A, B;
  	cin >> A >> B;
  	
  	int j = 0;
  	for(int i = A; i <= B ; i++) {
      	int c, d, e, f, g;
    	c = i % 10;//1
      	d = (i % 100 - c) / 10;//10
      	e = (i % 1000 - d * 10 - c) / 100;//100
      	f = (i % 10000 - e * 100- d * 10 - c) / 1000;//1000
      	g = (i - f * 1000 - e * 100 - d * 10 - c)/ 10000;
      
      	if (c == g && d == f) {
        	j +=1;
        }    	
    }
  	cout << j << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    string S;
    cin >> S;
    vector<int> A(4);
    A[0] = S[0] - '0';
    A[1] = S[1] - '0';
    A[2] = S[2] - '0';
    A[3] = S[3] - '0';


    REP(i, 1 << 3) {
        int ans = A[0];
        REP(j, 3) {
            if (i & (1 << j)) {
                ans += A[j + 1];
            }
            else { ans -= A[j + 1]; }
        }
        if (ans == 7) {
            cout << A[0];
            REP(j, 3) {
                if (i & (1 << j)) {
                    cout << "+";
                }
                else {
                    cout << "-";
                }
                cout << A[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from math import sqrt
import sys
sdin = sys.stdin.readline

q = int(sdin())
ab = []
for i in range(q):
    ab.append(tuple(map(int, sdin().split())))

for a, b in ab:
    if b-a == 0 or b-a == 1:
        print(2*a - 2)
        
    else:
        if not (sqrt(a*b) - int(sqrt(a*b))):
            c = int(sqrt(a*b) - 1)
        else:
            c  = int(sqrt(a*b))
        
        if c*(c+1) >= a*b:
            print(2*c - 2)
        else:
            print(2*c - 1)

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

int parity(int n){
  if(n*n*n*n%10 == 1)
    return 1;
  else
    return 0;
}

int power(int x, int y){
  int64_t n = 1ll;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}

int main(){
  string s;
  cin >> s;
  vector<char> ans;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '0'){
      ans.push_back('0');
    }
    if(s.at(i) == '1'){
      ans.push_back('1');
    }
    if(s.at(i) == 'B'){
      if(ans.size() > 0)
        ans.pop_back();
    }
  }
  for(char a : ans)
    cout << a;
  cout << endl;
}

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


int main() {
    int n, k, mini = 1e9;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    for(int i = 0; i <= n-k; ++i){
        mini = min({mini,
                   abs(x[i]) + abs(x[i+k-1] - x[i]),
                   abs(x[i+k-1]) + abs(x[i] - x[i+k-1])});
    }
    cout << mini << endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int fa[100005],p[100005];

int _getfa(int x){
	
	if(fa[x]==x)return x;
	return fa[x]=_getfa(fa[x]);

}

int main(){
	
	int n,m,i,x,y,a,b,ans;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&p[i]);
		fa[i]=i;
	}
	for(i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		a=_getfa(x);
		b=_getfa(y);
		if(a!=b)fa[a]=b;
	}
	ans=0;
	for(i=1;i<=n;i++)
		if(_getfa(i)==_getfa(p[i]))ans++;
	printf("%d",ans);
	return 0;
}
		
	

Measured memory_bytes: 896
#include <iostream>
using namespace std;
 
int main(){
  unsigned long long int nowmoney=100,x;
  int year=0;
  cin>>x;
  
  while(x>nowmoney){
    nowmoney=nowmoney*1.01;
    year++;
  }
  cout<<year<<endl;
  
  return 0;
}

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

int main() {
  int n, a;
  int count = 30;
  int tmp;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> a;
    tmp = 0;
    while (a%2 == 0) {
      a /= 2;
      tmp++;
    }
    if (tmp < count) count = tmp;
  }
  cout << count << endl;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    i64 cnt = N / 2;
    if (N % 2 == 0) cnt--;
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int N1=N%10;
      	int N2=(N%100-N1)/10;
      	int N3=(N%1000-N1-N2)/100;
      	int N4=(N-N1-N2-N3)/1000;
      if(N1==N2||N2==N3||N3==N4){
        System.out.println("Bad");
      }else{
      System.out.println("Good");
      }
	}
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){

    int W,H,ans[110][110]={},a,x,y,N,A;

    cin >> W>>H>>N;

    for(int i=1;i<=W;i++){
        for(int j=1;j<=H;j++){
            ans[i][j]=1;
        }
    }

    for(int i=1;i<=N;i++){
        
        cin >> x >> y >> a;

        if(a==1){
            for(int j=1;j<=x;j++){
                for(int k=1;k<=H;k++){
                    ans[j][k]=0;
                }
            }
        }else if(a==2){
            for(int j=x+1;j<=W;j++){
                for(int k=1;k<=H;k++){
                    ans[j][k]=0;
                }
            }
        }else if(a==3){
            for(int j=1;j<=W;j++){
                for(int k=1;k<=y;k++){
                    ans[j][k]=0;
                }
            }
        }else{
            for(int j=1;j<=W;j++){
                for(int k=y+1;k<=H;k++){
                    ans[j][k]=0;
                }
            }
        }
    }

    A=0;
    for(int k=H;k>=1;k--){
        for(int i=1;i<=W;i++){
            if(ans[i][k]==1)A++;
        }
    }

    cout << A<<endl;
    return 0;
}


Measured memory_bytes: 256
void main() {
	auto N = readAs!ulong;
	ulong a = 0;
	if(N % 2 == 1) {
		writeln(0);
		return;
	}
	for(ulong i = 10; N >= i; i *= 5) a += N / i;
	a.writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 372
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

string s, t;

int main() {
    cin >> s >> t;
    int slen = s.length(); int tlen = t.length();

    vector<int> salp(26, 0);
    vector< vector<int> > spos(26, vector<int>());
    for(int i = 0; i < slen; ++i) {
        int alpin = s.at(i) - 'a';
        salp.at(alpin)++;
        spos.at(alpin).emplace_back(i);
    }

    set<char> tst;
    for(int i = 0; i < tlen; ++i) tst.insert(t.at(i));

    bool flg = true;
    for(auto x : tst) {
        int talp = x - 'a';
        if(salp.at(talp) == 0) {
            flg = false;
            break;
        }
    }


    if(!flg) {
        cout << -1 << endl;
    }else {
        long long cnt = 0;
        long long now = -1;
        for(int i = 0; i < tlen; ++i) {
            char check = t.at(i);
            int tch = check - 'a';
            bool fflg = false;

            // nowに関して二部探索
            int chno = upper_bound(spos.at(tch).begin(), spos.at(tch).end(), now) - spos.at(tch).begin();
            int sposlen = spos.at(tch).size();
            if(chno == sposlen) {
                now = spos.at(tch).at(0);
                cnt++;
            }else {
                now = spos.at(tch).at(chno);
            }
            // cout << "cnt " << cnt << " now " << now << endl;
        }

        cout << (long long)slen * cnt + now + 1 << endl;
    }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define M 100002
using namespace std;
long long A[M],Ans[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&A[i]);
	Ans[1]=A[1];
	for(int i=2;i<=n;i+=2)Ans[1]-=A[i]-A[i+1];
	for(int i=1;i<n;i++)
		Ans[i+1]=(A[i]-Ans[i]/2)*2;
	for(int i=1;i<=n;i++)printf("%lld ",Ans[i]);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define deb(x) cout<<#x<<" "<<x<<endl;
#define ll long long int
#define ld long double
#define fo(i, n) for(ll i = 0; i<n; i++)
#define Fo(i, a, n) for(ll i = a; i<n; i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>
#define u_m unordered_map
#define u_s unordered_set
#define p_q priority_queue
using namespace std;
const int N = 1e3+2;
const ll MOD = 1e9+7;
ll dp[N][N];
void solve()
{
    int row, col;
    cin>>row>>col;
    string matrix[row];
    fo(i, row)
        cin>>matrix[i];
    fo(i, row)
    {
        fo(j, col)
        {
            if(matrix[i][j]=='#') dp[i][j] = 0;
            else
            {
                if(i==0 && j==0) dp[i][j] = 1;
                else if(i==0) dp[i][j] = (dp[i][j-1])%MOD;
                else if(j==0) dp[i][j] = (dp[i-1][j])%MOD;
                else dp[i][j] = (dp[i][j-1]+dp[i-1][j])%MOD;
            }
            //deb(i);deb(j);
            //cout<<dp[i][j]<<endl;
        }
    }
    cout<<dp[row-1][col-1]%MOD<<endl;
}
int main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    int t;
    //cin>>t;
    //while(t--)
		solve();	
    return 0;
}


Measured memory_bytes: 9088
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,ans=0;
  string s[105]={},t[105]={};
  map<string,int> ms,mt;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s[i];
    ms[s[i]]++;
  }
  cin >> m;
  for(int i=0; i<m; i++) {
    cin >> t[i];
    mt[t[i]]++;
  }
  for(auto ps:ms) {
    if(ps.second>mt[ps.first]) {
      ans=max(ans,ps.second-mt[ps.first]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
plist = list(map(int, input().split()))
answer=0

for i in range(n-2):
    x=[plist[i], plist[i+1], plist[i+2]]
    if x[1]>x[0] and x[1]<x[2]:
        answer+=1
    elif x[1]<x[0] and x[1]>x[2]:
        answer+=1

print(answer)

Measured memory_bytes: 3316
Scanf.scanf "%d %d %d %d" (fun n m v p ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort (fun a b -> compare b a) a;

    let judge x =
        if a.(x) + m < a.(p - 1) then false else
            let s = n - 1 - x + 1 + p - 1 in
            if s >= v then true else
                let rec loop k sum =
                    if k = x then sum else loop (k + 1) (sum + a.(x) + m - a.(k))
                in
                loop (p - 1) (m * s) >= m * v
    in

    let rec bin left right =
        if left = right then left else
            let mid = left + (right - left) / 2 in
            if judge mid then bin (mid + 1) right
                         else bin left mid
    in
    Printf.printf "%d\n" @@ bin p n
)

Measured memory_bytes: 5376
n,m=map(int,input().split())
marks = {i+1:-1 for i in range(n)}
marks[1] = 0
roots = {i+1:[] for i in range(n)}
count = 0
for i in range(m):
    a,b = map(int,input().split())
    roots[a].append(b)
    roots[b].append(a)

before_room = 1
searchs = [{'root':roots[1], 'mark':1}]
while searchs != []:
    next_search = []
    for search in searchs:
        for root in search['root']:
            new_root = []
            if marks[root] == -1:
                marks[root] = search['mark']
                count += 1
                new_root += roots[root]
            else:
                continue
            next_search.append({'root':roots[root], 'mark':root})
    searchs = next_search[:]

del marks[1]
print('Yes')
for v in marks.values():
    print(v)
    

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;
const int mod = (int)1e9 + 7;
const ull BS = 10000019ULL;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

vector < pii > g;

int ans[123][123];

int main(){
    int H = in(), W = in();
    for(int i = 1; i <= H; i++){
        if(i & 1){
            for(int j = 1; j <= W; j++){
                g.pb(mp(i, j));
            }
        }else {
            for(int j = W; j >= 1; j--){
                g.pb(mp(i, j));
            }
        }
    }
    int n = in();
    for(int i = 1; i <= n; i++){
        int how = in();
        while(how > 0){
            pii u = g.back();
            ans[u.fs][u.se] = i;
            how--;
            g.pop_back();
        }
    }
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            printf("%d ", ans[i][j]);
        }
        puts("");
    }
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#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 PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int a, b; cin >> a >> b;
  cout << max(0, a-2*b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/








int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    ll ans = 0;
    map<ll, int> cnt;
    cnt[0] = 1;
    ll sm = 0;
    rep(i, 0, N) {
        sm += A[i];
        ans += cnt[sm];
        cnt[sm]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13568
// Author : Harshdeep Sharma , IIT Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();

// function to calculate any numbered power of some number without modulo
ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
// function to check whether a bracketed sequence is balanced or not
bool isBalanced(const string &exp) {
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}
// function to sort by second in a set of pairs
bool sortbysec(const pair<pair<int, int>, int> &a,
               const pair<pair<int, int>, int> &b) {
	return (a.second < b.second);
}

void uniformly_distribute_k_numbers_in_a_square_grid(int n , int k ) {
	int p = 0 , q = 0 ;
	vector<vector<int>> a(n, vector<int>(n)) ;
	for (int i = 1 ; i <= k ; ++i ) {
		a[p][q] = 1 ;
		p = p + 1 ;
		q = (q + 1) % n ;
		if (p == n) {
			p = 0  ;
			q = (q + 1) % n ;

		}
	}
}

ll f(ll n) {
	ll res ;
	if (n % 2 != 0) {
		ll pairs = (n + 1) / 2 ;
		if (pairs % 2 == 0) {
			res = 0  ;
		} else {
			res = 1 ;
		}
	} else {
		// cout << "i\n";
		ll pairs = n / 2 ;
		if (pairs % 2 == 0) {
			res = 0  ;
		} else {
			res = 1 ;
		}
		res ^= n ;
	}
	return res ;
}



// main funtion
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {


	ll a , b , ans , ans1 , ans2 = 0 ;
	cin >> a >> b ;
	// we have to find the Xor of a , a+1 , a+2 , .... , b .
	ans = f(b) ;
	ans1 = f(a - 1) ;
	// cout << ans << "\n" ;
	// cout << ans1 << "\n";
	ans2 ^= ans ;
	ans2 ^= ans1 ;
	cout << ans2 << "\n";






	// }







	return 0 ;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int ans = 0;
  for (int i = 1; i < N+1; i++) {
    if ((i&1) && (A[i-1]&1)) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3628
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
l = list(map(int, input().split()))

flag = False
ok = True
pos = 10**9+7

for i in range(N-1,-1,-1):
    pre = l[i]
    if pos>=pre:
        pass
    else:
        if (pre - pos)==1:
            pre -= 1
        else:
            ok = False
            break
    pos = pre
if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include <stdio.h>

int main(void)
{
  long n,a,i,min,max,sum;
  sum=0;
  min=1000000;
  max=-1000000;

  scanf("%ld",&n);
  for(i=1; i<=n; i++){
  scanf("%ld", &a);
  sum+=a;
  if ( a < min )
  min=a;
  if ( a > max )
  max=a;
  }
  printf("%ld %ld %ld\n",min,max,sum);

  return 0;
}

Measured memory_bytes: 600
n=gets.to_i
a=gets.split.map &:to_i
b=gets.split.map &:to_i
c=gets.split.map &:to_i
s=0
n.times do |i|
  s+=b[i]
  s+=c[a[i-1]-1] if i>0&&a[i]-a[i-1]==1
end
puts s

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

char s[4040];

int main(){   

    ll N;
    cin >> N;
    ll r = 0, g = 0, b = 0;
    rep1(i, N){
        cin >> s[i];
        if(s[i] == 'R')r++;
        if(s[i] == 'G')g++;
        if(s[i] == 'B')b++;
    }
    ll ans = r * g * b;
    rep1(i, N){
        rep1(j, N){
            ll L = i - j;
            ll R = i + j;
            if(L < 1)break;
            if(R > N)break;
            if(s[i] != s[L] && s[i] != s[R] && s[L] != s[R])ans--;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int a, b;
    cin >> a >> b;

    if (a <= 0 && b >= 0) puts("Zero");
    else if (a > 0 || (b-a)%2) puts("Positive");
    else puts("Negative");

    return 0;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())

list_water = []
list_suger = []
max_conc = (100 * E) / (100 + E)
ans_conc = 0

for a in range(F // (100 * A) + 1) :
    for b in range(F // (100 * B) + 1) :
        if 100 * A * a + 100 * B * b <= F :
            water = 100 * A * a + 100 * B * b
            list_water.append(water)

for c in range(F // C + 1) :
    for d in range(F // D + 1) :
        if C * c + D * d <= F :
            suger = C * c + D * d
            list_suger.append(suger)

for i in list_water :
    for j in list_suger :
        if 0 < (i + j) <= F :
            concent = (100 * j) / (i + j)
            if ans_conc <= concent <= max_conc :
                ans_conc = concent
                ans = i + j
                ans_suger = j

print(ans, ans_suger)


Measured memory_bytes: 12456
import sys
input=sys.stdin.readline

def main(args):
    N = int(input())
    A = list(map(int,input().split()))
    
    ans = sum(A)
    count = [0]*(10**5+1)
    
    for a in A:
        count[a] += 1
    
    #print(count[:5])
    
    Q = int(input())
    for i in range(Q):
        B, C = map(int,input().split())
        ans -= B*count[B]
        count[C] += count[B]
        #print(count[:5])
        ans += C*count[B]
        count[B] = 0
        print(ans)
        
if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 85624
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(auto &x : a){
        cin >> x;
    }
    sort(ALL(a));
    vector<int> t(n, 0);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(x >= a[i]){
            x -= a[i];
            t[i] = a[i];
        }else{
            t[i] -= x;
            x = 0;
        }
    }
    if(x > 0) t[n - 1] += x;
    for(int i = 0; i < n; i++){
        if(a[i] == t[i]) cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include <iomanip>

using namespace std;
const int maxn = 100100;


int main()
{
	int n, k;
	cin >> n >> k;
	long double p=0.0;
	//double tmp = k/n;
	long double l[16] ;
	for (int i = 0; i < 16; i++)
	{
		//l[i] = powl(0.5, i);
	}
	for (int i = 1; i <= n; i++)
	{
		if (i>=k)
		{
			p = p + 1.0/n;
			continue;
		}
		long double tmp = ceil(log10l(((long double)k/(long double)i))/log10l(2.0));
		//cout <<  tmp<<' '<< pow(0.5, tmp) << endl;

		
		p = p + powl(0.5, tmp)/n;

		
		
	}
	p = p ;
	cout << fixed << setprecision(12) << p << endl;
	//system("pause");
	return 0;
}


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

using namespace std;

// when range [l, r), has property notP~P, want first P.
// when return r, means not found.
template <typename T>
T bs_first(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = (l+r)/2;
        if (f(mid)) {
            r = mid;
        }else {
            l = mid + 1;
        }
    }
    return r;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n<<1);
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    int board = bs_first<int>(0, n+1, [&](int x){
            int l = 2*x, r = 2*n-1;
            while (l < r) {
                if (a[l] + a[r] < m) return false;
                l++; r--;
            }
            return true;
            });
    int l = 0, r = 2*board-1;
    int res = 0;
    while (l < r) {
        res = max(res, a[l]+a[r]);
        l++; r--;
    }
    l = 2*board, r = 2*n-1;
    while (l < r) {
        res = max(res, a[l]+a[r]-m);
        l++; r--;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
bool ACGT(char c){
    if (c=='A'||c=='C'||c=='G'||c=='T') return true;
    else return false;
}
int mx,f;
str s;
int main(){
    cin>>s;
    f=0;
    for(int i=0;i<s.size();i++){
        if(ACGT(s[i])){f++;mx=max(mx,f);}
        else{f=0;}
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String[] date = sc.nextLine().split("/");
		if(Integer.parseInt(date[1])<=4) {
			System.out.println("Heisei");
		}
		else {
			System.out.println("TBD");
		}
	}
}

Measured memory_bytes: 23764
n,k=map(int,input().split())
s=list(input())
if s[k-1]=='A':
  s[k-1]='a'
elif s[k-1]=='B':
  s[k-1]='b'
else:
  s[k-1]='c'
for i in range(n):
  print(s[i],end='')

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

int selectionSort(int A[], int N){
    int i, j, sw=0, minj;
    for (i = 0; i < N - 1; i++){
        minj = i;
        for ( j = i; j < N; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        swap(A[minj],A[i]);
        if (minj != i) sw++;
    }
    return sw;
}

int main(){
    int A[100], N, i, sw;
    
    cin >> N;
    for (i = 0; i < N; i++) cin >> A[i];
    sw = selectionSort(A, N);
    for (i=0; i<N; i++){
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << "\n";
    cout << sw << endl;
    
    return 0;
}


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

long long n, a[5];

int main(int argc, char *argv[])
{
    cin >> n;
    long long minItem = INT64_MAX;
    for (long long &item : a)
    {
        cin >> item;
        minItem = min(minItem, item);
    }
    cout << (n % minItem == 0 ? n / minItem + 4 : n / minItem + 5);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := scanText()
	for _, c := range n {
		if c == '7'	 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 1e5+5;

ll n , k , a[N];

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    ll ans = 1e18 , mn , mx , tmp;
    for(int i=1; i+k-1<=n; i++)
    {
        if (a[i] <= 0 && a[i+k-1] <= 0)
        {
            ans = min(ans , abs(a[i]));
        }
        else if (a[i] >= 0 && a[i+k-1] >= 0)
        {
            ans = min(ans , a[i+k-1]);
        }
        else
        {
            mn = min(abs(a[i]) , a[i+k-1]);
            mx = max(abs(a[i]) , a[i+k-1]);
            tmp = 2*mn + mx;
            ans = min(ans , tmp);
        }
    }

    cout << ans << '\n';
//
    return 0;
}

Measured memory_bytes: 1024