akhauriyash/Code-Regression huggingface dataset:
/*
 * author :Sadik Hassan(_sad_)
 *
*/

#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(3);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)2e5+5;
const ll MOD =(ll)1e9+7;
const ll INF = (ll)1e18+5;
const int nn=1e5+5;

int main()
{
    _SAD()
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,b*d,a*d,b*c})<<nl;
    return 0;
}


Measured memory_bytes: 3540
import Control.Monad

shuffle :: String -> [Int] -> String
shuffle res [] = res
shuffle s (n:l) = shuffle (drop n s ++ take n s) l

main = do
  l <- getLine
  if l == "-" then return ()
  else do
    n <- getLine
    s <- replicateM (read n) getLine
    putStrLn $ shuffle l (map read s)
    main

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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n,b;
	cin >> n;
	LL res = 0;
	vector<LL> a(n,LLONG_MAX);
	for (LL i = 1; i < n; i++){
		cin >> b;
		a[i-1] = min(a[i-1],b);
		a[i] = min(a[i],b);
	}
	for (auto x : a)
		res += x;
	cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

string str;
int s = 0;
int valid;
void line();
int expr();
void assign();
int malloc();
void free();
int clone();
int variable();
int number();

int size;
int adress = 0;
map<int,int> data;
map<int,int> val; 

void line(){
  data[-1] = 0;
  val[-1] = 0;
  if(str[s] == 'f') free();
  else expr();
}

int expr(){
  
  if(str[s] == '(') {
    s++;
    int res = expr();
    s++;
    return res;
  }

  if(str[s] == 'N' && str[s+1] == 'U'){s += 4;return -1;}
  
  if(isupper(str[s])){
    int idx = variable();
    if(str[s] == '='){
      s++;
      val[idx] = expr();
      val[0] = data[0] = 0;
    }
    return val[idx];
  }
  
  if(str[s] == 'm') return malloc();
  if(str[s] == 'c') return clone();
}

int malloc(){
  assert(str.substr(s,6) == "malloc");
  s += 6; 
  s++;
  int sz = number();
  s++;
  if(size - sz < 0) return -1;
  size -= sz;
  data[++adress] = sz;
  return adress;
}

void free(){
  assert(str.substr(s,4) == "free");
  s += 4;
  int ad = expr();
  valid &= data.count(ad);
  if(data[ad] == 0) return;
  size += data[ad];
  data.erase(ad);

}

int clone(){
  assert(str.substr(s,5) == "clone");
  s += 5;
  int ad = expr();
  valid &= data.count(ad);
  int sz = data[ad];
  if(size - sz < 0) return -1;
  size -= sz;
  data[++adress] = sz;
  return adress;
}

int variable(){
  assert(isupper(str[s]));
  return str[s++];
}

int number(){
  assert(isdigit(str[s]));
  int res = 0;
  while(isdigit(str[s])) res = res*10 + str[s++] - '0';
  return res;
}

signed main(){
  int m;
  cin>>size;
  m = size;
  valid = 1;
  while(cin>>str){
    s = 0;
    line();
  }

  int ans = m - size;  
  for(auto p:val) ans -= data[p.second];
  if(!valid) cout<<"Error"<<endl;
  else cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <stdlib.h>
#define modes 1000000007

int main(){
    int N;
    long long Sum=0;
    scanf("%d",&N);
    long long *A = malloc(sizeof(long long)*N);
    int i,j;
    for(i=0;i<N;i++)scanf("%lld",&A[i]);
    for(i=0;i<60;i++){
        long long onum=0,sum;
        for(j=0;j<N;j++) if((A[j]>>i)&1) onum++;
        sum = (onum%modes)*((N-onum)%modes);
        for(j=0;j<i;j++) sum = sum*2%modes;
        Sum = (Sum+sum)%modes;
    }
    printf("%lld\n",Sum);
    return 0;
}

Measured memory_bytes: 4076
main=do
  [h,w]<-map read.words<$>getLine
  putStrLn['#'|i<-[1..w+2]]
  s<-unlines.map(('#':).(++"#")).lines<$>getContents
  putStr s
  putStrLn['#'|i<-[1..w+2]]


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

using namespace std;

int num[200010];
int main()
{
    int n;
    scanf("%d",&n);
    num[0]=0;
    int l;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&l);
        num[l]=i;
    }
    int imax=0;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(num[i]>num[i-1])
            cnt++;
        else
        {
            imax=max(cnt,imax);
            cnt=1;
        }
    }
    imax=max(cnt,imax);
    cout << n-imax << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

