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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

using ll = long long int;
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % M;
}

Int pow(Int x, Int n) { //x^n 計算量O(logn)
	Int ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(k + 1, 0);
    Int res = 0;
    for (Int i = k; (Int)i >= 1; i--) {
        Int add = RepeatSquaring(k / i, n, mod);
        for (Int j = 2; i * j <= k; j++) {
            add = (add - a[i * j] + mod) % mod;
        }
        a[i] = add;
    }
    for (Int i = 1; i <= (Int)k; i++) {
        Int add = a[i] * i % mod;
        res = (res + add) % mod;
    }
    print(res);
    return 0;
}


Measured memory_bytes: 4052
import numpy as np

N = input()
A, B = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

P = np.array(P)
P_1 = P[P <= A]
P_2 = P[(P >= (A+1)) & (P <= B)]
P_3 = P[P > B]
print(min(len(P_1), len(P_2), len(P_3)))

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define int long long

using namespace std;
using P = pair<int, int>;
using ll = long long;
const ll INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

signed main(){
    string s,t;
	cin>>s>>t;
	cout<<t<<s<<endl;
}


Measured memory_bytes: 256
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    A = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(1,n+1):
        if i%2 == 1:
            if A[i-1]%2 == 1:
                ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class393
    {
        static void Main()
        {
            var NQ = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NQ[0];
            int Q = NQ[1];
            string S = Console.ReadLine();
            int[] d = new int[N + 1];
            for (int i = 0; i < N-1; i++)
            {
                d[i + 2] = d[i + 1];
                if (S[i] == 'A' && S[i + 1] == 'C')
                {
                    d[i + 2]++;
                }
            }

            for (int i = 0; i < Q; i++)
            {
                var lr = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Console.WriteLine(d[lr[1]]-d[lr[0]]);
            }
        }
    }
}


Measured memory_bytes: 41528
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	int count[4] = {0}; // A, B, AB, O
	
	int no;
	char dummy;
	char buf[3];
	
	while ( cin >> no >> dummy >> buf ) {
		if ( strcmp(buf, "A") == 0 ) count[0]++;
		else if ( strcmp(buf, "B") == 0 ) count[1]++;
		else if ( strcmp(buf, "AB") == 0 ) count[2]++;
		else count[3]++;
	}
	
	for (int i=0; i<4; i++) cout << count[i] << endl;
	
	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll A, B;
    cin >> A >> B;

    vvc<ll> G(100, vl(100));

    repe(i, 50, 100) rep(j, 100) G[i][j] = 1;

    ll acnt = 0, bcnt = 0;

    bool isok = false;
    rep(i, 100){
        if (i % 2) continue;
        if (isok) break;

        rep(j, 50){
            if (acnt == A - 1){
                isok = true;
                break;
            }
            G[i][j * 2] = 1;
            acnt++;
        }
    }

    isok = false;
    repr(i, 100){
        if (i % 2 == 0) continue;
        if (isok) break;
        rep(j, 50){
            if(bcnt==B - 1){
                isok = true;
                break;
            }
            G[i][j * 2] = 0;
            bcnt++;
        }
    }

    cout << "100 100" << '\n';
    rep(i, 100){
        rep(j, 100) cout << (G[i][j] ? '.' : '#');
        cout << '\n';
    }
}

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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


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

template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }


int ar[100009];

int main()
{
	//cout.setf(ios::fixed); cout.precision(10);
	ios_base::sync_with_stdio(false);  cout.tie(nullptr); cin.tie(nullptr);

	int n,q;
	cin >> n>>q;

	string s;
	cin >> s;

	s = "?" + s;

	for (int i = 1; i < (int)s.size()-1; i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'C')
		{
			ar[i] = 1;
		}

		ar[i] += ar[i - 1];
	}

	ar[(int)s.size()-1] += ar[(int)s.size() - 2];

	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;

		r--;
		l--;

		cout << ar[r]- ar[l] << endl;
	}

	return 0;
}

Measured memory_bytes: 1388
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,n;
    cin>>n>>a>>b;
    int i,s_n,sum=0,r,ans=0;
    for(i=1;i<=n;i++){
        s_n=i;
        sum=0;
        while(s_n){
            r = s_n%10;
            sum+=r;
            s_n/=10;
        }
        if(sum>=a&&sum<=b){
           ans+=i;
        }

    }
    cout<<ans<<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);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(n<=k){
            System.out.println(x*n);
        }else{
            System.out.println(x*k+(n-k)*y);
        }
    }
}

