akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap as M
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IO
import Control.Monad

type Weight = Int
type Vertex = (Int, Weight)
type Graph = M.IntMap Neighbor
type Neighbor = M.IntMap Weight

main = do
  n <- readLn :: IO Int
  edge <- (\[x, y] -> zip x y) . transpose <$> getInt2DListBC
  fennec <- newArray (1, n) 0 :: IO (IOUArray Int Int)
  snuke <- newArray (1, n) 0 :: IO (IOUArray Int Int)
  fMark <- newArray (1, n) False :: IO (IOUArray Int Bool)
  sMark <- newArray (1, n) False :: IO (IOUArray Int Bool)
  let graph = foldl makeGraph M.empty edge
      fNeighbors = M.toList . fromJust $ M.lookup 1 graph
      sNeighbors = M.toList . fromJust $ M.lookup n graph
  writeArray fMark 1 True
  writeArray sMark n True
  foldM (search graph fennec 1) fMark fNeighbors
  foldM (search graph snuke n) sMark sNeighbors
  [x, y] <- group . sort <$> mapM (game fennec snuke) [1..n]
  if length x > length y then putStrLn "Fennec"
                         else putStrLn "Snuke"

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

game :: IOUArray Int Int -> IOUArray Int Int -> Int -> IO Int
game fennec snuke i = do
  f <- readArray fennec i
  s <- readArray snuke i
  return $ if f <= s then 0 else 1

makeGraph :: Graph -> (Int, Int) -> Graph
makeGraph graph (x, y) = let nX = M.lookup x graph
                             nY = M.lookup y graph
                             vX = if nX == Nothing
                                    then M.insert x (addNeighbor (y, 1) M.empty) graph
                                    else M.insert x (addNeighbor (y, 1) $ fromJust nX) graph
                         in if nY == Nothing
                              then M.insert y (addNeighbor (x, 1) M.empty) vX
                              else M.insert y (addNeighbor (x, 1) $ fromJust nY) vX

readWeight :: IOUArray Int Int -> Int -> (Int, Int) -> IO Int
readWeight weight k (x, y) = do
  kx <- readArray weight x
  ky <- readArray weight y
  return $ kx + ky

addNeighbor :: (Int, Int) -> Neighbor -> Neighbor
addNeighbor (i, weight) ne = M.insert i weight ne

readEdge :: Graph -> (Int, Int) -> Int
readEdge graph (i, j) = let ne = fromJust $ M.lookup i graph
                        in fromJust $ M.lookup j ne

search :: Graph -> IOUArray Int Int -> Int -> IOUArray Int Bool -> Vertex -> IO (IOUArray Int Bool)
search graph weight pre mark (i, w) = do
  isMark <- readArray mark i
  case isMark of
    True -> do
      return mark
    False -> do
      writeArray mark i True
      let ne = M.toList . fromJust $ M.lookup i graph
      wSum <- readArray weight pre
      writeArray weight i (wSum + w)
      return =<< foldM (search graph weight i) mark ne

Measured memory_bytes: 56700
import java.util.Scanner;

public class Main {

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

		while (scanner.hasNext()) {
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			int s = scanner.nextInt();

			if (x == 0 && y == 0 && s == 0) {
				break;
			}

			int maxNewPrice = 0;

			for(int i = 1; i < s; i++) {
				int ax = i;
				int bx = s-i;

				int ay = getMaxHontai(ax, x)*(100+y)/100;
				int by = getMaxHontai(bx, x)*(100+y)/100;

				if(ay ==0 || by ==0) {
					continue;
				}

				int newPrice = ay + by;



				if(newPrice>maxNewPrice){
					maxNewPrice=newPrice;
				}
			}


			System.out.println(maxNewPrice);

		}
		scanner.close();
		return;
	}

	public static int getMaxHontai(int ax, int x) {
		int i = ax;
		for(; ;i--) {
			int j = i*(100+x)/100;
			if(j==ax) {
				break;
			}
			if(j<ax) {
				return 0;
			}
		}

		return i;
	}
}


Measured memory_bytes: 29604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long


int main() {
	int R, G, B, N; cin >> R >> B >> G >> N;
	long ans=0;
	for(int i=0; R*i<=N; ++i){
	    for(int j=0; R*i+G*j<=N; ++j){
	        if((N-R*i-G*j)%B==0) ++ans;
	    }
	}
	cout << ans << endl;
	return 0;
}


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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  