ll n, k;
ll arr[200005];


void reset()
{
}

void input()
{
	cin>>n>>k;
	UU(i,1,n)
	{
		cin>>arr[i];
	}
}

bool check(ll h)
{
	ll cnt = 0;
	UU(i, 1, n)
	{
		if(arr[i] <= h)
		{
			continue;
		}
		cnt += arr[i]/h;
	}
	
	return (cnt <= k);
}

ll binser(ll l, ll r)
{
	if(l <= r)
	{
		ll m = l+(r-l)/2;
		if(check(m))
		{
			return min(m, binser(l,m-1));
		}
		else
		{
			return binser(m+1,r);
		}
	}
	return INT_MAX;
}

void solve()
{
	ll ans = 0;
	UU(i,1,n)ans = max(ans,arr[i]);
	cout<<min((ll)ans,binser(1,2e9))<<endl;
}

void LetsRock()
{
	solve();	
}

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

	input();
	reset();
	LetsRock();
	
	return 0;
}


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

int main() {
  int n,a,lastflag;
  cin >> n;
  
  for(int i=0; i<n; i++){
    cin >> a;
    int flag=0;
    while(true){
      if(a%2!=0){
        break;
      }
      a/=2;
      flag++;
    }
    if(i==0||lastflag>=flag)lastflag=flag;
  }
  
  cout << lastflag << endl;
    
}




Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    ans = 'None'
    for i in string.ascii_lowercase:
        if S.count(i) == 0:
            ans = i
            break

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10156
#include<bits/stdc++.h>
using namespace std;
int n, w; long long value[105] = {}, weight[105] = {};
long long dp[105][100005];
long long findSolution(int pos, long long Sum)
{
    if(pos <= 0 || Sum <= 0)
    {
        return 0;
    }
    if(dp[pos][Sum] != -1)
    {
        return dp[pos][Sum];
    }
    if(weight[pos] > Sum)
    {
        return findSolution(pos-1, Sum);
    }
    else
    {
        long long x = value[pos]+findSolution(pos-1, Sum-weight[pos]);
        long long y = findSolution(pos-1, Sum);
        return dp[pos][Sum] = max(x, y);
    }
}
int main()
{
    scanf("%d %d", &n, &w);
    for(int i = 0; i <= 100; i++)
    {
        for(int j = 0; j <= 100000; j++)
        {
            dp[i][j] = -1;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        scanf("%d %d", &weight[i], &value[i]);
    }
    long long Max = findSolution(n, w);
    printf("%lld\n", Max);
    return 0;
}


Measured memory_bytes: 82664
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

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

int main()
{

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q), r(q);
    REP(i, q)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        l[i] = a;
        r[i] = b;
    }
    vector<int> ac(n + 1, 0);
    int num = 0;

    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            ac[i + 1] += ac[i] + 1;
        }
        else
        {
            ac[i + 1] = ac[i];
        }
    }


    for (int i = 0; i < q; i++)
    {

        int ans = ac[r[i]] - ac[l[i]];
        Cout(ans);
    }

    return 0;
}

