akhauriyash/Code-Regression huggingface dataset:
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<Vec<char>> = (0..3)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();

    let mut now = 0usize;
    let mut cnt = vec![0; 3];
    loop {
        if cnt[now] == s[now].len() {
            println!("{}", ('A' as u8 + now as u8) as char);
            return;
        }
        match s[now][cnt[now]] {
            'a' => {
                cnt[now] += 1;
                now = 0;
            }
            'b' => {
                cnt[now] += 1;
                now = 1;
            }
            _ => {
                cnt[now] += 1;
                now = 2;
            }
        }
    }
}


Measured memory_bytes: 2092
from collections import deque
import math; floor,ceil = math.floor,math.ceil
import sys; input = lambda: sys.stdin.readline().rstrip()
aint = lambda: int(input()); ints = lambda: list(map(int, input().split()))
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
is_even = lambda x: True if x%2==0 else False
s = lambda x: int(x*(x+1)*0.5)

def main():
    n = aint()
    print(s(n)-3*s(int(n/3))-5*s(int(n/5))+15*s(int(n/15)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9484
#include <iostream>
#include <stack>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

stack<int> s;
stack<pair<int, int> > s2;
int ans[100000], _index = 0;

int main () {
  char c;
  int i = 0, sum = 0;
  
  while (scanf("%c", &c) != EOF) {
    if (c == '\\') {
      s.push(i);
    } else if (c == '/' && s.size() > 0) {
      int j = s.top();
      s.pop();

      sum += i - j;
      int result = i - j;

      while (s2.size() > 0 && s2.top().first > j) {
        result += s2.top().second;
        s2.pop();
      }

      s2.push(make_pair(j, result));
    }

    i++;
  }

  while (s2.size() > 0) {
    ans[_index++] = s2.top().second;
    s2.pop();
  }

  printf("%d\n", sum);
  printf("%d", _index);

  for (int j = _index - 1; j >= 0; j--)
    printf(" %d", ans[j]);
  
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ll H,W;
    cin >> H >> W;
    int A[H][W],B[H][W];
    bool D[H][W][80*(H+W)];
    rep(k,2){
        rep(i,H){
            rep(j,W){
                if(k==0){
                    cin >> A[i][j];
                }
                if(k==1){
                    cin >> B[i][j];
                }
            }
        }
    }
    rep(i,H){
        rep(j,W){
            rep(k,80*(H+W)){
                D[i][j][k]=false;
            }
        }
    }
    rep(i,H){
        rep(j,W){
            rep(k,(H+W)*80){
                ll X=abs(B[i][j]-A[i][j]);
                if(i+j==0){
                    D[0][0][abs(B[0][0]-A[0][0])]=true;
                }
                else if(i==0){
                    if(D[i][j-1][abs(k-X)]||(D[i][j-1][k+X]&&k+X<(H+W)*80)){
                        D[i][j][k]=true;
                    }
                }
                else if(j==0){
                    if(D[i-1][j][abs(k-X)]||(D[i-1][j][k+X]&&k+X<(H+W)*80)){
                        D[i][j][k]=true;
                    }
                }
                else if(i*j){
                    if(D[i-1][j][abs(k-X)]||D[i][j-1][abs(k-X)]||(k+X<(H+W)*80&&(D[i-1][j][k+X]||D[i][j-1][k+X]))){
                        D[i][j][k]=true;
                    }
                }
            }
        }
    }
    ll ans;
    rep(i,200){
        if(D[H-1][W-1][i]){
            ans=i;
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 83652
#pragma GCC optimize("O3")
/* #pragma GCC target ("avx2") */
/* #pragma GCC optimize("Ofast") */
/* #pragma GCC optimize("unroll-loops") */
/* #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T, typename cmp=less<T>>
using ordered_set=tree<T,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<typename K, typename V, typename cmp=less<K>>
using ordered_map=tree<K, V, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
using ll = long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax = 1000*1007;
#define ar array
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define tT template<typename T
#define tV typename V
#define ins inline string
#ifdef LOCAL
tT>ins to_string(T& t);
ins to_string(string s) {return '"' + s + '"';}
ins to_string(char c){string res="'";res.push_back(c);return res+"'";}
ins to_string(const char* s) {return to_string((string)s);}
ins to_string(char* s) {return to_string((string)s);}
template <size_t N>ins to_string(bitset<N> v) {string res="";for(size_t i = 0; i < N; i++){
res += static_cast<char>('0' + v[i]);}return res;}
ins to_string(bool b) {return (b ? "true" : "false");}
tT,tV>ins to_string(pair<T, V>& p){return "("+ to_string(p.first)+", "+to_string(p.second)+")";}
tT>ins to_string(T& v){string res="{";for(auto& i:v){res+=to_string(i)+',';} return res+'}';}
#define log(...) cerr<< "[" << #__VA_ARGS__ << " : "<< to_string(__VA_ARGS__) << "]"<<endl
#else
#define log(...) 0x30
#endif

vector<vector<int>> edges;
int dp[100001];

int solve(int i){
    if(edges[i].size() == 0) return 0;
    if(dp[i] != -1) return dp[i];
    for(auto edge : edges[i]){
        dp[i] = max(solve(edge)+1, dp[i]);
    }
    return dp[i];
}

inline void test_case(){
    memset(dp, -1, sizeof dp);
    int n, m;
    cin>>n>>m;
    edges.resize(n+1);
    for(int i=0; i<m; i++){
        int x;
        int y;
        cin>>x>>y;
        edges[x].push_back(y);
    }
    int mxm = INT_MIN;
    for(int i=1; i<=n; i++){
        mxm = max(mxm, solve(i));
    }
    /* for(int i=1; i<=n; i++){ */
    /*     log(dp[i]); */
    /* } */
    cout<<mxm<<'\n';
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    test_case();
}   



Measured memory_bytes: 7296
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll x=0, y=0, t;
	cin >> t;
	ll a[t];
	ll b[t];
	for(ll i=0; i<t; i++)
		cin >> a[i];
	for(ll i=0; i<t; i++){
		cin >> b[i];
		if(b[i] < a[i]){
			x += a[i];
			y += b[i];
		}
	}
	cout << x-y;
	return 0;
}

Measured memory_bytes: 3640
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri f head =
    let rec doit i ite =
      if ite == head then ()
      else begin
        f i ite.data;
        doit (i + 1) ite.next
      end in
    doit 0 head.next
end

module L = DoublyLinkedList

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let head = L.make () in
  for _ = 0 to n - 1 do
    match split_on_char ' ' (read_line ()) with
    | ["insert"; n] -> L.insert (int_of_string n) head
    | ["delete"; n] -> L.delete_node (int_of_string n) head
    | ["deleteFirst"] -> L.delete_first head
    | _ -> L.delete_last head
  done;
  L.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) head;
  print_newline ()

Measured memory_bytes: 41056
def f(N,X):
    if N==0:
        return 1
    elif X==1:
        return 0
    elif 1<X<=1+A[N-1]:
        return f(N-1,X-1)
    elif X==2+A[N-1]:
        return P[N-1]+1
    elif 2+A[N-1]<X<=2+2*A[N-1]:
        return P[N-1]+1+f(N-1,X-2-A[N-1])
    elif X==A[N]:
        return P[N]

#入力
from sys import stdin
readline=stdin.readline
N,X=map(int,readline().split())

P=[1]*(N+1)
A=[1]*(N+1)
for i in range(1,N+1):
    P[i]=2*P[i-1]+1
    A[i]=2*A[i-1]+3

print(f(N,X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;
const int LOGN = 30;



int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int n;
    cin >> n;
    int a[n];
    vector <int> b[LOGN];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        for (int j = LOGN - 1; j >= 0; j--) {
            if (x & (1 << j)) {
                x -= 1 << j;
            }
            b[j].push_back(x);
        }
    }
    for (int i = 0; i < LOGN; i++) {
        stable_sort(b[i].begin(), b[i].end());
    }
    int res = 0;
    vector <int> sum(LOGN, 0);
    for (int i = 0; i < n; i++) {
        int x = a[i];
        for (int j = LOGN - 2; j >= 0; j--) {
            if (x & (1 << (j + 1))) {
                x -= 1 << (j + 1);
            }
            int cnt1 = lower_bound(b[j + 1].begin(), b[j + 1].end(), (1 << j) - x) - b[j + 1].begin();
            int cnt2 = lower_bound(b[j + 1].begin(), b[j + 1].end(), (1 << (j + 1)) - x) - b[j + 1].begin() - cnt1;
            int cnt3 = lower_bound(b[j + 1].begin(), b[j + 1].end(), (1 << (j + 1)) + (1 << j) - x) - b[j + 1].begin() - cnt1 - cnt2;
            int cnt4 = n - cnt1 - cnt2 - cnt3;
            sum[j] += cnt2 + cnt4;
        }
    }
    for (int i = 0; i < LOGN; i++) {
        if (sum[i] % 2) {
            res += 1 << i;
        }
    }
    cout << res;
}


Measured memory_bytes: 30448
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
  int main(){
      lint n;
      cin>>n;
      tuple<lint,lint,lint> a[n];
      tuple<lint,lint,lint>b[n];
      rep(i,n){
          lint a1,b1;
          cin>>a1>>b1;
          a[i]=make_tuple(b1+a1,a1,i);
          b[i]=make_tuple(a1+b1,b1,i);
      }
      bool iseat[n];
      fill(iseat,iseat+n,false);
      sort(a,a+n,greater<tuple<lint,lint,lint>>());
      sort(b,b+n,greater<tuple<lint,lint,lint>>());
      lint ans=0;
      lint i=0,j=0,k=0;
      while(1){
          lint s1,v1,c1;
          tie(s1,v1,c1)=a[i];
           while(iseat[c1]){
               i++;
                tie(s1,v1,c1)=a[i];
           }
           iseat[c1]=true;
           ans+=v1;
           k++;
           if(k==n)break;
            tie(s1,v1,c1)=b[j];
           while(iseat[c1]){
               j++;
                tie(s1,v1,c1)=b[j];
           }
           iseat[c1]=true;
           ans-=v1;
           k++;
           if(k==n)break;
           i++;j++;
      }
      cout<<ans<<endl;
  }
  
     


Measured memory_bytes: 4992
#include<cstdio>

using namespace std;

int main(){
	int su,a,b,i;
	while(1){
		int p1=0,p2=0;
		scanf("%d",&su);
		if(su==0) break;
		for(i=0;i<su;i++){
			scanf("%d %d",&a,&b);
			if(a>b) p1+=a+b;
			else if(a<b) p2+=a+b;
			else {p1+=a;p2+=b;}
		}
		printf("%d %d\n",p1,p2);
	}
	return 0;
}

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

int main()
{
    int l;
    cin >> l;
    int max=0;
    double x=l/3.0;
    double ans = x * x * x;
    cout << fixed << setprecision(12) << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b, c;
    cin >> a >> b >> c;
    set< int > st;
    st.insert( a );
    st.insert( b );
    st.insert( c );
    cout << st.size() << endl;

    return 0;
}


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

#define task "test"

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

const ll LINF = 1E18;
const int INF = 1E9;
const int MOD = 1E9 + 7;

const int nmax = 1;

int t = 1;
ll a, b, c, d;

void Input()
{
     cin >> a >> b >> c >> d;
}

void Solve()
{
     ll ans = a * c;
     ans = max(ans, a * d);
     ans = max(ans, max(b * c, b * d));
     cout << ans;
}

int main()
{
     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
     if(fopen(task ".inp", "r")) {
          freopen(task ".inp", "r", stdin);
          freopen(task ".out", "w", stdout);
     }
     //cin >> t;
     while (t--) {
          Input();
          Solve();
     }
     return 0;
}



Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = ReadLine();
        var T = ReadLine();

        var same = new Dictionary<char, char>();
        for (int i = 0; i < S.Length; i++) {
            if (S[i] == T[i]) {
                if (!same.ContainsKey(S[i])) {
                    same.Add(S[i], T[i]);
                }
            }
        }


        var diff = new Dictionary<char, char>();
        var diff2 = new Dictionary<char, char>();
        for (int i = 0; i < S.Length; i++) {
            if (S[i] != T[i]) {
                if (diff.ContainsKey(T[i])) {
                    if (diff[T[i]] != S[i]) {
                        WriteLine("No");
                        return;
                    }
                } else {
                    diff.Add(T[i], S[i]);
                }

                if (diff2.ContainsKey(S[i])) {
                    if (diff2[S[i]] != T[i]) {
                        WriteLine("No");
                        return;
                    }
                } else {
                    diff2.Add(S[i], T[i]);
                }

                if (same.ContainsKey(S[i]) || same.ContainsKey(T[i])) {
                    WriteLine("No");
                    return;
                }
            }
        }



        WriteLine("Yes");
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 14688
import sys
sys.setrecursionlimit(10000000)

def main():
    N,Q = map(int,sys.stdin.readline().split())
    e = [ [ ] for i in range(N)]
    for i in range(N-1):
        a,b = map(int,sys.stdin.readline().split())
        e[a-1].append(b-1)

    from collections import defaultdict
    d = defaultdict(int)
    for i in range(Q):
        p,x = map(int,sys.stdin.readline().split())
        d[p-1] += x

    ansl = [0 for i in range(N)]

    def dfs(x,c):
        c += d[x]
        ansl[x] = c
        for v in e[x]:
            dfs(v,c)

    dfs(0,0)
    print(" ".join(map(str,ansl)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 287772
#include <cstdio>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
const int mod = 1e9+7;
int main() {
    int n; scanf("%d", &n);
    vector<char> s(n); repeat (i,n) scanf(" %c", &s[i]);
    vector<vector<ll> > cur(n+1, vector<ll>(n+1)); // dp : (requiring-up) \times (dangling-down) \to (count)
    vector<vector<ll> > prv(n+1, vector<ll>(n+1));
    cur[0][0] = 1;
    for (char c : s) {
        cur.swap(prv);
        repeat (i,n+1) repeat (j,n+1) {
            if (c == '-') {
                cur[i][j] = prv[i][j];
            } else if (c == 'U') {
                cur[i][j] = 0;
                ;                          cur[i][j] += prv[i][j] * i; // up
                if (i-1 >= 0 and j-1 >= 0) cur[i][j] += prv[i-1][j-1]; // down
                cur[i][j] %= mod;
            } else if (c == 'D') {
                cur[i][j] = 0;
                if (i+1 < n+1 and j+1 < n+1) cur[i][j] += prv[i+1][j+1] * (i+1) * (j+1); // up
                ;                            cur[i][j] += prv[i][j] * j; // down
                cur[i][j] %= mod;
            }
        }
    }
    printf("%lld\n", cur[0][0]);
    return 0;
}

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

int main(int argc, const char * argv[]) {
    char a;
    cin >> a;
    char r = 'a';
    if ('a' <= a && a <='z') {
        r = 'a';
    }
    else if ('A' <= a && a <='Z') {
        r = 'A';
    }

    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 1e5+10;

///--------------------START-------------------------
int n;
int a[MAXN];
int ans[MAXN];

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x; scanf("%d",&x);
        ans[x]++;
        ans[x+1]++;
        ans[x+1+1]++;
    }
    int ANS=0;
    for(int i=0;i<MAXN;i++){
        ANS=max(ANS,ans[i]);
    }
    printf("%d\n",ANS);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}








Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<a)cout << k;
  else if(k>=a&&k<=(a+b))cout << a;
  else if(k>(a+b))cout << a-(k-a-b);
}


Measured memory_bytes: 3596
fun main(args: Array<String>) {
    a75(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a75(args: Array<String>) {
    if (args.size != 2) {
        throw IllegalArgumentException()
    }
    val (dist, white) = args.map { it.toInt() }
    println(dist * dist - white)
}


Measured memory_bytes: 33784
import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
import numpy as np

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(list(map(int, readline().split())) for _ in range(N))
    A = np.array(A)
    D = dijkstra(A)
    if (A!=D).any():
        print(-1)
    else:
        ans = 0
        D += np.identity(N, int) * (10**10)
        for i in range(N):
            for j in range(i + 1, N):
                a = np.min(D[i] + D[j])
                if a > D[i, j]:
                    ans += D[i, j]
        print(int(ans))



if __name__ == '__main__':
    main()


Measured memory_bytes: 41772
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
WAc=0
for i in range(m):
	a,b=input().split()
	c=int(a)
	if AC[c-1]==0:
		if b=="AC":
			AC[c-1]+=1
		else:
			WA[c-1]+=1

for j in range(n):
	if AC[j]==1:
		WAc+=WA[j]

print(sum(AC),WAc)
	


Measured memory_bytes: 4596
from bisect import bisect_left
n = int(input())
ls = list(map(int, input().split()))
ls.sort()
count = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    bi = bisect_left(ls, ls[i] + ls[j])
    count += bi - j - 1
print(count)

Measured memory_bytes: 3188
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
use std::collections::HashSet;

const MOD : u64 = 1_000_000_000 + 7;

fn main() {
    
    let n = read::<usize>();
    //let b = read::<usize>();
    let h : Vec<u64> = (0..n).map(|_| {read::<u64>() }).collect();

    let mut ans = 0;
    let mut tmp = 0;
    for i in 0..n-1 {
        if h[i] >= h[i+1] {tmp += 1;}
        else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    
    ans = max(ans, tmp);
    
    println!("{}",ans);
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(1000000)
from bisect import bisect, bisect_left
def dfs(vertex):
  visited[vertex] = True
  value = a[vertex]
  j = bisect(dp, value)
  previous = dp[j]
  if dp[j-1] != value: # strict increasing
    dp[j] = value
  ans[vertex] = bisect_left(dp, float("inf"))-1
  for node in adjacent[vertex]:
    if not visited[node]:
      dfs(node)
  dp[j] = previous
  return
n = int(input())
a = list(map(int, input().split()))
adjacent = {i: [] for i in range(n)}
for _ in range(n-1):
  node1, node2 = map(int, input().split())
  node1 -= 1
  node2 -= 1
  adjacent[node1].append(node2)
  adjacent[node2].append(node1)
visited = [False]*n
ans = [0]*n
dp = [float("inf") for _ in range(n+1)]
dp[0] = float("-inf")
dfs(0)
[print(value) for value in ans]

Measured memory_bytes: 246744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;
    if(a+b<c)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())
cnt = 0
id = []
for _ in range(m):
        l= list(map(int, input().split()))
        if len(id) == 0:
                id = l
        else:
                if id[0] < l[0]:
                        id[0] = l[0]
                elif id[1] > l[1]:
                        id[1] = l[1]
if id[1] < id[0]:
        cnt = 0
else:
        cnt = id[1]-id[0]+1
print(cnt)


Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    VI a(3);
    REP(i,3){
    cin >> a[i];
    }

    SORT(a);
    if(a[2] == a[0]+a[1]){
        cout << "Yes" << ENDL;
    }else{
        cout << "No" << ENDL;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vllint a(n + 1);
	int x;
	a[0] = 0;
	rep(i, n) {
		cin >> x;
		a[i + 1] = a[i] + x;
	}
	sort(a.begin(), a.end());
	llint ans = 0;
	llint cnt = 1;
	rep(i, n) {
		if (a[i] == a[i + 1]) {
			cnt++;
		}
		else {
			ans += cnt*(cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt*(cnt - 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
 
int d[101][101];
int t[101][101],c[101][101];
int n,m;
const int INF = 10000000;
 
void warshall_floyd() {
 
  for ( int k = 0; k <= m; k++ ) {
    for ( int i = 0; i <= m; i++ ) {
      for ( int j = 0; j <= m; j++ ) {
    t[i][j] = min( t[i][j], t[i][k] + t[k][j] );
    c[i][j] = min( c[i][j], c[i][k] + c[k][j] );
      }
    }
  }
 
}
 
int main() {
 
  
  while ( cin >> n >> m, n || m ) {
    for ( int i = 0; i < 101; i++ ) {
      for ( int j = 0; j < 101; j++ ) {
    if ( i == j ) {
      t[i][j] = 0;
      c[i][j] = 0;
    } else {
      t[i][j] = INF;
      c[i][j] = INF;
    }
      }
    }
   
    for ( int i = 0; i  < n; i++ ) {
      int a,b,cost,time; cin >> a >> b >> cost >> time;
      t[a][b] = t[b][a] = time;
      c[a][b] = c[b][a] = cost;
    }
    warshall_floyd();
    int k; cin >> k;
    for ( int i = 0; i < k; i++ ) {
      int p,q,r; cin >> p >> q >> r;
      if ( r == 0 ) {
    cout << c[p][q] << endl;
      } else if ( r == 1) {
    cout << t[p][q] << endl;
      }
    }
 
  }
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10,inf=0x3f3f3f3f;
int tmp,Max[20][maxn],Min[20][maxn],a[maxn],f[1<<20],g[1<<20],R[maxn];
int main(){
	int n=read(),V=read();
	REP(i,1,n) a[i]=read();
	tmp=-1;
	memset(Min,inf,sizeof(Min));
	while(1){
		++tmp;
		int lst=1;
		REP(i,2,n) if(a[i]-a[i-1]>V){
			chkmax(Max[tmp][lst],i-1);
			chkmin(Min[tmp][i-1],lst);
			lst=i;
		}
		chkmax(Max[tmp][lst],n);
		chkmin(Min[tmp][n],lst);
		REP(i,1,n) chkmax(Max[tmp][i],Max[tmp][i-1]);
		Max[tmp][n+1]=n;
		DREP(i,n,1) chkmin(Min[tmp][i],Min[tmp][i+1]);
		Min[tmp][0]=1;
		if(V==0) break;
		V/=2;
	}
	memset(g,inf,sizeof(g));
	f[0]=0,g[0]=n+1;
	REP(i,0,(1<<tmp)-1)
		REP(j,1,tmp) if((i&(1<<(j-1)))==0){
			chkmax(f[i|(1<<(j-1))],Max[j][f[i]+1]);
			chkmin(g[i|(1<<(j-1))],Min[j][g[i]-1]);
		}
	memset(R,inf,sizeof(R));
	REP(i,0,(1<<tmp)-1){
		if(f[i]>=g[i^iend]-1){
			REP(j,1,n) printf("Possible\n");
			return 0;
		}
		chkmin(R[f[i]+1],g[i^iend]-1);
	}
	DREP(i,n,1) chkmin(R[i],R[i+1]);
	REP(i,1,n) printf("%s\n",(R[Min[0][i]]<=Max[0][i])?"Possible":"Impossible");
	return 0;
}


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

bool isdigit(char c);

int main(){
  string str;
  int num = 0;
  int ans = 0;
  while(cin >> str){
    
    for(int i=0; i<str.size(); ++i){
      
      if(isdigit(str[i])){	
	if(isdigit(str[i-1])){
	  num *= 10;
	  num += (int)(str[i]-'0');
	}else if(isdigit(str[i])){
	  num += (int)(str[i]-'0');
	}
	
      }
      
      if(!isdigit(str[i+1])){
	ans += num;
	num = 0;
      }
      
    }
    
  }
  cout << ans << endl;
  return 0;
}

bool isdigit(char c){
  switch(c){
  case '0': return true;
  case '1': return true;
  case '2': return true;
  case '3': return true;
  case '4': return true;
  case '5': return true;
  case '6': return true;
  case '7': return true;
  case '8': return true;
  case '9': return true;	    
  default : return false;
  }
}



Measured memory_bytes: 3136
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();

		double d = (double)l/3d;
		double v = Math.pow(d,3);

		System.out.println(String.format("%.9f",v));

	}
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
const int INF=1e5;
typedef vector<int> V;
typedef vector<V> VV;
vector<int> dp(int k,vector<int>&a){
    vector<int> res(k+1,-INF);
    res[0]=0;
    for(auto &it:a){
        vector<int> nxt(k+1,-INF);
        REP(i,k+1){
            int cost=it;
            if(i%2)cost*=-1;
            chmax(nxt[i],res[i]+cost);
            if(i<k){
                cost*=-1;
                chmax(nxt[i+1],res[i]+cost);
            }
        }
        swap(res,nxt);
    }
    return res;
}
int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    vector<int> a;
    vector<int> b;
    for(auto &it:s){
        if(it=='U')a.pb(1);
        if(it=='D')a.pb(-1);
        if(it=='R')b.pb(1);
        if(it=='L')b.pb(-1);
        
    }
    auto x=dp(k,a);
    auto y=dp(k,b);    
    for(auto &it:a)it*=-1;
    auto z=dp(k,a);
    for(auto &it:b)it*=-1;
    auto w=dp(k,b);
    int res=0;
    REP(i,k+1)REP(j,k+1)if(i+j<=k)chmax(res,x[i]+y[j]);
    REP(i,k+1)REP(j,k+1)if(i+j<=k)chmax(res,x[i]+w[j]);
    REP(i,k+1)REP(j,k+1)if(i+j<=k)chmax(res,z[i]+y[j]);
    REP(i,k+1)REP(j,k+1)if(i+j<=k)chmax(res,z[i]+w[j]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int num = 1;
    int count = 0;

    while (true) {
        num *= K;
        count++;
        if (num > N) {
            cout << count;
            break;
        }
    }
}

Measured memory_bytes: 256
import itertools
data = []
while True:
    s = list(map(int, input().split()))
    if s[0] == 0 and s[1] == 0:
        break
    data.append(s)
for n, x in data:
    z = 0
    a = list(range(1, n + 1))
    b = itertools.combinations(a, 3)
    for c in b:
        if sum(c) == x:
            z += 1
    print(z)


Measured memory_bytes: 5644
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  
  int ok = 0;
  int res;

  for (int i = 0; i <= n; i++){
    if(int(i*1.08) == n){
      ok = 1;
      res = i;
      break;
    }
  }

  if(ok)
    cout << res << endl;
  else
    cout << ":(" << endl;

  return 0;
}


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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  int ans = 0;
  REP(i, s.size()/2){
    if(s[i] != s[s.size()-1-i]) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = 2e5;
ll n, k;
ll a[N];

bool is_valid(int x){
    ll cnt = 0;
    for (int i = 0; i < n; i++){
        cnt += a[i]/x;
        if (a[i] % x == 0) cnt--;
    }
    return cnt <= k;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    ll lo, hi;
    ll ans = -1;
    lo = 1;
    hi = 1e9;
    while(lo <= hi){
        ll mid = hi - (hi-lo)/2;
        if (is_valid(mid)){
            ans = mid;
            hi = mid-1;
        }
        else {
            lo = mid+1;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5176
#include<stdio.h>
int A[1000000],n;
int binarySearch(int key){
  int left=0,right=n,mid;
  while(left<right){
    mid= (left+right)/2;
    if(key==A[mid])return 1;
    if(key>A[mid]) left=mid+1;
    else if(key<A[mid]) right=mid;
  }
  return 0;
}
int main(){
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k)) sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2104
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)


def main():
  n, k = map(int, input().split())
  A = np.array(input().split(), np.int64)
  
  A = np.sort(A)
  
  zero = A[A == 0]
  pos = A[A>0]
  neg = A[A<0]
  
  def F(x):
    cnt_tpl = 0
    #zero multipy ...
    if x>= 0:
      cnt_tpl += len(zero)*n
    #positive multipy ...
    cnt_tpl += np.searchsorted(A, x//pos, side='right').sum()
    cnt_tpl += (n - np.searchsorted(A, (-x-1)//(-neg), side='right')).sum()
    cnt_tpl -= np.count_nonzero(A*A<=x)
    assert cnt_tpl %2 ==0
    return cnt_tpl//2
  
  left = -10**18
  right = 10**18
  while left + 1 < right:
    mid = (left+right)//2
    if F(mid) >= k:
      right = mid
    else:
      left = mid
  print(right)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 36828
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        string s,t;
        cin>>s>>t;
        LL m=s.length();
        LL n=t.length();
        LL a[m+1][n+1];
        fr(i,0,m+1){ 
          fr(j,0,n+1){
            if (i == 0 || j == 0) a[i][j] = 0; 
            else if(s[i-1]==t[j-1]) a[i][j]=a[i-1][j-1]+1;
             else a[i][j]=max(a[i-1][j],a[i][j-1]);
          }
      }

   string lcs="";
   LL i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
          lcs+=s[i-1]; 
          i--; j--;      
      } 

      else if (a[i-1][j] > a[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   reverse(lcs.begin(), lcs.end()); 
    cout<<lcs<<endl;

    return 0;
}

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

int main() {
	long long int a;
	cin>>a;
	long long int b;
	b=a%10;
	if(b==3)
	cout<<"bon";
	else if(b==2||b==4||b==5||b==7||b==9)
	cout<<"hon";
	else
	cout<<"pon";

	return 0;
}


Measured memory_bytes: 3600