akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S, T;
int s[int(1e5+5)], t[int(1e5+5)];

int main(){
  cin >> S >> T;
  for (int i = 1; i <= S.length(); i++){
    s[i] = s[i-1];
    if (S[i-1] == 'A') s[i]++;
    else s[i] += 2;
  }

  for (int i = 1; i <= T.length(); i++){
    t[i] = t[i-1];
    if (T[i-1] == 'A') t[i]++;
    else t[i] += 2;
  }


  int Q; cin >> Q;
  for (int i = 0; i < Q; i++){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int nows = s[B] - s[A-1], nowt = t[D] - t[C-1];

    if ((nowt - nows) % 3 == 0) YES();
    else NO();
  }

  return 0;
}


Measured memory_bytes: 4552
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        while (a % 2 == 0){
            a /= 2;
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

const ll INF = 1ll<<60;
int a, b, q;
ll s[100100], t[100100], x;

bool isOK(int index, ll key, ll arr[]) {
    if (arr[index] >= key) return true;
    else return false;
}
int binary_search(ll key, ll arr[], int size) {
    int ng = -1;
    int ok = size;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (isOK(mid, key, arr)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    scanf("%d%d%d", &a, &b, &q);
    for(int i=1; i<=a; i++)scanf("%lld", &s[i]);
    for(int i=1; i<=b; i++)scanf("%lld", &t[i]);
    s[0] = -INF;s[a+1] = INF;t[0] = -INF; t[b+1] = INF;
    while(q--){
        scanf("%lld", &x);
        int i = binary_search(x, s, a+2);
        int j = binary_search(x, t, b+2);
        ll sum = min(min(max(s[i]-x, t[j]-x), max(x-s[i-1], x-t[j-1])), min(min(s[i]-x, x-t[j-1])+s[i]-t[j-1], min(t[j]-x, x-s[i-1])+t[j]-s[i-1]));
        printf("%lld\n", sum);
    }
    return 0;
}

Measured memory_bytes: 2816
N = gets.to_i
as = gets.split.map(&:to_i).sort
bs = gets.split.map(&:to_i).sort
cs = gets.split.map(&:to_i).sort

bc = Array.new(N)

N.times do |i|
    b = bs[i]
    while cs.length > 0 && cs[0] <= b
        cs.shift
    end
    bc[i] = cs.length
end

sum = 0
N.times do |i|
    b = bs[N - 1 - i]
    while as.length > 0 && b <= as[-1]
        as.pop
    end
    sum += as.length * bc[N - 1 - i]
end

print sum



Measured memory_bytes: 24688
//Love and Freedom.
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
using namespace std;
int a[(1<<18)|1];
int mx[1<<18][2];
int ans[1<<18];
bool cmp(int x,int y){return a[x]<a[y];}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<(1<<n);i++)
	{
		scanf("%d",&a[i]);
		mx[i][0] = i;
		mx[i][1] = (1<<n);
	}
	for(int i=0;i<(1<<n);i++)
	{
		int tmp[4]={0};
		for(int j=0;j<n;j++)
			if((i>>j)&1)
			{
				int _i = i^(1<<j);
				tmp[0] = mx[i][0]; tmp[1] = mx[i][1];
				tmp[2] = mx[_i][0]; tmp[3] = mx[_i][1];
				sort(tmp,tmp+4,cmp);
				mx[i][0] = tmp[3]; mx[i][1] = tmp[2]==tmp[3]?tmp[1]:tmp[2];
				//printf("%d %d\n",mx[i][0],mx[i][1]);
			}
		ans[i] = a[mx[i][0]] + a[mx[i][1]];
	}
	for(int i=1;i<(1<<n);i++)	ans[i] = max(ans[i],ans[i-1]);
	for(int i=1;i<(1<<n);i++)	printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 7304
#include<iostream>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b){
		int s=a+b;
		if(s>=1000000)a=7;
		else if(s<1000000&&s>=100000)a=6;
		else if(s<100000&&s>=10000)a=5;
		else if(s<10000&&s>=1000)a=4;
		else if(s<1000&&s>=100)a=3;
		else if(s<100&&s>=10)a=2;
		else a=1;
		cout<<a<<endl;
	}



	return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
