akhauriyash/Code-Regression huggingface dataset:
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
  s=input()
  Yes(s[0]!=s[1]or s[2]!=s[1]or s[0]!=s[2])

if __name__ == '__main__':
  main()

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

int main()
{
  int A, B;
  cin >> A >> B;
  int count = 1;
  for (int i = 0;; i++)
  {
    if (count >= B)
    {
      cout << i << endl;
      break;
    }
    count = count + A - 1;
  }
}


Measured memory_bytes: 256
#Breadth First Search

#for every node, print the last visited node before reaching itself
#starting from the source
from collections import deque

def bfs(graph,N,source):
    visited=[0]*N
    visited[source]=1
    q=deque([source])
    while len(q)>0:
        node=q.popleft()
        for i in graph[node]:
            if visited[i]==0:
                visited[i]=node+1
                q.append(i)
    return visited

n,m=map(int,input().split())
graph=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)
aw=bfs(graph,n,0)
print('Yes')
for i in range(1,n):
    print(aw[i])
    

    
        


Measured memory_bytes: 36980
#?´???°????????°????±???????????????°??????

#??°?????¢??°???include
include Math

#??\??????????????????????????°?????\????????????
n = gets.to_i

#?´???°??????????????????????????????????????\????????????
count = 0
for i in 0..n-1
    number = gets.to_i
    #?´???°??????????????¨??????????????°
    flag = 0
    for j in 2..sqrt(number)
        #??\??????????????°??????2??????number?????????????????§??§?????????????????£??????????´???°??§?????????
        if number % j == 0 then
            flag = 1
            break
        end
    end
    # j = 2
    # while j != sqrt(number) + 1 || flag != 1
    #     if number % j == 0
    #         flag = 1
    #     end
    #     j = j + 1
    # end
    if flag == 0 && number != 1 then
        count = count + 1
    end
end

#?´???°????????°?????¨????????????
print count, "\n"

Measured memory_bytes: 8708
V,E,r=map(int,input().split())
W=[tuple(map(int,input().split())) for _ in range(E)]
dis=[float('inf')]*V
dis[r]=0
for _ in range(V-1):
    update=False
    for s,t,d in W:
        if dis[t] > dis[s] + d:
            dis[t] = dis[s] + d
            update = True
    if not update: break
for i in dis:
    print(i if i!=float('inf') else 'INF')


Measured memory_bytes: 94800
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);

double ex[1010];

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    fore(i, 1, 1010)
    {
    	double e = 0;
    	fore(j, 1, i+1)
    	{
    		e += (double)j/(double)i;
    	}
    	ex[i] = e;
    }
    int n, k;
    cin >> n >> k;
    vi v(n);
    fore(i, 0, n)
    {
    	cin >> v[i];
    }
    double ans = 0, acc = 0;
    fore(i, 0, n)
    {
    	acc += ex[v[i]];
    	if (i >= k) acc -= ex[v[i-k]];
    	ans = max(ans, acc);
    }
    cout << fixed << setprecision(8) << ans << '\n';
    return 0;
}
// PLUS ULTRA!

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    vector<pair<ll,ll>> C(N);
    vector<ll> B(N);
    map<ll,ll> bucket;
    for (int i = 0; i < N; ++i) {
        ll tmp;
        cin >> tmp;
        C[i] = make_pair(tmp,i+1);
    }
    bucket[C[0].first + C[0].second]++;
    ll count = 0;
    for (int i = 1; i < N; ++i) {
        ll tmp = -C[i].first  + C[i].second;
        count += bucket[tmp];
        bucket[C[i].first + C[i].second]++;
    }
    cout << count << endl;


}


Measured memory_bytes: 30720
from itertools import combinations
a2e = [int(input()) for i in range(5)]
k = int(input())

com = list(combinations(list(range(5)), 2))
ans = "Yay!"
for i in com:
    if abs(a2e[i[0]] - a2e[i[1]]) > k:
        ans = ":("
        break

print(ans)


Measured memory_bytes: 3060
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0

for i in range(2**n):
    bulb = [0] * m
    for j in range(n):
        if i>>j & 1:
            for k in range(m):
                if j+1 in lst[k][1:]:
                    bulb[k] += 1

    flag = True
    for l in range(m):
        if bulb[l] % 2 != p[l]:
            flag = False
    if flag:
        ans += 1

