akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> LP;
int main()
{
  int x,c,m,n,l;
  string a;
  cin >> a;
  m=0;
  n=0;
  l=0;
  x=a.length();
  if(a[0]=='A')m=1;
  FOR(i,2,x-1){if(a[i]=='C'){n++;
                             c=i;
                            }
              }
  rep(i,x)if(i!=c&&a[i]<95)l++;
  if(m==1&&n==1&&l==1)printf("AC");
  else printf("WA");
}

Measured memory_bytes: 256
s = input()
d = {"a":0,"b":0,"c":0}
for i in s:
    d[i] += 1
flag = True
for i in d.values():
    if not(len(s)//3 <= i <= len(s)//3 + 1):
        flag =False
        break
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S));
    }

    private static String solve(String S) {
        StringBuilder ans = new StringBuilder();

        for (int i=0; i<S.length(); i++) {
            ans.append("x");
        }

        return ans.toString();
    }
}

Measured memory_bytes: 23892
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(true){
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d",&n);
  init();
  for(int i=0; i<n; ++i){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      ++np;
      ++size;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }else{
	deleteKey(key);
	++nd;
      }
      --size;
    }
  }

  printList();
  


  return 0;
}



Measured memory_bytes: 33952
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
inline void Fail(){printf("0");exit(0);}
inline void debug(int x){cerr<<"debug: "<<x<<"\n";}
inline void debug(int n,int x[]){cerr<<"debug "<<"\n";rep(i,n)cerr<<x[i]<<" ";cerr<<"\n";}
inline void debug(string x){cerr<<"debug: "<<x<<"\n";}

const int maxn=2005;
const int maxm=10005;
int n,k;
int C[maxn];
string s[maxn],ans;
bitset<1000005>dp[maxn];
pii cur[1000005][2];
char c[maxn*maxn];

int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%s",c);
		s[i]=c;
		rep(j,s[i].size())C[s[i][j]-'a']++;
	}
	int t=0;
	char p;
	rep(i,26)if(C[i]>0)t++,p=i+'a';
	if(t==1){
		printf("%s",string(k,p).c_str());
		return 0;
	}
	dp[n][0]=1;
    for(int i=n;i>0;--i)
        dp[i-1]=dp[i]|(dp[i]<<s[i-1].size());
	int cnt=0;
	t=0;
	rep(i,n)if(k>=s[i].size()&&dp[i+1][k-s[i].size()])cur[cnt++][t]=mp(i,0);
	rep(i,k){
		int id=INF;
		char mn='z';
		cnt=min(cnt,10000);
		rep(j,cnt)mn=min(mn,s[cur[j][t].first][cur[j][t].second]);
		ans+=mn;
		int ncnt=0;
		rep(j,cnt){
			int sid=cur[j][t].first,pos=cur[j][t].second;
			if(s[sid][pos]!=mn)continue;
			if(pos+1==s[sid].size())id=min(sid+1,id);
			else cur[ncnt++][t^1]=mp(sid,pos+1);
		}
		for(int j=id;j<n;j++){
			if(k-i-(int)s[j].size()-1>=0)
			if(dp[j+1][k-i-(int)s[j].size()-1])cur[ncnt++][t^1]=mp(j,0);
		}
		cnt=ncnt;t^=1;
	}
	printf("%s",ans.c_str());
	return 0;
}

/*
Input:
dp[i][j]=dp[i+1][j]||dp[i+1][j-s.size()] 
-----------------
Output:
*/

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

using namespace std;

int main(){
  unsigned long long n, a, b;
  cin >> n >> a >> b;
  cin.ignore();
  
  unsigned long long blocks = n / (a + b);
  n %= (a + b);
  unsigned long long ans = a * blocks;
  
  ans += (n > a) ? a : n;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<pll,ll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define piii pair<pii, int>
#define sort(p) sort(p.begin(),p.end())
#define rsort(p) sort(p.rbegin(),p.rend())
#define pb push_back
const ll llinf = 2e18 + 7;
const int inf = 2e9 + 7;
const ll mod = 998244353;
const ll N = 1e5 + 7;
const ld pi = 3.14159265358979; 

void solve() {
    ll n;
    cin>>n;
    vector<char> ch;
    for(char i='a';i<='z';i++) ch.pb(i);
    string ans = "";
    while(n>0) {
        n--;
        ll rem = n%26 ;
        ans = ch[rem] + ans;
        n/=26;
    }
    cout<<ans;
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<"\n";
    }
    return 0; 

}


