akhauriyash/Code-Regression huggingface dataset:
while True:
    mid_score, term_score, re_score = map(int, input().split())
    if mid_score == term_score == re_score == -1:
        break
    test_score = mid_score + term_score
    score = ''
    if test_score >= 80:
        score = 'A'
    elif test_score >= 65:
        score = 'B'
    elif test_score >= 50:
        score = 'C'
    elif test_score >=30:
        if re_score >= 50:
            score = 'C'
        else:
            score = 'D'
    else:
        score = 'F'
    if mid_score == -1 or term_score == -1:
        score = 'F'
    print(score)



Measured memory_bytes: 5592
N,X=map(int,input().split())
A=[1]*(N+1)
P=[1]*(N+1)
for i in range(1,N+1):
    P[i]=2*P[i-1]+1
    A[i]=2*P[i]-1

def f(N,X):
    if X==1:
        if N==0:
            return 1
        else:
            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])
    else:
        return 2*P[N-1]+1

print(f(N,X))

Measured memory_bytes: 9248
#include <iostream>
#include <queue>
#include <vector>

struct edge {
    typedef size_t weight_type;

    size_t m_to;

    edge(size_t to) : m_to(to) { }

    inline size_t to() const { return m_to; }

    inline weight_type weight() const { return 1; }

    friend std::ostream& operator<<(std::ostream &os, const edge &e) {
        os << "{ to: " << e.m_to << " }";
        return os;
    }
};

template <class Edge>
struct graph {
    typedef Edge edge_type;

    size_t m_n_vertices;
    std::vector<std::vector<edge_type>> m_edges;

    graph(size_t n_vertices) : m_n_vertices(n_vertices), m_edges(n_vertices) { }

    inline size_t n_vertices() const { return m_n_vertices; }

    inline void make_edge(size_t from, size_t to, typename edge_type::weight_type weight) {
        m_edges[from].emplace_back(edge_type(to, weight));
    }

    inline void make_edge(size_t from, size_t to) {
        m_edges[from].emplace_back(edge(to));
    }

    inline void make_edge(size_t from, const edge_type &e) {
        m_edges[from].emplace_back(e);
    }

    inline std::vector<edge_type> edges_from(size_t v) const {
        return m_edges[v];
    }
};

// time complexity: O(V + E)
template <class Graph>
std::vector<size_t> topological_sort(const Graph &g) {

    using Edge = typename Graph::edge_type;

    std::vector<size_t> topological_orders(g.n_vertices());
    std::vector<size_t> indegrees(g.n_vertices());

    for (size_t v = 0; v < g.n_vertices(); ++v) {
        for (const Edge &e: g.edges_from(v)) {
            ++indegrees[e.to()];
        }
    }

    std::queue<size_t> q;

    for (size_t v = 0; v < g.n_vertices(); ++v) {
        if (!indegrees[v]) {
            q.push(v);
        }
    }

    for (size_t i = 0; i < g.n_vertices(); ++i) {
        if (q.empty()) { // has cycle
            return { };
        }
        size_t u = q.front();
        q.pop();
        topological_orders[i] = u;
        for (const Edge &e: g.edges_from(u)) {
            size_t v = e.to();
            --indegrees[v];
            if (!indegrees[v]) {
                q.push(v);
            }
        }
    }

    return topological_orders;
}

int main() {
    using namespace std;

    using Graph = graph<edge>;

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

    int V, E;
    cin >> V >> E;
    Graph g(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        g.make_edge(s, t);
    }

    auto topological_orders = topological_sort(g);

    for (int i = 0; i < V; ++i) {
        cout << topological_orders[i] << '\n';
    }
    cout << flush;

    return 0;
}


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

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