print (ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	string s;
	cin>>s;
	int n=s.size();
	int k;cin>>k;
	int c0=0,c1=1;
	bool done[n]={0};
	bool ch1,ch2;
	for(int i=1;i<n;i++)
	{
		if(!done[i-1] && s[i]==s[i-1])
		{
			done[i]=1;
			c0++;
		}
	}
	if(s[0]!=s[n-1] || k==1)
	{
		cout<<c0*k<<'\n';
		return 0;
	}
	ch1=done[n-1];
	memset(done,0,sizeof(done));
	done[0]=1;
	for(int i=1;i<n;i++)
	{
		if(!done[i-1] && s[i]==s[i-1])
		{
			done[i]=1;
			c1++;
		}
	}
	ch2=done[n-1];
	int ans=0;
	bool curr=1;
	fo(i,k)
	{
		if(curr==1)
		{
			ans+=c0;
			curr=ch1;
		}
		else
		{
			ans+=c1;
			curr=ch2;
		}
	}
	cout<<ans<<'\n';
	printclock;
}

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

int main()
{
    long long n,ans;
    std::cin>>n;
    ans = 0;
    std::vector<int> a(n+1); //町ごとのモンスターの数
    std::vector<int> b(n); //倒せる数

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




    //各勇者について
    for(int i=0;i<n;i++){
        //勇者の倒せる数より優先街でモンスターが多ければ
        int first = std::min(a[i],b[i]);//最初の街で倒せるモンスター
        int second = std::min(a[i+1],b[i]-first);//次の街で倒せるモンスター
        a[i+1] -= second;
        ans += first;
        ans += second;
    }
    std::cout<<ans<<std::endl;
}

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

int main()
{
  int n;
  cin >> n;
  vector<ll> v(n + 1);

  v.at(0) = 2;
  v.at(1) = 1;
  for (int i = 2; i <= n; i++)
  {
    v.at(i) = v.at(i - 1) + v.at(i - 2);
  }
  cout << v.at(n) << endl;
}


Measured memory_bytes: 3600
from itertools import accumulate

N, W = map(int, input().split())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))

w_max = items[0][0] + 3
w0 = items[0][0]
w0_list = []
w1_list = []
w2_list = []
w3_list = []
for item in items:
    w, v = item
    if w == w0:
        w0_list.append(v)
    if w == w0 + 1:
        w1_list.append(v)
    if w == w0 + 2:
        w2_list.append(v)
    if w == w0 + 3:
        w3_list.append(v)
w0_list = sorted(w0_list, reverse=True)
w1_list = sorted(w1_list, reverse=True)
w2_list = sorted(w2_list, reverse=True)
w3_list = sorted(w3_list, reverse=True)

w0_accum = tuple(accumulate(w0_list))
w1_accum = tuple(accumulate(w1_list))
w2_accum = tuple(accumulate(w2_list))
w3_accum = tuple(accumulate(w3_list))

ans = 0
for i in range(len(w0_list)+1):
    for j in range(len(w1_list)+1):
        for k in range(len(w2_list)+1):
            for m in range(len(w3_list)+1):
                if w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * m > W:
                    continue
                else:
                    tmp = 0
                    if i > 0:
                        tmp += w0_accum[i-1]
                    if j > 0:
                        tmp += w1_accum[j-1]
                    if k > 0:
                        tmp += w2_accum[k-1]
                    if m > 0:
                        tmp += w3_accum[m-1]
                    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amotoma3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long s = in.nextLong();

            if (n < s) {
                out.println(-1);
                return;
            }

            if (n == s) {
                out.println(n + 1);
                return;
            }

            long i = 2;
            while (i * i <= n) {
                long tmp = n;
                long sum = 0;
                while (tmp > 0) {
                    sum += tmp % i;
                    tmp /= i;
                }
                if (sum == s) {
                    out.println(i);
                    return;
                }
                i++;
            }
            while (i * i >= n) i--;
            while (i > 0) {
                long b = (n - s) / i + 1;
                if (n / b + n % b == s) {
                    out.println(b);
                    return;
                }
                i--;
            }

            out.println(-1);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23124
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

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