Measured memory_bytes: 21844
import Data.Bits
import Data.List
import Data.Foldable(foldlM)
import Data.Maybe(fromJust)
import Control.Monad
import Data.Array as A ((!),accumArray)
import Data.Graph
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Char8 as BS

toTuple :: [a] -> (a,a)
toTuple (x:y:_) = (x,y)
toTuple _ = undefined

getInt :: IO Int
getInt = fst . fromJust. BS.readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile (== ' ')) <$> BS.getLine

getLineB :: (Read a) => IO [a] --直接入力
getLineB = map (read.BS.unpack) . BS.words <$> BS.getLine

mod' :: Int -> Int
mod' n = n `mod` 1000000007

main :: IO ()
main = do
  [a,b] <- getIntList
  print $ (b-2) `div` (a-1) + 1


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

using ll = long long;
using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    int mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int diff;
        if (i == 0) {
            diff = a[i];
        } else {
            diff = a[i] - a[i-1];
        }
        mx = max(mx, diff);
    }
    mx = max(mx, k + a[0] - a[n-1]);
    cout << k - mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


ll solve()
{
    int N;

    std::cin >> N;

    return (N  - 1) / 2;


}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}


Measured memory_bytes: 256
from itertools import combinations

def readinput():
    n,p=list(map(int,input().split()))
    a=list(map(int,input().split()))
    return n,p,a


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main(n,p,a):
    ne=0
    no=0
    for i in range(n):
        if a[i]%2==0:
            ne+=1
        else:
            no+=1
    #print('ne: {}, no: {}'.format(ne,no))

    alle=2**ne
    #print('alle: {}'.format(alle))

    allo=0
    if p==0:
        mo=0
    else:
        mo=1
    while mo<=no:
        allo+=cmb(no,mo)
        mo+=2
    #print('allo: {}'.format(allo))
    
    return alle*allo

if __name__=='__main__':
    n,p,a=readinput()
    ans=main(n,p,a)
    print(ans)


Measured memory_bytes: 9660
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,k = I()
d = l()
use = [i for i in range(11) if i not in d ]
a = True
price = n

while a:
    cnt = 0
    for i in str(price):
        a = len(str(price))
        if int(i) not in d:
            cnt += 1
        else:
            cnt = inf
        if a == cnt:
            print(price)
            sys.exit()
    price += 1
    
    
    



Measured memory_bytes: 10468
n,m=[int(x) for x in input().split()]

ab=[[int(x) for x in input().split()]for j in range(n)]

ab.sort(key=lambda x:x[0])
#print(ab)

ans=0
for i in range(n):
  if m<ab[i][1]:
    ans += m*ab[i][0]
    break
  else:
    ans += ab[i][0]*ab[i][1]
    m-= ab[i][1]
    
  #print(ans,ab[i])
    
    
print(ans)

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

const int MAXN = 1.1e6;
int N;
int A[MAXN];
int K;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  int s = 0; for (int i = 0; i < N; i++) s += A[i];
  for (int f = s; true; f--) {
    if (s % f != 0) continue;
    
    int v = 0;
    for (int i = 0; i < N; i++) {
      v += A[i] % f;
    }
    v /= f;
    sort(A, A+N, [&](int i, int j)->bool { return i%f < j%f; });
    int cost = 0;
    for (int i = 0; i < N-v; i++) {
      cost += A[i] % f;
    }
    if (cost <= K) { cout << f << '\n'; exit(0); }
  }
}

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