const int INF = 1e9 + 5;
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> dp(n + 10, INF), h(n+10), length;
    for (int i = 1; i <= k; ++i) {
        length.pb(i);
    }    
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int l : length) {
            int j = i + l;
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    cout << dp[n-1];
}

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

//  freopen ("in.txt", "r", stdin);
//  freopen ("err.txt", "w", stderr); 
//  freopen ("out.txt", "w", stdout);

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 3916
#include<stdio.h>
#include<string.h>
int main(void)
{
    int a,b,c,w=0;
	scanf("%d %d %d",&a,&b,&c);
	w=w+a*100+b*10+c;
	if(w%4==0) printf("YES\n");
	else if(w%4!=0) printf("NO\n");
	return 0;
}

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


int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int a=0;
  for(int i=0;i<n-1;++i) if(s[i]!=s[i+1]) a++;
  int ans=n-1-max(a-k*2,0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3

from heapq import heappush, heappop
import sys
import numpy as np

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# INF = sys.maxsize
INF = 10 ** 9 + 1
# INF = float("inf")


def dp(*x):  # debugprint
    print(*x)


try:
    profile
except:
    def profile(f): return f


@profile
def main(N, M, data):
    ABC = data[:3 * N]
    DEF = data[3 * N:]
    A, B, C = [ABC[i::3] for i in range(3)]
    D, E, F = [DEF[i::3] for i in range(3)]

    xticks = np.unique(np.concatenate((E, F, C, np.array([-INF, 0, INF]))))
    yticks = np.unique(np.concatenate((A, B, D, np.array([-INF, 0, INF]))))
    width = xticks[1:] - xticks[:-1]
    height = yticks[1:] - yticks[:-1]

    # compress
    A = np.searchsorted(yticks, A).astype(np.int16)
    B = np.searchsorted(yticks, B).astype(np.int16)
    C = np.searchsorted(xticks, C).astype(np.int16)
    D = np.searchsorted(yticks, D).astype(np.int16)
    E = np.searchsorted(xticks, E).astype(np.int16)
    F = np.searchsorted(xticks, F).astype(np.int16)

    GRAPH_WIDTH = len(xticks)
    GRAPH_HEIGHT = len(yticks)
    NUM_VERTEXES = GRAPH_HEIGHT * GRAPH_WIDTH

    ng_edges = np.zeros((NUM_VERTEXES, 4), dtype=np.uint8)
    direction = (-1, +1, -GRAPH_WIDTH, +GRAPH_WIDTH)

    # vertical lines A,C-B,C
    for i in range(N):
        x = C[i]
        for y in range(A[i], B[i]):
            pos = y * GRAPH_WIDTH + x
            ng_edges[pos, 0] = 1  # left
            ng_edges[pos - 1, 1] = 1  # right
    A = B = C = 0

    # horizontal lines D,E-D,F
    for i in range(M):
        y = D[i]
        for x in range(E[i], F[i]):
            pos = y * GRAPH_WIDTH + x
            ng_edges[pos, 2] = 1
            ng_edges[pos - GRAPH_WIDTH, 3] = 1
    D = E = F = 0

    total_area = 0
    visited = np.zeros(NUM_VERTEXES)

    x = np.searchsorted(xticks, 0)
    y = np.searchsorted(yticks, 0)
    start = y * GRAPH_WIDTH + x
    to_visit = [start]

    while to_visit:
        pos = to_visit.pop()
        y, x = divmod(pos, GRAPH_WIDTH)
        if visited[pos]:
            continue
        if y == 0 or y == GRAPH_HEIGHT - 1 or x == 0 or x == GRAPH_WIDTH - 1:
            print("INF")
            break

        total_area += width[x] * height[y]
        visited[pos] = 1
        # plan to visit neighbors
        for i in range(4):
            if not ng_edges[pos][i]:
                next = pos + direction[i]
                if visited[next]:
                    continue
                to_visit.append(next)
    else:
        print(total_area)


if sys.argv[-1] == 'ONLINE_JUDGE' or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export(
        'main',
        "void(i4, i4, i4[:])"
    )(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
    exit()
else:
    if sys.argv[-1] != '-p':
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import main  # pylint: disable=all

    # read parameter
    import numba
    N, M = map(int, input().split())
    data = np.int32(sys.stdin.read().split())
    main(N, M, data)


Measured memory_bytes: 237524
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	ll X;
	cin >> X;

	int cnt = 0;
	ll ima = 100;
	while (ima < X) {
		ll risoku = ima / 100;
		cnt++;
		ima += risoku;
	}
	co(cnt);



	Would you please return 0;
}

Measured memory_bytes: 3648
A = list(str(input()))
B = list(str(input()))
C = list(str(input()))
X="a"
while True:
    if X == "a":
        if len(A) == 0:
            print("A")
            break
        X = A[0]
        A.pop(0)
    elif X == "b":
        if len(B) == 0:
            print("B")
            break
        X = B[0]
        B.pop(0)
    else:
        if len(C) == 0:
            print("C")
            break
        X = C[0]
        C.pop(0)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}