const int P = int(1e9) + 7;

#define div divavadsad

int sum(int a, int b) {
  if ((a += b) > P) {
    a -= P;
  }
  return a;
}

int diff(int a, int b) {
  if ((a -= b) < 0) {
    a += P;
  }
  return a;
}

int prod(int a, int b) {
  return (int)(ll(a) * b % P);
}

int power(int a, int n) {
  int b = 1;
  while (n) {
    if (n & 1) { b = prod(a, b); }
    a = prod(a, a);
    n /= 2;
  }
  return b;
}

int inv(int a) {
  return power(a, P - 2);
}

int div(int a, int b) {
  return prod(a, inv(b));
}

void print(int x, const char *name) {
#ifdef LOCAL
  const int MAX = 1000;
  for (int i = 1; i <= MAX; ++i) {
    if (prod(x, i) <= MAX) {
      dbg("%s = %d/%d\n", name, prod(x, i), i);
      return;
    }
  }
#endif
}

int C(const vector<int> &fact, int n, int k) {
  return div(fact[n], prod(fact[k], fact[n - k]));
}

bool solve() {
  int b, w;
  if (scanf("%d%d", &b, &w) != 2) { return false; }

  int half = div(1, 2);
  vector<int> pow2(b + w + 1);
  pow2[0] = 1;
  for (int i = 1; i <= b + w; ++i) {
    pow2[i] = prod(pow2[i - 1], half);
  }
  vector<int> fact(b + w + 1);
  fact[0] = 1;
  for (int i = 1; i <= b + w; ++i) {
    fact[i] = prod(fact[i - 1], i);
  }

  int pw = 0;
  int pb = 0;
  for (int i = 0; i < b + w; ++i) {
    if (i >= w) {
      pw = sum(pw, prod(C(fact, i - 1, w - 1), pow2[i]));
    }
    if (i >= b) {
      pb = sum(pb, prod(C(fact, i - 1, b - 1), pow2[i]));
    }
  
    print(pb, "pb");
    print(pw, "pw");
    printf("%d\n", sum(pw, div(diff(1, sum(pw, pb)), 2)));
  }
  return true;
}

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

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, m;
	string s;
	cin>>n>>m>>s;
	vector<int> suf(n+2), dist(n+2, n+1), zeros;
	for(int i=n; i>=0; --i) {
		suf[i]=suf[i+1];
		if(s[i]=='0') {
			suf[i]++;
		}
	}
	for(int i=0; i<=n; ++i) {
		if(s[i]=='0') {
			zeros.push_back(i);
		}
	}
	if(s[0]=='1' || s[n]=='1') {
		cout<<-1;
		return 0;
	}
	dist[n]=0;
	for(int i=n-1; i>=0; --i) {
		while(zeros.size() && i+m<zeros.back()) {
			zeros.pop_back();
		}
		if(s[i]=='0' && zeros.size()) dist[i]=dist[zeros.back()]+1;
	}
	int pos=0;
	vector<int> jump;
	int shortest=dist[0];
	if(dist[0]>=n+1) {
		cout<<-1;
		return 0;
	}
	while(pos!=n) {
		for(int i=1; i<=m; ++i) {
			if(s[pos+i]=='0' && dist[pos+i]==shortest-1) {
				jump.push_back(i);
				pos+=i;
				break;
			}
		}
		shortest--;
	}
	for(int i: jump) {
		cout<<i<<' ';
	}
}


Measured memory_bytes: 2248
function main(input){
    out = 'Yes';

    if(input[2]!=input[3]){
        out = 'No';
    }
    if(input[4]!=input[5]){
        out = 'No';
    }
  console.log(out);

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef struct node Node;
typedef long long ll;

struct node{
  ll val;
  Node *lft,*rht;
};

Node* Insert(Node*,ll);
bool Find(Node*,ll);
void PrintInOrder(Node*);
void PrintPreOrder(Node*);

int main(int argc,char* argv[]){
  Node *root=NULL;
  int n;
  ll x;
  string str;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str;
    switch(str[0]){
    case 'i':
      cin>>x;
      root = Insert(root,x);
      break;
    case 'f':
      cin>>x;
      if(Find(root,x))
	cout<<"yes"<<endl;
      else
	cout<<"no"<<endl;
      break;
    case 'p':
      PrintInOrder(root); cout<<endl;
      PrintPreOrder(root); cout<<endl;
      break;
    }
  }

  return 0;
}

