akhauriyash/Code-Regression huggingface dataset:
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = false;


using namespace std;

int main(void)
{
    unsigned int x;
    cin >> x;
    double n = (sqrt(8. * x + 1) - 1) / 2.;
    cout << static_cast<int>(ceil(n)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <array>
#include <algorithm>
using namespace std;
typedef array<int,3> T;
vector<T> G[100];//to,dist,enemy;
int memo[100][101];//town,money
priority_queue<T,vector<T>,greater<T>> que;//attack,town,money

int main(){
    int N,M,L;
    while(cin>>N>>M>>L,N){
        for(int i=0;i<100;i++) G[i].clear();
        fill(memo[0],memo[100],1e8);
        for(int i=0;i<M;i++){
            int A,B,D,E;
            cin>>A>>B>>D>>E;
            A--;B--;
            G[A].push_back({B,D,E});
            G[B].push_back({A,D,E});
        }
        while(!que.empty())que.pop();
        que.push({0,0,L});
        memo[0][L]=0;
        while(!que.empty()){
            auto t=que.top(); que.pop();
            int attack=t[0], town=t[1], money=t[2];
            if(town==N-1){
                cout<<attack<<endl;
                break;
            }
            for(auto e:G[town]){
                int to=e[0], dist=e[1], enemy=e[2];
                if(money>=dist){
                    if(memo[to][money-dist]>attack){
                        memo[to][money-dist]=attack;
                        que.push({attack,to,money-dist});
                    }
                }
                if(memo[to][money]>attack+enemy){
                    memo[to][money]=attack+enemy;
                    que.push({attack+enemy,to,money});
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>

int parent(int index){
	return index / 2;
}

int heapleft(int index){
	return index * 2;
}

int heapright(int index){
	return index * 2 + 1;
}

int main(void)
{
	int i ,n;
	int node[250];

	//??????????????????H
	scanf("%d", &n);

	//???????????????
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &node[i]);
	}

	//??????
	for (i = 1; i <= n; i++)
	{
		printf("node %d: key = %d, ", i, node[i]);
		if (i != 1)
		{
			printf("parent key = %d, ", node[parent(i)]);
		}
		if (n >= heapleft(i) )
		{
			printf("left key = %d, ", node[heapleft(i)]);
		}
		if (n >= heapright(i) )
		{
			printf("right key = %d, ", node[heapright(i)]);
		}
		printf("\n");
	}

	return 0;
}

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

#define rep(i,n) for(auto i=0*(n);i<(n);++i)

using namespace std;

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

  rep(i,s.size()){
    cout << s[i];
    if(i==3)cout << " ";
  }
  cout << endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

ll pow2(ll a, ll b) {
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int main() {

    int h, w;
    cin >> h >> w;

    vector<vector<char>> board = vector<vector<char>>(h + 2, vector<char>(w + 2, '.'));
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            cin >> board[y + 1][x + 1];
        }
    }

    for (int y = 1; y <= h; y++) {
        for (int x = 1; x <= w; x++) {

            bool b = [&] {

                if (board[y][x] == '.') return true;

                if (board[y - 1][x] == '#') return true;
                if (board[y + 1][x] == '#') return true;
                if (board[y][x - 1] == '#') return true;
                if (board[y][x + 1] == '#') return true;

                return false;

            }();

            if (!b) {

                cout << "No" << endl;
                return 0;
            }

        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<string, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.RRS", "r", stdin );
	int n, q;
	scanf ("%d %d", &n, &q );
	vector<P> task (n );
	rep (i, n ){
		string name;
		int time;
		cin >> name >> time;
		task[i].first = name;
		task[i].second = time;
	} // end rep
	queue<P> que;
	rep (i, n ){
		que.push (task[i] );
	} // end rep
	int curr_time = 0;
	vector<P> res;
	while (!que.empty() ){
		P curr = que.front(); que.pop();
		if (curr.second <= q ){
			curr_time += curr.second;
			res.push_back (P (curr.first, curr_time ) );
		}else{
			curr.second -= q;
			curr_time += q;
			que.push (curr );
		} // end if
	} // end while
	rep (i, n ){
		cout << res[i].first << ' ' << res[i].second << endl;
	} // end rep

	return 0;
}

Measured memory_bytes: 0
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	writeln(N - K + 1);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;

  for (int i = 0; i < s.length(); i++) {
    if (i % 2 == 0) {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
from operator import itemgetter
N = int(input())
inf = {}
for i in range(1,N+1):
  s,p = input().split()
  pint = int(p)
  inf[(s,pint)] = i
a = sorted(inf.keys(), key=itemgetter(1), reverse=True)
dic2 = sorted(a, key=itemgetter(0))
for i in range(N):
  print(inf[dic2[i]])

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

int main(){
    int h , w , k; cin >> h >> w >> k;
    vector<string> c(h);
    for(int i=0; i<h; i++) cin >> c[i];

    //answer
    int ans = 0;

    for(int i=0; i<(1<<h); i++){
        for(int j=0; j<(1<<w); j++){
            int cnt = 0; // the nuber of black
            for(int m=0; m<h; m++){
                if(i & (1<<m)) continue;
                for(int n=0; n<w; n++){
                    if(j & (1<<n)) continue;
                    if(c[m][n] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
N = int(input())
h = list(map(int,input().split()))

# 足場 i までにたどり着くまでに最小のコスト
dp = [0]*N
# 初期値設定
dp[1] = abs(h[1]-h[0])     

for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    
print(dp[-1])

Measured memory_bytes: 13928
#include<stdio.h>

int main(void)
{
   int n, p[10], i, a=0, s=0;

   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%d",&p[i]);
      s+=p[i];
      if(p[i]>a)
         a=p[i];
   }

   printf("%d\n",s-a/2);
   return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    static int BinSearchIndex(long v, long[] list)
    {
        int minRange = 0;
        int maxRange = list.Count();
        while (minRange != maxRange)
        {
            var center = (minRange + maxRange) / 2;
            if (list[center] < v)
            {
                minRange = center + 1;
            }
            else
            {
                maxRange = center;
            }
        }

        return minRange;
    }


    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var K = vals[2];
        var A = new long[1].Concat(Console.ReadLine().Split(' ').Select(long.Parse)).ToArray();
        var B = new long[1].Concat(Console.ReadLine().Split(' ').Select(long.Parse)).ToArray();

        for (int i = 1; i < A.Length; i++)
        {
            A[i] += A[i - 1];
        }
        for (int i = 1; i < B.Length; i++)
        {
            B[i] += B[i - 1];
        }

        var best = 0;
        for (int i = 0; i < A.Length; i++)
        {
            if (A[i] > K)
            {
                break;
            }

            var count = i;
            var t = K - A[i];
            var index = BinSearchIndex(t, B);
            while (0 <= index && (index >= B.Length || B[index] > t))
            {
                index--;
            }
            count += index;
            best = Math.Max(best, count);
        }

        Console.WriteLine(best);
    }
}

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

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

    long long n;
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 15 == 0);
        else if(i % 3 == 0);
        else if(i % 5 == 0);
        else{
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  int x = 0;
  int MAX = -101;
  int ans = MAX;
  rep(i, n) {
    if(s[i] == 'I') x++;
    if(s[i] == 'D') x--;
    ans = max(ans, x);
  }
  if(ans < 0) ans = 0;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
n, d = map(int, input().split())
cordinate = []
for i in range(n):
    cordinate.append(list(map(int, input().split())))

ans = 0

for r in cordinate:
    if (r[0]**2 + r[1]**2)**(1/2) <= d:
        ans += 1

print(ans)

Measured memory_bytes: 45836
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INFll (1LL << 60)
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;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    vector<int> b(m);
    vector<pair<int,int>> c(m);
    rep(i,m){
        cin>>a[i]>>b[i];
        c[i].second=a[i];
        c[i].first=b[i];
    }
    sort(all(c));
    int memo=0;
    int ans=0;
    rep(i,m){
        if(c[i].second<=memo){
            continue;
        }
        else{
            ans++;
            memo=c[i].first-1;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1920
a, b = map(int, input().split())
if (a <= 0 and b >= 0) or (a >= 0 and b <= 0):
  print("Zero")
elif a > 0:
  print("Positive")
elif b < 0:
  print("Negative") if (abs(b-a)+1) % 2 == 1 else print("Positive")

Measured memory_bytes: 3060
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecint = vector<int>;
using vecll = vector<long long>;
using pll = pair<long, long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define nextline() (std::cerr << "\n")
#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

//ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

/*****/

void Main()
{
	ll x, y;
	cin >> x >> y;

	ll ret = 0;
	if (x <= 3)	ret += (4 - x) * 100000;
	if (y <= 3)	ret += (4 - y) * 100000;
	if (x == 1 && y == 1)	ret += 400000;

	cout << ret;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int D;
int c[26];
int S[365][26];
int t[365];
int lst[26];
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>S[i][j];
	int ans=0;
	for(int i=0;i<D;i++)
	{
		cin>>t[i];
		t[i]--;
		ans+=S[i][t[i]];
		lst[t[i]]=i+1;
		for(int j=0;j<26;j++)ans-=c[j]*(i+1-lst[j]);
	}
	int M;cin>>M;
	for(;M--;)
	{
		int d,q;cin>>d>>q;d--,q--;
		ans-=S[d][t[d]];
		ans+=S[d][q];
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ans-=c[t[d]]*(r-d)*(d-l);
		r=d+1;
		while(r<D&&t[r]!=q)r++;
		l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ans+=c[q]*(r-d)*(d-l);
		t[d]=q;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3588
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	n, a := readLengthAndSlice()
	sum := cumulativeSum(a)

	var ans int64 = math.MaxInt64
	for i := 1; i < n; i++ {
		v := absInt64(sum(0, i) - sum(i, n))
		ans = minInt64(ans, v)
	}
	println(ans)
}

// -----------------------------------------------------------------------------

// cumlativeSum returns a function func(i, j int) int64 which returns
// the sum of a[i:j]
func cumulativeSum(a []int) func(int, int) int64 {
	n := len(a)
	b := make([]int64, n+1)
	for i := 0; i < n; i++ {
		b[i+1] = int64(a[i]) + b[i]
	}
	return func(i, j int) int64 {
		return b[j] - b[i]
	}
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 5248
def solve(price, ps, is_prime):
    dp = [0] * ((price >> 5) + 1)
    for i in range(0, price + 1,ps[0]):
        dp[i >> 5] |= 1 << (i & 31)
    dp[0] = 1
    for i in range(1, len(ps)):
        cur_p = ps[i]
        r = cur_p & 31
        rest = 0
        if cur_p >= 32:
            for p in range(cur_p, price + 1, 32):
                i1 = (p - cur_p) >> 5
                i2 = p >> 5
                v = dp[i1]
                dp[i2] |= ((v << r)&(2**33-1)) | rest
                rest = (v >> (32 - r)) & ((1 << r) - 1)
        else:
            for p in range(cur_p, price + 1):
                dp[p >> 5] |= (dp[(p - cur_p) >> 5] >> ((p - cur_p) & 31) & 1) << (p & 31)

    p = -1
    for i in range(price+1, 0,-1):
        if is_prime[i] and (dp[i >> 5] >> (i & 31) & 1):
            p = i
            break
    if p == -1:
        print("NA")
    else:
        print(p)
     
def main():
    N = 1000001
    temp = [True]*(N+1)
    temp[0] = temp[1] = False
    for i in range(2, int((N+1)**0.5)+1):
        if temp[i]:
            temp[i+i::i] = [False]*(len(temp[i+i::i]))

    while True:
        n, price = map(int,input().split())
        if n == 0 and price == 0:
            return
        ps = []
        for i in range(n):
            ps.append(int(input()))
        solve(price, ps, temp)
 
main()


Measured memory_bytes: 21044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	
	cin >> s;
	if(s[0] == s[1] and s[1] == s[2] and s[0] == 'R')
		cout << 3;
	else if(s[0] == s[1] and s[1] == 'R')
		cout << 2;
	else if(s[1] == s[2] and s[2] == 'R')
		cout << 2;
	else if(s[0] == 'R' or s[1] == 'R' or s[2] == 'R')
		cout << 1;
	else 
		cout << 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

unordered_map<long, unordered_set<long>> joint;

// 最も遠い点、距離
pair<long, long> rec(long start, unordered_set<long> &used) {
  pair<long, long> result = make_pair(start, 0);
  for (long n: joint[start]) {
    if (used.count(n)) continue;
    used.insert(n);
    auto tmp = rec(n, used);
    if (result.second <= tmp.second) result = make_pair(tmp.first, tmp.second + 1);
  }
  return result;
}

int main(void) {
  long N;
  cin >> N;
  rep (i, N) {
    long a, b;
    cin >> a >> b;
    joint[a].insert(b);
    joint[b].insert(a);
  }

  unordered_set<long> used;
  used.insert(1);
  auto foo = rec(1, used);
  // cerr << "foo.first: " << foo.first << ", foo.second: " << foo.second << endl;

  unordered_set<long> used2;
  used2.insert(foo.first);
  auto bar = rec(foo.first, used2);
  // cerr << "bar.first: " << bar.first << ", bar.second: " << bar.second << endl;

  if (bar.second % 3 == 1) cout << "Second" << endl;
  else cout << "First" << endl;

  return 0;
}


Measured memory_bytes: 71880
s = input()
p1 = 0
p2 = 0
for i in range(len(s)):
    if i%2==0:
        if s[i]!="0":
            p1 += 1
    else:
        if s[i]!="1":
            p1 += 1

for i in range(len(s)):
    if i%2==0:
        if s[i]!="1":
            p2 += 1
    else:
        if s[i]!="0":
            p2 += 1
            
print(min(p1, p2))



Measured memory_bytes: 3188
s=input()
l=list(s)
import collections
c=collections.Counter(l)
m=c.most_common()
ll=[]
for i,j in m:
    ll.append(j)
if len(m)<=2:
    if len(m)==1 and max(ll)==1:
        print("YES")
    elif len(m)==2 and max(ll)==1:
        print("YES")
    else:
        print("NO")
else:
    if max(ll)-min(ll)<=1:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int dp[150][10500];
int main() {
	int N;
	int v[105],w[105];
	int W;
	cin>>N>>W;
	for(int i=0;i<N;i++){
		cin>>v[i]>>w[i];
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i]){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
			}
		}
	}
	cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 7192
while ((h,w = gets.split(" ").map(&:to_i)).select{|i| i != 0}.length > 0) do
  h.times do |i|
    w.times do |j|
      print (i%2==0) ? ((j%2==0) ? "#" : ".") : ((j%2==0) ? "." : "#")
      puts "" if (j == w-1)
    end
  end
  puts ""
end

Measured memory_bytes: 8708
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[1001][1001]={0};
int main(){
  int i,j,q,e,l,z,m,u,n;
  char x[2001],y[2001];
  cin>>q;
  for(e=0;e<q;e++){
    scanf("%s %s",x,y);
    l=strlen(x);
    z=strlen(y);
 
    for(i=0;i<=l;i++){
      for(j=0;j<=z;j++){
        p[i][j]=0;
      }
    }
    for(i=1;i<=z;i++){
      for(j=1;j<=l;j++){
        if(y[i-1]==x[j-1])p[j][i]=p[j-1][i-1]+1;
        else p[j][i]=max(p[j-1][i],p[j][i-1]);
      }
    }
    cout<<p[l][z]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7056
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> H, N;
  vector<pair<int,int>> AB(N);
  
  for (auto&& i : AB)
    cin >> i.first >> i.second;
  
  bst::sort(AB);
  
  vector<ll> dp(H + 1, 99999999999LL);
  dp[0] = 0;
  
  for (auto i = 1; i <= H; i++) {
    for (const auto& j : AB) {
      dp[i] = min(dp[i], dp[max(0, i - j.first)] + j.second);
    }
  }


  return dp[H];
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll c[30],s[400][30],las[30];

int main()
{
	int D;
	cin >> D;
	rep(i,26)
	{
		cin >> c[i];
	}
	rep(i,D)
	{
		rep(j,26)
		{
			cin >> s[i][j];
		}
	}
	rep(i,D)
	{
		ll best = -1 * 1e10;
		ll bestv = 0;
		rep(j,26)
		{
			ll tmp = 0;
			tmp += s[i][j];
			rep(k,26)
			{
				if (k != j)
				{
					tmp -= c[k] * (i+1 - las[k]);
				}
			}
			if (tmp > best)
			{
				best = tmp;
				bestv = j+1;
			}
		}
		cout << bestv << endl;
		las[bestv] = i+1;
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#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 main(void)
{
    int n;
    cin >> n;

    int a=n/10;
    a*=10;
    n-=a;
    if(n==3){
        cout << "bon" << endl;
    }else if(n==0||n==1||n==6||n==8){
        cout << "pon" << endl;
    }else {
        cout << "hon" << endl;
    }

    return 0;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; ll b; ll k;
    cin >> a >> b >> k;
    ll hiku_taka = min(a, k);
    cout << a - hiku_taka << " " << max(ll(0), b - (k - hiku_taka)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string S, T;
  cin >> S >> T;
  ll ans = 0;
  rep(i, S.size()) {
    if (S[i] != T[i]) ans++;
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3840
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

if N < 10:
	print(N)
	exit()

ans1 = 9*(len(str(N))-1) + int(str(N)[0])-1

ans2 = sum([int(x) for x in list(str(N))])

ans3 = sum([int(x) for x in list(str(N//10*10-1))])

print(max(ans1, ans2, ans3))

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

signed main(){
	int A[3];
	REP(i,3){
		cin >> A[i];
	}

	sort(A,A+3);
	cout << A[0] * A[1] / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n),ans(2*m+1,0),add(2*m+1,0);
    cins(all(a));
    ll b = 0;
    rep(i,n-1){
        ll l = a[i],r = a[i+1];
        if (l > r) r += m;
        b += r-l;
        if (r-l < 2) continue;
        ans[l+1]++;
        ans[r]--;
        add[r] -= r-l-1;
    }
    rep(i,2*m){
        ans[i+1] += ans[i];
    }
    rep(i,2*m+1){
        ans[i] += add[i];
    }
    rep(i,2*m){
        ans[i+1] += ans[i];
    }
    rep(i,m){
        ans[i] += ans[i+m];
    }
    PRINT(b-*max_element(ans.begin(),ans.begin()+m));
    //array_output(all(ans));
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
    ll k;
    cin>>k;
    ll cnt=0;
    if(k<10) return cout<<k,0;
    queue<ll> v;
    vector<ll> ans;
    for(int i=1;i<10;i++) v.push(i),ans.push_back(i);
    cnt=9;
    while(!v.empty()){
        ll p=v.front();
        v.pop();
        if(p%10!=0){
        v.push(p*10+(p%10)-1);
        ans.push_back(p*10+(p%10)-1);
        cnt++;
        }
        v.push(p*10+p%10);
        ans.push_back(p*10+p%10);
        if(p%10!=9){
        v.push(p*10+(p%10)+1);
        ans.push_back(p*10+(p%10)+1);
        cnt++;
        }
        cnt+=1;
        if(cnt>=k) break;
    }
    cout<<ans[k-1];
}

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

int main(void){
    int a,b;
    cin >> a >> b;
    
    int A = max(a,b);
    int B = min(a,b);
    for(int i = 0 ; i < A ; i++){
        cout << B;
    }
    cout << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222222;
int a[N];
unordered_set<int> st;
int n, x;

void place(int i, int y) {
    a[i] = y;
    st.erase(y);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x;
    n = 2 * n - 1;
    if(n == 3) {
        if(x != 2) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
            cout << 1 << endl;
            cout << 2 << endl;
            cout << 3 << endl;
        }
    } else {
        if(x == 1 || x == n) {
            cout << "No" << endl;
        } else {
            rep(i, 1, n) {
                st.insert(i);
            }
            int mult = x == 2 ? -1 : 1;
            int m = n + 1 >> 1;
            place(m - 2, x - 2 * mult);
            place(m - 1, x);
            place(m, x + mult);
            place(m + 1, x - mult);
            rep(i, 1, n) {
                if(!a[i]) {
                    a[i] = *(st.begin());
                    st.erase(st.begin());
                }
            }
            cout << "Yes" << endl;
            rep(i, 1, n) {
                cout << a[i] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 10568
#include<cstdio>
#define MAXN 200002
using namespace std;
int n,t[MAXN],a;
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d",&a);
		t[a]++;
	}
	for(int i=1;i<=n;i++) printf("%d\n",t[i]);
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int mp[30];
  for (int i = 0; i < 30; i++) mp[i] = -1;
  for (int i = 0; i < s.length(); i++) {
    if (mp[s[i] - 'a'] != -1 && mp[s[i] - 'a'] != t[i] - 'a') {
      puts("No");
      return 0;
    }
    mp[s[i] - 'a'] = t[i] - 'a';
  }
  for (int i = 0; i < 26; i++) {
    if (mp[i] == -1) continue;
    for (int j = i + 1; j < 26; j++) {
      if (mp[i] == mp[j]) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}

Measured memory_bytes: 776
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

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

	final long MOD=998244353;
	
	int MAX=(int)5e5;
	long[] fac=new long[MAX];
	long[] ifac=new long[MAX];
	
	{
		fac[0]=1;
		for (int i=1;i<MAX;++i) fac[i]=fac[i-1]*i%MOD;
		for (int i=0;i<MAX;++i) ifac[i]=inv(fac[i]);
	}
	
	long pow(long a,long n) {
		return n!=0?pow(a*a%MOD,n/2)*(n%2==1?a:1)%MOD:1;
	}
	
	long inv(long a) {
		return pow(a,MOD-2);
	}
	
	long comb(int n,int k) {
		return fac[n]*ifac[k]%MOD*ifac[n-k]%MOD;
	}

	void solve() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		int K=sc.nextInt();
		long ans=0;
		for (int i=0;i<=K;++i) {
			ans=(ans+M*pow(M-1,N-1-i)%MOD*comb(N-1,i)%MOD)%MOD;
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}


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

int main() {

    int h, w;
    cin >> h >> w;

    vector<vector<char>> sij (h, vector<char>(w));
    vector<vector<int>> cnt (h, vector<int>(w));

    int def_black_num = 0;
    for ( int i = 0; i < h; i++ ) {
        for ( int j = 0; j < w; j++ ) {
            cin >> sij[i][j];
            cnt[i][j] = -1;
            if ( sij[i][j] == '#' ) def_black_num++;
        }
    }

    const int dx[4] = {1, -1, 0, 0};
    const int dy[4] = {0, 0, 1, -1};
    queue<pair<int, int>> que;
    que.push(pair<int,int>(0,0));
    cnt[0][0] = 0;
    bool break_flg = false;
    while(!que.empty()) {
        pair<int, int> now_p = que.front();
        que.pop();

        for ( int i = 0; i < 4; i++ ) {
            int y = now_p.first + dy[i];
            int x = now_p.second + dx[i];
            if ( y < 0 || y >= h || x < 0 || x >= w || sij[y][x] == '#' || cnt[y][x] != -1 ) continue;
            cnt[y][x] = cnt[now_p.first][now_p.second] + 1;
            if ( y == h-1 && x == w - 1 ) {
                break_flg = true;
                break;
            }
            que.push(pair<int, int>(y, x));
        }
        if ( break_flg ) break;
    }

    if ( cnt[h-1][w-1] == -1 ) {
        cout << -1 << endl;
    }
    else {
        cout << h * w - cnt[h-1][w-1] - def_black_num - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	vector<ll> a(2);
	cin>>a[1]>>a[0];
	sort(a.begin(),a.end());
	ll N=a[0],M=a[1];
	ll ans;
	if(N==1&&M==1){
		ans=1;
	}
	else if(N==1){
		ans=M-2;
	}
	else if(N==2){
		ans=0;
	}
	else{
		ans=(N*M)-2*N-2*M+4;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}
#define maxn 1000005
int n;
struct edge{
	int to,nxt;
}e[maxn<<1];
int tot,head[maxn];
inline void adde(int u,int v){
	e[++tot]=(edge){v,head[u]};
	head[u]=tot;
}
stack<int>s1,s2;
bool d[maxn],vis[maxn];
int res[maxn];
void dfs(int u,int pa)
{
	d[u]=d[pa]^1;
	(d[u]?s1:s2).push(u);
	for(int i=head[u];i;i=e[i].nxt)
		if(e[i].to!=pa)dfs(e[i].to,u);
}
signed main()
{
	n=read();
	For(i,2,n){
		int u=read(),v=read();
		adde(u,v);adde(v,u);
	}dfs(1,0);
	if(s1.size()>s2.size())swap(s1,s2);
	int c1=(n+2)/3,c2=(n+1)/3,c3=n/3;
	if(s1.size()<=c3){
		int x=0;
		while(!s1.empty()){
			x+=3;res[s1.top()]=x;
			s1.pop();vis[x]=1;
		}x=1;
		For(i,1,n)
			if(!res[i]){
				while(vis[x])x++;
				res[i]=x;x++;
			}
	}else{
		int x=-2;
		while(!s1.empty()){
			x+=3;res[s1.top()]=x;
			s1.pop();
		}
		x=-1;
		while(!s2.empty()){
			x+=3;res[s2.top()]=x;
			s2.pop();
		}
		x=0;
		For(i,1,n)
			if(res[i]>n)x+=3,res[i]=x;
	}
	For(i,1,n)cout<<res[i]<<' ';puts("");
    return 0;
}

Measured memory_bytes: 20916
'use strict';

function main(input) {
  let inputs = input.split(' ');
  let a = parseInt(inputs[0]);
  let b = parseInt(inputs[1]);
  if ((a * b) % 2 == 0) {
    console.log('Even');
  } else {
    console.log('Odd');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <cmath>

int main()
{
    long long a, b, c;
    std::cin >> a >> b >> c;
    long long cab = c - a - b;
    if (4 * a * b >= cab * cab || cab < 0)
    {
        std::cout << "No" << std::endl;
    }
    else
    {
        std::cout << "Yes" << std::endl;
    }
    return 0;
}


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    int d = min(a, k);
    k -= d;
    ans += d;

    d = min(b, k);
    k -= d;

    d = min(c, k);
    ans -= d;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3624
N,A,B=map(int, input().split())
D=[int(input()) for i in range(N)]

def f(a):
  E=[]
  for i in range(N):
    if D[i]-a*B>0:
      E.append(D[i]-a*B)
  cnt=0
  for i in E:
    cnt+=-(-i//(A-B))
  if cnt<=a:
    return True
  else:
    return False
l,r=0,10**9
for i in range(50):
  mid=(l+r)//2
  if f(mid):
    r=mid
  else:
    l=mid
print(r)

Measured memory_bytes: 185244