Measured memory_bytes: 2176
import java.util.ArrayList;
import java.util.Collection;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> l = new ArrayList<>();
        for(int i = 0; i < N; i++){
            l.add(sc.nextInt());
        }
        l.sort(null);
        long total = 0;
        for(int i = 0; i < l.size()-K; i++){
            total += l.get(i);
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 94904
n,k = map(int,input().split())
p = list(map(int,input().split()))
max_array = sum(p[0:k])
u = max_array
for i in range(k, n):
    u = u + p[i]-p[i-k]
    max_array = max(max_array, u)
print((max_array+k) / 2)


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


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


ll x[3];
int main(void) {
  ll h, w, a;
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0) {
	cout << "0" << endl;
	return 0;
  }
  tmp = inf;
  mi = min(h, w);

  a = w / 3;
  if (a > 0 && a < w) {
	x[0] = a * h;
	x[1] = (w - a)*(h / 2);
	x[2] = (w - a)*((h + 1) / 2);
	sort(x, x + 3);
	tmp = min(tmp, x[2] - x[0]);
  }

  a++;
  if (a > 0 && a < w) {
	x[0] = a * h;
	x[1] = (w - a)*(h / 2);
	x[2] = (w - a)*((h + 1) / 2);
	sort(x, x + 3);
	tmp = min(tmp, x[2] - x[0]);
  }


  a = h / 3;
  if (a > 0 && a < h) {
	x[0] = a * w;
	x[1] = (h - a)*(w / 2);
	x[2] = (h - a)*((w + 1) / 2);
	sort(x, x + 3);
	tmp = min(tmp, x[2] - x[0]);
  }

  a++;
  a = h / 3;
  if (a > 0 && a < h) {
	x[0] = a * w;
	x[1] = (h - a)*(w / 2);
	x[2] = (h - a)*((w + 1) / 2);
	sort(x, x + 3);
	tmp = min(tmp, x[2] - x[0]);
  }

  ans = min(mi, tmp);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
l = []

while True:
    l.append(list(map(int , input().split())))
    if l[-1][0] == 0 and l[-1][1] == 0:
        break

cnt = 0
l_size = len(l)-1

while(cnt < l_size):

    H = l[cnt][0]
    W = l[cnt][1]

    for i in range(H):
        for j in range(W):
            print("#", end="")
        print()
    print()

    cnt += 1



Measured memory_bytes: 7004
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
int main() {
	ll N;
	cin >> N;
	for (int n = 1; n <= 3500;++n) {
			for (int h = 1; h <= 3500;++h) {
				ll under = 4 * n*h - n * N - h * N,up=N*h*n;
				ll w;
				if(under>0)if (up%under == 0) {
					w = up / under;
					cout << n << " " << w << " " << h << endl; return 0;
				}
				else break;
			}
		}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)throws Exception {


        Scanner sc = new Scanner(System.in);

        String[] array = sc.nextLine().split("[\\s]");
        sc.close();
        double x1 = Double.parseDouble(array[0]);
        double x2 = Double.parseDouble(array[1]);
        double y1 = Double.parseDouble(array[2]);
        double y2 = Double.parseDouble(array[3]);

        double x = Math.pow((y1-x1), 2);
        double y = Math.pow((y2-x2), 2);

        double n = Math.sqrt(x+y);

        System.out.println(n);
    }

}

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