Node* Insert(Node *p,ll x){
  if(p == NULL){
    Node *q = new Node;
    q->val = x;
    q->lft = q->rht = NULL;
    return q;
  }
  else if(x < p->val)
    p->lft = Insert(p->lft,x);
  else
    p->rht = Insert(p->rht,x);

  return p;
}

bool Find(Node *p,ll x){
  if(p == NULL)
    return false;
  else if(x == p->val)
    return true;
  else if(x < p->val)
    return Find(p->lft,x);
  else
    return Find(p->rht,x);
}

void PrintInOrder(Node *p){
  if(p != NULL){
    PrintInOrder(p->lft);

    cout<<" "<<p->val;

    PrintInOrder(p->rht);
  }
}

void PrintPreOrder(Node *p){
  if(p != NULL){
    cout<<" "<<p->val;

    PrintPreOrder(p->lft);
    PrintPreOrder(p->rht);
  }
}

Measured memory_bytes: 13704
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    val c = scanner.nextInt()
    if (a == b) {
        if (b == c) println("No") else println("Yes")
    } else if (a == c) {
        if (b == c) println("No") else println("Yes")
    } else if (b == c) {
        if (a == c) println("No") else println("Yes")
    }else println("No")
}

Measured memory_bytes: 31268
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;
    int main(){
      int N,W[101],S=0,s=0,ans=10000000;
      cin>>N;
      for(int i=1;i<N+1;i++){
        cin>>W[i];
      }
      for(int t=1;t<N;t++){
        s=0;
        S=0;
        for(int k=1;k<=t;k++){
          s=s+W[k];
        }
        for(int l=N;l>t;l--){
          S=S+W[l];
        }
        ans=min(ans,abs(S-s));
      }
      cout<<ans<<endl;
      return 0;
    }

Measured memory_bytes: 256
a=[[0,0,0] for i in range(3)]
for i in range(3):
    *a[i], = map(int, input().split())    
def check(b):
    for i in range(3):
        for j in range(3):
            if b==a[i][j]:
                a[i][j]=0
                break
def bingo():
    if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
        return True
    if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
        return True    
    for i in range(3):
         if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
                return True
    for j in range(3):
         if a[0][j]==0 and a[1][j]==0 and a[2][j]==0:
                return True
    return False

n=int(input())
for i  in range(n):
    check(int(input()))

if bingo():
    print('Yes')
else:
    print('No')

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int h; cin >> h;
    int res = 0;
    int mul = 1;
    while (h) {
        res += mul;
        h /= 2;
        mul *= 2;
    }
    cout << res << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

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

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