void PDF(vector < string > v)
{
    int i,s = 0;
    sort(v.begin(), v.end());

    for(i = 0 ;i<v.size();i++)
    {
        if(v[i]!= v[i+1])
            s += 1;
    }
    cout << s <<endl;
}
int main()
{
    int n,i,j,l;
    string S;
    vector < string > m;
    cin >> n;

    for(i = 0; i<n ;i++)
    {
        cin >> S;
        m.push_back(S);
    }
    PDF(m);

    return 0;
}


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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C;
  cin >> K;
  int ans;
  if(A >= B && A >= C) ans = (A << K) + B + C;
  else if(B >= C && B >= A) ans = (B << K) + A + C;
  else if(C >= A && C >= B) ans = (C << K) + A + B;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

class Main {

  static final int MOD = 1000000007;

  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for (int a = 1; a <= 3500; a++) {
      for (int b = 1; b <= 3500; b++) {
        double num = (double) n * a * b / (4 * a * b - n * b - n * a);
        // if(num<0)break;
        // System.out.println(a + " " + b + " " + num);
        if (num > 0 && Math.abs(num - Math.round(num)) == 0) {
          System.out.println(a + " " + b + " " + Math.round(num));
          return;
        }
      }
    }
    throw new Exception();
  }
}

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

int main() {
  long n, m;
  cin >> n >> m;
  vector<pair<long, long>> card(n + m);
  for (int i = 0; i < n; i++) {
    cin >> card.at(i).first;
    card.at(i).second = 1;
  }
  for (int i = 0; i < m; i++) {
    cin >> card.at(i + n).second >> card.at(i + n).first;
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  long num = 0;
  long sum = 0;
  for (int i = 0; i < (n + m); i++) {
    int newest = card.at(i).first;
    sum += card.at(i).first * card.at(i).second;
    num += card.at(i).second;
    if (num >= n) {
      sum -= (num - n) * newest;
      break;
    }
  }
  cout << sum;
}

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

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int A = sc.nextInt();
        int B =sc.nextInt();
        out.println(A*B);

        out.flush();

    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

    }
}

Measured memory_bytes: 32792
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d,q;

string a[3];

int main()
{
    string s;
    int temp=1;
    cin>>s;

    for(int i=0;i<s.length();i++)
    {
        if(i%2==0)
        {if(s[i]=='L')
        {
            temp=0;
            cout<<"No"<<endl;
            break;
        }}
        else
        {
            if(s[i]=='R')
            {
                temp=0;
                cout<<"No"<<endl;
                break;
            }
        }
    }
    if(temp==1)
        cout<<"Yes"<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e,f;
	float x,y;
	
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != EOF){
			
	x = (float)(c*e-f*b)/(a*e-d*b);
	y = (float)(c*d-f*a)/(b*d-e*a);
	
	if(x == -0){
		x = 0;
	}
	if(y == -0){
		y = 0;
	}
	printf("%.3f %.3f\n",x,y);
	}
	
	return(0);
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    priority_queue<pii> pq;
    rep(i, n) {
        Int(tmp);
        pq.push({tmp, 1});
    }
    rep(i, m) {
        int2(a, b);
        pq.push({b, a});
    }

    int cnt = 0, ans = 0;
    while (cnt < n) {
        pii tmp = pq.top();
        pq.pop();
        int num = min(tmp.second, n - cnt);
        ans += num * tmp.first;
        cnt += tmp.second;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int ans = INF;
  for(int i = 0; i+2<s.size();i++){
    int n = stoi(s.substr(i,3));
    ans=min(ans,abs(n-753));
  }
  cout  << ans << endl;
}


Measured memory_bytes: 256
def kaibun(strings):
    global flag
    for i in range(len(strings)):
        if strings[i] is not strings[len(strings)-1-i]:
            #print("iは")
            #print(i)
            #print(strings[i])
            #print(strings[len(strings)-1-i])
            flag=1
            #print("flagは1になった")
            #print(flag)
        else:
            pass