unsigned GetDigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main(){
	ll N;
	cin>>N;
	int ans=GetDigit(N);

	for(ll i=1;i*i<=N;i++){
		if(N%i==0){
				int tmp=max(GetDigit(i),GetDigit(N/i));
				ans=min(ans,tmp);
		}	
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <istream>
#include <map>
#include <ostream>
namespace ac {
    using namespace std;
}
using namespace std;
using namespace ac;
namespace ac {
    template<typename T> map<T, bool> sieveOfEratosthenes(T n) {
        map<T, bool> res;
        res[0] = false;
        res[1] = false;
        for (size_t i = 2; i <= (size_t)n; i++) {
            res[i] = true;
        }
        // size_t p = 0;
        for (size_t i = 2; i <= (size_t)n; i++) {
            if (res[i]) {
                // prime[p++] = i;
                for (size_t j = 2 * i; j <= (size_t)n; j += i) {
                    res[j] = false;
                }
            }
        }
        return res;
    }
}
int table2017[100005];
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        auto s = sieveOfEratosthenes(100005);
        for (int i = 1; i <= 100000; i++) {
            table2017[i] = (s[i] && s[(i + 1) / 2]) + table2017[i - 1];
        }
        for (int i = 0; i < n; i++) {
            int l, r, ans = 0;
            in >> l >> r;
            ans = table2017[r] - table2017[l - 1];
            out << ans << '\n';
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 5760
def cross(x, y):
    return (x.conjugate() * y).imag
 
def inside_triangle(p, x, y, z):
    a = cross(y-x, p-y)
    b = cross(z-y, p-z)
    c = cross(x-z, p-x)
    if a*b > 0 and b*c > 0:
        return True
    return False
 
import sys
 
for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    x = complex(x1, y1)
    y = complex(x2, y2)
    z = complex(x3, y3)
    p = complex(xp, yp)
    if inside_triangle(p, x, y, z):
        print('YES')
    else:
        print('NO')




Measured memory_bytes: 5592
def prime_factorize(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    a.add(n)
    return a
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
a, b = list(map(int, input().split()))
x = gcd(a, b)
print(len(prime_factorize(x)))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    string s,t;
    cin >> s >> t;
    for(int i = 0;i < n;i++)
    {
        printf("%c%c", s[i],t[i]);
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll a, b, c, d, ans;
    ll m1, m2, m3, m4;

    cin >> a >> b >> c >> d;

    m1 = b*d;
    m2 = a*c;
    m3 = a*d;
    m4 = b*c;

    ans = max(m1,m2);
    ans = max(ans,m3);
    ans = max(ans,m4);

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  int N;
  cin >> N;
  int A[N];
  int num_of_flat = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if( (A[i]%2) == 0){
      // 偶数。
      num_of_flat++;
    }
  }
  long int res = pow(3,N) - pow(2,num_of_flat);
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 512
from heapq import heappush, heappop
from collections import defaultdict
N = int(input())
E = defaultdict(list)
for i in range(N - 1):
    a, b, c = map(int, input().split())
    E[a - 1].append((b - 1, c))
    E[b - 1].append((a - 1, c))
Q, K = map(int, input().split())

# def dijkstra(K, E, N):
d = [float("inf")] * N
d[K - 1] = 0
q = []
heappush(q, (K - 1, 0))
while q:
    now, dist = heappop(q)
    if d[now] < dist:
        continue

    for nxt, w in E[now]:
        t = dist + w
        if t < d[nxt]:
            d[nxt] = t
            heappush(q, (nxt, t))
for _ in range(Q):
    t1, t2 = map(int, input().split())
    print(d[t1 - 1] + d[t2 - 1])

Measured memory_bytes: 55960
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char    s[4];

    cin >> s;

    if (strcmp(s, "AAA") == 0 || strcmp(s, "BBB") == 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val a = scanner.nextInt()
		val b = scanner.nextInt()
		val c = scanner.nextInt()

		println(Math.min(b/a, c))
	}
}

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

int main() {
	string s;
	int a[26]={};
	for(;cin>>s;)
	for(int i=0;i<s.length();i++){
		if(s[i]>='a'&&s[i]<='z')a[s[i]-'a']++;
		else if(s[i]>='A'&&s[i]<='Z')a[s[i]-'A']++;
	}
	for(int i=0;i<26;i++)
	{
		cout<<(char)('a'+i)<<" : "<<a[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>

int main (){
  int a, b, c, aux=0;
  scanf("%d%d%d", &a, &b, &c);

  aux=a;
  a=b;
  b=aux;

  aux=a;
  a=c;
  c=aux;

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 128
import collections

N = int(input())
A = list(map(int, input().split()))

c = list(collections.Counter(A).items())
c.sort(reverse=True)

a = 0
b = 0
e = -1

for i in range(N):
    if c[i][1] >= 4:
        a = c[i][0]
        b = c[i][0]
        break
    elif c[i][1] >= 2:
        a = c[i][0]
        e = i
        break

if a == 0:
    print(0)
elif e !=-1:
    for i in range(e+1, N):
        if c[i][1] >= 2:
            b = c[i][0]
            break
    if b == 0:
        print(0)
    else:
        print(a*b)
else:
    print(a*b)




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

int main() {
  int n;

  cin >> n;

  for( int i = 1; i <= n; i++ ) {
    if( i % 3 == 0 ) {
      cout << " " << i;
    }
    else {
      for( int x = i; x > 0; x /= 10 ) {
        if( x % 10 == 3 ) {
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3084
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
ll d[114514],d_sn[114514];
int n;
map<int,pii > data;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		data[a].second++;
		if(data[a].first == 0)data[a].first=i;
		else data[a].first = min(data[a].first,i);
	}
	ll ans[114514]={0};
	while(data.rbegin()->second.first != 1){
		auto now = data.rbegin();
		auto bef = next(now);
		int diff = now->first - bef->first;
		ans[(now->second.first)] += diff * 1ll * now->second.second;
		bef->second.second+=now->second.second;
		bef->second.first=min(bef->second.first,now->second.first);
		data.erase(prev(data.end()));
	}
	for(map<int,pii>::iterator itr = data.begin(); itr !=data.end(); ++itr){
		ans[1] += itr->first * 1ll * itr->second.second;
	
	}
	rep(i,n)cout<<ans[i+1]<<endl;
}

Measured memory_bytes: 8448
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        long max = (long) Math.pow(10, 18);
        long[] a = new long[n];
        BigInteger sum = new BigInteger("1");

        for (int i = 0; i < n; i++) {
            a[i] = scn.nextLong();
            if (a[i] == 0) {
                System.out.println(0);
                return;
            } else if (a[i] > max) {
                System.out.println(-1);
                return;
            }


        }

        for (int i = 0; i < n; i++) {
            sum = sum.multiply(BigInteger.valueOf(a[i]));
            if (sum.compareTo(BigInteger.valueOf(max))==1) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(sum);



        scn.close();


    }


}

Measured memory_bytes: 50192
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int arr[1000001];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    int q;
    cin >> q;
    while (q--) {
        int m;
        cin >> m;
        int t = lower_bound(arr, arr + n, m) - arr;
        if (t >= n)
            cout << n << endl;
        else cout << t << endl;
    }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
map<ll, ll> divs;

void prime_factorize(ll n) {
  for(ll i=2; i*i<=n; i++){
    while(n%i==0){
      divs[i]++;
      n/=i;
    }
  }
  if(n != 1) divs[n]++;
}

int main(void) {
  ll n;
  cin >> n;
  arr(a,n);
  sortall(a);
  vecb exist(1000001, false);
  vecb dob(1000001, false);
  rep(i,n){
    if(exist[a[i]]) dob[a[i]]=true;
    if(!dob[a[i]]) exist[a[i]]=true;
  }

  int ans=0;
  REP(i,1,1000001){
    if(i==1 && exist[i] && !dob[i]){
      prt(1);
      return 0;
    } else if(i==1 && exist[i] && dob[i]){
      prt(0);
      return 0;
    } else {
      if(exist[i]){
        if(!dob[i]){ans++;}
        for(int j=1; i*j<=1000000; j++){
          //prt2(i, i*j);
          exist[i*j]=false;
        }
      }
    }
  }

  prt(ans);


}


Measured memory_bytes: 4320
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		char []c = sc.next().toCharArray();
		
		if(n % 2 ==1) {
			System.out.println("No");
			return;
			
		}
		
		int temp = -1;
		
		for(int i = 0 ; i < n/2 ; i++) {
			if(c[i] != c[i+n/2]) {
				temp = 0;
				break;
			}
		}
		
		if(temp == -1) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
def main():
    input_str = input()

    a,b,c = input_str.split(' ')
    a = int(a)
    b = int(b)
    c = int(c)
    flag = False

    for i in [a,b,c,'fin']:
        if i == 'fin':
            if a+b+c== 17:
                flag = True
        elif not i in [5,7]:
            break

    if flag:
        print('YES')
    else:
        print('NO')


if __name__=='__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a[100005];
	int n;
	scanf("%d",&n);
	long long sum=0;
	int b[100005]={0};
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	for(int i=0;i<n;i++){
		int t=a[i];
		a[i]++;
		b[a[i]]++;
		t--;
		b[t]++;
	}
	int max=0;
	for(int i=0;i<100005;i++){
		if(max<b[i])
			max=b[i];	
	}
	printf("%d\n",max);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  string s;

  cin >> n >> s;

  if (n%2 == 0) {
    rep(i, n/2) {
      if (s[i] != s[i+n/2]) {
    cout << "No" << endl;
      return 0;
      }
    }
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
<?php

$times = trim(fgets(STDIN));



echo mod_fact($times) . "\n";
die();


function mod_fact($num)
{
	$ans = 1;
	$mod = 1000000007;
	
	for ($i = 1; $i <= $num; $i++ )
	{
		$ans = ($ans*$i)%$mod;
	}
	
	return $ans;
}

Measured memory_bytes: 3576
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))

n,m=nm()
s=[]
o=[]
for i in range(m):
    s.append(nl())
p=nl()

for i in range(2**n):
    op = [0]*n
    for j in range(n):
        if ((i>>j)&1):
            op[n-1-j]=1
    o.append(op)

ans=0
denkyu=0
for oo in o:
    denkyu=0
    for i in range(m):
        cnt=0
        k=s[i][0]
        for j in range(k):
            if oo[s[i][j+1]-1]==1:
                cnt+=1
        if cnt%2==p[i]:
            denkyu+=1
    if denkyu==m:ans+=1
print(ans)

Measured memory_bytes: 3188
#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;
using prique = priority_queue<int>;
const ll INF = LLONG_MAX/3;

/*-----Library-----*/

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 {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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));
}
//コンビネーション
/*
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 */
/*-----Library-----*/
const int MOD=1234567;
signed main(){
	int n;
	cin>>n;
	string a[110000];
	rep(i,n)cin>>a[i];
	int ans=0;
	rep(i,n){
		if(a[i]=="E869120")ans++;
	}
	cout<<ans<<endl;
}



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

int main() {
  vector<int> a(10); for (int i = 0; i < 10; ++i) cin >> a[i];
  sort(begin(a), end(a), greater<int>());
  for (int i = 0; i < 3; ++i) cout << a[i] << endl;
  return 0;
}



Measured memory_bytes: 3128
/*
Original problem: https://atcoder.jp/contests/abc134/tasks/abc134_c
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
        int n;
		cin >> n;
		VI A(n);
		deque<int> dq;

		// my attempt at a O(n) solution
		// trying to avoid O(nlogn) sorting

		REP(i,0,n) {
			cin >> A[i];

			if (dq.size() == 0) {
				dq.push_front(A[i]);
			} else if (dq.size() == 1) {
				if (A[i] >= dq.front()) {
					dq.push_front(A[i]);
				} else {
					dq.push_back(A[i]);
				}
			} else if (A[i] >= dq.front()) {
				dq.push_front(A[i]);
				dq.pop_back();
			} else if (A[i] >= dq.back()) {
				dq.pop_back();
				dq.push_back(A[i]);
			}
		}

		REP(i,0,n) {
			if (dq.size() == 1) {
				cout << dq.front() << endl;
			} else {
				if (A[i] == dq.front()) {
					cout << dq.back() << endl;
				} else {
					cout << dq.front() << endl;
				}
			}
		}
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
int N;
int main(void){
    cin >> N;
    cout << ceil(float(N)/2) << endl;
    return 0;
}



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

void selectionsort(vector<pair<char,int>> &A){
    for(int i=0; i<A.size(); ++i){
        int minj = i;
        for(int j=i+1; j<A.size(); ++j){
            if( A[minj].second > A[j].second){
                minj = j;
            }
        }
        if( i!= minj){
            swap(A[i],A[minj]);
        }
    }
}

void bubblesort(vector<pair<char,int>> &A){
    bool flag = true;
    while(flag){
        flag = false;
        for(int j=A.size()-1; j>0; --j){
            if(A[j].second < A[j-1].second){
                swap(A[j], A[j-1]);
                flag =true;
            }
        }
    }
}

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

    vector<pair<char,int>> A(n);
    vector<pair<char,int>> B(n);
    for(int i=0; i<n; ++i){
        string C;
        cin >> C;
        A[i] = make_pair(C[0],C[1]-'0');
        B[i] = make_pair(C[0],C[1]-'0');
    }


    bubblesort(A);
    for(int i=0; i<n; ++i){
        if( i!= 0)
            cout << ' ';
        cout << A[i].first << A[i].second;
    }
    cout << endl;
    cout << "Stable"<< endl;

    selectionsort(B);

    for(int i=0; i<n; ++i){
        if( i!= 0)
            cout << ' ';
        cout << B[i].first << B[i].second;
    }
    cout << endl;
    bool flag = true;

    for(int i=0; i<A.size(); ++i){
        if( A[i].first != B[i].first or A[i].second != B[i].second){
            flag =false;
            break;
        }
    }

    if(flag){
        cout << "Stable";
    }else {
        cout << "Not stable";
    }
    cout << endl;

}


Measured memory_bytes: 3152
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse", "sse2", "avx", "avx2")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int mod = 1e9 + 7;
const int K = 120;
const int N = 2e5;
int p[N][3];

int fast_pow(int a, int n) {
    if (!n) return 1;
    if (n & 1) return a * fast_pow(a, n - 1) % mod;
    return fast_pow(a * a % mod, n / 2);
}

int cnt[N], d[N], ans[N];

signed main() {
    accell();
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; ++i) {
        cnt[i]++;
    }
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j * i <= k; ++j) {
            d[i] += cnt[i * j];
        }
    }
    for (int i = k; i >= 1; --i) {
        for (int j = 1; j * i <= k; ++j) {
            ans[i] -= ans[j * i];
            ans[i] += mod;
            ans[i] %= mod;
        }
        ans[i] += fast_pow(d[i], n);
        ans[i] %= mod;
    }
    int res = 0;
    for (int i = 1; i <= k; ++i) {
        // cout << d[i] << ' ';
        res += ans[i] * i % mod, res %= mod;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 5996
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main()
{
    int n,a,b,c,d;
    cin >> n;
    for(int de = 0;de < 4;de++){
        if(de == 0){
            d = n % 10;
        }
        if(de == 1){
            c = n % 10;
        }
        if(de == 2){
            b = n % 10;
        }
        if(de == 3){
            a = n % 10;
        }
        n = n / 10;
    }
    std::vector<char> op;
    op.push_back('+');
    op.push_back('-');
    char op1,op2,op3;
    bool result = false;
    int answer;
    for(char x:op){
        if(result){
            break;
        }
        for(char y :op){
            if(result){
                break;
            }
            for(char z :op){
                if(x == '+'){
                    answer = a + b;
                }else{
                    answer = a - b;
                }
                if(y == '+'){
                    answer = answer + c;
                }else{
                    answer = answer - c;
                }
                if(z == '+'){
                    answer = answer + d;
                }else{
                    answer = answer - d;
                }
                if(answer == 7){
                    result = true;
                    op1 = x;
                    op2 = y;
                    op3 = z;
                    break;
                }
            }
        }
    }
    std::string ans;
    ans += to_string(a);
    ans += op1;
    ans += to_string(b);
    ans += op2;
    ans += to_string(c);
    ans += op3;
    ans += to_string(d);
    ans += "=7";
    std::cout <<ans<<endl;
    return 0;
}


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

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	string s;
	cin>>s;
	if(s=="ARC") cout<<"ABC";
	else cout<<"ARC";



return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#ifdef DEBUG
  #include "debug.hpp"
#else
  #define DUMP(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
using value_type = typename iterator_traits<FwdIter>::value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int main(const int /*argc*/, char ** /*argv*/) {
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

  constexpr uint64_t mod = 1000000007ULL;
  size_t n;
  uint64_t k;
  cin >> n >> k;
  vector<size_t> a(n);
  cin >> a;

  vector<size_t> cnt(2001);
  for (const size_t i: a) {
    ++ cnt[i];
  }

  uint64_t dpr = 0;  // distinct pairs
  for (const size_t x: cnt) {
    dpr += x * (n - x) % mod;
    dpr %= mod;
  }
  dpr /= 2;
  DUMP(dpr);

  uint64_t out = (k * (k - 1) / 2 % mod) * dpr % mod;
  for (size_t i = 0; i < n; ++i) {
    for (size_t j = i + 1; j < n; ++j) {
      if (a[i] > a[j]) {
        out += k % mod;
        out %= mod;
      }
    }
  }

  cout << out % mod;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main (void)
{
  int a[3][3],b[100],n,i,j,k;
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      cin>>a[i][j];
    }
  }
  cin>>n;
  for(i=0;i<n;i++){cin>>b[i];}
for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      for(k=0;k<n;k++)
      if(a[i][j]==b[k]){a[i][j]=0;}
    }
  }
  for(i=0;i<3;i++){if(a[i][1]==0&&a[i][2]==0&&a[i][0]==0){cout<<"Yes"<<endl;return 0;}}
  for(i=0;i<3;i++){if(a[1][i]==0&&a[2][i]==0&&a[0][i]==0){cout<<"Yes"<<endl;return 0;}}
  if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0){cout<<"Yes"<<endl;return 0;}
  if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0){cout<<"Yes"<<endl;return 0;}
  cout<<"No"<<endl;return 0;
 
}



Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
typedef pair<int,int> Pos;
typedef pair<Pos,Pos> P;