Measured memory_bytes: 3648
import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, D, A, *XH = map(int, read().split())
    monster = [0] * N
    for i, (x, h) in enumerate(zip(*[iter(XH)] * 2)):
        monster[i] = (x, (h + A - 1) // A)

    monster.sort()

    pos = []
    damage = []
    idx = 0
    cur_damage = 0

    for x, h in monster:
        while idx < len(pos) and pos[idx] < x:
            cur_damage -= damage[idx]
            idx += 1

        if h > cur_damage:
            pos.append(x + 2 * D)
            damage.append(h - cur_damage)
            cur_damage += h - cur_damage

    print(sum(damage))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 152048
#include <iostream>

using namespace std;

int main(){
  int N,M,re = 0;
  int *former,**latter;
  //1次元配列の取得
  cin >> N;
  former = new int[N];
  for (int i = 0 ; i < N ; i++) {
    cin >> former[i];
    re += former[i]; //normalの総時間  
  }
  //二次元配列の取得
  cin >> M;
  latter = new int*[M];
  for (int i = 0 ; i < M ; i++) {
  latter[i] = new int[2] ;
  cin >> latter[i][1] >> latter[i][2] ;
  }
  // 短くした時の総時間
  for(int m = 0 ; m < M ; m++ ) cout << re - former[latter[m][1] - 1] + latter[m][2] << endl;
  return 0;
}


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

using namespace std;

typedef long long int lli;
typedef vector <lli> vi;
typedef vector <vi> vvi;
typedef pair <lli, lli> pi;

int main() { 
  int num;

  cin >> num;
  
  for (int j = 1; j <= 9; ++j) {
    for (int k = 1; k <= 9; ++k) {
      if (j * k == num) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c,d,e;
    long long ans=0;
    cin >> a >> b >> c >> d >> e;
    if(a+b<=c*2){
        ans = a*d + b*e;
    }else{
        if(d==e){
            ans = c*d*2;  
        }else if(d<e){
            ans = c*min(d,e)*2;
            if(b>c*2){
                ans += c*abs(d-e)*2;
            }else{
                ans += b*abs(d-e);
            }
        }else{
            ans = c*min(d,e)*2;
            if(a>c*2){
                ans += c*abs(d-e)*2;
            }else{
                ans += a*abs(d-e);
            }
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

vll factorize(ll n)
{
    vll res;
    ll tmp;
    do {
        bool flg = false;
        rep(i, 2, floor(sqrt(n))+1) {
            if (n % i == 0) {
                res.push_back(i);
                tmp = i;
                flg = true;
                break;
            } 
        }
        if (! flg) {
            res.push_back(n);
            break;
        }
        n /= tmp;
    } while (n);
    sort(res.begin(), res.end());
    return res;
}

int main()
{
    ll n;
    cin >> n;
    vll ans;
    ans = factorize(n);
    cout << n << ':';
    for(ll el:ans) {
        cout << ' ' << el;
    }
    cout << endl;
}


Measured memory_bytes: 3156
#include <iostream>

const int MAX = 100000 + 5;
const int NIL = -1;

struct Node {
	int parent = NIL;
	int left = NIL;
	int right = NIL;
};

Node T[MAX];
int D[MAX];

void cal_depth(int i, int d) {
	D[i] = d;
	if (T[i].right != NIL) {
		cal_depth(T[i].right, d);
	}
	if (T[i].left != NIL) {
		cal_depth(T[i].left, d + 1);
	}
}

void print(int i) {
	std::cout << "node " << i << ": ";
	std::cout << "parent = " << T[i].parent << ", ";
	std::cout << "depth = " << D[i] << ", ";

	if (T[i].parent == NIL) {
		std::cout << "root, ";
	} else if (T[i].left == -1) {
		std::cout << "leaf, ";
	} else {
		std::cout << "internal node, ";
	}
	std::cout << "[";
	for (int j = 0, c = T[i].left; c != NIL; ++j, c = T[c].right) {
		if (j) std::cout << ", ";
		std::cout << c;
	}
	std::cout << "]" << std::endl;
}

int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i != n; ++i) {
		int id, k;
		std::cin >> id >> k;
		int l = 0;  // l won't be used first when i == 0.
		for (int j = 0; j != k; ++j) {
			int c;
			std::cin >> c;
			if (j == 0) {
				T[id].left = c;
			} else {
				T[l].right = c;
			}
			l = c;
			T[c].parent = id;
		}
	}

	for (int j = 0; j != n; ++j) {
		if (T[j].parent == NIL) {
			cal_depth(j, 0);
		}
	}

	for (int j = 0; j != n; ++j) {
		print(j);
	}

	return 0;
}


Measured memory_bytes: 7756
#include<iostream>
#include<string>
#include<vector>

using namespace std;

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

template<typename T> struct edge {
  int to;
  T cap;
  int rev_id;

  edge(int to_,T cap_,int rev_id_) : to(to_),cap(cap_),rev_id(rev_id_){};
};


template<typename T> struct Graph_for_flow {
  vector< vector<edge<T>> > G;
  vector<bool> used;
  int V,E;

  Graph_for_flow(T V_) {
    init(V_);
  }

  void init(int V_) {
    V = V_;

    G.clear();
    G.resize(V);

    used.resize(V);

  }

  void add_edge(int from,int to,T cap) {
    if(from < 0 || from >= V || to < 0 || to >= V ) {
      cerr << "warning" << endl;
    }

    G[from].push_back(edge<T>(to,cap,G[to].size()));
    G[to].push_back(edge<T>(from,0,G[from].size() - 1));
  }

  T dfs(int v,int t,T f) {
    if(v == t) return f;

    used[v] = true;

    for(auto &e : G[v]) {
      if(!used[e.to] && e.cap > 0) {
        T d = dfs(e.to,t,min(f,e.cap));
        if(d > 0) {
          e.cap -= d;
          G[e.to][e.rev_id].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  T max_flow(int s,int t) {
    T flow = 0;
    for(;;) {
      fill(used.begin(),used.end(),false);
      T f = dfs(s,t,1e9);
      if(f == 0)break;
      flow += f;
    }
    return flow;
  }
};

using ll = long long;
ll N;
vector<string> S;

int main() {
  cin >> N;

  S.resize(N);

  rep(i,N) cin >> S[i];


  vector<char> ans;

  rep(i,26) {
    Graph_for_flow<ll> graph(28);
    int deg_out = 0,deg_in = 0;
    int s = 26,t = 27;
    rep(j,N) {
      char u = S[j].front() - 'a';
      char v = S[j].back() - 'a';

      if(u == i) {u = s;deg_out++;}
      if(v == i) {v = t;deg_in++;}

      graph.add_edge(u,v,1);
    }

    ll flow = graph.max_flow(s,t);

    if(flow >= deg_out && deg_in > 0)ans.push_back(i + 'a');
  }

  for(auto v : ans) {
    cout << v << endl;
  }
  return 0;
}



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

typedef long long ll;

ll findMoves(ll health){
    if(health == 1){
        return 1;
    }
    return findMoves(health/2) * 2 + 1; 
}

int main(){
    ios_base::sync_with_stdio(false);
    ll health;
    cin>>health;
    if(health == 0){
        cout<<0<<endl;
    }else{
        cout<<findMoves(health)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
q = int(input())
prime = [True for _ in range(10 ** 5 + 1)]
prime[0] = False
prime[1] = False
ans = [0 for _ in range(10 ** 5 + 1)]
total = 0
for num in range(2, 10 ** 5 + 1):
    if prime[num]:
        tmp = num * 2
        while tmp <= 10 ** 5:
            prime[tmp] = False
            tmp += num
        if prime[(num + 1) // 2]:
            total += 1
    ans[num] = total
for _ in range(q):
    l, r = map(int, input().split())
    print(ans[r] - ans[l - 1])

Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const ll K=110000;
const ll INFTY=1e15;
ll k, a[K];

ll fw(ll x) {
    for(ll i=0; i<k; i++) x-=x%a[i];
    return x;
}

ll bs(ll x) {
    ll l=0, r=INFTY, m;
    while(l<r) {
        m=(l+r)/2;
        if(fw(m)>x) r=m;
        else l=m+1;
    }
    return l;
}

int main() {
    ll i, l, r;
    scanf("%lld", &k);
    for(i=0; i<k; i++) scanf("%lld", &a[i]);
    l=bs(1); r=bs(2);
    if(l<r) printf("%lld %lld\n", l, r-1);
    else printf("-1\n");
    return 0;
}

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

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

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  
  auto f = [](string S){
    int tmp = 0;
    for(char c: S){
      int num = c - '0';
      tmp += num;
    }
    return tmp;
  };
  int ans = 0;
  for(int i = 0; i <= N; i++){
    string s = to_string(i);
    int tmp = f(s);
    if(tmp >= A && tmp <= B){
      ans+=i;
    }
  }
  cout << ans << endl;
}





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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int ans;

int main(void) {
  // Here your code !
  cin >> s;

  int cnt0 = 0;
  // 0 start
  for (int i = 0; i < s.size(); ++i) {
    char cur = (i % 2 == 0) ? '0' : '1';
    if (cur != s[i]) cnt0 += 1;
  }

  int cnt1 = 0;
  // 1 start
  for (int i = 0; i < s.size(); ++i) {
    char cur = (i % 2 == 0) ? '1' : '0';
    if (cur != s[i]) cnt1 += 1;
  }

  ans = min(cnt0, cnt1);

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

  return 0;
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())

	if e != nil {
		panic(e)
	}

	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)

	if e != nil {
		panic(e)
	}

	return i
}

func nextFloat() float32 {
	f, e := strconv.ParseFloat(sc.Text(), 32)

	if e != nil {
		panic(e)
	}

	return float32(f)
}

func nextFloat64() float64 {
	f, e := strconv.ParseFloat(sc.Text(), 64)

	if e != nil {
		panic(e)
	}

	return f	
}

func nextBool() bool {
	sc.Scan()
	b, e := strconv.ParseBool(sc.Text())

	if e != nil {
		panic(e)
	}

	return b
}

func nextStr() string {
	sc.Scan()

	return sc.Text()
}

// struct field begin

type pair struct {
	first int
	second int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	if p[i].first < p[j].first {
		return true
	} else if p[i].first == p[j].first {
		return p[i].second < p[j].second
	} else {
		return false
	}
}

func Newpair() *pair {
	return &pair {
		first : 0,
		second : 0,
	}
}

// struct field end

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	g := make([][]pair, n)
	for i := 0; i < n - 1; i++ {
		a, b, c := nextInt(), nextInt(), nextInt()

		g[a - 1] = append(g[a - 1], pair{b - 1, c})
		g[b - 1] = append(g[b - 1], pair{a - 1, c})	
	}
	q, k := nextInt(), nextInt()

	min_cost := make([]int64, n)
	var dfs func(int, int, int64)
	dfs = func(v, p int, cost int64) {
		min_cost[v] = cost

		for _, e := range g[v] {
			if e.first == p {
				continue
			}

			dfs(e.first, v, cost + int64(e.second))
		}
	}
	dfs(k - 1, -1, 0)

	for i := 0; i < q; i++ {
		x, y := nextInt(), nextInt()

		Println(min_cost[x - 1] + min_cost[y - 1])
	}
}

Measured memory_bytes: 61824
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        Edge[] e = new Edge[n];
        for (int i = 0; i < n; i++) e[i] = new Edge();
        for (int i = 0; i < m; i++) {
            int from = in.ni()-1, to = in.ni()-1;
            e[from].add(to);
        }
        int s = in.ni()-1, t = in.ni()-1;
        long[][] ans = new long[3][n];
        for (int i = 0; i < 3; i++) Arrays.fill(ans[i],-1);
        ans[0][s] = 0;
        ArrayDeque<Pair> deq = new ArrayDeque<>();
        deq.addFirst(new Pair(s,0));
        while(!deq.isEmpty()){
            Pair p = deq.pollLast();
            for(Integer to: e[p.point]){
                if(ans[(p.num+1)%3][to]==-1){
                    ans[(p.num+1)%3][to] = ans[p.num][p.point]+1;
                    deq.addFirst(new Pair(to,(p.num+1)%3));
                }
            }
        }
        out.println(ans[0][t]!=-1?ans[0][t]/3:-1);
    }
    public static class Edge extends ArrayList<Integer>{}
    public static class Pair{
        int point, num;
        public Pair(int x, int y){
            point = x;
            num = y;
        }
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int  n, k; cin >> n >> k;
	double ans = 0.0;

	for (int i = 1; i <= n; i++) {
		double tmp = 1.0;
		ll now = i;
		while (now < k) {
			now *= 2.0;
			tmp /= 2.0;
		}
		ans += tmp;
	}
	ans /= n;
	cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		int count=1;
		int max=list.get(0);
		for(int i=0;n-1>i;i++) {
			if(list.get(i+1)>max)
				max=list.get(i+1);
			if(list.get(i)<=list.get(i+1)) {
				if(list.get(i+1)>=max)
					count++;
			}
			//System.out.println(max);
		}

		System.out.println(count);
	}
}



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

int main(){
    int n;
    int ich;
    cin >>n;
    ich=n%10;
    if(ich==2 ||ich==4 ||ich==5||ich==7||ich==9){
        cout<<"hon\n";
    }
    else if(ich==0||ich==1||ich==6||ich==8){
        cout<<"pon\n";
    }
    else if(ich==3){
        cout<<"bon\n";
    }
    else{
        cout<<"error\n";
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1010;
char g[N][N];
int n,m,a,b,r,c;
void nosol() {
	puts("NO");
	exit(0);
}
void sol() {
	rep(i,0,n) rep(j,0,m) if (g[i][j]=='<') {
		if (a==0) g[i][j]=g[i][j+1]='.'; else --a;
	}

	rep(i,0,n) rep(j,0,m) if (g[i][j]=='^') {
		if (b==0) g[i][j]=g[i+1][j]='.'; else --b;
	}
	puts("YES");
	rep(i,0,n) puts(g[i]);
	exit(0);
}
int main() {
	scanf("%d%d%d%d",&n,&m,&a,&b);
	rep(i,0,n) rep(j,0,m) g[i][j]='.';
	r=0; c=0;
	rep(i,0,n) rep(j,0,m-1) if (g[i][j]=='.') {
		g[i][j]='<'; g[i][j+1]='>'; r++;
	}
	rep(i,0,n-1) rep(j,0,m) if (g[i][j]=='.') {
		g[i][j]='^'; g[i+1][j]='v'; c++;
	}
	if (a>r) nosol();
	if (r>=a&&c>=b) sol();
	rep(i,0,n-1) rep(j,0,m-1) if (g[i][j]=='<'&&g[i][j+1]=='>'&&g[i+1][j]=='<'&&g[i+1][j+1]=='>') {
		if (r-2>=a) {
			g[i][j]=g[i][j+1]='^';
			g[i+1][j]=g[i+1][j+1]='v';
			r-=2; c+=2;
			if (r>=a&&c>=b) sol();
		} else if (r-1>=a&&g[i+2][j+2]=='.') {
			g[i+1][j]='^';
			g[i+2][j]='v';
			g[i+1][j+1]='.';
			g[i+2][j+1]='<';
			g[i+2][j+2]='>';
			--r; ++c;
			if (r>=a&&c>=b) sol();
		}
	}
	nosol();
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define X				first.first
#define Y				first.second

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

int cost[25][25];
int N, M;



signed main() {
	fill( cost[0], cost[25], INF );
	REPONE( i, N ) cost[i][i] = 0;

	char c;
	cin >> N >> M;
	REP( i, M ) {
		int from, to, ft, tf;
		cin >> from >> c >> to >> c >> ft >> c >>  tf;
		cost[from][to] = ft;
		cost[to][from] = tf;
	}
	int s, g, v, p;
	cin >> s >> c >> g >> c >> v >> c >> p;

	REPONE( k, N ) {
		REPONE( i, N ) {
			REPONE( j, N ) {
				chmin( cost[i][j], cost[i][k] + cost[k][j] );
			}
		}
	}

	cout << v - ( cost[s][g] + cost[g][s] ) - p << endl;

}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <vector>
#include <utility>
#include <time.h>
#include <set>
#include <unordered_set>
#include <list>
#include <iterator>
#include <time.h>
#include <chrono>
#include <deque>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <climits>
#include <tuple>
#include <map>
using namespace std;

#define ll long long
#define ldb long double

ll mod(ll a, ll b)
{
	return (b + (a % b)) % b;
}

ll subMod(ll a, ll b, ll M)
{
	return mod((mod(a, M) - mod(b, M)), M);
}

ll dayofweek(ll d, ll m, ll y)
{
	static ll t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
	y -= m < 3;
	return (y + y / 4 - y / 100 +
		y / 400 + t[m - 1] + d) % 7;
}

void test()
{

}


void solve()
{
	ll n, r;
	cin >> n >> r;

	if (n >= 10)
	{
		cout << r;
	}
	else
	{
		cout << r + 100 * (10 - n);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//test();

	solve();

	return 0;
}

Measured memory_bytes: 256
class ProblemB
  def solve
    while true
      total = 0

      n, m = gets.split.map(&:to_i)
      break if n <= 0

      pn = gets.split.map(&:to_i).sort {|a, b| b <=> a }

      while pn.count > 0
        t = []
        m.times do
          t.push pn.shift
          break if pn.count <= 0
        end
        t.pop if t.count == m
        t.each { |price| total += price }
      end
      p total
    end
  end
end

thanksgiving = ProblemB.new
thanksgiving.solve

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll L, k;

int main(int argc, char **argv)
{
	cin >> L >> k;
	vector<ll> x(L), y(L), sx, sy;
	REP(i, L) cin >> x[i] >> y[i];
	sx = x;
	sy = y;

	sort(ALL(sx));
	sort(ALL(sy));

	ll res = (sx.back() - sx.front()) * (sy.back() - sy.front());

	for (ll xi = 0; xi < L-1; ++xi)
	{
		for (ll xj = xi + 1; xj < L; ++xj)
		{
			for (ll yi = 0; yi < L-1; ++yi)
			{
				for (ll yj = yi + 1; yj < L; ++yj)
				{
					ll x1 = sx[xi];
					ll x2 = sx[xj];
					ll y1 = sy[yi];
					ll y2 = sy[yj];

					ll cnt{0};
					REP(i, L)
						cnt += (x1 <= x[i] && x[i] <= x2) && (y1 <= y[i] && y[i] <= y2);

					if (cnt >= k)
						res = min(res, (x2-x1)*(y2-y1));
				}
			}
		}
	}

	std::cout << res << std::endl;
}


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

double dp[3000][6001];

int main(){
    int N;
    cin >> N;
    double P[3000];
    for(int i=0; i<N; i++) cin >> P[i];

    dp[0][3000] = 1;
    for(int i=0; i<N; i++){
        for(int j=3000-i; j<=3000+i; j++){
            dp[i+1][j+1] += dp[i][j] * P[i];
            dp[i+1][j-1] += dp[i][j] * (1-P[i]);
        }
    }

    double ans = 0;
    for(int j=3001; j<=6000; j++) ans += dp[N][j];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 139008
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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 (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

template<class V, int ME> class BIT {
public:
    V bit[1<<ME];
    V total(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
    void update(int e, V val) {e++; while(e<=1<<ME) bit[e-1]+=val,e+=e&-e;}
};
BIT<int, 18> bi;
ll count_inversion(vector<ll> &a, int s, int t){
    ////!!!!!!!! BIT をでかく取りすぎるとTLE するので適切に長さを変える！！ !!!!!!!!!////////
    // [s, t]（閉区間）の転倒数を求める
    REP(i, 1<<18) bi.bit[i] = 0;
    ll res = 0;
    for(int i=t;i>s-1;i--){
        res+=bi.total(a[i]);
        bi.update(a[i], 1);
    }
    return res;
}

ll inversion_distance(string &s, string &t){
    ll N = s.size();

    vector<ll> corr(N, 0);
    REP(moji, 26){
        queue<ll> tmp;
        REP(i, N) if(s[i]-'a' == moji) tmp.push(i);
        REP(i, N){
            if(t[i]-'a' == moji){
                corr[i] = tmp.front();
                tmp.pop();
            }
        }
    }
    //cout << corr << endl;
    ll res = count_inversion(corr, 0, N-1);
    return res;
}

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

    string S;
    cin >> S;
    ll N = S.size();

    vector<ll> cnt(26, 0);
    REP(i, N) cnt[S[i]-'a']++;

    ll odd = 0;
    REP(i, 26) if(cnt[i]&1) odd++;

    if(odd>1){
        cout << -1 << endl;
        return 0;
    }

    string A = "";
    string B = "";
    string C = "";

    vector<ll> rui(26, 0);
    REP(i, N){
        ll pos = S[i]-'a';
        
        if(cnt[pos]&1){
            if(rui[pos]<cnt[pos]/2) A += S[i];
            else if(rui[pos]==cnt[pos]/2) B += S[i];
            else C += S[i];
        }else{
            if(rui[pos]<cnt[pos]/2) A += S[i];
            else C += S[i];
        }
        rui[pos]++;
    }

    string T = A + B + C;
    //cout << T << endl;

    ll res = 0;
    res += inversion_distance(S, T);
    reverse(C.begin(), C.end());
    res += inversion_distance(A, C);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4116
import java.util.Scanner;

public class Main {
    static int[][][] caves = new int[2][1000][1000];
    static boolean[] primes = new boolean[1000000];
    static int[][] dp = new int[2][1000];
    static int[] vx = {1, 0, -1, 0};
    static int[] vy = {0, -1, 0, 1};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        MakeCaves();
        while (true){
            int m = sc.nextInt();
            int n = sc.nextInt();
            if(m==0 && n==0) break;

            int x = -1, y = -1;
            for (int i = 0; i < 1000; i++) {
                for (int j = 0; j < 1000; j++) {
                    if(caves[0][i][j]==n){
                        x = j; y = i;
                        break;
                    }
                }
                if(x!=-1) break;
            }
            for (int i = 0; i <1000 ; i++) {
                dp[0][i] = dp[1][i] = 0;
            }

            int max = 0, dy = 0, mx = x, my = y;
            while (y+dy<1000){
                for (int i = (x-dy>=0)?x-dy:0; i <= ((x+dy<1000)?x+dy:999); i++) {
                    if(caves[0][y+dy][i]>m) continue;
                    dp[dy%2][i] = dp[(dy+1)%2][i] + caves[1][y+dy][i];
                    if(i>0&&dp[(dy+1)%2][i-1]!=0){
                        dp[dy%2][i] = Math.max(dp[dy%2][i], dp[(dy+1)%2][i-1] + caves[1][y+dy][i]);
                    }
                    if(i<999&&dp[(dy+1)%2][i+1]!=0){
                        dp[dy%2][i] = Math.max(dp[dy%2][i], dp[(dy+1)%2][i+1] + caves[1][y+dy][i]);
                    }
                    if(max<dp[dy%2][i]){
                        max = dp[dy%2][i];
                        mx = i; my = y + dy;
                    }else if(max==dp[dy%2][i] && caves[1][y+dy][i]==1){
                        if(caves[0][my][mx]<caves[0][y+dy][i]){
                            mx = i; my = y + dy;
                        }
                    }
                }
                dy++;
            }
            System.out.println(max+" "+((max!=0)?caves[0][my][mx]:0));
        }
    }

    static void FindPrimes() {
        primes[0] = true;
        for (int i = 1; i < 500000; i++) {
            if(primes[i]) continue;
            int j = (i+1)*2;
            while (j<1000000){
                primes[j-1] = true;
                j += i+1;
            }
        }
    }

    static void MakeCaves() {
        int n = 2, x = 499, y = 500;
        FindPrimes();
        caves[0][y][x] = 1;
        caves[1][y][x] = 0;

        for (int i = 0; i < 2000; i++) {
            for (int j = 0; j <= i/2; j++, n++) {
                if(n==1000001) break;
                x+=vx[i%4]; y+=vy[i%4];
                caves[0][y][x] = n;
                caves[1][y][x] = (primes[n-1])?0:1;
            }
        }
    }
}

Measured memory_bytes: 45648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> s(n);
    int mins = 10000,maxs = -10000;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        mins = min(mins,s[i]);
        maxs = max(maxs,s[i]);
    }
    int ans = 1324324234;
    for(int i = mins; i <= maxs; i++){
        int tmp = 0;
        for(int j = 0; j < n; j++){
            tmp += pow(s[j]-i,2);
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl; 
    
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A>>B>>C>>D;
  if(A%D!=0){
    if(C/B<A/D+1){
      cout<<"Yes"<<endl;
    }
    else if(C/B==A/D+1){
      if(C%B==0){
        cout<<"Yes"<<endl;
      }
      else {
        cout<<"No"<<endl;
      }
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else if(A%D==0){
    if(C/B==A/D){
      if(C%B==0){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }
    else if(C/B<A/D){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vecll var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prtseq(var, n)   rep(i,n){cout << var[i] << " ";} cout << endl;

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

class Graph{

public:
  vector<vector<int>> tree;
  vector<int> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS

  Graph(int n){
    tree.resize(n);
    init(n);
  }
  ~Graph(){}

  void addpath(int m){
    int a, b;
    rep(i,m){
      cin >> a >> b;
      a--; b--;
      tree[a].push_back(b);
      tree[b].push_back(a);
    }
  }

  void init(int n){
    check.assign(n, false);
    dist.assign(n, -1);
  }
  void resetCheck(){
    rep(i,check.size()){
      check[i] = false;
    }
  }

  void dfs(int v){
    check[v] = true;

    for(auto next_v : tree[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }

  void bfs(int v){
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : tree[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }

  ll casedfs(int k, int now, int from){
    int can_use_color_num;
    if(from == -1){ // -1 indicates the point has no parent
      can_use_color_num = k-1;
    } else {
      can_use_color_num = k-2;
    }
    if(k<tree[now].size()){ // OK color number is less than points
      return 0;
    } else {
      ll case_num = 1;
      for(int e : tree[now]){
        if(e==from){continue;}

        case_num*=can_use_color_num;
        can_use_color_num--;
        case_num%=MOD;
      }
      for(auto e : tree[now]){
        if(e==from){continue;}

        case_num *= casedfs(k,e,now);
        case_num %= MOD;
      }
      return case_num;
    }
  }

};

int main(void) {
  int n, k;
  cin >> n >> k;

  Graph g(n);
  g.addpath(n-1);

  //prt("path");
  //rep(i,n){prt2("---from : ", i);rep(j,g.tree[i].size()){prt(g.tree[i][j]);}}

  ll ans=k*g.casedfs(k,0,-1);
  ans%=MOD;
  prt(ans);


}


Measured memory_bytes: 9856
#ABC 97, B - exponential

def compute():
    x = int(input())
    if x == 1:
        print(1)
    else:
        beki = []
        for b in range(31, 1, -1):
            for p in range(9, 1, -1):
                beki.append(b**p)
        for y in sorted(beki)[::-1]:
            if y <= x:
                print(y)
                return
compute()


Measured memory_bytes: 2940
n = gets.to_i
t = gets.chomp.split.map &:to_i
r = 0
s = 0
ans = 0
t.each.with_index(1) do |d,i|
  if(d == i)
    s = i if(s == 0)
    r += 1
  else
    unless(r == 0)
      ans += r / 2
      unless((r % 2) == 0)
        if(d == (i - 1) and t[s - 2] == s)
          ans += 2
          t[i - 1] = 1000000
        else
          t[i - 1] = 1000000 unless(d == (i - 1))
          ans += 1
        end
      end
    end
    s = 0
    r = 0
  end
end
unless(r == 0)
  ans += r / 2
  unless((r % 2) == 0)
    if(t[s - 2] == s)
      ans += 2
    else
      ans += 1
    end
  end
end
p ans

Measured memory_bytes: 8716
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b){
  if(a < b) swap(a, b);
  ll r = a % b;
  if(r==0)return b;
  while(r!=0){
    r = a % b;
    a = b,b = r;
  }
  return a;
}

int main(int argc, char const *argv[]) {
  ll A, B, C, D;
  std::cin >> A >> B >> C >> D;
  ll CokB = B/C, CokA = (A-1)/C, DokB=B/D, DokA=(A-1)/D;
  ll lcm = (C*D)/gcd(C, D);
  ll CDokB = B/lcm,CDokA=(A-1)/lcm;
  //std::cout << lcm << '\n';
  //std::cout << DokB << " " << DokA << " " << CokB << " " << CokA << '\n';
  //std::cout << CDokB << " " << CDokA << '\n';
  std::cout << B - A + 1  -(DokB+CokB-CokA-DokA-(CDokB-CDokA)) << '\n';
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const double pi=acos(-1);
const ll P = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
const double eps=1e-5;
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int maxn=2e5+10;
int a[maxn];
int n;
ll check(int x)
{ 
  ll ans=0;
  for(int i=1;i<=n;i++)
  { 
        ans+=abs(a[i]-x);
  }
  return ans;
}

int main()
{
  cin>>n;
  int l=-1e9,r=1e9;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    a[i]-=i;
  }
  while(l<r-1)
  {
    int midl=l+r>>1;
    int midr=midl+r>>1;
    if(check(midl)>check(midr)) l=midl;
    else r=midr;
  }
  cout<<min(check(l),check(r))<<endl;
}

Measured memory_bytes: 4352
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a '30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    string s;
    cin >> s;
    if(s[1] == 'B') s[1] = 'R'; else s[1] = 'B';
    cout << s << '\n';
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    string s,t;
    cin >> s >> t;
    int s_size = s.size();
    int t_size = t.size();
    int dp[3005][3005];

    REP(i,t_size + 1) dp[0][i] = 0;
    REP(i,s_size + 1) dp[i][0] = 0;

    REP(i,s_size){
        REP(j,t_size){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else{
                chmax(dp[i+1][j+1], max( dp[i+1][j],dp[i][j+1]) );
            }
        }
    }  
    string ans;
    int i = s_size;
    REPR(j,t_size){
        if(dp[i][j+1] > dp[i][j]){
            ans = t[j] + ans;
            while(s[i-1] != t[j]){
                i--;
                if(i == 0) break;
            }
            i --;
        }
        if(i == -1) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 70784
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int x, y, z;
  readf("%s %s %s\n", &x, &y, &z);

  auto yz = y + z;
  int res;
  auto w = z;
  while (w < x) {
    if (w + yz <= x) {
      res++;
      w += yz;
    } else {
      break;
    }
  }

  res.writeln;
}


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

int main() {
  int K, N;
  cin >> N >> K;
  vector<int> xs(N);
  for (auto& x : xs) cin >> x;
  sort(xs.rbegin(), xs.rend());
  for (int i = 1; i < N; ++i) xs[i] += xs[i - 1];
  cout << xs[K - 1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char s[MN+5];
int n,nxt[MN+5][26],f[MN+5];
int main()
{
    scanf("%s",s+1);n=strlen(s+1);for(int i=0;i<26;++i)nxt[n+1][i]=n+1;
    for(int i=n;i;--i) memcpy(nxt[i],nxt[i+1],sizeof(nxt[0])),nxt[i][s[i]-'a']=i;
    for(int i=n;~i;--i)
    {
        f[i]=1e9;
        for(int j=0;j<26;++j) f[i]=min(f[i],f[nxt[i+1][j]]+1);
    }
    for(int i=0;i<=n;)
        for(int j=0;j<26;++j) if(f[nxt[i+1][j]]==f[i]-1)
        {
            printf("%c",j+'a');i=nxt[i+1][j];
            break;
        }
    return 0;
}


Measured memory_bytes: 21504
#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>;

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

int main() {
    // 全探索
    int H, W;
    cin >> H >> W;
    int CH, CW;
    cin >> CH >> CW;
    --CH; --CW;
    int DH, DW;
    cin >> DH >> DW;
    --DH; --DW;
    vector<string> S(H);
    rep(i, H) {
        string s;
        cin >> s;
        S[i] = s;
    }

    vector<vector<int>> dist(H, vector<int> (W, INF));
    queue<P> que;
    queue<P> queWarp;
    auto update = [&] (int i, int j, int d) {
        if (dist[i][j] < d) return;
        dist[i][j] = d;
        que.emplace(i, j);
    };
    auto updateWarp = [&] (int i, int j, int d) {
        if (dist[i][j] < d) return;
        dist[i][j] = d;
        queWarp.emplace(i, j);
    };    
    update(CH, CW, 0);
    // queWarp.emplace(CH, CW);
    while (!que.empty() || !queWarp.empty()) {
        if (!que.empty()) {
            int ci = que.front().first;
            int cj = que.front().second; que.pop();
            int cd = dist[ci][cj]; // 現在のワープ魔法の回数
            rep(dir, 4) {
                int ni = ci + dx[dir];
                int nj = cj + dy[dir];
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if (S[ni][nj] == '#' || dist[ni][nj] <= cd) continue;
                update(ni, nj, cd);
            }       
            for (int i = -2; i <= 2; i++) {
                for (int j = -2; j <= 2; j++) {
                    int ni = ci + i;
                    int nj = cj + j;
                    if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                    if (S[ni][nj] == '#' || dist[ni][nj] <= cd) continue;
                    updateWarp(ni, nj, cd + 1);
                }
            }
        } else if (!queWarp.empty()) {
            int ci = queWarp.front().first;
            int cj = queWarp.front().second; queWarp.pop();
            int cd = dist[ci][cj]; // 現在のワープ魔法の回数
            rep(dir, 4) {
                int ni = ci + dx[dir];
                int nj = cj + dy[dir];
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if (S[ni][nj] == '#' || dist[ni][nj] <= cd) continue;
                update(ni, nj, cd);
            }
            for (int i = -2; i <= 2; i++) {
                for (int j = -2; j <= 2; j++) {
                    int ni = ci + i;
                    int nj = cj + j;
                    if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                    if (S[ni][nj] == '#' || dist[ni][nj] <= cd) continue;
                    updateWarp(ni, nj, cd + 1);
                }
            }            
        }        
    }
    int ans = dist[DH][DW];
    if (ans == INF) ans = -1;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 9336