int main(){
    int h, w;
    cin >> h >> w;

    char mat[h][w];
    int bomb[h+2][w+2] = {};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
            if(mat[i][j] == '#'){
                for(int k = 0; k < 8; k++){
                    bomb[i+dx[k]+1][j+dy[k]+1]++;
                }
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mat[i][j] == '#')    cout << "#";
            else                    cout << bomb[i+1][j+1];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
import sys

N,W = map(int, sys.stdin.readline().split())

items= [list(map(int, sys.stdin.readline().split()) )for _ in range(N)]
s  =0
for i in range(N):
    s += items[i][1]
INF = 10 **15
dp = [[ INF for _ in range(s +1)] for _ in range(N + 1) ]
#dp[今何個目か][価値] = その時の重さの最小値 重さの最小値がW以下の中で価値最大を出力
dp[0][0] = 0

for j in range(N):  # j 個目の荷物で
    for i in range(s + 1): # 価値

        w,v = items[j]
        if i >= v:
        #遷移 d[j + 1][i] =  (d[j][i - v] + w ) 新しい荷物を選んだ場合
            dp[j + 1 ][i] = dp[j][i - v]  + w  # dp[j][i - w]  + v → j 個持ったところに、更に 価値v のitemが追加されて j+ 1になった
        dp[j + 1][i] =  min(dp[j + 1][i] ,dp[j][i]) #選ばなかった場合
ans = 0
for i in range(s + 1): #価値i
    for j in range(N + 1):  # j 個目の荷物で
        if dp[j][i] <= W:
            ans = max(i,ans)

print(ans)

Measured memory_bytes: 171504
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
const int MAX = 100000;
bool prime[MAX];
vector<ll> V;
ll m,a,b;

void make(){
  fill(prime,prime+MAX,true);

  prime[0] = prime[1] = false;

  for(int i = 0; i*i < MAX; i++)
    if(prime[i])
      for(int j = 2; i*j < MAX; j++) prime[i*j] = false;

  for(int i = 2; i < MAX; i++)
    if(prime[i]) V.push_back(i);
}

int main(){

  make();
  while(cin >> m >> a >> b && m+a+b){
    P ans = P(0,0);

    for(int i = 0; V[i] < m && i < V.size(); i++){
      for(int j = i; V[i]*V[j] <= m && j < V.size(); j++){
	if(a*V[j] <= b*V[i] && V[i]*V[j] > ans.first*ans.second)
	  ans = P(V[i],V[j]);
      }
    }
    cout << ans.first << " " << ans.second << endl;
  }

  return 0;
}

Measured memory_bytes: 1432
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
ll n;
ll a[100010];
int main(){
    cin >> n;
    rep(i, n) cin >> a[i];
    ll ans = 0;
    int cnt =0;
    ll mn = 1L << 60;
    bool f = false;
    rep(i, n) {
        ans += abs(a[i]);
        if(a[i] == 0) {
            f =true;
        }
        if(a[i] < 0) cnt++;
        (chmin(mn, abs(a[i])));
    }
    if(f) cout << ans << endl;
    else {
        if(cnt % 2){
            if(mn > 0) mn = -1 * mn;
            cout << ans + 2 * mn << endl;
        }else{
            cout << ans << endl;

        }
    }



}



Measured memory_bytes: 1024
#include<iostream> 
#include<cstdio> 
using namespace std; 
int main()
{
    int a,b,c;
    char op;
    while(1){
        cin >>a >>op >>b; 
        if ( op == '+' ){
            c=a+b; 
        } else if ( op == '-' ){
            c=a-b; 
        } else if ( op == '*' ){
            c=a*b; 
        } else if ( op == '/' ){
            c=a/b; 
        } else {
            break;
        }
        cout << c <<endl;
    }
}


Measured memory_bytes: 3084
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]*n
for i in range(n-1):
  b[i+1]=b[i]+a[i+1]
c=[]
for i in range(n-1):
  c.append(abs(b[n-1]-b[i]-b[i]))
print(min(c))
  

Measured memory_bytes: 28252
from sys import stdin


def main():
    N, Q = map(int, input().split())
    S = input().strip()
    LR = [int(x) - 1 for x in  stdin.read().split()]
    AC = []
    pre = None
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
            pre = None
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for l, r in zip(*[iter(LR)] * 2):
        print(AC[r] - AC[l])
    return


main()


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

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main(){
  int n,k,a;
  a = 0;
  
  cin >> n >> k;
  int p[n];
  
  for(int i=0;i<n;i++)
    cin >> p[i];
  
  quick_sort (p, 0, n-1);
  
  for(int i=0;i<k;i++)
    a += p[i];
  
  cout << a << endl;
  
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string a;
    cin >> a;
    int p = (a[0] - '0') * 10 + (a[1] - '0');
    int d = (a[2] - '0') * 10 + (a[3] - '0');
    bool rm;
    if (d >= 1 && d <= 12)
        rm = true;
    else
        rm = false;
    bool mr;
    if (p >= 1 && p <= 12)
        mr = true;
    else
        mr = false;
    if (rm && mr)
        cout << "AMBIGUOUS";
    if (rm && !mr)
        cout << "YYMM";
    if (!rm && mr)
        cout << "MMYY";
    if (!rm && !mr)
        cout << "NA";
    return 0;
}


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

#define int long long
#define INF 1e18