// code starts
int main()
{
  int n;cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  rep(i,n)cin>>a[i]>>b[i];
  sort(all(a));
  sort(all(b));
  int ans=0;
  if(n%2==1)
  {
    int minn=a[n/2];
    int maxn=b[n/2];
    ans=maxn-minn+1;
  }
  else
  {
    int minn=a[n/2]+a[n/2-1];
    int maxn=b[n/2]+b[n/2-1];
    ans=maxn-minn+1;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 4844
/**
*	created: 22.08.2020 21:04:08
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep2(i,1,n) {
        if (a[i] < a[i-1]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	int count = 1;
	vector<int>note(n);
	rep(i, n) {
		cin >> note[i];
	}
	sort(all(note));
	deque<int>kind;
	rep(i, n-1) {
		if (note[i] == note[i + 1]) {
			count++;
		}
		else {
			kind.push_back(count);
			count = 1;
		}
	}
	kind.push_back(count);
	sort(all(kind));
	reverse(all(kind));
	int sum = 0;
	rep(i, kind.size()) {
		sum += kind[i];
	//	cout << kind[i] << endl;
		if (i >= k-1) {
			break;
		}
	}
	cout << n - sum << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MAX 1001*1001*1001
int dp[1001][1001];
int main(void)
{
	int N,M;
	int C[1001],D[1001];
	int i,j;
	cin>>N>>M;
	for(i=1;i<=N;i++){
		cin>>D[i];
	}
	for(i=1;i<=M;i++){
		cin>>C[i];
	}
	for(i=1;i<=M;i++){
		for(j=0;j<=N;j++){
			dp[i][j]=MAX;
		}
	}
	
	dp[1][0]=0;
	dp[1][1]=D[1]*C[1];
	for(i=1;i<M;i++){
		for(j=0;j<=N;j++){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			if(j<N){
				dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+C[i+1]*D[j+1]);
			}
		}
	}
	/*for(i=1;i<=M;i++){
		for(j=0;j<=N;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/

	cout<<dp[M][N]<<endl;
	return 0;
}



Measured memory_bytes: 6980
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    #define hi            cout<<"hi"<<endl;
    const ll maxn=200005;
    void solve()
    {
      ll n;
      cin>>n;
      string s;
      cin>>s;
      ll r=0,b=0,g=0;
      rep(i,0,n)
      {
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
      }
      ll sum=r*g*b;
      ll sub=0;
      rep(i,0,n)
      {
        rep(j,i+1,n)
        {
          if(s[i]==s[j]) continue;
          ll k=2*j-i;
          if(k>=n || s[i]==s[k]|| s[j]==s[k]) continue;
          sub++;
        }
      }
      cout<<sum-sub<<endl;

    }

    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }
    
   
 /*
 1 2 1 1 2 2 3 2 2 
 0 1 2 3 4 5 6 7 8
 */

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
      int x=D();
    int sum = 0;
    for(int i=1;i<=x;i++)
    {
        sum+=i;
        if(sum>=x)
        {
            cout<<i<<endl;;
            return 0;
        }
    }
}


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

int H, A[MAX+1];

void maxHeapify(int i) {
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;
    
    if (l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if (r <= H && A[r] > A[largest]) largest = r;
    
    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int main() {
    cin >> H;
    for (int i = 1; i <= H; i++) cin >> A[i];
    
    for (int i = H / 2; i >= 1; i--) maxHeapify(i);
    
    for (int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 5048
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	String s = sc.next();
        char[] color = new char[n];
        for (int i=0; i<n; i++) {
        	color[i] = s.charAt(i);
        }
		
        int count = 0;
      
        int i = 0;
        while (i<n-1) {
          	boolean isSame = true;
            int j = 1;
          while (isSame) {      
        	if (i+j < n && color[i+j] == color[i]) {
              count++;
              j++;
            } else {
              isSame = false;
            }
          }
			i = i+j;
        }
      
        System.out.println(n-count);      
	}
}

Measured memory_bytes: 25268
import java.util.Scanner;

public class Main {

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

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		int count = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) count++;
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 26340
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int H, W, D;
        H = cin.nextInt();
        W = cin.nextInt();
        D = cin.nextInt();

        int[,] A = new int[H, W];
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                A[i, j] = cin.nextInt() - 1;
            }
        }

        int N = H * W;
        int[] sum = new int[N];
        int[] Y = new int[N];
        int[] X = new int[N];
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                X[A[i, j]] = j;
                Y[A[i, j]] = i;
            }
        }

        for (int i = D; i < N; i++)
        {
            sum[i] = sum[i - D] + Math.Abs(X[i] - X[i - D]) + Math.Abs(Y[i] - Y[i - D]);
        }

        int Q = cin.nextInt();
        for (int i = 0; i < Q; i++)
        {
            int L = cin.nextInt() - 1;
            int R = cin.nextInt() - 1;

            Console.WriteLine(sum[R] - sum[L]);
        }

    }
}




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;
    }
}



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