int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    for(int i=0;i<n;i++)
        cin >> l[i];
    
    int d = 0;
    int ans = 0;
    for(int i=0;i<=n;i++){
        d += l[i];
        ans++;
        if(d>x){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

using namespace std;

using ll = long long;

ll A[2000200];

int main() {
  int N;
  cin >> N;
  ll total = 0;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
    total += A[i];
  }

  bool even = total % 2 == 0;
  ll half   = total / 2;
  ll t1     = 0;
  ll t2     = 0;
  ll tt     = 0;
  for(int i = 0; i < N; ++i) {
    if(tt == 0) {
      if(t1 + A[i] == half && even) { // 偶数で切れ目が半分の場所にある場合は
        cout << 0 << endl;
        return 0;
      }
      if(t1 + A[i] > half) {
        tt = A[i];
      } else {
        t1 += A[i];
      }
    } else {
      t2 += A[i];
    }
  }
  int result = min(abs(t1 + tt - t2), abs(t2 + tt - t1));
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include<bitset>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double EPS = 0.000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================


	int N, M;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

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

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}

	if (sum % 10 != 0) {
		cout << sum;
		return 0;
	}

	int min = -INF;
	for (int i = 0; i < N; i++) {
		if (A[i] % 10 != 0) {
			min = A[i];
			break;
		}
	}

	if (min == -INF) {
		cout << 0;
	}
	else {
		cout << sum - min;
	}


}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
        cin >> a[i];
    vector<int> ans(n);
    REP(i, n){
        ans[a[i]-1] = i+1;
    }
    print_container(ans);
    return 0;
}

Measured memory_bytes: 1536
while line = gets do
    a,op,b = line.split
    a = a.to_i
    b = b.to_i
    case op
    when "+" then
        puts a+b
    when "-" then
        puts a-b
    when "*" then
        puts a*b
    when "/" then
        puts a/b
    when "?" then
        break
    end
end