int main(){
  int T,gy,gx,n,x1,x2,y1,y2;
  int imap[17][17];
  map<P,bool> NotExist;
  cin >> T;
  while(T-- > 0){
    NotExist.clear();
    cin >> gx >> gy;

    for(int i=0;i<=gy;i++)for(int j=0;j<=gx;j++)imap[i][j] = 0;
 
    cin >> n;
   

    for(int i=0;i<n;i++){
      cin >> x1 >> y1 >> x2 >> y2;
      NotExist[P(Pos(x1,y1),Pos(x2,y2))] = true;
      NotExist[P(Pos(x2,y2),Pos(x1,y1))] = true;
    }

    imap[0][0] = 1;
    for(int i=1;i<=gy;i++){
      if(NotExist[P(Pos(0,i),Pos(0,i-1))] || imap[i-1][0] == 0){
	imap[i][0] = 0;
      }
      else imap[i][0]=1;
    }

    for(int i=1;i<=gx;i++){
      if(NotExist[P(Pos(i,0),Pos(i-1,0))] || imap[0][i-1] == 0){
	imap[0][i] =0;
      }
      else imap[0][i] = 1;
    }
    int sumx,sumy;
    for(int i=1;i<=gy;i++){
      for(int j=1;j<=gx;j++){
	if(!NotExist[P(Pos(j-1,i),Pos(j,i))])sumx = imap[i][j-1];
	else sumx =0;

	if(!NotExist[P(Pos(j,i-1),Pos(j,i))])sumy = imap[i-1][j];
	else sumy = 0;
	imap[i][j] = sumx+sumy;
      }
    }

   
    if(imap[gy][gx] != 0)cout << imap[gy][gx] << endl;
    else cout << "Miserable Hokusai!"  << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, a, b; cin >> n >> a >> b;
    cout << min(a, b) << " " << (a+b > n ? a+b-n : 0) << endl;
}

Measured memory_bytes: 3548
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int total = 0;

        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
            total = total + A[i];
        }

        int count = 0;
        for(int i=0;i<N;i++){
            if (A[i] >= (total * 0.25/ M)){
                count++;
            }
        }

        if(count>=M){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
const ll ccc=1000000;
bool prime[ccc+1];
vector<ll> pr;
void makeprime(){
	ll i,j;
	for(i=2;i<=ccc;i++) prime[i]=true;
	for(i=2;i*i<=ccc;i++) if(prime[i]) for(j=2;j*i<=ccc;j++) prime[j*i]=false;
	for(i=2;i<=ccc;i++) if(prime[i]) pr.push_back(i);
}
ll ans[500][500];
int main(){
	makeprime();
	const int N = 500;
	int off = N+1;
	rep(i,N) rep(j,N){
		if((i+j)%2==0){	//small
			int x = (i+j)/2;
			int y = (i-j+N)/2 + off;
			ans[i][j] = pr[x] * pr[y];
		}else{
			int x = (i+j)/2;
			int y = (i-j+N)/2 + off;
			ans[i][j] = pr[x]*pr[x+1]*pr[y]*pr[y+1] + 1;
		}
	}
	rep(i,N) rep(j,N) assert(ans[i][j] <= 1000000000000000LL);
	int n;
	cin>>n;
	rep(i,n){
		rep(j,n) cout<<ans[i][j]<<" ";
		puts("");
	}

}


Measured memory_bytes: 6772
# D - Semi Common Multiple

N, M = map(int, input().split())
a = list(map(int, input().split()))
assert len(a) == N

def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    g = gcd(a, b)
    return g * (a // g) * (b // g)

for i in range(N):
    a[i] //= 2

l = 1
for x in a:
    l = lcm(l, x)
    if l > M:
        print(0)
        exit()

if all((l // x) % 2 != 0 for x in a):  # 全a_iの奇数倍
    n_scm = M // l
    n_scm = (n_scm + 1) // 2  # 奇数倍の倍数の個数
else:
    n_scm = 0

print(n_scm)


Measured memory_bytes: 63856
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
using namespace std;


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

    int a=0,b=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){a=i;break;}
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='Z'){b=i;break;}
    }
    cout<<b-a+1<<endl;

    return 0;
}