int main() {

	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;

	for (int i = 1; i <= n; i++) {
		int num = i,sum=0;
		while (num > 0) {
			sum += num % 10;
			num /= 10;
			
		}
		if (a <= sum && sum <= b) {
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
N = gets.chomp.to_i
monster = gets.chomp.split(" ").map(&:to_i)
breaves_power = gets.chomp.split(" ").map(&:to_i)

total_beated = 0
for town in 0...N do
  breave_power = breaves_power[town]
  beated1 = 0
  beated2 = 0

  if monster[town] > 0
    beated1 = breave_power - monster[town]
    if beated1 < 0
      beated1 = breave_power
    else
      beated1 = monster[town]
    end
    breave_power -= beated1
    monster[town] -= beated1
  end

  if monster[town+1] > 0
    beated2 = breave_power - monster[town+1]
    if beated2 < 0
      beated2 = breave_power
    else
      beated2 = monster[town+1]
    end
    monster[town+1] -= beated2
  end

  total_beated += beated1 + beated2
end

p total_beated


Measured memory_bytes: 17556
#include <iostream>
#include <string>

#include <algorithm>
using namespace std;

long long diff9 (long long n) {
    long long sum = 0;
    while (n > 9) {     // largest number is not counted
        sum += 9 - (n % 10);
        n /= 10;
    }   
    return sum;
}

long long deg(long long n){
    long long res = 0;
    while (n > 0) {
        ++res;
        n /= 10;
    }
    return res;
}


long long  top_num(long long n) {
    long long m = deg(n);
    while (m > 1) {
        n = n/10;
        --m;
    }
    return n;
}

int main() {
    long long N;
    cin >> N;
    long long res = -1;
    
    if (N < 10) res = N;
    else {
        if (diff9(N) >= 1) {
        res = top_num(N) -1 + 9 * (deg(N)-1);
        } 
        else {
            res = top_num(N) + 9 * (deg(N)-1);
        }
    }
    cout  << res << endl;
}

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

#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}


long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
class Combination{
	
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < N+2; i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		long long int al = k[k.size() - 1];
		long long int iv = ppow(k[k.size() - 1],MOD-2);
		r[k.size() - 1] = iv;
		for (int i = (int)(r.size()) - 2; i >= 0; i--){
			r[i] = r[i + 1] * (i + 1);
			if (r[i] >= MOD){
				r[i] %= MOD;
			}
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
	long long int catalan_number(int n){
		return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;
	}
};
Combination C;

int conv(int a,int b){
	return a*60+b;
}
int main(){
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int z=conv(h2,m2)-conv(h1,m1);
	z-=k;
	cout<<z<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int A,B,C,X[105][105],Y[105][105],i,j,k;
long long t;
int main()
{
	scanf("%d%d%d",&A,&B,&C);
	for(i=0;i<A;i++)
		for(j=0;j<B;j++)
			scanf("%d",&X[i][j]);
	for(i=0;i<B;i++)
		for(j=0;j<C;j++)
			scanf("%d",&Y[i][j]);
	for(i=0;i<A;i++)
	{
		for(j=0;j<C;j++)
		{
			for(k=t=0;k<B;k++)
				t+=X[i][k]*Y[k][j];
			printf("%lld%s",t,j==C-1?"\n":" ");
		}
	}
	return 0;
}

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


int main(){


    long long n, i, j, x;

    vector<long long> a;

    vector<long long> b;

    map<long long, long long> mp;


    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> x;

         a.push_back(x);

         mp[x] += 1;

         }


    sort( a.rbegin(), a.rend() );


    for( i = 0 ; i < n ; i = i + 1 ){

         while( mp[ a.at(i) ] / 2 >= 1 ){

                b.push_back( a.at(i) );

                mp[ a.at(i) ] -= 2;

                }

         }

              
    if( b.size() == 0 ) cout << 0 << endl;

    else cout << b.at(0) * b.at(1) << endl;


    return 0;

    }


Measured memory_bytes: 7412
#![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};
use std::num;

fn main() {
    
    let n = read::<usize>();
    let mut h = (0..n).map(|_| { read::<u64>() }).collect::<Vec<u64>>();
    
    if n == 1 {
        println!("Yes");
        return;
    }
    
    for i in (0..n-1).rev() {
        if h[i] > h[i+1] { h[i] -= 1; }
    }
    
    let mut flg = true;
    for i in 0..n-1 {
        if h[i] > h[i + 1] {
            flg = false;
            break;
        }
    }
    
    if flg { println!("Yes"); }
    else{ println!("No"); }
}

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

int main(){
  int a,b,i,dig,f=0;cin>>a>>b;
  dig=log10(b)+1;
  a=a*pow(10,dig)+b;
  for(i=1;i*i<=a;i++){
    if(i*i==a) f=1;
  }
  cout<<(f?"Yes":"No");
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll H;
ll ans;
int main(){
	cin >> H;
	ans = 1;
	while(H >= 1){
		H/=2;
		ans *= 2;
	}
	p(ans-1);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int k, s; cin >> k >> s;
    
    int ans = 0;
    rep(i, k+1){
        rep(j, k+1){
            int l = s - i - j;
            if(0 <= l && l <= k) ++ans;
        }
    }

    cout << ans << endl;

return 0;
}


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


int main(){
    int n;
    cin>>n;
    vector<int> L(n);
    rep(i,n) cin>>L[i];

    int maxL = *max_element(L.begin(),L.end());

    int temp = 0;
    rep(i,n) temp += L[i];

    cout<< (temp > 2*maxL ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String line;
		int length;
		int count;
		
		line = sc.nextLine();
		while (!line.equals("END OF INPUT")) {
			count = 0;
			length = line.length();
			for (int i = 0; i < length; i++) {
				if (line.charAt(i) != ' ') {
					count++;
				} else {
					System.out.print(count);
					count = 0;
				}
			}
			System.out.println(count);
			line = sc.nextLine();
		}
	}
}

Measured memory_bytes: 12000
N=int(input())
same=0
D=[]
for i in range(N):
    D.append(input())

for i in range(N):
    D_1,D_2=map(int,D[i].split())
    if D_1==D_2:
        same+=1
    else:
        same=0
    if same>=3:
        print("Yes")
        break

if same<3:
    print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define ld double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-22
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s, t;
    cin >> s >> t;
    while (s.length() < t.length()) s = "0" + s;
    while (s.length() > t.length()) t = "0" + t;
    if (s < t) cout << "LESS";
    else if (s == t) cout << "EQUAL";
    else cout << "GREATER";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int sx=Integer.parseInt(sc.next());
        int sy=Integer.parseInt(sc.next());
        int tx=Integer.parseInt(sc.next());
        int ty=Integer.parseInt(sc.next());
        sc.close();
        StringBuffer bf=new StringBuffer();
        for(int i=0;i<tx-sx;i++){
            bf.append('R');
        }
        for(int i=0;i<ty-sy;i++){
            bf.append('U');
        }

        for(int i=0;i<tx-sx;i++){
            bf.append('L');
        }
        for(int i=0;i<ty-sy;i++){
            bf.append('D');
        }

        bf.append('D');
        for(int i=0;i<tx-sx+1;i++){
            bf.append('R');
        }
        for(int i=0;i<ty-sy+1;i++){
            bf.append('U');
        }
        bf.append('L');

        bf.append('U');
        for(int i=0;i<tx-sx+1;i++){
            bf.append('L');
        }
        for(int i=0;i<ty-sy+1;i++){
            bf.append('D');
        }
        bf.append('R');

        System.out.println(bf);
    }
}

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

using namespace std;




int main(void)
{
    string w;
    bool ansFlag=true;
    map<char,int> mp;

    cin>>w;

    for(int i=0;i<w.size();i++){
        mp[w[i]]++;
    }

    for(auto i:mp){
        if(i.second %2 != 0){
            ansFlag = false;
        }
    }

    if(ansFlag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

 
	return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
using namespace std;
static const long long MOD = 1000000007LL;
int n;
char s[100005];
uint64_t dp[100005][13];
int main() 
{ int i, j, ki; 
uint64_t res = 0;
scanf("%s", s); 
n = strlen(s);
dp[0][0] = 1;
for (i = 0; i < n; i++) {
int c;
if (s[i] == '?') c = -1; 
else c = s[i] - '0';
	for (j = 0; j < 10; j++) {

if (c != -1 && c != j) continue; 
for (ki = 0; ki < 13; ki++) {
dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]; }
}
for (j = 0; j < 13; j++) 
dp[i + 1][j] %= MOD; }
res = dp[n][5];
printf("%llu\n", res);
return 0; }

Measured memory_bytes: 10496
import java. util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		String b = scan.next();
		String s = a +b;

		double i = Integer.parseInt(s);
		double sqr = Math.sqrt(i);
		int c = (int)sqr;

		if(c==sqr) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}



	}

}


Measured memory_bytes: 22612
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        int X = Integer.parseInt(s);

        int ans = 0;

        for (int i = 0; i <= X; i++) {
            if ((long)X <= (long)i * (i + 1) / 2) {
                ans = i;
                break;
            }
        }

        out.println(ans);

        out.flush();
    }
}