Measured memory_bytes: 6912
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
n = len(s)
m = (n-1)//2
for i in range(m//2):
    if not (s[i]==s[m-1-i]==s[m+1+i]==s[2*m-i]):
        print('No')
        exit()
if m%2==1 and s[m//2]!=s[m+1+m//2]:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int main() {
    double ans;
    int N;
    double coeff = 380000.0;
    scanf("%d", &N);
    rep(i, N) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += coeff * x;
    }
    printf("%f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
using namespace std;

int main(){
  int a,b;
  scanf("%d%d", &a, &b);
  int ans = 0;
  REP(i,2){
    ans += max(a,b);
    if(a > b) a--;
    else b--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# encoding: utf-8
N = int(input())
A = list(map(int, input().split()))

A.sort()

view = 10 ** 9 + 7
lengths = [0] * 2
idx = 0
for Ai in reversed(A):
    if Ai < view:
        view = Ai
        cnt = 0
    cnt += 1
    if cnt >= 2:
        lengths[idx] = view
        cnt = 0
        idx += 1
    if idx > 1: break

# print("#", lengths)
print(lengths[0] * lengths[1] if idx > 1 else 0)

Measured memory_bytes: 14244
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,2 * a - 1,2 * b - 1 }) << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  int NG = N;
  if (NG % 2 == 0)
    NG++;

  vector<int> a, b;
  rep(i, N) {
    repp(j, i + 1, N - 1) {
      if (i + j + 2 != NG) {
        a.pb(i + 1), b.pb(j + 1);
      }
    }
  }

  int M = len(a);
  cout << M << "\n";
  rep(i, M) {
    cout << a[i] << ' ' << b[i] << "\n";
  }
}

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

#define int		long long

using namespace std;

void solve()
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	while(a>=b or b>=c){
		if(b<=a){
			b*=2;
			k--;
		}
		if(k==0){
			if(a>=b or b>=c){
				cout<<"No"<<endl;
				return;
			}
			break;
		}
		if(c<=b){
			c*=2;
			k--;
		}
		if(k==0){
			if(a>=b or b>=c){
				cout<<"No"<<endl;
				return;
			}
			break;
		}
	}

	cout<<"Yes"<<endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	//int t;cin >> t;while(t--)
		solve();;
	
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

vector<int>v(5);
int k;
int main(){
	for (int i = 0; i < 5; ++i) {
		cin >> v[i];
	}
	cin >> k;
	if (v[4] - v[0] > k) {
		puts(":(");
		return 0;
	}
	puts("Yay!");
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define ll           long long
#define pll          pair<ll,ll>
#define pb           push_back
#define eb           emplace_back
#define F            first
#define S            second
#define vll(v)       v.begin(),v.end()
#define bug(a)       cerr << #a << " : " << a << endl;
#define fastread()     ios_base::sync_with_stdio(false);cin.tie(NULL);

const int Max = 1e4+10;


int main()
{
       fastread();

       ll n,i;

          cin>>n;


        ll dp[4][n+2];

        dp[1][0]=dp[2][0]=dp[3][0]=0;


       for(i=1; i<=n; i++)
       {
           cin>>dp[1][i]>>dp[2][i]>>dp[3][i];

           dp[1][i]+=max(dp[2][i-1],dp[3][i-1]);

           dp[2][i]+=max(dp[1][i-1],dp[3][i-1]);

           dp[3][i]+=max(dp[1][i-1],dp[2][i-1]);
       }

       cout<<max3(dp[1][n],dp[2][n],dp[3][n])<<endl;




}


Measured memory_bytes: 5968
N,M=map(int,input().split())

a=[]

for i in range(N):
    a.append(list(map(int,input().split())))

c=[]

for i in range(M):
    c.append(list(map(int,input().split())))


for i in range(N):
    ans=1000
    min=1000000000
    for j in range(M):
        d=abs(c[j][0]-a[i][0])+abs(c[j][1]-a[i][1])
        if d <min:
            ans=j+1
            min=d
    print(ans)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 998244353;
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
void add(ll &l, ll r) {l = (l + r) % mod;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    VL l(k), r(k);
    rep(i, 0, k) cin >> l[i] >> r[i];
    VL dp(2*n+10, 0), imos(2*n+19, 0);
    imos[1] = 1; imos[2] = -1;
    rep(i, 1, n+1) {
        rep(j, 0, k) {
            add(imos[i+l[j]], imos[i]);
            add(imos[i+r[j]+1], -imos[i]);
        }
        add(imos[i+1], imos[i]);
    }
    imos[n] += mod;
    imos[n] %= mod;
    cout << imos[n] << endl;
    return 0;
}

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

using namespace std;

int main(){
   int H,W; //H tate W yoko 
   cin >> H >> W;
   vector<string> A(H); //[tate][yoko]
   for(int i=0;i<H;i++) cin >> A[i];
   int move = 0;
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         if(A[i][j] == '#')move++;
      }
   }
   if(move == H+W-1)cout << "Possible" << endl;
   else cout << "Impossible" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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

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

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

const ll mod = 1e9+7;

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

    // 前処理
    vector<ll> inv(n+1), kai(n+1);
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
        inv[i] = mod - (mod/i)*inv[mod%i] % mod;
    }
    kai[0] = 1;
    for (int i = 1; i <= n; i++) {
        kai[i] = kai[i-1] * i % mod;
    }

    ll a = 0;
    ll ans = 0;
    repf(i, 1, n) {
        (a += kai[n-1]*inv[i]) %= mod;
        (ans += a*(x[i]-x[i-1])) %= mod;
        // cout << a << endl;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define PB push_back
#define int long long int
using namespace std;
typedef vector<int> VI;
const int INF = 3e18;

int a, b, n;
int ans = INF;

int divide[110];

signed main()
{
  cin >> a >> b >> n;
  for(int i = 1; i <= n; i++){
    if(b % i){
      divide[i] = -1;
    }
    else{
      divide[i] = b / i;
    }
  }

  for(int i = 1; i <= n; i++){
    if(divide[i] != -1){
      for(int j = 1; j <= n; j++){
	ans = min(ans, abs(a - divide[i] * j));
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  // n = k(m+1)　なるmがお気に入りの数になりうる
  ll ans = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ll m1 = n / i - 1;
      ll m2 = i - 1;
      if (m1 != 0 && n / m1 == n % m1) {
        ans += m1;
      }
      if (m1 != m2 && m2 != 0 && n / m2 == n % m2) {
        ans += m2;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
keep = []
ans = 0
for i in range(n):
    s = list(input().split())
    keep.append(s)
for j in range(n):
    st = keep[j]
    if st[1] == 'JPY':
        ans += float(st[0])
    else:
        ans += float(st[0]) * 380000
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y;
  cin >> x >> y;
  for(int i=0;i<x+1;i++){
    for(int j=0;j<x+1;j++){
      if(i*2+j*4==y&&i+j==x){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}

Measured memory_bytes: 3660
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c = nm()

    a, b, c = sorted([a, b, c])

    op1 = c - b
    op2 =  math.ceil((c - (a + op1)) / 2)

    if a + op1 + 2*op2 > c:
        op1 += 1

    print(op1 + op2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3696
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



map<long long, long long> sum;
int a[100000];

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

	int n;
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		sum[a[i]] += a[i];
	}
	long long s = 0;
	for (auto &p : sum) {
		auto x = p.second;
		p.second += s;
		s += x;
	}
	long long 
	int ans = 0;
	rep(i,n) {
		long long x = a[i];
		while (1) {
			long long prev = x;
			x = (--sum.upper_bound(2 * x))->second;
			if (x == prev)break;
		}
		if (x == sum.rbegin()->second) {
			ans++;
		}
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif */

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    string s;
    cin>>s;
    ll ans = 0;
    ll temp = 0;
    rep(i,0,3)
    {
      if(s[i] == 'R')
        temp++;
      else
      {
        temp = 0;
      }
      ans= max(ans,temp);
    } 
    ans = max(ans,temp);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main (void)
{
  int x,y;
  in("%c %c\n",&x,&y);
  if(x-y<0)
  {
    puts("<");
  }
  else if(x-y>0)
  {
    puts(">");
  }
  else
  {
    puts("=");
  }
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int max_1 = a + a - 1;
    int max_2 = a + b;
    int max_3 = b + b - 1;
    cout << max(max(max_1,max_2),max_3) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

int main() {
  vi x(5);
  rep(i,5) cin >> x[i];
  
  int ans;
  rep(i,5) {
    if(x[i]==0) ans=i+1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
	int a,b=0;
	char c;
	scanf("%d\n",&a);
	char ch[a];
	for(int i=0;i<a;i++)
	scanf("%c",&ch[i]);
		for(int i=0;i<a;i++)
		{
		if(ch[i]==ch[i+1])
		continue;
		else
	    b++;
		}
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast			ios_base::sync_with_stdio(0);cin.tie(0)
#define f0(a,b,c) 		for(int a=b;a<c;a++)
#define f1(a,b,c) 		for(int a=b;a<=c;a++)
#define rev(a,b,c) 		for(int a=b;a>=c;a--)
#define trav(a,x)		for(auto &a:x)
#define ini(a,x)		memset(a,x,sizeof(a))
#define pb 				push_back
#define eb				emplace_back
#define fi 				first
#define se 				second
#define all(con) 		con.begin(),con.end()
#define ll 				long long
#define vi 				vector<int> 
#define vll 			vector<ll>
#define mod 			1000000007
#define pi 				pair<int,int>
#define pll 			pair<ll,ll>
#define mi 				map<int,int> 
#define mll				map<ll,ll>
#define umi 			unordered_map<int,int>
#define umll 			unordered_map<ll,ll>
#define lb 				lower_bound
#define ub 				upper_bound
#define pq 				priority_queue<ll,ll>
#define st				stack<int>
#define qu				queue<int>
#define endl            "\n"
#define sz(a)			(int)a.size()
using namespace std;
using ull = unsigned long long;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}
 
template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}
 
template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

ll powm(ll a , ll n)
{
	ll res = 1;
	
	while(n)
	{
		if(n & 1)
		res = (res * a);
		
		n >>= 1;
		a = (a * a);
	}
	
	return res;
}

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

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

int main()
{
	int t=1;
	//cin>>t;
	while(t--)
	{
		int h,w;
		cin>>h>>w;
		int u,v;
		cin>>u>>v;
		u--;v--;
		int x,y;
		cin>>x>>y;
		x--,y--;
		int vis[h][w];
		memset(vis,0,sizeof(vis));
		ll dist[h][w];
		char s[h][w];
		f0(i,0,h)
		{	cin>>s[i];
			f0(j,0,w)
			{
				vis[i][j]=(s[i][j]=='#');
				dist[i][j]=1e9+5;
			}
		}
		deque<pair<int,int>> q;
		
		q.push_front({u,v});
		
		dist[u][v]=0;
		
		while(!q.empty())
		{
			pi a=q.front();
			
			q.pop_front();
			
			if(vis[a.fi][a.se])	continue;
			
			vis[a.fi][a.se]=1;
			
			ll d=dist[a.fi][a.se];
			
			f0(i,0,4)
			{
				int xx=a.fi+dx[i];
				int yy=a.se+dy[i];
				if(xx<0 || xx>=h || yy<0 || yy>=w)
					continue;
				if(dist[xx][yy]<=d)
					continue;
				dist[xx][yy]=d;
				q.push_front({xx,yy});
			}
			
			f1(i,-2,2)
			{
				f1(j,-2,2)
				{
					int xx=a.fi+i;
					int yy=a.se+j;
					if(xx<0 || xx>=h || yy<0 || yy>=w)
						continue;
					if(dist[xx][yy]<=d+1)
						continue;
					dist[xx][yy]=d+1;
					q.push_back({xx,yy});
				}
			}
			
		}
		dist[x][y]==1e9+5?cout<<-1:cout<<dist[x][y];
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	in(x);

	if(x < 1200)
		cout << "ABC" << endl;
	else
		cout << "ARC" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  int n = pow(2, t);
  vector<int> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  vector<int> slime = {s.back()};
  multiset<int> st;
  rep(i, n-1) st.insert(s[i]);
  rep(i, t) {
    int sz = slime.size();
    rep(j, sz) {
      auto it = st.lower_bound(slime[j]);
      if (it == st.begin()) {
        cout << "No" << endl;
        return 0;
      }
      it--;
      slime.push_back(*it);
      st.erase(it);
    }
    sort(slime.rbegin(), slime.rend());
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 14464
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    # if h == eh and w == ew:
    #     dst[h][w] = d
    #     break

    # if dst[h][w] >= 0 or S[h][w] == '#': continue
    # if dst[h][w] >= 0: continue
    # if dst[h][w] == -1 or d < dst[h][w]: dst[h][w] = d
    # else: continue
    # dst[h][w] = d

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        # if dst[nh][nw] >= 0: continue
        if dst[nh][nw] == -1 or d < dst[nh][nw]:
            dq.appendleft((nh, nw, d))
            dst[nh][nw] = d

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        if dst[nh][nw] == -1 or d + 1 < dst[nh][nw]:
            dq.append((nh, nw, d + 1))
            dst[nh][nw] = d + 1

print(dst[eh][ew])


Measured memory_bytes: 95076
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, d: f64,
        xyv: [(isize, isize); n]
    };

    let res = xyv
        .into_iter()
        .filter(|&(x, y)| {
            let v = ((x * x + y * y) as f64).sqrt();
            v <= d
        })
        .count();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 6828
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

// 二分累乗法
template <typename T>
T modpow(T a, T n, T mod) {
    T ret = 1;

    if (mod == 1) {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a;
            }
            a = a * a;
            n >>= 1;
        }
    } else {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
    }

    return ret;
}

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

    int n, k;
    cin >> n >> k;

    if (k <= (n + 1) / 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s;
  string p;
  cin >> s;
  p = s.at(5);
  p += s.at(6);
  int month = stoi(p);
  //cout << s.at(5) << s.at(6) << endl << p << endl;
  if(month > 4) cout << "TBD" << endl;
  else cout << "Heisei" << endl;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.readline
n,k = map(int,input().split())
edge = [[] for i in range(n)]
alledge = []
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    alledge.append((a-1,b-1))

def f(x,y,c):
    global tmp
    c += 1
    for e in edge[x]:
        if e == y:
            continue
        if c > d:
            tmp +=1
        f(e,x,c)

sys.setrecursionlimit(4100000)

if k % 2 == 0:
    d = k//2
    ass = 2001
    for i in range(n):
        tmp = 0
        f(i,-1,0)
        ass = min(ass,tmp)
    print(ass)
else:
    d = (k-1)//2
    ass = 2001
    for e1 in alledge:
        tmp = 0
        f(e1[0],e1[1],0)
        f(e1[1],e1[0],0)
        ass = min(ass,tmp)
    print(ass)


Measured memory_bytes: 126680
#include<iostream>
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<math.h>
#include<climits>
#include<map>
#include<string.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000009
using namespace std;
#define ll long long





int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    float n, k, t;
    cin >> n >> k >> t;
    int r = ceil(n / k);
    ll m = r * t;
    cout << m << endl;
}




Measured memory_bytes: 3716
import numpy as np

N = int(input())

expo = []
for i in range(1,10000):
    if i == 1:
        expo.append(i)
    else:
        for j in range(2,1000):
            tmp = i**j
            if tmp > N:
                break
            expo.append(tmp)
expo.sort()

expo = np.array(expo)

print(max(expo[expo<=N]))

Measured memory_bytes: 21148