signed main() {
    vector<int> v(1, 0); cin >> v[0];

    int idx = 0;
    while(true) {
        if(v[idx] % 2 == 0) {
            v.push_back(v[idx] / 2);
            idx++;
        } else {
            v.push_back(v[idx] * 3 + 1);
            idx++;
        }
        for(int i = 0; i < v.size() - 1; i++) {
            for(int j = i + 1; j < v.size(); j++) {
                if(v[i] == v[j]) {
                    cout << j + 1 << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      
      double a[] =new double[N];//入力する値を格納する
      
      for(int i=0; i<N; i++){
      a[i] = sc.nextInt();
      }
      
      Arrays.sort(a);//入力した値を小さい順から並べる
      
      double min = a[0];//最小の値を決めておく

      for(int j=1; j<N; j++){
      min = (min+a[j])/2;//小さい値から足して計算していけば,最大値を出せる
      }                  //min=(200+a[1]==300)/2,250=(250+a[2]==500)/2...繰り返し...
      System.out.println(min);
    }
}

Measured memory_bytes: 35892
gets;A=$<.map{|e|e.split.map &:to_i}.sort_by{|x,y|x+y};H=[0];A.map{|x,y|(s=H.size-1).downto(0){|i|x>=H[i]&&(i==s&&H<<1e9;H[i+1]>H[i]+y&&H[i+1]=H[i]+y)}};p H.size-1

Measured memory_bytes: 2300
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second)
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
#define umap unordered_map
#define fileio(in, out) freopen("in", "r", stdin); freopen("out", "w", stdout)
const int mod = (int)(1e9) + 7;
//endregion

ll num_groups, p[100005], grpsize[100005];
int par(int x) { return (p[x]==x)? x:par(p[x]); } //No compression
bool isSameGroup(int a, int b) { return par(a) == par(b); }
void merge(int a, int b) {
    a = par(a), b = par(b);
    num_groups -= (!isSameGroup(a, b));
    if (grpsize[a] < grpsize[b]) {
        p[a] = b;
        grpsize[b] += grpsize[a];
    }
    else {
        p[b] = a;
        grpsize[a] += grpsize[b];
    }
}

int main() {
    io();
    ll n, m, t, x, y;
    in2(n, m);
    vll ans(m);
    fori (i, n) p[i] = i, grpsize[i] = 1;
    num_groups = n;
    vii arr(m);
    viin(arr, m);
    t = n*(n-1)/2;
    ford (i, m) {
        ans[i] = t;
        x = par(arr[i].first-1), y = par(arr[i].second-1);
        if (x == y) continue;
        t -= (grpsize[x] * grpsize[y]);
        merge(x, y);
    }
    fori (i, m) outn(ans[i]);
}


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

class Program
{
    static void Main(string[] args)
    {
        var num = int.Parse(Console.ReadLine());
        var people = Console.ReadLine().Split(' ');

        var resultNum = 0;
        var resultSum = int.MaxValue;


        for (var i = 1; i < 101; i++)
        {
            var sum = 0;
            for(var j = 0; j < num ; j++) 
            { 
                var person = int.Parse(people[j]);
                sum += (person - i) * (person - i);
            }

            if(sum < resultSum)
            {
                resultNum = i;
                resultSum = sum;
            }

        }

        Console.WriteLine(resultSum
            );
        Console.ReadLine();

    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;
#define F first
#define S second
const int INF = 1 << 31, MAX_N = 5000;
typedef pair<int, int> P;

void dijkstra();
void bfs(int s, int dis, int cost);
int n, k;
vector<int> road[MAX_N + 1];
int taxi[MAX_N + 1][2];
int reach[MAX_N + 1];

int main(){
	fill(reach + 2, reach + MAX_N + 1, INF);
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> taxi[i][0] >> taxi[i][1];
	}
	for (int i = 0; i < k; i++){
		int a, b;
		cin >> a >> b;
		road[a].push_back(b);
		road[b].push_back(a);
	}
	dijkstra();
	cout << -reach[n] << endl;
	return 0;
}

priority_queue<P> pq;

void dijkstra(){
	bfs(1, taxi[1][1], -taxi[1][0]);
	while (!pq.empty()){
		P p = pq.top();
		pq.pop();
		if (reach[p.S] < p.F){
			reach[p.S] = p.F;
			bfs(p.S, taxi[p.S][1], p.F - taxi[p.S][0]);
		}
	}
}



void bfs(int s, int dis, int cost){
	queue<P> que;
	bool rea[5001] = {};
	que.push(P(s, dis));
	while (!que.empty()){
		P p = que.front();
		que.pop();
		if (p.S){
			for (int i = 0; i < road[p.F].size(); i++){
				if (!rea[road[p.F][i]]){
					rea[road[p.F][i]] = 1;
						que.push(P(road[p.F][i], p.S - 1));
						pq.push(P(cost, road[p.F][i]));
				
				}
			}
		}
	}
}

Measured memory_bytes: 133480
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    string s;
    cin>>s;
    int q;
    cin>>q;
    vvc v(2);
    int front=0;
    int back=1;
    int modeone;
    rep(_,q){
        int mode;
        cin>>mode;
        if(mode==1){
            modeone++;
            swap(front,back);
        } else {
            int fb;
            char c;
            cin>>fb>>c;
            if(fb==1){
                v[front].pb(c);
            } else {
                v[back].pb(c);
            }
        }
    }
    if(modeone%2==0){
        for(int i=v[0].size()-1;i>=0;i--){
            cout<<v[0][i];
        }
        cout<<s;
        rep(i,v[1].size()){
            cout<<v[1][i];
        }
        cout<<endl;
    } else {
        for(int i=v[1].size()-1;i>=0;i--){
            cout<<v[1][i];
        }
        if(modeone%2==1)reverse(all(s));
        cout<<s;
        rep(i,v[0].size()){
            cout<<v[0][i];
        }
        cout<<endl;
    }
    

}


Measured memory_bytes: 1024
#include<stdio.h>

int main() {
  int a, s, d, f;
  
  scanf("%d %d", &a, &s);
  
  d = a % 2;	f = s % 2;
  
  if(d != 0&&f != 0) {
    printf("Odd");
  }
  else {
    printf("Even");
  }
  return 0;
}


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

using namespace std;

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

  string o, e;
  cin >> o >> e;
  int osz = o.size();
  int esz = e.size();

  for (int i = 0; i < min(osz, esz); ++i) {
    cout << o[i] << e[i];
  }
  if (osz > esz) 
    cout << o[osz-1] << endl;
  else if (esz > osz) 
    cout << e[esz-1] << endl;
  else cout << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 int main(){
 int N,K;
 cin>>N>>K;

 int cnt=0;
 for(int i=0;i<N;i++){
 int h;
 cin>>h;
 if(h>=K) cnt++;
 }

 cout<<cnt<<endl;
 return 0;
 }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    vector<vector<pii>> g(n), h(n);
    REP(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        g[u].push_back({v, a});
        g[v].push_back({u, a});
        h[u].push_back({v, b});
        h[v].push_back({u, b});
    }
    
    heap<pii> hp;
    hp.push({0, s});
    vi cost_a(n, INF);
    cost_a[s] = 0;
    while (!hp.empty()) {
        int v = hp.top().second;
        hp.pop();
        FORE(e, g[v]) {
            int w = e.first, c = e.second;
            if (chmin(cost_a[w], cost_a[v] + c)) {
                hp.push({cost_a[w], w});
            }
        }
    }
    hp.push({0, t});
    vi cost_b(n, INF);
    cost_b[t] = 0;
    while (!hp.empty()) {
        int v = hp.top().second;
        hp.pop();
        FORE(e, h[v]) {
            int w = e.first, c = e.second;
            if (chmin(cost_b[w], cost_b[v] + c)) {
                hp.push({cost_b[w], w});
            }
        }
    }
    
    vector<pii> tmp(n);
    REP(i, n) {
        int a = cost_a[i];
        int b = cost_b[i];
        tmp[i] = {a + b, i};
    }
    sort(ALL(tmp));
    
    vi seq;
    vi cost;
    REP(i, n) {
        int x = tmp[i].second, y = tmp[i].first;
        if (!seq.empty() && seq.back() > x) continue;
        seq.push_back(x);
        cost.push_back(y);
        if (x == n - 1) break;
    }
    int idx = 0;
    REP(i, n) {
        cout << 1000000000000000LL - cost[idx] << endl;
        if (seq[idx] == i) idx++;
    }
    return 0;
}


Measured memory_bytes: 20844
import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
INF = 10 ** 12

dp = np.array([0] + [INF for _ in range(N - 1)], dtype=np.int64)
for i in range(1, N):
    x = max(0, i - K)
    dp[i] = np.min(dp[x:i] + np.abs(h[i] - h[x:i]))

print(dp[N-1])

Measured memory_bytes: 22784
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

const int MAXN = (int)2e5 + 1;

struct Node {
  vector<int> node;
};

bool cmp(Node x, Node y) {
  if (x.node.size() != y.node.size()) 
    return x.node.size() < y.node.size();
  else {
    for (int i = 0; i < x.node.size(); ++i) {
      if (x.node[i] != y.node[i])
        return x.node[i] < y.node[i];
    }
  }
}

Node a[26], b[26];
char s[MAXN], t[MAXN];

bool solve() {
  int n = strlen(s);
  for (int i = 0; i < n; ++i) {
    a[s[i] - 'a'].node.push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    b[t[i] - 'a'].node.push_back(i);
  }
  for (int i = 0; i < 26; ++i) {
    sort(a[i].node.begin(), a[i].node.end());
    sort(b[i].node.begin(), b[i].node.end());
  }
  sort(a, a + 26, cmp);
  sort(b, b + 26, cmp);
  for (int i = 0; i < 26; ++i) {
    if (a[i].node.size() != b[i].node.size())
      return false;
    for (int j = 0; j < a[i].node.size(); ++j) {
      if (a[i].node[j] != b[i].node[j])
        return false;
    }
  }
  return true;
}

int main() {
  scanf("%s", s);
  scanf("%s", t);
  if (solve()) puts("Yes");
  else puts("No");
  return 0;
}


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

int n;
int a[100001];

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


  long long ans = 0;
  for (int i = 0; i < n; i++){
    ans += a[i] / 2;
    a[i] %= 2;
    if (a[i] && a[i + 1]){
      ans++;
      a[i + 1]--;
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 640
package main

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

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

var sc = bufio.NewScanner(os.Stdin)

func gcd(a, b int) int {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a*b/gcd(a,b)
}

func nextLine() string {
    sc.Scan()
    return sc.Text()
}


func main(){
	var A,B,res int
	fmt.Scan(&A)
	fmt.Scan(&B)
	if (A>B){
		res=lcm(A,B)
	}else{
		res=lcm(B,A)
	}
	fmt.Println(res)

}


Measured memory_bytes: 640
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
cnt = [0]*N
for i in range(N):
    cnt[i] = cnt[i-1] + bisect.bisect_left(A,B[i])
ans = 0
for i in range(N):
    target = bisect.bisect_left(B,C[i])
    if target > 0:
        ans += cnt[target-1]
print(ans)

Measured memory_bytes: 106832
using System;
using System.Collections.Generic;

class Program {
    static int Main(string[] args) {
        string v = Console.ReadLine();
        int n = int.Parse(v);

        v = Console.ReadLine();
        string[] vs = v.Split(' ');
        List<int> list = new List<int>();

        long total = 0;
        for (int i = 0; i < n; i++) {
            list.Add(int.Parse(vs[i]));
            total += list[i];
        }

        list.Sort();

        Console.WriteLine(string.Format("{0} {1} {2}", list[0], list[n - 1], total));


        return 0;
    }
}

Measured memory_bytes: 10284
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	for a := -1000; a <= 1000; a++ {
		for b := -1000; b <= 1000; b++ {
			y := a*a*a*a*a - (b * b * b * b * b)
			if x == y {
				fmt.Println(a, b)
				return
			}
		}
	}
}


Measured memory_bytes: 1756
#include <iostream>
using namespace std;
int main(){
    int n,x;
    cin >> n;
    for(int i = 1;i<n+1;i++){
        if(i % 3 == 0){
            cout << " "<< i;
        }else if(i % 10 == 3){
            cout << " "<< i;
        }else{
            x = i/10;
            while(x > 0){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll x;
 	cin >> x;
 	cout << 1 - x << endl;   
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int x;
    cin >> x;
    int max = 1;
    for(int i=1;i<x;i++){
        for(int j=2;j<x;j++){
            int k = pow(i,j);
            if(k >= max && k <= x){
                max = k;
            }
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 512