S=input()
length=len(S)
S_2=S[0:(length-1)//2]
#print(S_2)
S_3=S[(length+3)//2-1:length]
#print(S_3)

flag=333
#print("flagはいくつ？")
flag=0
#flagが0なら回文である
#なぜかflagが最後に書き換わってしまう。


kaibun(S)
kaibun(S_2)
kaibun(S_3)
#print("呼び出し")

#print(flag)

if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cstdio>

int main(){
	int n;
	scanf("%d", &n);
	int yz_num;
	int i, j,ans=0;
	for (i = 1; i <= n; i+=2){
		yz_num=0;
		for (j = 1; j <= n; ++j)
			if (!(i % j))
				++yz_num;
		if (yz_num==8)
			++ans;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
L, *A = map(int, open(0))

D = [(2, 1), (1, 0), (0, 1)]

s0 = s1 = s2 = s3 = s4 = 0

for a in A:
    e, o = D[(a - 1) % 2 + 1 if a else 0]

    s0 += a
    s1 = s0 if s0 < s1 + e else s1 + e
    s2 = s1 if s1 < s2 + o else s2 + o
    s3 = s2 if s2 < s3 + e else s3 + e
    s4 = s3 if s3 < s4 + a else s4 + a

print(min(s0, s1, s2, s3, s4))


Measured memory_bytes: 11036
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);

	int n;
	long long a, b;
	long long left = 0;

	scanf("%d", &n);

	scanf("%lld %lld", &a, &b);

	b += a;

	for (int i = 0; i < n - 2; i++)
	{
		long long input;

		scanf("%lld", &input);

		left ^= input;
	}

	long long bit[40] = { 0, };

	long long temp = left;

	long long diff = b;

	long long val = 1;

	for (int i = 0; i < 40 && temp; i++)
	{
		bit[i] = temp % 2;

		diff -= bit[i] * val;

		temp /= 2;
		val *= 2;
	}

	if (diff < 0 || diff % 2)
	{
		printf("-1\n");

		return 0;
	}

	temp = diff / 2;

	val = 1;
	long long add = 0;

	for (int i = 0; i < 40 && temp; i++)
	{
		if (temp % 2)
		{
			if (bit[i])
			{
				printf("-1\n");

				return 0;
			}

			add += val;
		}

		temp /= 2;
		val *= 2;
	}

	if (add > a)
	{
		printf("-1\n");

		return 0;
	}

	long long diff2 = a - add;
	long long sol = diff2;

	for (int i = 39; i >= 0; i--)
	{
		if (bit[i])
		{
			long long val = (long long)pow(2.0, i);

			if (val <= diff2)
			{
				diff2 -= val;
			}
		}

		if (diff2 < sol)
		{
			sol = diff2;
		}
	}

	if (sol == a)
	{
		printf("-1\n");

		return 0;
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 2540
// ------------------------------------
// Date:2018/ 3/24
// Problem:One Stroke Path re_c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 8;


struct Edge {
  Edge(int _to)
    : to(_to){}
  int to;
};

vector< Edge > e[MAX_N];

int N;

bool check(vector< bool > state)
{
  REP(v, state.size()) {
    if (!state[v]) return false;
  }
  return true;
}

int dfs(int from, vector< bool > _state)
{
  int res = 0;
  
  _state[from] = true;
  
  if (check(_state)) {
    return 1;
  }
  EACH(to, e[from]) {
    if (_state[to.to]) continue;
    res += dfs(to.to, _state);
  }
  return res;
}

int main()
{
  int M;
  cin >> N >> M;
  vector< int > a(M);
  vector< int > b(M);
  REP(i, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    e[a[i]].emplace_back(Edge(b[i]));
    e[b[i]].emplace_back(Edge(a[i]));
  }

  vector< bool > state(N, false);
  state[0] = true;
  
  int ans = dfs(0, state);

  cout << ans << endl;

  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>	
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());

using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
 
int pref[101];
int a[101];

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int n, x;
	cin >> n >> x;	
	for(int i = 1; i <= n; i++) cin >> a[i];
	pref[1] = 0;
	for(int i = 1; i <= n; i++) pref[i + 1] = pref[i] + a[i];
	int cnt = 0;
	for(int i = 1; i <= n + 1; i++) if(pref[i] <= x) cnt++;
	cout << cnt;
}                                


Measured memory_bytes: 256
from collections import deque
N,Q = map(int,input().split())
adj = [ [] for _ in range(N) ]
for _ in range(N-1):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append(v)
  adj[v].append(u)

scores = [0] * N
for _ in range(Q):
  u,p = map(int,input().split())
  u -= 1
  scores[u] += p

res = [0] * N
visited = [False] * N
q = deque([(scores[0], 0)])
while q:
  s,n = q.popleft()
  res[n] = s
  visited[n] = True

  for nei in adj[n]:
    if not visited[nei]:
      q.append((s+scores[nei], nei))

print(" ".join(map(str, res)))

Measured memory_bytes: 141072
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String S[] = new String[N];
        for (int i = 0; i < N; i++) {
            S[i] = sc.next();
        }
        Arrays.sort(S);
        String ans = String.join("", S);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

const int T=1e5+10;

int n,c;
vi imos;
vi chnl[35];
int s,t,x;

signed main(){
    io();
    cin>>n>>c;
    imos.resize(2*T+10);
    REP(i,1,c+1) chnl[i].resize(2*T+10);

    rep(i,n){
        cin>>s>>t>>x;
        if(chnl[x][2*s]==-1){
            chnl[x][2*s]++;
        }else{
            chnl[x][2*s-1]++;
        }

        if(chnl[x][2*t-1]==1){
            chnl[x][2*t-1]--;
        }else{
            chnl[x][2*t]--;
        }
    }
/*
    REP(i,1,c+1){
        rep(j,2*t+1){
            cerr<<i<<","<<j<<" = "<<chnl[i][j]<<endl;
        }
    }
*/
    REP(i,1,c+1){
        rep(j,2*T){
            imos[j]+=chnl[i][j];
        }
    }

    int ans=-1;
    rep(i,2*T) {
        imos[i+1]+=imos[i];
        ans=max(imos[i+1],ans);
    }
    //rep(i,25) show(imos[i]);
    
    out(ans);

    return 0;
}


Measured memory_bytes: 50816
package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"strconv"
	"strings"
	"time"
)

var cnt int

func main() {
	rand.Seed(time.Now().UnixNano())
	cnt = 0
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n := scanInt(stdin)

	a := scanIntArray(stdin)
	m, g := shellSort(a, n)
	fmt.Println(m)
	fmt.Println(strings.Trim(fmt.Sprint(g), "[]"))
	fmt.Println(cnt)
	for _, v := range a {
		fmt.Println(v)
	}

}

func shellSort(a []int, n int) (int, []int) {

	m, g := calcInterval(n)

	for _, v := range g {
		insertSort(a, n, v)
	}
	return m, g
}

func calcInterval(n int) (int, []int) {
	rg := []int{}
	m := 0
	for v := 1; v <= n; v = 3*v + 1 {
		m++
		rg = append(rg, v)
	}
	g := []int{}
	for i := len(rg) - 1; i >= 0; i-- {
		g = append(g, rg[i])
	}
	return m, g
}

func insertSort(a []int, n, g int) {
	for i := g; i < n; i++ {
		v := a[i]
		j := i - g
		for j >= 0 && a[j] > v {
			a[j+g] = a[j]
			j = j - g
			cnt++
		}
		a[j+g] = v
	}
}

func scanIntArray(stdin *bufio.Scanner) []int {
	is := []int{}
	for stdin.Scan() {
		i := scanInt(stdin)
		is = append(is, i)
	}
	return is
}

func scanInt(sc *bufio.Scanner) int {
	t := sc.Text()
	i, err := strconv.Atoi(t)
	if err != nil {
		panic(err)
	}
	return i
}



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 1020304050607080901
typedef pair<int,int> ip;
typedef pair<ll,ip> P;


int main()
{
  int n,m,s;
  cin >> n >> m >> s;
  s = min(s,n*50);
  vector<int> u(m);
  vector<int> v(m);
  vector<int> a(m);
  vector<int> b(m);
  int i,j;
  rep(i,m)
  {
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    u[i]--;
    v[i]--;
  }
  vector<int> c(n);
  vector<int> d(n);
  rep(i,n)
  {
    cin >> c[i] >> d[i];
  }
  vector<vector<ip>> g(n);
  rep(i,m)
  {
    g[u[i]].emplace_back(make_pair(v[i],i));
    g[v[i]].emplace_back(make_pair(u[i],i));
  }
  vector<vector<ll>> cost(n,vector<ll>(n*50+1,INF));
  cost[0][s] = 0;
  priority_queue<P,vector<P>,greater<P>> pq;
  pq.push(make_pair(0,make_pair(0,s)));
  while(!pq.empty())
  {
    P nowp = pq.top();
    pq.pop();
    ll ncost = nowp.first;
    ip nowip = nowp.second;
    int now = nowip.first;
    int money = nowip.second;
    if(ncost > cost[now][money]) continue;
    rep(i,g[now].size())
    {
      ip next = g[now][i];
      int to = next.first;
      int ind = next.second;
      if(money >= a[ind] && cost[now][money]+b[ind] < cost[to][money-a[ind]])
      {
        cost[to][money-a[ind]] = cost[now][money]+b[ind];
        pq.push(make_pair(cost[now][money]+b[ind],make_pair(to,money-a[ind])));
      }
    }
    int ifadd = min(money+c[now],n*50);
    if(cost[now][money]+d[now] < cost[now][ifadd])
    {
      cost[now][ifadd] = cost[now][money]+d[now];
      pq.push(make_pair(cost[now][money]+d[now],make_pair(now,ifadd)));
    }
  }
  for(i=1;i<n;i++)
  {
    ll ans = INF;
    rep(j,n*50+1)
    {
      ans = min(ans, cost[i][j]);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 6076
h, n = map(int, input().split())
dp = [10**10]*(h+10**4+1)
dp[0] = 0

for _ in range(n):
  a, b = map(int, input().split())
  for i in range(a, len(dp)):
    dp[i] = min(dp[i-a]+b, dp[i])

print(min(dp[h:]))

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


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

    reverse(s.begin(), s.end());


    string divide[4] = {"dream", "dreamer", "erase", "eraser"};

    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    bool can = true;

    for (int i = 0; i < s.size();){
        bool can2 = false;
        for (int j = 0; j < 4; ++j){
            string d = divide[j];
            if (s.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }

        if(can2 == false){
            can = false;
            break;
        }
    }



    if (can == true) cout << "YES" << endl;
    else cout << "NO" << endl;


}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
char s[200005],t[200005];

int main(){
    scanf("%s%s",s+1,t+1);
    int n = strlen(s+1);
    int ans = 0;
    for(int i = 1; i <= n; i++) ans += (s[i]!=t[i]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int X; cin>>X;
    int ans=1;
    for(int p=2;p<=10;p++){
        for(int i=1;;i++){
            int k=pow(i,p);
            if(k<=X){
                ans=max(ans,k);
            }
            else break;
        }
    }
    cout<<ans<<endl;

}

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

int main(){

	int n, m ;
	cin >> n >> m ;

	map<int,int> ar ;
	LL x, sum = 0 ;
	
	ar[sum]++ ;
	while(n--){
		cin >> x ;
		sum = (sum + x) % m ;
		ar[sum]++ ;
	}

	LL ans = 0 ;
	for(auto i : ar){
		x = i.second ;
		ans += (x * (x - 1)) / 2 ;
	}
	cout << ans << endl ;

	return 0;
}

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

const int N = 1e5 + 3;
int n, ans;
pair<int, int> seg[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		int x, l; scanf("%d %d", &x, &l);
		seg[i] = make_pair(x + l, x - l);
	}
	sort(seg + 1, seg + 1 + n);
	for(int i = 1, cur = INT_MIN; i <= n; i++) 
		if(seg[i].second >= cur) ans++, cur = seg[i].first;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+9

using namespace std;

//j本目の判定関数;
int hantei (int i,int j){
    int t=i/(pow(4,j));
    int e=t%4;
    if(e==0) return 0;
    else if(e==1) return 1; //A
    else if(e==2) return 2; //B
    else return 3; //C
}


int main(){
    int n,a,b,c;
    cin >> n >> a >> b >>c;
    int l[n+10];
    rep(i,n) cin >> l[i];
    int t=pow(4,n);
    int cost[t];
    rep(i,t){
        int A,B,C;
        A=0;B=0;C=0;
        int d,e,f;
        d=0;e=0;f=0;
        //コスト計算用
        rep(j,n){
            if(hantei(i,j)==1) {
                A+=l[j];
                d++;
            }
            else if(hantei(i,j)==2) {
                B+=l[j];
                e++;
            }
            else if(hantei(i,j)==3) {
                C+=l[j];
                f++;
            }
        }
        //全部使ったか？
        if(d==0){
            cost[i]=INF;
            continue;
        }
        if(e==0){
            cost[i]=INF;
            continue;
        }
        if(f==0){
            cost[i]=INF;
            continue;
        }
        int entyou=d+e+f-3;
        cost[i]=abs(A-a)+abs(B-b)+abs(C-c)+10*entyou;
    }
    int ans=INF;
    rep(i,t) ans=min(ans,cost[i]);
    cout << ans << endl;
}


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

#define FOR(i,start,end) for(int i=start; i<(int)(end); i++)
#define REP(i,n) FOR(i,0,n)
#define SIZE_OF_ARRAY(array)  (sizeof(array)/sizeof((array)[0]))

template<class T> void print(const T& value) { cout << value << "\n"; }

int main() {

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

    int x, y;
    scanf("%d %d", &x, &y);

    if(x > y) {
        printf("a > b\n");
    } else if(x < y) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }


    return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll gcd( ll a, ll b )
{
  ll t;
  if( a < b ){ t = a; a = b; b = t; }
  while( ( t = a % b ) != 0 ){ a = b; b = t; }
  return b;
}
ll lcm( ll a, ll b )
{
  return (a / gcd(a,b)) * b;
}
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  ll ret, a;
  cin >> ret;
  for( int i=1; i<N; i++ ){
    cin >> a;
    ret = lcm( ret, a );
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(300).
01 S          PIC X(100).
01 T          PIC X(100).
01 ans        PIC X(200).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO S T.
  STRING FUNCTION TRIM(T) FUNCTION TRIM(S) INTO ans.
  DISPLAY FUNCTION TRIM(ans).
  STOP RUN.


Measured memory_bytes: 3708
#include<stdio.h>
int main(void)
{
	float a,b;
	while(scanf("%f %f",&a,&b)!=EOF){
	if(a<35.5 && b<71.0){
			printf("AAA\n");
			}
	else if(a<37.5 && b<77.0){
			printf("AA\n");
			}
	else if(a<40.0 && b<83.0){
			printf("A\n");
			}
	else if(a<43.0 && b<89.0){
			printf("B\n");
			}
	else if(a<50.0 && b<105.0){
			printf("C\n");
			}
	else if(a<55.0 && b<116.0){
			printf("D\n");
			}
	else if(a<70.0 && b<148.0){
			printf("E\n");
			}
		else{
			printf("NA\n");
		}
		}
	return 0;
}
	

Measured memory_bytes: 604
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
#define N 5010
ll f[N][N]; int a[N];
void upd(ll &x,ll y){x=x<y?x:y;}
int main()
{
	int n=read(),A=read(),B=read();
	for(int i=1;i<=n;i++)	a[i]=read();
	memset(f,48,sizeof(f)); f[0][0]=0;
	for(int i=1;i<=n;i++)	for(int j=0;j<=n;j++)
		if(a[i]>j)	upd(f[i][j],f[i-1][j]+A),upd(f[i][a[i]],f[i-1][j]);
		else	upd(f[i][j],f[i-1][j]+B);
	for(int i=1;i<=n;i++)	upd(f[n][0],f[n][i]);
	printf("%lld\n",f[n][0]);
	return 0;
}


Measured memory_bytes: 196224
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
typedef long long int ll;

#define min(x,y)(x<y?x:y)
 
using namespace std;

#define MAX 1000

int main() {
	FAST;
	
    int n, m;
    long long x, y, z;
    priority_queue<long long> q1;
    priority_queue<long long> q2;
    priority_queue<long long> q3;
    priority_queue<long long> q4;
    priority_queue<long long> q5;
    priority_queue<long long> q6;
    priority_queue<long long> q7;
    priority_queue<long long> q8;
 
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> z;
        //sum = abs(x) + abs(y) + abs(z);
        q1.push(+x + y + z);
        q2.push(-x + y + z);
        q3.push(+x - y + z);
        q4.push(+x + y - z);
        q5.push(-x - y + z);
        q6.push(+x - y - z);
        q7.push(-x + y - z);
        q8.push(-x - y - z);
    }
 
    long long  sum1 = 0;
    long long  sum2 = 0;
    long long  sum3 = 0;
    long long  sum4 = 0;
    long long  sum5 = 0;
    long long  sum6 = 0;
    long long  sum7 = 0;
    long long  sum8 = 0;
    while (m--) {
        sum1 += q1.top(); q1.pop();
        sum2 += q2.top(); q2.pop();
        sum3 += q3.top(); q3.pop();
        sum4 += q4.top(); q4.pop();
        sum5 += q5.top(); q5.pop();
        sum6 += q6.top(); q6.pop();
        sum7 += q7.top(); q7.pop();
        sum8 += q8.top(); q8.pop();
    }
 
    priority_queue<long long> total_sum;
    total_sum.push(sum1);
    total_sum.push(sum2);
    total_sum.push(sum3);
    total_sum.push(sum4);
    total_sum.push(sum5);
    total_sum.push(sum6);
    total_sum.push(sum7);
    total_sum.push(sum8);
 
    cout << total_sum.top() << endl;
 
    return 0;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,c; cin >> a >> b >> c;
    OUT((a * b) / 2);

    return 0;
}

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

int main() {
    int n , t , a;
    cin >> n >> t >> a;
    //vector<int> h(n);
    vector<pair<double, double>> h(n);
    for (int i = 0;i < n; i++) {
        int x; cin >> x;
        h[i] = make_pair(abs(a-(t-x*0.006)),i+1);
    }
    /*
    for (int i = 0;i < n; i++) cin >> h.at(i);
    vector<int> nh(n);
    for (int i = 0;i < n; i++) {
        nh.at(i) = t - h.at(i) * 0.006;
        cout << nh.at(i) << endl;
    }
    */
   sort(h.begin(),h.end());
   cout << h[0].second << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
vector<ll>lom;
void solve(string k)
{
    ll ka =stol(k);
    lom.pb(ka);
    if(k.size()==11)return;
    string next1=k,next2=k,next3=k;
    if(k[k.size()-1]!='9')
    {
        next1.pb(k[k.size()-1]+1);
        solve(next1);
    }  
    if(k[k.size()-1]!='0')
    {
        next2.pb(k[k.size()-1]-1);
        solve(next2);
    }
    next3.pb(k[k.size()-1]);
    solve(next3);
}
int main()
{
  //flash;
    ll x;
    cin>>x;
    ll index=0;
    for (ll i = 1; i <= 9; ++i)
    {
        string n;
        n.pb((char)(i+'0'));
        solve(n);
    }
    sort(lom.begin(),lom.end());
    cout<<lom[x-1];
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 10608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(s=="AC") ac++;
        if(s=="WA") wa++;
        if(s=="TLE") tle++;
        if(s=="RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

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

int main(){
	int K,S;
  	cin>>K>>S;
  int count =0;
    int X,Y;
  	for(int X=0;X<=K;X++){
    	for(int Y = 0; Y<=K;Y++){
            	if(S-X-Y>=0 && S-X-Y<=K){
                	count++;
                }
            }
        }
   

  cout << count <<endl;
}


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

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

    int l=S.size();
    if(l%2==0){
        int i;
        for(i=0;i<l/2;i++){
            int a=l/2-1-i, b=l/2+i;
            if(S[a]!=S[l/2] || S[b]!=S[l/2]) break;
        }
        cout << (l/2+i) << endl;
    }else{
        int i;
        for(i=0;i<l/2;i++){
            int a=l/2-1-i, b=l/2+1+i;
            if(S[a]!=S[l/2] || S[b]!=S[l/2]) break;
        }
        cout << (l/2+i+1) << endl;
    }

    return 0;
}

Measured memory_bytes: 512
# @author 

import sys

class LDeque:
    def solve(self):
        n = int(input())
        a = [int(_) for _ in input().split()]
        dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
        for i in range(n - 1, -1, -1):
            dp[i][i] = a[i]
            for j in range(i + 1, n):
                dp[i][j] = max(a[i] - dp[i + 1][j], -dp[i][j - 1] + a[j])

        print(dp[0][n - 1])

solver = LDeque()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 120156
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX_M 201
#define MAX_N 1111
using namespace std;

int x[MAX_M],y[MAX_M],xx[MAX_N],yy[MAX_N];

void solve(){
 int m,n;
 for(;;){
  cin>>m;
  if(!m) break;
  set<pii> st;
  vector<pii> v;
  FOR(i,m) cin>>x[i]>>y[i];
  cin>>n;
  FOR(i,n){
   cin>>xx[i]>>yy[i];
   st.insert(mp(xx[i],yy[i]));
  }
  FOR(i,m){
   v.pb(mp(x[i]-x[0],y[i]-y[0]));
  }
  set<pii>::iterator ite;
  FOR(i,n){
   bool f=true;
   FOR(j,v.size()){
    ite=st.find(mp(v[j].first+xx[i],v[j].second+yy[i]));
    if(ite==st.end()){
     f=false;
     break;
    }
   }
   if(f){
    cout<<xx[i]-x[0]<<" "<<yy[i]-y[0]<<endl;
    break;
   }
  }
 }
}

int main(){
 solve();
 return 0;
}

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

int main() {
    int n;
    long long ans=0;
    cin >> n;

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

    for (int i=0; i<n; ++i) {
        cin >> b;
        if (a[i] - b >= 0)
            ans += b;
        else {
            ans += a[i];
            b -= a[i];
            if (a[i+1] - b >= 0) {
                ans += b;
                a[i+1] -= b;
            }
            else {
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,k;cin>>n>>k;
  double b=0.0;
  reps(i,1,n+1){
    int c=1,d=i;
    while(d<k){
      c*=2;
      d*=2;
    }
    b+=1.0/(double)c;
  }
  cout<<fixed<<setprecision(11)<<b/(double)n;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;ll k;
    cin >> n >> k;
    vi a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    
    ll l=0, r=-1;
    rep(i, n) {
        ll t = (ll)a[i] * f[i];
        l = (t > l)? t:l;
    }
    
    while (l - r > 1){
        ll x = (l + r) / 2;
        ll s=0;
        rep(i, n){
            s += max(0ll, a[i] - (x/f[i]));
        }
        if (s <= k) l = x;
        else r = x;
    }
    cout << l << endl;
}


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

int main(){
    int N, K, X, Y;
    int sum;

    cin >> N >> K >> X >> Y;

    if (N <= K){
        sum = N*X; 
    }
    else {
        sum = N * X - (X - Y) * (N - K);
    }

    cout << sum << endl;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int M=gi();
        int D=gi();
        
        int c=0;
        for (int i=1;i<=M;i++) {
        	for (int j=22;j<=D;j++) {
            	int one=j%10;
            	int ten=(j-one)/10;
            	if(one>=2 && ten>=2 && one*ten==i) c++;
            }
        }

        System.out.print(c);

//        if (s>L[n-2]) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35692
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var x int
	con.Scan(&x)
	q := x / 11
	r := x % 11
	q = q * 2
	if r > 0 {
		q++
		if r > 6 {
			q++
		}
	}
	con.Println(q)
	return nil
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0)
        cout << "Zero" << endl;
    else if (a > 0)
        cout << "Positive" << endl;
    else
    {
        if ((a - b + 1) % 2 == 0)
            cout << "Positive" << endl;
        else
            cout << "Negative" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------
int main(void)
{

	int a, b, c;

	cin >> a >> b >> c;

	int ans = 0;

	if (a == b) ans++;
	if (a == c) ans++;
	if (b == c) ans++;





	if (ans == 1)cout << "Yes" << endl;
	else cout << "No" << endl;


}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,k;
    cin>>n>>k;
    int a[n+1];
    memset(a,0,sizeof(a));
    rep(i,k){
        int d;
        cin>>d;
        rep(i,d){
            int aa;
            cin>>aa;
            a[aa]=1;
        }
    }
    int ans=0;
    rep(i,n){
        if (a[i+1]==0)ans+=1;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3600
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n-1):
  num = [p[i-1], p[i], p[i+1]]
  if (max(num) == num[0] or max(num) == num[2]) and\
  (min(num) == num[0] or min(num) == num[2]):
    count += 1
print(count)

Measured memory_bytes: 3064
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val arr = IntArray(n){scn.nextInt()}
	val map = mutableMapOf<Int, Int>()
	arr.forEach { map[it] = map.getOrElse(it){0} + 1 }
	var sum = 0L
	map.forEach {
		val v = it.value.toLong()
		sum += v*(v-1)/2
	}
	arr.forEach {
		println(sum-(map[it] ?:0)+1)
	}
}

Measured memory_bytes: 81148
import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		String ss=s.next();
		int c=1;
		for(int i=1;i<ss.length();i++){
		    if(ss.charAt(i)!=ss.charAt(i-1))
		    c++;
		}
		if(c>1)
		System.out.println("Yes");
		else
		System.out.println("No");
	    
	}
}

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

int main(){
    int N;
    long long a_sum = 0;
    long long a_list[200010];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a_list[i];
        a_sum += a_list[i];
    }
    long long x = a_list[0];
    long long x_y;
    long long min = abs(2*x - a_sum);
    for(int i=1; i<N-1; i++){
        x += a_list[i];
        x_y = abs(2*x - a_sum);
        if(x_y <= min){
            min = x_y;
        }
    }
    cout << min;
    return EXIT_SUCCESS;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

int main(int argc, char *argv[])
{
  string s;
  while (cin >> s) {
    stack<char> t;
    each (c, s) {
      if (t.size() && t.top() == 'S' && c == 'T') t.pop();
      else t.push(c);
    }
    cout << t.size() << endl;
  }
  return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    string s;
    cin >> s;
    deque<char> q;
    for(char c:s)
        q.push_back(c);
    bool flip = false;
    int Q;
    cin >> Q;
    rep(qi,Q){
        int ty;
        cin >> ty;
        if(ty==1){
            flip = !flip;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if (flip)
                f = 3 - f;
            if(f==1){
                q.push_front(c);
            }else{
                q.push_back(c);
            }
        }
    }
    if(flip)
        reverse(q.begin(), q.end());
    string ans;
    for(char c: q) ans += c;
    cout << ans << endl;

}

Measured memory_bytes: 1412