int main() {
	string N;
	cin >> N;
	int x = 0;
	for (int i = 0;i < N.size();++i) {
		x += N[i]-'0';
	}
	cout << (stoi(N) % x == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let r = read::<usize>();
    println!("{}", 3 * r * r);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
using namespace std;

main(){

  int A, B, X;
  cin >> X;



  for(int i = -120; i <= 120; i++){
    for(int j = -120; j <= 120; j++){
      int A5 = powl(i, 5), B5 = pow(j, 5);

      if(A5 - B5 == X){
        cout<<i<<" "<<j;
        return 0;
      }

    }
  }


}

Measured memory_bytes: 4112
n=int(input())
s=[]
for i in range(n):
  s.append(input())
m=0
a=0 
r=0
c=0
h=0
for j in range(n):
  if s[j][0]=="M":
    m+=1
  elif s[j][0]=="A":
    a+=1
  elif s[j][0]=="R":
    r+=1
  elif s[j][0]=="C":
    c+=1
  elif s[j][0]=="H":
    h+=1
    
ans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*c*h+a*r*h+r*c*h

print(ans)

Measured memory_bytes: 9772
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int x, a;
	cin >> x >> a;
	if (x < a) cout << 0 << endl; else cout << 10 << endl;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (auto& x : l) cin >> x;

    sort(l.begin(), l.end(), greater<int>());
    int S = 0;
    for (int i = 0; i < K; ++i)  S += l[i];

    cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

int main(void) {
  int i, c[3][3], j;
  for(i = 0; i < 3; ++i) for(j = 0; j < 3; ++j) scanf("%d", &c[i][j]);
  for(i = 0; i < 3; ++i) for(j = 2; j >= 0; --j) c[i][j] -= c[i][0];
  int s = 0;
  for(i = 0; i < 3; ++i) {
    for(j = 1; j < 3; ++j) {
      if(c[j][i] != c[0][i]) {
        s = 1;
        break;
      }
      if(s) break;
    }
  }
  if(s) printf("No");
  else printf("Yes");
  return 0;
}

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


int main(){
  int n; cin>>n;
  vector<int> w(n);
  int ans=100000;
 
 
  for(int i=0;i<n;i++){
     int a;
    cin>>a;
    w[i]=a;
 
  }

    for(int t=1;t<n;t++){
        int sum1=0;
      int sum2=0;
      for(int j=0;j<n;j++){
        
      if(j+1<=t)sum1+=w[j];
      else sum2+=w[j];
      }
      int b=sum1-sum2;
       
       if(b<0)b=-b;
      if(ans>b)ans=b;

    }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/07/20.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> c(n,1);
    multimap<int,int> mp;
    rep(i,n){
        auto itr=mp.upper_bound(-a[i]);
        if(itr!=mp.end()){
            mp.erase(itr);
        }
        mp.insert({-a[i],i});
    }
    cout << mp.size() << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(void) {
  int x,a,b;
  scanf("%d", &x);
  scanf("%d", &a);
  scanf("%d", &b);
  if((a-b) >= 0) {
     printf("delicious");
  } else if (x+(a-b) >= 0) {
     printf("safe");}
  else { printf("dangerous"); }     
  return 0;
   



}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
#define abs(a) ((a) > 0 ? (a) : -(a))

double P, E, T;
double ret(double k, double r, double l)
{
    double h = (r + l) / 2;
    if (k == 0) 
        return (abs(h-T) < E ? 1.0 : 0.0);
    if (l < T - E)
        return 0.0;
    if (r > T + E) 
        return 0.0;
    if (T - E < r && l < T + E) 
        return 1.0;
    if ((r+l)/2 >= T) 
        return P * ret(k-1, r, h) + (1.0 - P) * ret(k-1, h, l);
    else 
        return P * ret(k-1, h, l) + (1.0 - P) * ret(k-1, r, h);
}

int main(void)
{
    double K, R, L;
    cin >> K >> R >> L >> P >> E >> T;
    P = 1 - P;

    printf("%.6f", ret(K, R, L));
    return 0;
}

Measured memory_bytes: 1240
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=t(r.split("\n")[0].split(" ").map(function(r){return Number(r)}),2),n=e[0],o=e[1],u=0,i=1;i<=n;i++)for(var f=20;f<=o;f++){var l=Math.floor(f/10),a=Math.floor(f%10);a>=2&&i==a*l&&(u+=1)}console.log(u)}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 9548
#include<iostream>
#include<tuple>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;

#define INF ((int)(1e9))
#define MAX 110000

int n, k, a, q, query, x, y;
string key;
map<string,int> se;

int main(){
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>query>>key;
		if(!query){
			cin>>x;
			se[key] = x;
		} else if(query == 1){
			cout<<se[key]<<endl;
		} else if(query == 2){
			se.erase(key);
		}
	}
	return 0;
}