Measured memory_bytes: 22484
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////


int main() {

	long long X;
	cin >> X;
	long long ans = 0;
	ans += (X / 500) * 1000;
	ans += ((X % 500) / 5) * 5;
	cout << ans << endl;
}

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

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 9;
using ll = long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
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 int MAX_N = 105;
const int MAX_v = 1005;

int main() {
    int N, W;
    cin >> N >> W;
    vint w(MAX_N), v(MAX_N);
    REP1(i, N) {
        cin >> w[i] >> v[i];
    }
    // dp[i][j]:品物i番目までで価値の総和がjとなる最小のw
    vvll dp(MAX_N, vll(MAX_N * MAX_v, INF));
    REP(i,N+1){
        dp[i][0] = 0;
    }
    REP1(i, N) {
        REP(j, MAX_N * MAX_v) {
            if (j == 0) {
                dp[i][j] = 0;
            } else {
                chmin(dp[i][j], dp[i - 1][j]);
                if (j >= v[i])
                    chmin(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    ll ans;
    REP(i, MAX_N * MAX_v) {
        if (dp[N][i] <= W)
            ans = i;
    }
    cout << ans;
}

Measured memory_bytes: 88064
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, m;
    scan(n, m);
    auto a = readln.split.to!(int[]).sort();
    auto b = readln.split.to!(int[]).sort();

    //a.sort();
    //b.sort();

    debug {
        stderr.writeln(a);
        stderr.writeln(b);
    }

    int[int] row;
    int[int] col;

    foreach (i ; 0 .. n) {
        if (a[i] in row) {
            writeln(0);
            return;
        }
        row[a[i]] = i;
    }

    foreach (j ; 0 .. m) {
        if (b[j] in col) {
            writeln(0);
            return;
        }
        col[b[j]] = j;
    }

    long ans = 1;
    long used;

    foreach_reverse (k ; 1 .. n * m + 1) {
        if (k in row && k in col) {
        }
        else if (k in row) {
            auto up = b.upperBound(k).length.to!long;
            ans *= up;
            ans %= mod;
        }
        else if (k in col) {
            auto up = a.upperBound(k).length.to!long;
            ans *= up;
            ans %= mod;
        }
        else {
            auto upr = a.upperBound(k).length.to!long;
            auto upc = b.upperBound(k).length.to!long;
            ans *= max(0, upr * upc - used) % mod;
            ans %= mod;
        }
        used++;
    }

    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg ; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg ; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

long powmod(long x, long y, long mod = 1_000_000_007L) {
    long res = 1L;

    while (y > 0) {
        if (y & 1) {
            (res *= x) %= mod;
        }
        (x *= x) %= mod;
        y >>= 1;
    }

    return res;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
using namespace std;
typedef long long LL;
const LL mod = (1e9 + 7);

int nexts[200005][27], pos[27], dp[200005][27], pos2[200005][27], len;
char ch[200005];

void dfs(int u, int v)
{
    if(dp[u][v] != -1)
        return;
    dp[u][v] = inf;
    if(nexts[u][v] == len + 1)
    {
        dp[u][v] = 1;
        pos2[u][v] = v;
    }
    else
    {
        for(int i = 0;i < 26;i++)
        {
            dfs(nexts[u][v], i);
            if(dp[u][v] > dp[nexts[u][v]][i] + 1)
            {
                dp[u][v] = dp[nexts[u][v]][i] + 1;
                pos2[u][v] = i;
            }
        }
    }

}

void pr(int a, int b)
{
    printf("%c", b + 'a');
    if(nexts[a][b] == len + 1)
        return;
    pr(nexts[a][b], pos2[a][b]);
}

int main()
{
    mem(dp, -1);
    scanf("%s", ch + 1);
    len = strlen(ch + 1);
    for(int i = 0;i < 26;i++)
        pos[i] = len + 1;
    for(int i = len;i >= 1;i--)
    {
        for(int j = 0;j < 26;j++)
            nexts[i][j] = pos[j];
        pos[ch[i] - 'a'] = i;
    }
    for(int i = 0;i < 26;i++)
        nexts[0][i] = pos[i];
    for(int i = 0;i <= len;i++)
    {
        for(int j = 0;j < 26;j++)
        {
            if(dp[i][j] == -1)
                dfs(i, j);
        }
    }
    int ans = inf, ans2;
    for(int i = 0;i < 26;i++)
    {
        if(ans > dp[0][i])
            ans = dp[0][i], ans2 = i;
    }
    pr(0, ans2);
    puts("");
    return 0;
}


Measured memory_bytes: 64000
/*
 * ARC079_D.cpp
 *
 *  Created on: Jun 6, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

lng lim = 1000 + 10000000000000000LL;

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

	lng K;
	cin >> K;

	if(K == 0) {
		cout << 2 << endl;
		cout << 1 << " " << 1 << endl;
		return 0;
	}
	if(K == 1) {
		cout << 2 << endl;
		cout << 0 << " " << 2 << endl;
		return 0;
	}

	lng n, c, p;
	FOR(i, 2, 50) {
		lng d = K / i;
		lng r = K % i;
		if(d < 1) continue;
		if(i+d-1+r > lim) continue;
		n = i;
		c = d-1;
		p = r;
		break;
	}

	cout << n << endl;
	REP(i, n) {
		if(i > 0) cout << " ";
		lng x = i+1 + c;
		if(i >= n-p) x += 1;
		cout << x;
	}
	cout << endl;
}






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

const int N = 305;
typedef long long LL;

int n, m;
LL ans, mod, f[N][N], suf[N][N], c[N][N];

int main() {
	cin>>n>>m>>mod;
	c[0][0] = 1;
	for(int i = 1; i <= max(n, m); i++) {
		c[i][0] = 1;
		for(int j = 1; j <= i; j++)
		    c[i][j] = (c[i - 1][j - 1] + c[i - 1][j])%mod; 
	}
	for(int i = 0; i <= m; i++) 
		f[1][i] = 1, suf[1][i] = m - i + 1;
	for(int i = 2; i <= n + 1; i++) {
		for(int j = m; j >= 0; j--) {
			for(int k = 1; k < i; k++)
				f[i][j] = (f[i][j] + c[i - 2][k - 1]*f[i - k][j]%mod*suf[k][j + 1])%mod;
			suf[i][j] = (suf[i][j + 1] + f[i][j])%mod;
		}
	}
	cout<<f[n + 1][0]<<endl;
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (s.at(i) != s.at(i - 1)) {
			ans++;
		}
	}
	cout << ans << endl;
}

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


void solve(ll a, ll b){
    cout<<max(0LL,a-2*b)<<endl;
}

int main(){
    ll a;
    scanf("%lld",&a);
    ll b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	char ch=getchar();int f=0;x=0;
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005,inf=1e9+99;
struct node{
	int level,mx;
	vi pre,suf;
	node(int _x=inf){
		level=_x,mx=1;
		if(_x>=0)pre=suf={1};
	}
}stk[N],emp;
int a[N],n,L,top;
ll ans;

node merge(node a[],int n){
	static int sum[N],tot[N];
	rep(i,1,n)sum[i]=sum[i-1]+a[i].mx;
	if(sum[n]<L)return emp;
	tot[n+1]=0;
	per(i,n,1)tot[i]=tot[i+1]+a[i].pre[0];
	for(int l=1,r=1,q=1;r<=n;l++)
		per(i,a[l].mx,1){
			while(l==r)r++,q=1;
			while(r<=n&&i+sum[r-1]-sum[l]+q<L){
				q++;
				if(q<=a[r].mx)continue;
				r++,q=1;
			}
			if(r<=n){
				int A=a[l].suf[i-1]-(i<a[l].mx?a[l].suf[i]:0);
				int B=a[r].pre[q-1]+tot[r+1];
				ans+=(ll)A*B;
			}
		}
	node res(-1);
	res.level=a[1].level+1;
	res.mx=sum[n]/L;
	res.pre.resize(res.mx);
	res.suf.resize(res.mx);
	for(int i=1,cnt=0;i<=n;i++)
		rep(j,1,a[i].mx)
			if(++cnt>=L){
				int tmp=a[i].pre[j-1]-(j<a[i].mx?a[i].pre[j]:0);
				res.pre[cnt/L-1]+=tmp;
			}
	for(int i=n,cnt=0;i>=1;i--)
		rep(j,1,a[i].mx)
			if(++cnt>=L){
				int tmp=a[i].suf[j-1]-(j<a[i].mx?a[i].suf[j]:0);
				res.suf[cnt/L-1]+=tmp;
			}
	per(i,res.mx-1,1){
		res.pre[i-1]+=res.pre[i];
		res.suf[i-1]+=res.suf[i];
	}
	return res;
}

int main(){
	read(n),read(L),ans=n;
	rep(i,1,n)read(a[i]);
	a[n+1]=inf;
	rep(i,1,n){
		stk[++top]=node(a[i]);
		int flag=0;
		while(flag&&stk[top].level<inf||stk[top].level<a[i+1]){
			int cur=top;
			while(cur&&stk[cur].level==stk[top].level)
				cur--;
			stk[cur+1]=merge(stk+cur,top-cur);
			top=cur+1;
			if(stk[top].level==inf)flag=1,top--;
		}
		if(flag)stk[++top].level=inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26368
/*
 * main.c
 *
 *  Created on: 2019/02/09
 *      Author: londo
 */

#include<stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	int sec = N % 60;
	int min = N / 60 % 60;
	int hour = N / 60 / 60;

	printf("%d:%d:%d\n",hour,min,sec);

	return 0;
}



Measured memory_bytes: 2104
from collections import Counter
s = input()

ls = len(s)
t = [0]
j = 1
for i in range(ls):
    u = (int(s[ls-1-i])*j + t[-1]) % 2019
    t.append(u)
    j = (j * 10) % 2019
c = Counter(t)
k = list(c.keys())
ans = 0
for i in k:
    ans += c[i]*(c[i]-1)/2
print(int(ans))

Measured memory_bytes: 16756
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
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; } 
using ll=long long;
 int main(){
  int n,k,g;
   cin>>n>>k;
   map<int,int> m;
   rep(i,k){
   cin>>g;
     rep(j,g){
     int x;
       cin>>x;
       m[x]=1;
     }
   }
   cout<<n-m.size()<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    deque<char> deq;
    for (auto x : s) {
        deq.push_back(x);
    }
    ll q;
    cin >> q;
    ll rev = 0;
    while (q--) {
        ll type;
        cin >> type;
        if (type == 1) rev = (rev + 1) % 2;
        else {
            ll f;
            char c;
            cin >> f >> c;
            if ((f + rev) % 2) deq.push_front(c);
            else deq.push_back(c);
        }
    }
    s = "";
    for (auto x : deq) s += x;
    if (rev == 1) reverse(ALL(s));
    cout << s << endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    int n,m; ll k;
    cin>>n>>m>>k;
    ll a[200005],b[200005];
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<m;i++)cin>>b[i];
    ll suma[200005],sumb[200005];
    for(i=1;i<n+1;i++){
    	suma[i]=suma[i-1]+a[i-1];
	}
	for(i=1;i<m+1;i++){
		sumb[i]=sumb[i-1]+b[i-1];
	}
    int ans=0;
	for(i=0;i<n+1;i++){
		if(suma[i]>k) break;
		int l=0,r=m;
		while(l<r){
			int mid=(l+r+1)/2;
			if(sumb[mid]>k-suma[i]){
				r=mid-1;
			}
			else l=mid;
		}
		ans=max(ans,i+l);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9884
import sys

n = int(input())
a = [0] + [int(input()) for _ in range(n)]

ans = 0

v = set([0])
x = 1
while True:
    x = a[x]
    if x in v:
        ans = -1
        break
    v.add(x)
    ans += 1
    if x == 2:
        break

print(ans)

Measured memory_bytes: 13720
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int a[2010][2010];
int b[2010][2010];
int c[2010][2010];

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    vector<string> s(n);
    rep(i,n)cin >> s[i];
    rep(i,n){
        rep(j,m){
            if(s[i][j]=='1'){
                a[i+1][j+1] = 1;
            }
        }
    }
    rep(i,n){
        rep(j,m){
            if(j+1<m&&s[i][j]=='1'&&s[i][j+1]=='1'){
                b[i+1][j+2]++;
            }
            if(i+1<n&&s[i+1][j]=='1'&&s[i][j]=='1'){
                c[i+2][j+1]++;
            }
        }
    }
    rep(i,n){
        rep(j,m){
            a[i+1][j+1] += a[i+1][j];
            b[i+1][j+1] += b[i+1][j];
            c[i+1][j+1] += c[i+1][j];
        }
    }
    rep(i,n){
        rep(j,m){
            a[i+1][j+1] += a[i][j+1];
            b[i+1][j+1] += b[i][j+1];
            c[i+1][j+1] += c[i][j+1];
        }
    }
    rep(zz,q){
        int d,f,g,h;
        cin >> d >> f >> g >> h;
        int sm = 0;
        sm += a[g][h] - a[d-1][h] - a[g][f-1] + a[d-1][f-1];
        //cerr << sm << endl;
        sm -= b[g][h] - b[d-1][h] - b[g][f] + b[d-1][f];
        //cerr << sm << endl;
        sm -= c[g][h] - c[d][h] - c[g][f-1] + c[d][f-1];
        cout << sm << endl;
        //cerr << endl;
    }
    return 0;
}

Measured memory_bytes: 55168
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s;
    ll ans=0;
    ll n=s.length();
    bool maki;
    for(int i=0;i<n;i++){
        if(i==0){
            t=s[i];
            ans++;
            maki=false;
        }
        else{
            if(maki){
                t+=s[i];
                ans++;
                maki=false;
            }else{
                if(t[0]==s[i]&&(t.length()==1)){
                    t=s[i];
                    maki=true;
                }
                else{
                    t=s[i];
                    ans++;
                    maki=false;
                }
            }
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> x(m);
  for(int i=0;i<m;i++) cin>>x[i];

  if(n >= m) {
    cout << 0 << endl;
    return 0;
  }

  sort(x.begin(),x.end());

  vector<int> l(m-1);
  for(int i=0;i<m-1;i++){
    l[i] = x[i+1] - x[i];
  }

  sort(l.begin(),l.end());

  int ans = x[m-1] - x[0];
  for(int i=0;i<n-1;i++){
    ans -= l[l.size()-1-i];
  }
  cout << ans << endl;
}


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

int main(){
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = (N % 1000) / 100;
  c = (N % 100) / 10;
  d = N % 10;
  if (b == c){
    if (a == b){
      cout << "Yes" << endl;
    }
    else if (c == d){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;
typedef long long ll;

int a[51];
int cnt = 0;

int main()
{
 	ios_base::sync_with_stdio(0);
 	int n;
 	cin >> n;
 	int m=1e7, M=-1e7;
 	int mind=0, Mind=0;
 	for(int i=1; i<=n; i++) {
 		cin >> a[i];
 		if(a[i] < m) {
 			m = a[i];
 			mind = i;
 		}
 		if(a[i] > M) {
 			M = a[i];
 			Mind = i;
 		}
 	}

 	if(m+M<0) {
 		cout << 2*n - 1 << endl;
 		for(int i=1; i<=n; i++) {
 			cout << mind << " " << i << endl;
 		}
 		for(int i=n; i>1; i--) {
 			cout << i << " " << i-1 << endl;
 		}
 		return 0;
 	}
 	else {
 		cout << 2*n - 1 << endl;
 		for(int i=1; i<=n; i++) {
 			cout << Mind << " " << i << endl;
 		}
 		for(int i=1; i<n; i++) {
 			cout << i << " " << i+1 << endl;
 		}
 		return 0;
 	}
}


Measured memory_bytes: 256