Measured memory_bytes: 3760
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,A[200020],memo[200200]={};

int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 0; i < N-1; i++){
        cin>>A[i];
        memo[A[i]]++;
    }
    for(long long int i = 1; i <= N; i++){
        cout<<memo[i]<<endl;
    }

}    


Measured memory_bytes: 6756
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int n,a,mn,ans=0,sum=0;
	cin>>n;
	vector<int>v;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		sum=sum+a;
		v.push_back(a);
	}
	sum=round(double(sum)/n);
	for(int j=0;j<v.size();j++)
	{
		ans=ans+((sum-v[j])*(sum-v[j]));
	}
	cout<<ans<<endl;
}

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

struct VV {
	VV *bef=NULL;
	VV *nex=NULL;
	int v;
}*l,*r;
void insertl(int val) {
	VV *tmp = new VV();
	tmp->v = val;
	l->bef = tmp;
	tmp->nex = l;
	l=tmp;
}
void insertr(int val) {
	VV *tmp = new VV();
	tmp->v = val;
	r->nex = tmp;
	tmp->bef = r;
	r=tmp;
}
int main() {
	int n;
	cin>>n; n--;
	int tmp; cin>>tmp;
	r = l = new VV();
	r->v = tmp; r->bef=r->nex=NULL;
	bool direction = true;
	while (n--) {
		int tt; cin>>tt;
		if (direction)
			insertr(tt);
		else
			insertl(tt);
		direction = !direction;
	}
	if (direction)
		for (VV *t=l;t;t=t->nex)
			cout<<t->v<<" ";
	else
		for (VV *t=r;t;t=t->bef)
			cout<<t->v<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 8448