Measured memory_bytes: 27872
#define _GLIBCXX_DEBUG

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

int main(){
    int N;
    int count = 0;
    cin >> N;
    
    vector<int> data(N);

    rep(i, N)
    {
        cin >> data.at(i);
    }
    sort(data.begin(), data.end());

    rep(i, N - 2){
        int a = data.at(i);

        for(int j = i + 1; j < N - 1; j++){
            int b = data.at(j);
            if(b == a) continue;

            for(int k = j + 1; k < N; k++){
                int c = data.at(k);
                if((c == a) || (c == b)) continue;
                if(c < a + b) count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3636
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t = s;
  sort(t.begin(), t.end());
  int count = 0;
  // cout << t << endl;
  for(int i = 0; i < (int)s.size(); i++)
    if(s[i] != t[i])
      count++;
  cout << (count/2) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  for(int tt = 1; tt <= t; tt++) {
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55 - rank 3
// 69 12 19 - rank 3
// 70 12 34 - rank 100
// 71 12 58 -

ull gcd(ull a, ull b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int n;
    cin >> n;
    string line1;
    string line2;
    cin >> line1 >> line2;
    vector<ll> cnt;
    if (line1[0] == line2[0]) {
        cnt.push_back(3);
    } else {
        cnt.push_back(6);
    }

    int mod = 1e9 + 7;

    for (int l = 1; l < n; ++l) {
        if (line1[l] == line1[l - 1]) {
            continue;
        }
        if (line1[l - 1] == line2[l - 1]) {
            cnt.push_back((cnt.back() * 2) % mod);
        } else {
            if (line1[l] == line2[l]) {
                cnt.push_back(cnt.back());
            } else {
                cnt.push_back((cnt.back() * 3) % mod);
            }
        }
    }

    cout << cnt.back() % mod << "\n";



}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		// コンソール入力
		Scanner scan = new Scanner(System.in);
		// 文字列の長さ
		int N = scan.nextInt();
		// 文字列
		String S = scan.next();
		// 入力終わり
		scan.close();
		// カウント用変数
		int result = 0;
		//フラグ
		boolean A = false;
		boolean B = false;

		// 文字列を一文字ずつ取得し、
		// 連続したABCの塊がいくつあるかカウントする
		for(char tmp:S.toCharArray()) {
			if(tmp=='A'&&!A&&!B) {
				A=true;
			}else if(tmp=='B'&&A&&!B) {
				B=true;
			}else if(tmp=='C'&&A&&B) {
				result++;
				A=false;
				B=false;
			}else {
				if(tmp!='A') {
				A=false;
				}
				B=false;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
正面衝突の場合 U-D, L-R
斜め衝突の場合 U-L, L-D, D-R, R-U





*/


int X[1<<18], Y[1<<18];
char D[1<<18];
vector<pair<int, char>> V1[1<<19];
vector<pair<int, char>> V2[1<<19];

int n;

int solve_UR(){
	int Answer = (1 << 24);
	for (int i = 0; i <= 500000; i++) V1[i].clear();
	for (int i = 1; i <= n; i++) {
		if (!(D[i] == 'R' || D[i] == 'U')) continue;
		V1[X[i] + Y[i]].push_back(make_pair(X[i], D[i]));
	}
	for (int i = 0; i <= 500000; i++) {
		sort(V1[i].begin(), V1[i].end());
		for (int j = 0; j < (int)V1[i].size() - 1; j++) {
			if (!(V1[i][j].second == 'R' && V1[i][j + 1].second == 'U')) continue;
			Answer = min(Answer, V1[i][j + 1].first - V1[i][j].first);
		}
	}
	return Answer * 10;
}



int solve_UD(){
	int Answer = (1 << 24);
	for (int i = 0; i <= 500000; i++) V2[i].clear();
	for (int i = 1; i <= n; i++) {
		if (!(D[i] == 'L' || D[i] == 'R')) continue;
		V2[Y[i]].push_back(make_pair(X[i], D[i]));
	}
	for (int i = 0; i <= 500000; i++) {
		sort(V2[i].begin(), V2[i].end());
		for (int j = 0; j < (int)V2[i].size() - 1; j++) {
			if (!(V2[i][j].second == 'R' && V2[i][j + 1].second == 'L')) continue;
			Answer = min(Answer, V2[i][j + 1].first - V2[i][j].first);
		}
	}
	return Answer * 5;
}


void rotate(){
    int tmp;
    rep1(i, n){
        tmp = X[i];
        X[i] = 200000-Y[i];
        Y[i] = tmp;
        if (D[i] == 'U') D[i] = 'L';
        else if (D[i] == 'L') D[i] = 'D';
        else if (D[i] == 'D') D[i] = 'R';
        else D[i] = 'U';
    }
    
}


int main()
{
    cin >> n;
    rep1(i, n){
        cin >> X[i] >> Y[i] >> D[i];
    }

    int t_time = 2000001;    
    rep(t, 4){
        t_time = min(t_time, solve_UD());
        t_time = min(t_time, solve_UR());
        rotate();
    }

    if (t_time == 2000001) cout << "SAFE" << endl;
    else cout << t_time << endl;

}



Measured memory_bytes: 42516
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int[] S=new int[N];
	    
	    double m=0;
	    for (int i=0; i<N; i++) {
	    	S[i]=gi();
	    	m+=S[i];
	    }
	    m=Math.round(m/N);

	    long s=0;
	    for (int i=0; i<N; i++) {
	    	s+=(m-S[i])*(m-S[i]);
	    }

        System.out.print(s);
//        if (s.charAt(0)=='0' && N!=1) {
//        	System.out.println(-1);
//        }else {
//        	System.out.println(s);
//        }
	}

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

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

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

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

Measured memory_bytes: 35584
// by adiforluls
#pragma GCC optimize ("-O2")
#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;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    int n,m; cin>>n>>m;
    priority_queue<pii> pq;
    rep(i,0,n)
    {
        int x; cin>>x;
        pq.push({x,i});
    }
    while(m--)
    {
        if(pq.empty()) break;
        int price = pq.top().F;
        int idx = pq.top().S;
        pq.pop();
        price/=2;
        if(price) pq.push({price,idx});
    }
    ll ans = 0;
    while(!pq.empty())
    {
        ans+=pq.top().F;
        pq.pop();
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

int dp[400];
int main() {
    int N; cin >> N;
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for(int i=0; i<N; i++) {
        int s, l, p; cin >> s >> l >> p;
        for(int j=0; j<400; j++) {
            for(int k=s; k<=l; k++) {
                if(j - k < 0) continue;
                if(dp[j - k] < 0) continue;
                dp[j] = max(dp[j], dp[j - k] + p);
            }
        }
    }
    
    int M; cin >> M;
    bool no_answer = false;

    vector<int> rec(M);
    for(int i=0; i<M; i++) {
        int v; cin >> v;
        rec[i] = v;
        no_answer |= (dp[v] < 0); 
    }

    if(no_answer) cout << -1 << endl;
    else {
      for(int i=0; i<M; i++) {
        cout << dp[ rec[i] ] << endl;
      }
    }
    return 0;
}



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

#define fi first
#define se second
#define SZ(x) (int)x.size()
#define ll long long
#define pb push_back
#define pq priority_queue
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i,a,b) for (int i=a;i<(b);i++)

const int maxn=3e6+10;

int n,m;
ll fac[maxn];

ll p0w(ll base,int p) {
	ll res=1;
	while (p) {
		if (p%2==1) res*=base,res%=mod;
		base=base*base%mod;
		p>>=1;
	}
	return res;
}

ll C(int x,int y) {
	return fac[x]*p0w(fac[x-y],mod-2)%mod*p0w(fac[y],mod-2)%mod;
}

int main(){
	std::ios::sync_with_stdio(false);
	fac[0]=1;
	rep(i,1,maxn) fac[i]=fac[i-1]*(ll)i%mod;
	cin>>n;
	string s;
	cin>>s;
	n+=SZ(s);
	int m=SZ(s);
	ll ans=0;
	for (int i=m;i<=n;i++) {
		ans+=C(i-1,m-1)*p0w(25,i-m)%mod*p0w(26,n-i)%mod;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 27732
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int max = Math.max(x, y);
        int min = Math.min(x, y);
        int prs = 0;

        //AピザX枚＋BピザY枚を購入
        int sum = a * x + b * y;

        //ABピザを最大数購入
        int sumABmax = c * 2 * max;


        if(max==x) {
        	prs = a;
        }else {
        	prs = b;
        }

        //ABピザを最小数購入、不足分を追加購入
        int sumABmin = (c * 2 * min) + (max-min)*prs;

        System.out.println(Math.min(Math.min(sumABmax,sum), sumABmin));
    }

	private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

using namespace std;

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

int main() {
    int fans = 1012345678;
    vector<int> menus(5);
    rep(i, 5) cin >> menus[i];
    vector<int> order = {0, 1, 2, 3, 4};

    while (next_permutation(order.begin(), order.end())) {
        int ans = 0;
        rep(i, menus.size()) {
            while (ans % 10 != 0) ans++;
            ans += menus[order[i]];
        }
        fans = min(fans, ans);
    }

    cout << fans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin>>S;
    int count0=0;
    int count1=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='0')count0++;
        else count1++;
    }
    cout<<min(count0,count1)*2<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,x;
ll k;
int a[200200],sum[200200];
bool vis[200200];
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int num=1,tot=0;
	while(!vis[num])
	{
		tot++;
		vis[num]=true;
		sum[num]=tot;
		num=a[num];
	}
	int rec=tot+1-sum[num];
	if(k<sum[num])
	{
		int j=1;
		for(int i=1;i<=k;i++)
		{
			j=a[j];
		}
		printf("%d\n",j);
	}
	else
	{
		k-=sum[num];
		k%=rec;
		int j=k+sum[num];
		int q=1;
		for(int i=1;i<=j;i++)
		{
			q=a[q];
		}
		printf("%d\n",q);
	}
	return 0;
}

Measured memory_bytes: 5584
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    vmax(a)        *max_element(all(a))
#define    vmin(a)        *min_element(all(a))
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {ikarus_101

    int  n , m , i , j , k , x ;


    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(max(a*c,a*d),max(b*c,b*d)) << endl;












    return 0;
}


Measured memory_bytes: 3648
// ---------- begin snipet ----------
pub trait MoOperator {
    type Value;
    type Answer;
    fn insert(&mut self, x: &Self::Value);
    fn delete(&mut self, x: &Self::Value);
    fn answer(&self) -> Self::Answer;
}

pub struct MoSolver<S: MoOperator> {
    array: Vec<S::Value>,
    query: Vec<(usize, usize)>,
    phantom: std::marker::PhantomData<S>,
}

impl<S: MoOperator> MoSolver<S> {
    fn new(array: Vec<S::Value>) -> Self {
        MoSolver {
            array: array,
            query: vec![],
            phantom: std::marker::PhantomData,
        }
    }
    fn add(&mut self, l: usize, r: usize) {
        self.query.push((l, r));
    }
    fn solve_with_size(&mut self, mut state: S, answer: &mut [S::Answer], batch: usize) {
        let size = self.array.len();
        let mut q = vec![vec![]; size / batch + 1];
        for (k, &(l, r)) in self.query.iter().enumerate() {
            q[l / batch].push((r, l, k));
        }
        let array = &self.array;
        let mut x = 0;
        let mut y = 0;
        for (i, mut q) in q.into_iter().enumerate() {
            q.sort_unstable_by_key(|p| p.0);
            if i % 2 == 1 {
                q.reverse();
            }
            for (r, l, k) in q {
                let min = std::cmp::min;
                for v in array[min(l, x)..x].iter().rev() {
                    state.insert(v);
                    x = l;
                }
                for v in array[min(r, y)..r].iter() {
                    state.insert(v);
                    y = r;
                }
                for v in array[min(l, x)..l].iter() {
                    state.delete(v);
                    x = l;
                }
                for v in array[min(r, y)..y].iter().rev() {
                    state.delete(v);
                    y = r;
                }
                answer[k] = state.answer();
            }
        }
    }
}
// ---------- end Mo algorithm ----------

struct State {
    cnt: Vec<u32>,
    ans: u32,
}

impl MoOperator for State {
    type Value = usize;
    type Answer = u32;
    fn insert(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&self) -> Self::Answer {
        self.ans
    }
}

fn solve(c: &[usize], ask: &[(usize, usize)]) -> Vec<u32> {
    let mut solver = MoSolver::<State>::new(c.iter().cloned().collect());
    for &(l, r) in ask {
        solver.add(l, r);
    }
    let state = State {
        cnt: vec![0; c.len()],
        ans: 0,
    };
    let mut ans = vec![0; ask.len()];
    solver.solve_with_size(state, &mut ans, 1024);
    ans
}

use proconio::*;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ans = solve(&c, &ask);
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 55732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

int main(){

	std::string str;

	std::cin >> str;

	bool used_c[26] = {};

	if(str == "zyxwvutsrqponmlkjihgfedcba"){
		std::cout << -1 << std::endl;
		return 0;
	}

	std::vector<std::string> strs;
	if(str.length() == 26){
		for(int i = 0; i < 26; ++i){
			for(int j = 0; j < 26; ++j){
				if(!used_c[j] && str[i] - 'a' < j){
					strs.push_back(str.substr(0, i) + char('a' + j));
				}
			}
			used_c[str[i] - 'a'] = true;
		}
	}
	else{
		for(int i = 0; i < str.length(); ++i){
			used_c[str[i] - 'a'] = true;
		}
		for(int i = 0; i < 26; ++i){
			if(!used_c[i]){
				std::cout << str << char('a' + i) << std::endl;
				return 0;
			}
		}
	}

	std::sort(strs.begin(), strs.end());
	std::cout << strs[0] << std::endl;

	return 0;
}


Measured memory_bytes: 256